[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: template matching using namespace

Subject: Re: template matching using namespace
From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx>
Date: Wed, 29 Nov 2006 02:49:43 -0800
xsl 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)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.