XInclude Issue !

J

john fra

Hi,

I want to include a part of many XML files into an unique XML file with
XInclude.

Example!

File1.xml, File2.xml, File3.xml... seems to that :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="doc.xsl" type="text/xsl"?>
<!DOCTYPE doc []>
<doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:noNamespaceSchemaLocation="doc.xsd">
<group1>
<b1>
<b11>lalala</b11>
<b12>lilili</b12>
</b1>
</group1>
</doc>

I want to extract this bloc from each files :

<b1>
<b11>lalala</b11>
<b12>lilili</b12>
</b1>

I want to create ONE unique file like this file :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="doc.xsl" type="text/xsl"?>
<!DOCTYPE doc []>
<doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:noNamespaceSchemaLocation="doc.xsd">
<group1>
<b1>
<b11>lalala</b11>
<b12>lilili</b12>
</b1>
<b1>
<b11>lalala</b11>
<b12>lilili</b12>
</b1>
<b1>
<b11>lalala</b11>
<b12>lilili</b12>
</b1>
</group1>
</doc>


To do that i've inserted xinclude like that but it doesn't work :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="doc.xsl" type="text/xsl"?>
<!DOCTYPE doc []>
<doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:noNamespaceSchemaLocation="doc.xsd">
<group1>
<xi:include href="File1.xml" xpointer="group1">
<xi:fallback>NotFoundError</xi:fallback>
</xi:include>

<xi:include href="File2.xml" xpointer="group1">
<xi:fallback>NotFoundError</xi:fallback>
</xi:include>

<xi:include href="File3.xml" xpointer="group1">
<xi:fallback>NotFoundError</xi:fallback>
</xi:include>
</group1>
</doc>

What's wrong ?
Any help would be greatly appreciated.

regards
Mike
 
J

Joseph Kesselman

When you say "doesn't work", what are you getting instead?

Are you sure you're running this through software which implements XInclude?

Are you sure the documents can be found at those relative URIs (which,
in some systems, may be case-sensitive)?
 
J

john fra

Le Fri, 08 Sep 2006 15:21:10 -0400, Joseph Kesselman a écrit :
When you say "doesn't work", what are you getting instead?

With :

<xi:include href="test.xml" xpointer="group1">
<xi:fallback> FICHIER NON TROUVE </xi:fallback>
</xi:include>

There's the following error:

"Include operation failed, reverting to fallback. Resource error reading
file as XML (href='File1.xml'). Reason: XPointer resolution unsuccessful."

the element group1 seems not to be found ?? I've tried many calls like
xpointer="element(group1)" ...

Are you sure you're running this through software which implements XInclude?

I've tryed in eclipse with oxygenxml plugin there is a checkbox to activate
XInclude, and i've checked it.
Are you sure the documents can be found at those relative URIs (which,
in some systems, may be case-sensitive)?

documents can be found, each file File1.xml, File2.xml, ... are parsed and
i can transform them individualy with my stylesheets.



Thank you!
 
J

john fra

Le Fri, 08 Sep 2006 15:21:10 -0400, Joseph Kesselman a écrit :
When you say "doesn't work", what are you getting instead?

With :

<xi:include href="File1.xml" xpointer="group1">
<xi:fallback> 404ERR </xi:fallback>
</xi:include>

There's the following error:

"Include operation failed, reverting to fallback. Resource error reading
file as XML (href='File1.xml'). Reason: XPointer resolution unsuccessful."

the element group1 seems not to be found ?? I've tried many calls like
xpointer="element(group1)" ...

Are you sure you're running this through software which implements XInclude?

I've tryed in eclipse with oxygenxml plugin there is a checkbox to activate
XInclude, and i've checked it.
Are you sure the documents can be found at those relative URIs (which,
in some systems, may be case-sensitive)?

documents can be found, each file File1.xml, File2.xml, ... are parsed and
i can transform them individualy with my stylesheets.



Thank you!
 
J

Joseph Kesselman

john said:
"Include operation failed, reverting to fallback. Resource error reading
file as XML (href='File1.xml'). Reason: XPointer resolution unsuccessful."

the element group1 seems not to be found

Hm. Are the examples really as simple as those you've shown us, or are
namespaces involved?

I haven't used xpointer yet, so I'm not sure what else to suggest checking.
 
R

Richard Tobin

john fra said:
<xi:include href="File1.xml" xpointer="group1">

That would include an element with ID "group1", not name "group1".
I've tried many calls like
xpointer="element(group1)" ...

And so would that.

In your original message you say the files are like this:

<doc ...>
<group1>
<b1>
<b11>lalala</b11>
<b12>lilili</b12>
</b1>
</group1>
</doc>

and that you want the <b1> element.

You can get that by using xpointer="element(/1/1/1)" - that is, the
first child of the first child of the first child of the document. To
get it by element name you would have to use something like the
XPointer xpointer() scheme, which may not be supported by your
XInclude implementation. The syntax would (I think) be something like
xpointer="xpointer(//b1)".

-- Richard
 
J

Joe Kesselman

Ah. Thanks; that helps me too. I'm so used to thinking in terms of XPath
syntax that I apparently have trouble reading XPointer syntax.
>XPointer xpointer() scheme, which may not be supported by your
> XInclude implementation. The syntax would (I think) be something like
> xpointer="xpointer(//b1)".

That looks more like an XPath. Did you mistype, or did they confuse the
terminology?
 
R

Richard Tobin

XPointer xpointer() scheme, which may not be supported by your
XInclude implementation. The syntax would (I think) be something like
xpointer="xpointer(//b1)".
[/QUOTE]
That looks more like an XPath.

Yes, that's essentially what the XPointer xpointer scheme is - a
syntax for using XPaths to identify fragments.
Did you mistype, or did they confuse the
terminology?

If I remember correctly, the original plan for XPointer was to use
XPaths. It was only later reduced to a core of "barenames" (IDs) and
the numeric element scheme, with the XPath part relegated to a
never-completed optional scheme.

See http://www.w3.org/TR/xptr - in particular the "previous version"
and "superseded by" links.

-- Richard
 
J

Joe Kesselman

Richard said:
If I remember correctly, the original plan for XPointer was to use
XPaths. It was only later reduced to a core of "barenames" (IDs) and
the numeric element scheme, with the XPath part relegated to a
never-completed optional scheme.

Hm. If I'd known about it at the time, I'd have protested loudly. Might
not have had any effect, but...

(I understand why they might not want to support full XPath. I even
understand why they might want the default to be match-by-IDs. But
introducing a completely different syntax Bothers me.)
 
J

john fra

Le 8 Sep 2006 23:53:17 GMT, Richard Tobin a écrit :
That would include an element with ID "group1", not name "group1".


And so would that.

In your original message you say the files are like this:

<doc ...>
<group1>
<b1>
<b11>lalala</b11>
<b12>lilili</b12>
</b1>
</group1>
</doc>

and that you want the <b1> element.

You can get that by using xpointer="element(/1/1/1)" - that is, the
first child of the first child of the first child of the document. To
get it by element name you would have to use something like the
XPointer xpointer() scheme, which may not be supported by your
XInclude implementation. The syntax would (I think) be something like
xpointer="xpointer(//b1)".

-- Richard

Ok, thank for all who've answered in this thread.

I understand why it don't work :

-1st : oxygenxml don't allow range, range-inside, and many others (maybe
due to parsers saxon or xalan). xpointer="xpointer(//b1)" isn't don't work
too.

-2nd : oxygenxml isn't able to deal with empty tags like this :
<doc ...>
<group1>
<b1>
<b11/>
<b12/>
</b1>
</group1>
</doc>

The result on inclusion is a truncated file (Bug?)
When I replace tags like <b11/> by <b11></b11> it works...

-3rd : I've forgottent to declare
<!ELEMENT xi:include EMPTY>
<!ATTLIST xi:include
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
encoding CDATA #IMPLIED>
in doctype!...
 
C

C. M. Sperberg-McQueen

That looks more like an XPath. Did you mistype, or did they confuse
the terminology?

No accident. Recall that XPath 1.0 was produced by the XSL and XML
Linking working groups as a common sublanguage for XSLT (where it is
used in match and select expressions) and for XPointer. Both host
languages extend the core language a bit, but it's been a long time
since I read the documentation for the xpointer scheme.

--C. M. Sperberg-McQueen
World Wide Web Consortium
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top