XPATH question

Questions about XML that are not covered by the other forums should go here.
doncristiano
Posts: 1
Joined: Fri Feb 05, 2010 11:41 am

XPATH question

Post by doncristiano » Fri Feb 05, 2010 11:53 am

Hello

I have one question regarding an XPATH expression . Code:

Code: Select all


<?xml version="1.1" encoding="UTF-8"?>
<foo:root xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://foo" foo:schemaLocation="http://foo file:/c:/c1.xsd"/>
and schema:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://foo" xmlns:foo = "http://foo" elementFormDefault="qualified">
<xs:element name="root"/>
<xs:simpleType name="range">
<xs:restriction base="xs:integer">
<xs:minInclusive value="17"/>
<xs:maxInclusive value="18"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
When I'm executing this XPath:

Code: Select all

17 instance of foo:range
I get the following error

Code: Select all

net.sf.saxon.trans.StaticError: XPath syntax error at char 17 (...). There is no imported schema for namespace http://foo
I do not know where is the mistake. Can you help me please?
Thanks.

Regards
Donoiu Cristian, ro

adrian
Posts: 2659
Joined: Tue May 17, 2005 4:01 pm

Re: XPATH question

Post by adrian » Fri Feb 05, 2010 3:37 pm

Hi,

I believe you can't use a simple type name after 'instance of' only an atomic type or a kind test:
http://www.w3.org/TR/xpath20/#id-instance-of

By the way is your XML instance another schema in itself? If not, you might have a mistake here.
I see you have another XML schema namespace declaration in the XML file:

Code: Select all

xmlns:xs="http://www.w3.org/2001/XMLSchema"
Usually an XML instance has the XML instance namespace declaration and the schema location, like this:

Code: Select all

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://foo file:/c:/c1.xsd"
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Post Reply