473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 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
Sep 8 '06 #1
11 1821
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)?
Sep 8 '06 #2
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:fallbackFICHIER 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!
Sep 8 '06 #3
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:fallback404ERR </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!
Sep 8 '06 #4
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
Sep 8 '06 #5
In article <ky*****************************@40tude.net>,
john fra <jo**@localhost.localdomainwrote:
<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 <b1element.

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
Sep 8 '06 #6
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?
Sep 9 '06 #7
In article <Gu******************************@comcast.com>,
Joe Kesselman <ke************@comcast.netwrote:
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
Sep 9 '06 #8
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
Sep 9 '06 #9
Le 8 Sep 2006 23:53:17 GMT, Richard Tobin a écrit :
In article <ky*****************************@40tude.net>,
john fra <jo**@localhost.localdomainwrote:
> <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 <b1element.

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></b11it 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!...

Sep 11 '06 #10
john fra wrote:
-2nd : oxygenxml isn't able to deal with empty tags like this :
If that's really true, report a bug to its developers and/or change tools.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 11 '06 #11
Joe Kesselman <ke************@comcast.netwrites:
>>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?
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

Sep 12 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erdem Guven | last post by:
I try to include some xml documents to another one and validate them. I get 'invalid content starting with element "xi:include".' error message at pointsample.xml line 6 from xml plugin of jedit...
1
by: CB | last post by:
I am using xerces 2.5.0 and xalan 2.6.0, and am following the xinclude instructions on the xerces faq at http://xml.apache.org/xerces2-j/faq-xinclude.html, and I am having no luck. I imagine I...
3
by: rene | last post by:
Hello everybody, i have these 2 xml files ------1.xml------ <?xml version="1.0" encoding="UTF-8"?> <root> <element>1</element> <element>2</element> </root>
1
by: Larry | last post by:
Given the "includer" xml file: <?xml version="1.0"?> <test-includer xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:testns="http://www.w3.org/TR/REC-xml-names"...
9
by: Tjerk Wolterink | last post by:
I have an xml document that conforms to my xschema document. Now i wanted to use xinclude in my xml document. But when i want to validate the xml document to the xschema i get the following...
1
by: Sergey Numerov | last post by:
Of the numerous XML standards, the classes of System.XML support only XPath, XML Schema and DTD. If I want to exploit XLink, XInclude or XQuery, can .NET offer me anything? Are there third-party...
4
by: Tim Arnold | last post by:
I'm using ElementTree to access some xml configuration files, and using the module's xinclude capability. I've got lines like this in the parent xml file (which lives in the same directory as the...
7
by: shaun roe | last post by:
I should like to use xslt to produce a document like the following: <crate xmlns:xi="http://www.w3.org/2001/XInclude"> <rod id="0"> <slot>1</slot> <xi:include...
2
by: McSwell | last post by:
I have an XML file that looks something like this: ------------------------ <?xml ...?> <!DOCTYPE ...> <src:fragment id="foo" ...> <Ph:Itemsome stuff </Ph:Item> <Ph:Itemsome more stuff...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.