|
58 | 58 | */ |
59 | 59 | public class FunTransformITTest { |
60 | 60 |
|
| 61 | + private static final XmldbURI TEST_IMPORT_XSLT_COLLECTION = XmldbURI.create("/db/fn-transform-import-test"); |
| 62 | + private static final XmldbURI IMPORT_A_XSLT_NAME = XmldbURI.create("a.xsl"); |
| 63 | + private static final XmldbURI IMPORT_B_XSLT_NAME = XmldbURI.create("b.xsl"); |
| 64 | + |
| 65 | + private static final String IMPORT_A_XSLT = |
| 66 | + "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n" + |
| 67 | + " <xsl:import href=\"b.xsl\"/>\n" + |
| 68 | + " <xsl:template match=\"/\">\n" + |
| 69 | + " <doc><p>From A</p><xsl:call-template name=\"from-b\"/></doc>\n" + |
| 70 | + " </xsl:template>\n" + |
| 71 | + "</xsl:stylesheet>"; |
| 72 | + |
| 73 | + private static final String IMPORT_B_XSLT = |
| 74 | + "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n" + |
| 75 | + " <xsl:template name=\"from-b\"><p>From B</p></xsl:template>\n" + |
| 76 | + "</xsl:stylesheet>"; |
| 77 | + |
| 78 | + private static final String SAME_DIR_IMPORT_VIA_DB_LOCATION_QUERY = |
| 79 | + "fn:transform(map {\n" + |
| 80 | + " \"stylesheet-location\": \"/db/fn-transform-import-test/a.xsl\",\n" + |
| 81 | + " \"source-node\": document { <empty/> }\n" + |
| 82 | + "})?output"; |
| 83 | + |
| 84 | + private static final String SAME_DIR_IMPORT_VIA_XMLDB_LOCATION_QUERY = |
| 85 | + "fn:transform(map {\n" + |
| 86 | + " \"stylesheet-location\": \"xmldb:exist:///db/fn-transform-import-test/a.xsl\",\n" + |
| 87 | + " \"source-node\": document { <empty/> }\n" + |
| 88 | + "})?output"; |
| 89 | + |
| 90 | + private static final String SAME_DIR_IMPORT_VIA_DB_NODE_QUERY = |
| 91 | + "fn:transform(map {\n" + |
| 92 | + " \"stylesheet-node\": doc(\"/db/fn-transform-import-test/a.xsl\"),\n" + |
| 93 | + " \"source-node\": document { <empty/> }\n" + |
| 94 | + "})?output"; |
| 95 | + |
| 96 | + private static final String SAME_DIR_IMPORT_VIA_XMLDB_NODE_QUERY = |
| 97 | + "fn:transform(map {\n" + |
| 98 | + " \"stylesheet-node\": doc(\"xmldb:exist:///db/fn-transform-import-test/a.xsl\"),\n" + |
| 99 | + " \"source-node\": document { <empty/> }\n" + |
| 100 | + "})?output"; |
| 101 | + |
61 | 102 | private static final XmldbURI TEST_IDENTITY_XSLT_COLLECTION = XmldbURI.create("/db/transform-identity-test"); |
62 | 103 | private static final XmldbURI IDENTITY_XSLT_NAME = XmldbURI.create("xsl-identity.xslt"); |
63 | 104 |
|
@@ -143,6 +184,30 @@ public class FunTransformITTest { |
143 | 184 | @ClassRule |
144 | 185 | public static ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, true); |
145 | 186 |
|
| 187 | + @Test |
| 188 | + public void sameDirectoryImportViaDbLocation() throws XPathException, PermissionDeniedException, EXistException { |
| 189 | + final Source expected = Input.fromString("<doc><p>From A</p><p>From B</p></doc>").build(); |
| 190 | + expectQuery(SAME_DIR_IMPORT_VIA_DB_LOCATION_QUERY, expected); |
| 191 | + } |
| 192 | + |
| 193 | + @Test |
| 194 | + public void sameDirectoryImportViaXmldbLocation() throws XPathException, PermissionDeniedException, EXistException { |
| 195 | + final Source expected = Input.fromString("<doc><p>From A</p><p>From B</p></doc>").build(); |
| 196 | + expectQuery(SAME_DIR_IMPORT_VIA_XMLDB_LOCATION_QUERY, expected); |
| 197 | + } |
| 198 | + |
| 199 | + @Test |
| 200 | + public void sameDirectoryImportViaDbNode() throws XPathException, PermissionDeniedException, EXistException { |
| 201 | + final Source expected = Input.fromString("<doc><p>From A</p><p>From B</p></doc>").build(); |
| 202 | + expectQuery(SAME_DIR_IMPORT_VIA_DB_NODE_QUERY, expected); |
| 203 | + } |
| 204 | + |
| 205 | + @Test |
| 206 | + public void sameDirectoryImportViaXmldbNode() throws XPathException, PermissionDeniedException, EXistException { |
| 207 | + final Source expected = Input.fromString("<doc><p>From A</p><p>From B</p></doc>").build(); |
| 208 | + expectQuery(SAME_DIR_IMPORT_VIA_XMLDB_NODE_QUERY, expected); |
| 209 | + } |
| 210 | + |
146 | 211 | @Test |
147 | 212 | public void identityPersistentDom() throws XPathException, PermissionDeniedException, EXistException { |
148 | 213 | final Source expected = Input.fromString(IDENTITY_XML).build(); |
@@ -212,6 +277,11 @@ public static void storeResources() throws EXistException, PermissionDeniedExcep |
212 | 277 | Tuple(IDENTITY_XML_NAME, IDENTITY_XML) |
213 | 278 | ); |
214 | 279 |
|
| 280 | + createCollection(broker, transaction, TEST_IMPORT_XSLT_COLLECTION, |
| 281 | + Tuple(IMPORT_A_XSLT_NAME, IMPORT_A_XSLT), |
| 282 | + Tuple(IMPORT_B_XSLT_NAME, IMPORT_B_XSLT) |
| 283 | + ); |
| 284 | + |
215 | 285 | transaction.commit(); |
216 | 286 | } |
217 | 287 | } |
|
0 commit comments