![]() |
|
|
|
#1 |
|
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 xmlns 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 xmlns 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 xmlns 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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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)? |
|
|
|
#3 |
|
Posts: n/a
|
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! |
|
|
|
#4 |
|
Posts: n/a
|
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! |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|
|
|
#7 |
|
Posts: n/a
|
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? |
|
|
|
#8 |
|
Posts: n/a
|
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 |
|
|
|
#9 |
|
Posts: n/a
|
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 |
|
|
|
#10 |
|
Posts: n/a
|
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 xmlns href CDATA #REQUIRED parse (xml|text) "xml" encoding CDATA #IMPLIED> in doctype!... |
|