[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
I'm working with Saxon 6.5.3 and Xerces 2.4. My experiences suggest that if the source document contains a default namespace then you have to map the namespace to an alternate prefix (ddi: in my example) otherwise the templates "match and select" statements do not work), in other words its impossible to match elements in the default xmlns namespace without mapping that namespace to a different prefix. I see this done often in the FAQ, see for example:
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d5145e970
I find this counter-intuitive. It seems that if the default namespace is just a namespace with the prefix "". then if I try to match elements in that namespace, then they just shouldn't have a prefix. In other words:
should work on the following document no matter if the xmlns is present or not:
-Mark
David Carlisle wrote:
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] exclude result prefixes doesn't stop prefix from showing up.
Subject: Re: [xsl] exclude result prefixes doesn't stop prefix from showing up. From: "Mark R. Diggory" <mdiggory@xxxxxxxxxxxxxxxxx> Date: Fri, 22 Aug 2003 13:18:36 -0400 |
I'm working with Saxon 6.5.3 and Xerces 2.4. My experiences suggest that if the source document contains a default namespace then you have to map the namespace to an alternate prefix (ddi: in my example) otherwise the templates "match and select" statements do not work), in other words its impossible to match elements in the default xmlns namespace without mapping that namespace to a different prefix. I see this done often in the FAQ, see for example:
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d5145e970
I find this counter-intuitive. It seems that if the default namespace is just a namespace with the prefix "". then if I try to match elements in that namespace, then they just shouldn't have a prefix. In other words:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.icpsr.umich.edu/DDI" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="codeBook"> <xsl:copy> <xsl:apply-templates select="@*"/> <docDscr> ... <titl> <xsl:value-of select="stdyDscr/citation/titlStmt/titl"/> </titl> ... </docDscr> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:template>
... </xsl:stylesheet>
should work on the following document no matter if the xmlns is present or not:
<?xml version="1.0" encoding="utf-8"?> <codeBook xmlns="http://www.icpsr.umich.edu/DDI" > <stdyDscr> <citation> <titlStmt> <titl>foo</titl> </titleStmt> </citation> </stdyDscr> </codeBook>
-Mark
David Carlisle wrote:
I thought to myself, there should be some way I can match the default namespace in the source document?
there is nothing special about the default namespace just think of it as having prefix "" with a special syntax trick that if teh prefix is "" you don't use a colon.
Xpath is essentially blind to the prefixes used in the source, it doesn't matter if it is <x:foo> or <b:foo> or <foo> so long as in each case it is foo in the same namespace you always use the same Xpath to select the element.
David
________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] exclude result prefixes d, David Carlisle | Thread | RE: [xsl] exclude result prefixes d, Michael Kay |
Re: [xsl] exclude result prefixes d, Mark R. Diggory | Date | Re: AW: [xsl] exclude result prefix, Mark R. Diggory |
Month |
Keywords