By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,959 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,959 IT Pros & Developers. It's quick & easy.

Need help: Problem with XML/XSL namespace matching

P: n/a
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="" xlink:type="extended">
5 <locator xlink:type="locator"
6 <locator xlink:type="locator"
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"
4 <xsl:output method="html" />
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.


Lothar Lemnitzer
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
In article <35************************** >,
Lothar Lemnitzer <lo****> wrote:
4 <con_rel name="hyperonymy" dir="one"
xmlns:xlink="" xlink:type="extended"> 2 <xsl:stylesheet version="1.0"
xmlns: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
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.