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

Re: Template priority problem

Subject: Re: Template priority problem
From: david_n_bertoni@xxxxxxxxxx
Date: Tue, 6 Sep 2005 12:36:48 -0700
xsl template priority attribute
> > When people come to this list and say that a template
> > isn't matching when they expect it to, the most common
> > reason is that the elements are in a namespace (typically
> > a default namespace). You haven't shown us the source
> > document, so that's just a guess.
> 

> Yes of course you are right. Damn Default namespace. Whats
> the best approach to solve my problem when all elements in
> the input XML are in a non-blank default namespace? I am
> thinking this may screw up the identity transform template.

No, it doesn't affect the canonical identity transformation.  However, it 
does affect the specialized templates you add to modify the identity 
transformation:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0"
    xmlns:foo="http://www.foo.com/foo">

<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="foo:field">
  <!-- Here's where we should do something special... -->
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Some other comments:

1. "@* | node()" is a less verbose version of "* | comment()
| text() | processing-instruction() | @*"

2. The priority attribute you are using are not necessary.  In most cases, 
the default priorities for match patterns are sufficient.

3. Default namespaces may also affect the XPath expressions you use in 
your xsl:variable definitions.

Dave

Dave

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.