You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Serge Emantayev <se...@yahoo.com> on 2007/11/12 16:22:52 UTC
Avoiding namespace in XPath expressions
Hi
My XML documents have a schema and a default namespace like:
<?xml version="1.0"?>
<emp_list
xmlns:myns="http://www.test.com"
xmlns="http://www.test.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.test.com emp_list.xsd">
<employee xsi:type="emp_list.employee">
<id>10</id>
...
To compose an XPath expression I need to prefix each tag with 'myns':
/myns:emp_list/myns:employee[myns:id=10]/myns:name
Is there a way to specify a default namespace for Xalan like I do it for Xerces?
xmlns="http://www.test.com"
That would make XPath expressions much simpler and more readable. I mean I would like to write:
/emp_list/employee[id=10]/name
yet, /emp_list/employee[@xsi:type='emp_list.employee' and id=10]/name
Best regards,
Sergey Emantayev
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Avoiding namespace in XPath expressions
Posted by David Bertoni <db...@apache.org>.
Serge Emantayev wrote:
> Hi
>
> My XML documents have a schema and a default namespace like:
>
> <?xml version="1.0"?>
> <emp_list
> xmlns:myns="http://www.test.com"
> xmlns="http://www.test.com"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.test.com emp_list.xsd">
>
> <employee xsi:type="emp_list.employee">
> <id>10</id>
> ...
>
> To compose an XPath expression I need to prefix each tag with 'myns':
>
> /myns:emp_list/myns:employee[myns:id=10]/myns:name
>
> Is there a way to specify a default namespace for Xalan like I do it for
> Xerces?
No, XPath 1.0 does not support a default namespace for path expressions.
Dave