Page 1 of 1

XInclude, XPointer, & Oxygen: what works?

Posted: Sat Sep 20, 2008 12:23 am
by graybeal
I think I've read all the current posts on XInclude/XPointer, and some of the older ones; it is difficult to sort out what comments still apply today. So here's my situation -- I want to grab (import on XSL processing) the contents of Deployment in the included file below, which does not have an 'id' attribute in the schema at the moment. What is it I don't understand in XInclude, XPointer, Oxygen, or is there a better way to do this simple thing?

I'm using Oxygen 9.3, mostly with the default parser, but also with Xsltproc. I have tried about 20 ways of putting fragment/entity/pointer information into an xi:include statement, all of them copied off of allegedly working examples on the web, with only 1 success. Using xi:include without xpointers or fragments works, but I get the whole document of course; and if I use "element(/1/1/1)", this works, but is fragile of course.

With fragments like 'href=1632.xml#/Metadata", I get "Fragment identifiers must not be used."

WIth xpointer="/", "/Metadata", "//", etc., I get: "InvalidShortHandPointer: The NCName of the ShortHand Pointer '/' is invalid."

My understanding is that xpointer supports XPath patterns, but apparently I'm not grokking how to do that correctly.

My included file is '1632.xml', as follows:

Code: Select all


  <Metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ourschemalocation">
<Deployment>
<Device name="TestName" />
<output>more stuff</output>
</Deployment>
</Metadata>
My encompassing file is of the form

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<Metadata xsi:noNamespaceSchemaLocation="http://myschemalocation" >
<DataProducer name="2008.09.18">
<DataProducer name="Port Optode">
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="1632.xml" xpointer="/" >
<xi:fallback>
<Device name="ERROR: could not include data from 1632.xml" id="1632">
</Device>
</xi:fallback>
</xi:include>
</DataProducer>
</DataProducer>
</Metadata>

Re: XInclude, XPointer, & Oxygen: what works?

Posted: Mon Sep 22, 2008 12:00 pm
by Radu
Hi,

Oxygen uses Xerces to validate XIncludes.

Xerces does not fully support the XPointer syntax. See this http://xerces.apache.org/xerces2-j/faq- ... html#faq-8

It only supports the XPointer element() Scheme http://www.w3.org/TR/2003/REC-xptr-element-20030325/ which means you can use XPointer values like

Code: Select all

element(/1/2)
to address the second child of the root element.

In order to use correctly the XPointer XPath syntax the XPointer attribute value should be like:

Code: Select all

xpointer(/sect1/para)
for which Xerces gives a clear error messsage :

Code: Select all

SchemeUnsupported: The XPointer scheme 'xpointer' is not supported.
Although Oxygen shows validation errors, we tested and the XPointer scheme seems to work when transforming the XML file using XSLT Proc.

Regards,
Radu