Subject: Re: [xsl] 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 |
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.
<xsl:stylesheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" ........>
cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How do templates get invo, David Carlisle | Thread | Re: [xsl] How do templates get invo, M. David Peterson |
Re: [xsl] How do templates get invo, David Carlisle | Date | Re: [xsl] How do templates get invo, M. David Peterson |
Month |