Lothar Lemnitzer
Usenet Archive
- Joined
- Sep 21, 2004
- Messages
- 1
- Reaction score
- 0
Dear fellows,
I have a problem with matching namespaces in an XML document and an XSLT stylesheet (at least I think that this is the source of trouble).
My XML document looks like this:
1 <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> 2 <!DOCTYPE relations SYSTEM "germanet_relations.dtd"> 3 <relations> 4 <con_rel name="hyperonymy" dir="one" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="extended"> 5 <locator xlink:type="locator" xlink:href="adj.Allgemein.xml#aAllgemein.1" xlink:label="aAllgemein.1"/> 6 <locator xlink:type="locator" xlink:href="adj.Allgemein.xml#aAllgemein.2" xlink:label="aAllgemein.2"/> 7 <arc xlink:type="arc" xlink:from="aAllgemein.2" xlink:to="aAllgemein.1" xlink:actuate="onRequest" xlink:show="other"/> 8 </con_rel> 9 ....
10 </relations>
(line numbering for convenience)
My stylesheet looks like this:
1 <?xml version='1.0' encoding="iso-8859-1"?>
2 <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink/"> 3 4 <xsl
utput method="html" /> 5 7 <xsl:template match="/"> 8 <xsl:apply-templates select="//con_rel"/> 9 </xsl:template>
10 <xsl:template match="con_rel[@name='hyperonymy']">
11 <xsl:value-of select="./arc[1]/@xlink:from" />
12 <xsl:text>
13 </xsl:text>
14 </xsl:template>
15 </xsl:stylesheet>
Produces only empty lines in the target document.
The namespace declarations in the source document (line 4) and in the stylesheet (line 2) match (i.e. they point to the same URI)..
From the production of new lines in the target document I see that the source document elements are "matched" (i.e., the template in line 10-14 is entered)
11 <xsl:value-of select="./arc[1]/@from" />
(without the ns prefix does not work either).
11 <xsl:value-of select="./arc[1]/@*[local-name='from']" />
does indeed work, but the meaning is "I do not care about the namespace prefix" what is not exactly what I want to do.
I used "xsltproc" and the Saxon parser 7.5, with the same results.
You help is very much appreciated.
Yours
Lothar Lemnitzer
I have a problem with matching namespaces in an XML document and an XSLT stylesheet (at least I think that this is the source of trouble).
My XML document looks like this:
1 <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> 2 <!DOCTYPE relations SYSTEM "germanet_relations.dtd"> 3 <relations> 4 <con_rel name="hyperonymy" dir="one" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="extended"> 5 <locator xlink:type="locator" xlink:href="adj.Allgemein.xml#aAllgemein.1" xlink:label="aAllgemein.1"/> 6 <locator xlink:type="locator" xlink:href="adj.Allgemein.xml#aAllgemein.2" xlink:label="aAllgemein.2"/> 7 <arc xlink:type="arc" xlink:from="aAllgemein.2" xlink:to="aAllgemein.1" xlink:actuate="onRequest" xlink:show="other"/> 8 </con_rel> 9 ....
10 </relations>
(line numbering for convenience)
My stylesheet looks like this:
1 <?xml version='1.0' encoding="iso-8859-1"?>
2 <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink/"> 3 4 <xsl
10 <xsl:template match="con_rel[@name='hyperonymy']">
11 <xsl:value-of select="./arc[1]/@xlink:from" />
12 <xsl:text>
13 </xsl:text>
14 </xsl:template>
15 </xsl:stylesheet>
Produces only empty lines in the target document.
The namespace declarations in the source document (line 4) and in the stylesheet (line 2) match (i.e. they point to the same URI)..
From the production of new lines in the target document I see that the source document elements are "matched" (i.e., the template in line 10-14 is entered)
11 <xsl:value-of select="./arc[1]/@from" />
(without the ns prefix does not work either).
11 <xsl:value-of select="./arc[1]/@*[local-name='from']" />
does indeed work, but the meaning is "I do not care about the namespace prefix" what is not exactly what I want to do.
I used "xsltproc" and the Saxon parser 7.5, with the same results.
You help is very much appreciated.
Yours
Lothar Lemnitzer