Skip to content

Instantly share code, notes, and snippets.

@patdavid
Created May 4, 2018 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patdavid/daed5c1b7d8011ffdf3aacb33a764eb9 to your computer and use it in GitHub Desktop.
Save patdavid/daed5c1b7d8011ffdf3aacb33a764eb9 to your computer and use it in GitHub Desktop.
Identity Transform and targeting an XPath node
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//Point/X">
<X><xsl:value-of select=". * 25.4"/></X>
</xsl:template>
<xsl:template match="//Point/Y">
<Y><xsl:value-of select=". * 25.4"/></Y>
</xsl:template>
<xsl:template match="//Point/Z">
<Z><xsl:value-of select=". * 25.4"/></Z>
</xsl:template>
</xsl:stylesheet>
@patdavid
Copy link
Author

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="node()|@*">
      <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
    </xsl:template>

    <xsl:template match="//Point/X">
        <X><xsl:value-of select=". * 25.4"/></X>
    </xsl:template>

    <xsl:template match="//Point/Y">
        <Y><xsl:value-of select=". * 25.4"/></Y>
    </xsl:template>

    <xsl:template match="//Point/Z">
        <Z><xsl:value-of select=". * 25.4"/></Z>
    </xsl:template>

</xsl:stylesheet>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment