-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #999 from lat-lon/cleanUpXmlDependencies-5801
Added support of XSLT 2.0
- Loading branch information
Showing
15 changed files
with
170 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
deegree-core/deegree-core-commons/src/test/java/org/deegree/commons/xml/XsltUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.deegree.commons.xml; | ||
|
||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.CoreMatchers.instanceOf; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
|
||
import javax.xml.transform.TransformerFactory; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> | ||
*/ | ||
public class XsltUtilsTest { | ||
|
||
@Test | ||
public void verifyXslt_20_ImplementationIsAvailable() { | ||
TransformerFactory factory = TransformerFactory.newInstance(); | ||
assertThat( factory, is( instanceOf( net.sf.saxon.TransformerFactoryImpl.class ) ) ); | ||
} | ||
|
||
@Test | ||
public void testXslt10() | ||
throws Exception { | ||
InputStream docToTransform = XsltUtilsTest.class.getResourceAsStream( "feature.gml" ); | ||
URL xslt = XsltUtilsTest.class.getResource( "featureToHtml-Xslt10.xslt" ); | ||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||
XsltUtils.transform( docToTransform, xslt, bos ); | ||
bos.close(); | ||
|
||
assertThat( bos.toString(), containsString( "Identifier: i1 Name: feature name 1 Props: 1a, 1b" ) ); | ||
assertThat( bos.toString(), containsString( "Identifier: i2 Name: feature name 2 Props: 2a, 2b, 2c" ) ); | ||
} | ||
|
||
@Test | ||
public void testXslt20() | ||
throws Exception { | ||
InputStream docToTransform = XsltUtilsTest.class.getResourceAsStream( "feature.gml" ); | ||
URL xslt = XsltUtilsTest.class.getResource( "featureToHtml-Xslt20.xslt" ); | ||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||
XsltUtils.transform( docToTransform, xslt, bos ); | ||
bos.close(); | ||
|
||
assertThat( bos.toString(), containsString( "Identifier: i1 Name: feature name 1 Props: 1a, 1b" ) ); | ||
assertThat( bos.toString(), containsString( "Identifier: i2 Name: feature name 2 Props: 2a, 2b, 2c" ) ); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
deegree-core/deegree-core-commons/src/test/resources/org/deegree/commons/xml/feature.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<gml:FeatureCollection xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:app="http://deegree.org/app"> | ||
<gml:boundedBy> | ||
<gml:Envelope srsName="EPSG:25833"> | ||
<gml:lowerCorner>334830.868300 5871407.128200</gml:lowerCorner> | ||
<gml:upperCorner>358634.056200 5900836.645100</gml:upperCorner> | ||
</gml:Envelope> | ||
</gml:boundedBy> | ||
<gml:featureMember> | ||
<app:Instance gml:id="Instance_1"> | ||
<app:identifier>i1</app:identifier> | ||
<app:name>feature name 1</app:name> | ||
<app:prop1>1a</app:prop1> | ||
<app:prop1>1b</app:prop1> | ||
</app:Instance> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<app:Instance gml:id="Instance_2"> | ||
<app:identifier>i2</app:identifier> | ||
<app:name>feature name 2</app:name> | ||
<app:prop1>2a</app:prop1> | ||
<app:prop1>2b</app:prop1> | ||
<app:prop1>2c</app:prop1> | ||
</app:Instance> | ||
</gml:featureMember> | ||
</gml:FeatureCollection> |
36 changes: 36 additions & 0 deletions
36
...deegree-core-commons/src/test/resources/org/deegree/commons/xml/featureToHtml-Xslt10.xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0"?> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:app="http://deegree.org/app"> | ||
|
||
<xsl:output method="html" indent="yes"/> | ||
|
||
<xsl:template match="/"> | ||
<html lang="de"> | ||
<head/> | ||
<body> | ||
<div> | ||
<ul> | ||
<xsl:for-each select="//app:Instance"> | ||
<xsl:apply-templates select="."/> | ||
</xsl:for-each> | ||
</ul> | ||
</div> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
|
||
<xsl:template match="app:Instance"> | ||
<li> | ||
<xsl:text>Identifier: </xsl:text> | ||
<xsl:value-of select="app:identifier"/> | ||
<xsl:text> Name: </xsl:text> | ||
<xsl:value-of select="app:name"/> | ||
<xsl:text> Props: </xsl:text> | ||
<xsl:for-each select="app:prop1"> | ||
<xsl:value-of select="."/> | ||
<xsl:if test="position() != last()">, </xsl:if> | ||
</xsl:for-each> | ||
</li> | ||
</xsl:template> | ||
</xsl:stylesheet> |
32 changes: 32 additions & 0 deletions
32
...deegree-core-commons/src/test/resources/org/deegree/commons/xml/featureToHtml-Xslt20.xslt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0"?> | ||
<xsl:stylesheet version="2.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:app="http://deegree.org/app"> | ||
|
||
<xsl:output method="html" indent="yes"/> | ||
|
||
<xsl:template match="/"> | ||
<html lang="de"> | ||
<head/> | ||
<body> | ||
<h1>Ergebnis GFI</h1> | ||
<div> | ||
<ul> | ||
<xsl:for-each select="//app:Instance"> | ||
<xsl:apply-templates select="."/> | ||
</xsl:for-each> | ||
</ul> | ||
</div> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
|
||
<xsl:template match="app:Instance"> | ||
<li> | ||
<xsl:text> </xsl:text> | ||
<xsl:value-of select="('Identifier:', app:identifier, 'Name:', app:name)" separator=" "/> | ||
<xsl:text> Props: </xsl:text> | ||
<xsl:value-of select="app:prop1" separator=", "/> | ||
</li> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...esources/org/deegree/services/wms/controller/capabilities/serialize/capabilities2html.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...wms/src/test/resources/org/deegree/services/wms/controller/exceptions/exceptions2html.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters