A. W. Dunstan wrote:
Quote:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
For XPath stuff you should always use a namespace aware factory/document
builder so make sure you call the method to enable that.
Quote:
The XML source (src.xml, above) is:
>
<ns2:nuc2 xsi:schemaLocation="nuc2.xsd" xmlns:ns1="Exer_Sets"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="nuc2">
>
<ns1:Exer SetSequence="1" SetDescription="Exercise Identification">
<ExerciseNickname>pushups</ExerciseNickname>
<ExerciseAdditionalIdentifier>whatever</ExerciseAdditionalIdentifier>
</ns1:Exer>
>
</ns2:nuc2>
|
So your XML uses namespaces, to cater for that the XSLT stylesheet needs
to bind prefixes to the namespaces used:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:ns2="nuc2"
xmlns:ns1="Exer_Sets"
exclude-result-prefixes="ns1 ns2">
then you need to use those prefixes in your XPath expressions and in
your XSLT match patterns:
<xsl:value-of select="/ns2:nuc2/ns1:Exer/ExerciseNickname"/>
You just got lucky with your Java program as you used a not namespace
aware DOM I think, if you use a namespace aware DOM then you need
prefixes in your XPath expressions too and need to manage them in your
Java program too.
--
Martin Honnen
http://JavaScript.FAQTs.com/