87883

Saxon Xpath namespace

Given the following xml:

<Document xmlns="urn:company.com:catalog.01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <book> <author>Wells</author> </book> </Document>

With Xerces the following xpath query works:

//urn:company.com:catalog.01:author

When I use Saxon (v 8.7) I a StaticError with message 'Invalid QName local part {company.com:catalog....}'.

What should the Xpath query look like to get the value of author?

Answer1:

Xerces should not allow an XPath expression like

//urn:company.com:catalog.01:author

XPath is XML Names compliant, so a : (colon) in a QName divides the prefix part from local name part of a QName.

There is no syntax in XPath to use the full expanded QName in name test:

You could use

//*[local-name()='author'][namespace-uri()='urn:company.com:catalog.01']

Answer2:

You didn't post your XSL file. I went through this recently, and the solution was to make sure the xsl file has a line like:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:c="urn:company.com:catalog.01">

Then your references to elements in the xml file are prefixed with "c:":

//c:author

Recommend

  • shared memory mutex with struct pointers
  • Is there a simple way to convert Excel inline strings to shared strings table in Java?
  • SAX parser ignores text because of a tag
  • Parsing XML doesn't take backspace in Android
  • Axis generating nil on a non null Array
  • How to correctly consume a produced Web Service? (Apache CXF) [closed]
  • How to load N-TRIPLE file in apache jena?
  • How to play a video url from server in an iPhone app
  • How does cm:countable aspect works in alfresco?
  • How to return custom objects in Apache Axis2 WebService
  • XSD problem: The value of attribute on element is not valid with respect to its type
  • Checking absence of attribute with cts:query
  • SAXParseException localized
  • How to generate xml from xsd schema?
  • Jenkins build fails after running Cucumber tests on Java heap space exception
  • Exclude jar from war Maven 3
  • How do I retrieve the text in a table column using Selenium RC?
  • Failing to get duration of youtube video using xpath
  • Searching an XML file using PHP [closed]
  • Which table should be Parent table and which should be child table?
  • parsing xml and html page with lxml and requests package in python
  • Capturing STDOUT in RSpec
  • Mongoose TypeError: Cannot use 'in' operator to search for '_id' in
  • Reloading table causes flickering
  • Can you build a truly RESTful service that takes many parameters?
  • ASP.NET MVC2 Error: No parameterless constructor defined for this object
  • xcode don't localize specific strings
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Using variable in a value field in jMeter
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Accessing IRQ description array within a module and displaying action names
  • How to recover from a Spring Social ExpiredAuthorizationException
  • ILMerge & Keep Assembly Name
  • Display Images one by one with next and previous functionality
  • Large data - storage and query
  • WOWZA + RTMP + HTML5 Playback?
  • Numpy divide by zero. Why?
  • SQL merge duplicate rows and join values that are different
  • Getting Messege Twice Using IMvxMessenger