Need help: Problem with XML/XSL namespace matching

L

Lothar Lemnitzer

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:eek: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
 
R

Richard Tobin

Lothar Lemnitzer said:
4 <con_rel name="hyperonymy" dir="one"
xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="extended">
2 <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink/">
The namespace declarations in the source document (line 4) and in the
stylesheet (line 2) match

No, one has a slash on the end and the other doesn't.

Namespace names are matched literally, that is character-by-character.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top