diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-18 14:17:18 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-18 14:17:18 +0100 |
commit | b74a054bd7e7538594824445a0bc666ebb337689 (patch) | |
tree | 12de69267471c6f6b42e05a94a60128d41895c1d /test/plugins/xml | |
parent | 64705a0c297121c6011e91c3b40d66fbcc2c160f (diff) |
added support for primitive subtree fields in XMLOutput.
Diffstat (limited to 'test/plugins/xml')
-rw-r--r-- | test/plugins/xml/XmlOutputTest.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/plugins/xml/XmlOutputTest.cpp b/test/plugins/xml/XmlOutputTest.cpp index 403078d..fcf72d2 100644 --- a/test/plugins/xml/XmlOutputTest.cpp +++ b/test/plugins/xml/XmlOutputTest.cpp @@ -107,5 +107,45 @@ TEST(DemoHTMLTransformer, AnnotationProcessing) "><book:text>blub</book:text><a:end:emphasized/" "><book:text>bla</book:text><a:end:strong/>") != std::string::npos); } + +TEST(DemoHTMLTransformer, PrimitiveSubtreeFields) +{ + // Construct Manager + TerminalLogger logger{std::cerr, true}; + Manager mgr{1}; + Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; + // Construct a simple domain. + Rooted<Domain> domain{new Domain(mgr, sys, "myDomain")}; + + Rooted<StructuredClass> A{new StructuredClass( + mgr, "A", domain, Cardinality::any(), nullptr, false, true)}; + Rooted<FieldDescriptor> A_a = + A->createPrimitiveFieldDescriptor(sys->getStringType(), logger, + FieldDescriptor::FieldType::SUBTREE, + "a").first; + Rooted<FieldDescriptor> A_b = + A->createPrimitiveFieldDescriptor(sys->getStringType(), logger, + FieldDescriptor::FieldType::SUBTREE, + "b").first; + Rooted<FieldDescriptor> A_main = + A->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; + ASSERT_TRUE(domain->validate(logger)); + // Construct a document for it. + Rooted<Document> doc{new Document(mgr, "myDoc")}; + Rooted<StructuredEntity> A_impl = doc->createRootStructuredEntity(A); + A_impl->createChildDocumentPrimitive("test_a", "a"); + A_impl->createChildDocumentPrimitive("test_b", "b"); + A_impl->createChildDocumentPrimitive("test"); + ASSERT_TRUE(doc->validate(logger)); + // now transform this document. + ResourceManager dummy; + XmlTransformer transformer; + std::stringstream out; + transformer.writeXml(doc, out, logger, dummy, false); + const std::string res = out.str(); + ASSERT_TRUE( + res.find("<myDomain:A><a>test_a</a><b>test_b</b>test</myDomain:A>") != + std::string::npos); +} } }
\ No newline at end of file |