Go Back   Velocity Reviews > Newsgroups > XML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

XML - XInclude Issue !

 
Thread Tools Search this Thread
Old 09-08-2006, 07:33 PM   #1
Default XInclude Issue !


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 xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnsi="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 xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnsi="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 xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnsi="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


john fra
  Reply With Quote
Old 09-08-2006, 08:21 PM   #2
Joseph Kesselman
 
Posts: n/a
Default Re: XInclude Issue !

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)?
  Reply With Quote
Old 09-08-2006, 10:22 PM   #3
john fra
 
Posts: n/a
Default Re: XInclude Issue !

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!
  Reply With Quote
Old 09-08-2006, 10:25 PM   #4
john fra
 
Posts: n/a
Default Re: XInclude Issue !

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!
  Reply With Quote
Old 09-08-2006, 10:35 PM   #5
Joseph Kesselman
 
Posts: n/a
Default Re: XInclude Issue !

john fra wrote:
> "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.



--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
  Reply With Quote
Old 09-09-2006, 12:53 AM   #6
Richard Tobin
 
Posts: n/a
Default Re: XInclude Issue !

In article <kyvqcm8hzfr8$.o1ioe6bfl1bo$.>,
john fra <> wrote:

> <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
  Reply With Quote
Old 09-09-2006, 01:20 AM   #7
Joe Kesselman
 
Posts: n/a
Default Re: XInclude Issue !

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?
  Reply With Quote
Old 09-09-2006, 02:05 AM   #8
Richard Tobin
 
Posts: n/a
Default Re: XInclude Issue !

In article <GuCdnUF->,
Joe Kesselman <keshlam-> wrote:

> > 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.


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
  Reply With Quote
Old 09-09-2006, 02:52 PM   #9
Joe Kesselman
 
Posts: n/a
Default Re: XInclude Issue !

Richard Tobin wrote:
> 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.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
  Reply With Quote
Old 09-11-2006, 11:37 AM   #10
john fra
 
Posts: n/a
Default Re: XInclude Issue !

Le 8 Sep 2006 23:53:17 GMT, Richard Tobin a écrit :

> In article <kyvqcm8hzfr8$.o1ioe6bfl1bo$.>,
> john fra <> wrote:
>
>> <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


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
xmlnsi CDATA #FIXED "http://www.w3.org/2001/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
encoding CDATA #IMPLIED>
in doctype!...

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump