[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: template matching using namespace
> <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)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|