Created
August 2, 2017 11:53
-
-
Save tanaka9230/1d2da0e80097a14b60a915ba1ceb2fbe to your computer and use it in GitHub Desktop.
XSL example
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- Apache Ant build.xml --> | |
<project name="example" default="main"> | |
<target name="init"> | |
<property name="source" value="source/main/xml"/> | |
<property name="target" value="target"/> | |
<property name="xsl" value="source/main/resources/example.xsl"/> | |
</target> | |
<target name="main" depends="init"> | |
<xslt style="${xsl}" basedir="${source}" destdir="${target}" extension=".xml"> | |
<factory name="com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"/> | |
<!--<factory name="net.sf.saxon.TransformerFactoryImpl"/>--> | |
</xslt> | |
</target> | |
</project> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:uuid="xalan://java.util.UUID" | |
version="2.0" | |
> | |
<!-- | |
- | |
- XSL Example | |
- | |
--> | |
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="yes"/> | |
<!-- =============================================================== --> | |
<!-- | |
- customers (Root) | |
--> | |
<xsl:template match="customers"> | |
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> | |
<Customers> | |
<xsl:apply-templates select="*" /> | |
</Customers> | |
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> | |
</xsl:template> | |
<!-- =============================================================== --> | |
<!-- | |
- customer (Entry) | |
--> | |
<xsl:template match="customer"> | |
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> | |
<xsl:variable name="no" select="position()"/> | |
<xsl:variable name="uuid" select="uuid:randomUUID()"/> | |
<xsl:variable name="name" select="@name"/> | |
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> | |
<Customer id="{$uuid}"> | |
<No><xsl:value-of select="$no"/></No> | |
<DispName><xsl:value-of select="$name"/></DispName> | |
</Customer> | |
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> | |
</xsl:template> | |
<!-- =============================================================== --> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment