Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2006, 08:09 AM
Registered User
 
Join Date: Jun 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default XPST0081: XPath syntax error ... with Saxon

Hello all,
I want to check with XMLUnit if a xml-stream has got an element.
I have following input:

The XML Stream:

<ta:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:dbm="ta.xsd"
           xmlns:xf="http://www.w3.org/2002/08/xquery-functions"
           xsi:schemaLocation="ta.xsd ta.xsd">

<ta:table name="person">
      <ta:column name="name"/>
<ta:table/>

<ta:schema/>


and the source code :

..
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);

DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(inputFile);
...
assertXpathExists("//ta:table[@name='person']", document );
...


I got the error

XPST0081: XPath syntax error at char 11 in {//ta:table[@}:
    Undeclared namespace prefix {ta}

even when I load the Document with namespace-awareness on!

What goes wrong and how to avoid this?

Cheers



 
Old June 22nd, 2006, 08:20 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

assertXPathExists() is your own method so I can't see what actual Saxon methods you are calling.

Before you compile an XPath expression you must declare to the static context any namespace prefixes you use in the expression. The exact way of doing this depends on the API you are using.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 22nd, 2006, 09:28 AM
Registered User
 
Join Date: Jun 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
the method assertXpathExists comes from XMLUnit .

It takes for the first argument the xpath expression and the second one the document.

So how to setup then the static context in case of Saxon ??
I haven't found any examples..

cheers

 
Old June 22nd, 2006, 09:53 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

A quick look at XMLUnit doesn't suggest any obvious ways of binding namespaces for use in XPath expressions, but perhaps I've missed something. I suggest you take it up with the XMLUnit developers.

The following gives some background:
http://www.xml.com/pub/a/2004/02/25/qanda.html

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
what is this error generated by saxon processor? muki XSLT 8 February 12th, 2007 03:57 PM
error on saxon 8.8 rjonk XSLT 1 October 24th, 2006 09:03 AM
error XTDE0410 (from saxon generator)??? ronisc XSLT 2 June 27th, 2006 09:18 AM
Syntax help with string-length and XPath EstherMStrom XSLT 1 February 9th, 2005 08:02 PM
xpath syntax problem nrane26 XSLT 1 January 22nd, 2005 01:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.