Subject: Re: [xsl] template matching using namespace From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx> Date: Wed, 29 Nov 2006 02:49:43 -0800 |
> <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.robinson@xxxxxxxxxxxx Stanford University HighWire Press http://highwire.stanford.edu/ +1 650 7237294 (Work) +1 650 7259335 (Fax)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] template matching using names, Nima Kaviani | Thread | Re: [xsl] template matching using n, Florent Georges |
[xsl] template matching using names, Nima Kaviani | Date | Re: [xsl] template matching using n, Florent Georges |
Month |