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

Re: How do templates get invoked for elements decorate

Subject: Re: How do templates get invoked for elements decorated with namespaces?
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 5 Dec 2006 13:56:12 +0000
how to decorate an urn
On 12/5/06, Mark Wilson <mark@xxxxxxxxxxxx> wrote:
Hi,

I have no idea how to even look this problem up in the archives. If the
answer is there, I apologize.

I find that a template such as

<xsl:template match="/Workbook">

<xsl:apply-templates select="DocumentProperties" />

</xsl:template>

is invoked when the element name is undecorated with a namespace attribute:

 <Workbook>
.
</Workbook>

but is not invoked when the namespace is present:

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"

xmlns:o="urn:schemas-microsoft-com:office:office"

xmlns:x="urn:schemas-microsoft-com:office:excel"

xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"

xmlns:html="http://www.w3.org/TR/REC-html40">

...

</Workbook>

How does the template have to be changed to be invoked for the second case?

In the second case <Workbook> is in the namespace "urn:schemas-microsoft-com:office:spreadsheet" because it's unprefixed and the default namespace (the one used by unprefixed elements) has been changed using xmlns="..."

Oddly the same namespace has been defined again for the "ss" prefix,
which is a bit pointless - either <Workbook> should be changed to
<ss:Workbook> and don't change the default namespace, or the "ss"
prefix should be dropped.

Either way, what you need to do to define that namespace in your
stylesheet and give it a prefix, say "ss" as well, then use that
prefix when referring to that element.

For example:

<xsl:stylesheet
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" ........>

and then

<xsl:apply-templates select="ss:Workbook"/>

<xsl:template match="ss:Workbook">

etc

cheers
andrew

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.