<xsl:template match="constraint:*">
<!-- some code -->
</xsl:template>
if I apply my template to the XML file above then it will catch all
the three elements. is there any way I can find out which one is
currently being caught by the current template that the program
counter is in?
See
http://www.w3.org/TR/xpath-functions/#func-local-name
<xsl:template match="constraint:*">
<xsl:variable name="ln" select="local-name(.)"/>
<xsl:choose>
<xsl:when test="$ln eq 'SimpleConstraint'">
... handle constraint:SimpleConstraint ...
</xsl:when>
<xsl:when test="$ln eq 'And'">
... handle constraint:And ...
</xsl:when>
<xsl:otherwise>
<!-- otherwise just process the contents -->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
My second question, is there any way I can identify and copy those
parts of the code that have not been caught by any of the defined XSLT
template, to the output?
Well, a default template is the way we normally handle that. At
the top of many stylesheets which are mostly copying the input data
you will find something like this:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
Jim
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson
jim(_dot_)robinson(_at_)stanford(_dot_)edu
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--