Thanks, but I'm not using a stylesheet,

The application is JMeter - we have an XPath extractor which can be
used to extract items from an XML document sample - there is no
stylesheet involved, just the XML document and the XPath query.

S///
On 03/09/07, Mukul Gandhi <[EMAIL PROTECTED]> wrote:
> You need to provide the namespace declaration,
> xmlns:ns="http://biz.aol.com/schema/2006-12-18"; in the stylesheet
> also. Then it should work.
>
> For e.g., this stylesheet
>
> <?xml version="1.0"?>
> <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                        xmlns:ns="http://biz.aol.com/schema/2006-12-18";
>                        version="1.0">
>
>  <xsl:output method="text" />
>
>  <xsl:template match="/">
>   <xsl:value-of select="count(//ns:result)" />
>  </xsl:template>
>
> </xsl:stylesheet>
>
> When applied to your source document, works fine.
>
> On 9/3/07, sebb <[EMAIL PROTECTED]> wrote:
> > I'm using xalan-j 2.7.0; testing using the ApplyXPathDOM sample code.
> > ====
> >
> > Sample XML document:
> >
> > ===
> > <?xml version="1.0" encoding="utf-8"?>
> > <soapenv:Envelope
> >  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
> >  <soapenv:Body
> >  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
> >  <ns:registerOfferResponse  xmlns:ns="http://biz.aol.com/schema/2006-12-18";>
> >   <ns:result>0</ns:result>
> >  </ns:registerOfferResponse>
> >  </soapenv:Body>
> > </soapenv:Envelope>
> > ===
> >
> > Using the XPath
> >
> > //ns:result
> >
> > generates the error:
> >
> > "Prefix must resolve to a namespace: ns"
> >
> > If I move the declaration to the top-level element in the xml document, as 
> > in
> >
> > ===
> > <?xml version="1.0" encoding="utf-8"?>
> > <soapenv:Envelope xmlns:ns="http://biz.aol.com/schema/2006-12-18";
> >  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
> >  <soapenv:Body
> >  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
> >  <ns:registerOfferResponse>
> >   <ns:result>0</ns:result>
> >  </ns:registerOfferResponse>
> >  </soapenv:Body>
> > </soapenv:Envelope>
> > ===
> >
> > then the XPath //ns:result works fine.
> >
> > I get the same error as before if "ns" is declared in the Body element.
> >
> > It apears that the XPath processing requires the namespace to be
> > defined only in the top-level element, whereas AIUI XML allows the
> > namespace to be defined on first use of an namespace.
> >
> > Is this correct?
> >
> > If so, is there any way to tell xalan to use the namespace
> > declarations from child elements?
> >
> > BTW, I have seen a work-round, which is to use the query:
> >
> > //*[local-name()='result' and
> > namespace-uri()='http://biz.aol.com/schema/2006-12-18' ]
> >
> > but that is really messy.
> >
> > S///
> >
>
>
> --
> Regards,
> Mukul Gandhi
>

Reply via email to