Skip to content

Instantly share code, notes, and snippets.

@emiliano-poggi
Created August 10, 2011 17:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save emiliano-poggi/1137530 to your computer and use it in GitHub Desktop.
Save emiliano-poggi/1137530 to your computer and use it in GitHub Desktop.
XSLT 1.0 xsl:choose vs. XPath
$a | self::node()[$a]
can stay for:
<xsl:choose>
<xsl:when test="$a">
<xsl:value-of select="$a"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:variable name="vinyl" select="document('test_i2.xml')"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- xsl:choose
<xsl:template match="@vinyl">
<xsl:attribute name="vinyl">
<xsl:variable name="test" select="
$vinyl/Vinyl/Album[Title=current()/../@Title]/Vinyl"/>
<xsl:choose>
<xsl:when test="$test">
<xsl:value-of select="$test"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
-->
<!-- XPath
<xsl:template match="@vinyl">
<xsl:attribute name="vinyl">
<xsl:value-of select="
$vinyl/Vinyl/Album[Title=current()/../@Title]/Vinyl
|
self::node()[count($vinyl/Vinyl/Album[Title=current()/../@Title])=0]"/>
</xsl:attribute>
</xsl:template>
-->
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment