You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Gareth Western <ga...@garethwestern.com> on 2009/02/02 23:20:40 UTC

XInclude and XPointer

Hi,

I have an application which uses Xerces-J (2.9.0) to parse a large xml
document which I'd like to split into several smaller files just to
make it easier to manage. The main file looks like this:

<function-set xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="PrivateFunctions.xml" />
  <xi:include href="GroupFunctions.xml" />
   ...
</function-set>

Each of the included files is similar to the following:

<function-set>
  <function code="FC1000" />
  <function code="FC1001" />
   ...
</function-set>

The schema prevents me from including the entire inner file, as that
would result in nested function-set elements, so ideally i'd like to
only include the functions from each inner file. XPointer looks like
it would be the answer to this, changing the main file to look
something like:

<function-set xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="PrivateFunctions.xml" xpointer="/function-set/*" />
   ...
</function-set>

... however according to the Xerces XInclude FAQ only the "element()"
scheme is supported. Does this mean I can only reference specific
individual elements from the included file, as opposed to the full
range of functions?

For example, the following works perfectly, but only includes the
first function from PrivateFunctions.xml:

<function-set xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="PrivateFunctions.xml" xpointer="element(/1/1)" />
</function-set>

Any suggestions as to how to accomplish what I'm trying to do? Let me
know if you have any questions / if I haven't explained the situation
very well.

Thanks!

Gareth

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XInclude and XPointer

Posted by Michael Ludwig <mi...@gmx.de>.
Michael Glavassevich schrieb am 31.03.2009 um 10:09:01 (-0400):
> Michael Ludwig <mi...@gmx.de> wrote on 03/28/2009 12:39:14 PM:
> 
> > Gareth Western schrieb am 02.02.2009 um 22:20:40 (+0000):
> > > Hi,
> > >
> > > I have an application which uses Xerces-J (2.9.0) to parse a large
> > > xml document which I'd like to split into several smaller files
> > > just to make it easier to manage.
> >
> > > The schema prevents me from including the entire inner file, as
> > > that would result in nested function-set elements, so ideally i'd
> > > like to only include the functions from each inner file.
> >
> > The answer is probably too late, but I just learnt about the entity
> > business that was saved from SGML into XML, and it might come in
> > quite handy here.
> 
> Depends on your scenario. I recall Gareth needed more than what
> Xerces' current XInclude implementation currently supports. General
> entities provide even less than that.

Hi Michael,

it certainly does depend on the scenario. Gareth seemed to want to
include the document without the document element <function-set> as that
would have resulted in a schema violation. Freeing the data underneath
<function-set> from the document grip and putting it in an external
general parsed entity, which isn't constrained to conform to an XML
document, would have allowed him to easily include it in any number of
documents, which just consist of the internal or external subset, the
document element, and the entity references. But I may have overlooked
something.

Cheers,

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XInclude and XPointer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Michael,

Michael Ludwig <mi...@gmx.de> wrote on 03/28/2009 12:39:14 PM:

> Gareth Western schrieb am 02.02.2009 um 22:20:40 (+0000):
> > Hi,
> >
> > I have an application which uses Xerces-J (2.9.0) to parse a large xml
> > document which I'd like to split into several smaller files just to
> > make it easier to manage.
>
> > The schema prevents me from including the entire inner file, as that
> > would result in nested function-set elements, so ideally i'd like to
> > only include the functions from each inner file.
>
> The answer is probably too late, but I just learnt about the entity
> business that was saved from SGML into XML, and it might come in quite
> handy here.

Depends on your scenario. I recall Gareth needed more than what Xerces'
current XInclude implementation currently supports. General entities
provide even less than that.

> You could do without the new-fangled XInclude and XPointer stuff, by
> using [general] external parsed entities and entity references to
> organize your documents into physical components.
>
> http://www.w3.org/TR/REC-xml/#sec-physical-struct
>
> --------
>
> C:\dev\XML\entities :: dir /b
> AllFunctions.xml
> AllFunctions2.xml
> function-set.dtd
> GroupFunctions.ent
> GroupFunctions.xml
> PrivateFunctions.ent
> PrivateFunctions.xml
>
> C:\dev\XML\entities :: type PrivateFunctions.ent
> <function code="FC1000" />
> <function code="FC1001" />
>
> C:\dev\XML\entities :: type GroupFunctions.ent
> <function code="FC5000" />
> <function code="FC5001" />
>
> C:\dev\XML\entities :: type PrivateFunctions.xml
> <?xml version="1.0" standalone="yes"?>
> <!DOCTYPE function-set [
> <!ENTITY PrivateFunctions SYSTEM "PrivateFunctions.ent">
> ]>
> <function-set>
>         &PrivateFunctions;
> </function-set>
>
> C:\dev\XML\entities :: type GroupFunctions.xml
> <?xml version="1.0" standalone="yes"?>
> <!DOCTYPE function-set [
> <!ENTITY GroupFunctions SYSTEM "GroupFunctions.ent">
> ]>
> <function-set>
>         &GroupFunctions;
> </function-set>
>
> C:\dev\XML\entities :: type AllFunctions.xml
> <?xml version="1.0" standalone="yes"?>
> <!DOCTYPE function-set [
> <!ENTITY PrivateFunctions SYSTEM "PrivateFunctions.ent">
> <!ENTITY GroupFunctions   SYSTEM "GroupFunctions.ent">
> ]>
> <function-set>
>         &PrivateFunctions;
>         &GroupFunctions;
> </function-set>
>
> --------
>
> You could also put all the entity declarations into a DTD and reference
> it from your document entities.
>
> C:\dev\XML\entities :: type function-set.dtd
> <!ELEMENT function-set (function*)>
> <!ELEMENT function EMPTY>
> <!ATTLIST function code NMTOKEN #REQUIRED>
> <!ENTITY PrivateFunctions SYSTEM "PrivateFunctions.ent">
> <!ENTITY GroupFunctions   SYSTEM "GroupFunctions.ent">
>
> C:\dev\XML\entities :: type AllFunctions2.xml
> <?xml version="1.0"?>
> <!DOCTYPE function-set SYSTEM "function-set.dtd">
> <function-set>
>         &PrivateFunctions;
>         &GroupFunctions;
> </function-set>
>
> Michael Ludwig
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: XInclude and XPointer

Posted by Michael Ludwig <mi...@gmx.de>.
Gareth Western schrieb am 02.02.2009 um 22:20:40 (+0000):
> Hi,
> 
> I have an application which uses Xerces-J (2.9.0) to parse a large xml
> document which I'd like to split into several smaller files just to
> make it easier to manage.

> The schema prevents me from including the entire inner file, as that
> would result in nested function-set elements, so ideally i'd like to
> only include the functions from each inner file.

The answer is probably too late, but I just learnt about the entity
business that was saved from SGML into XML, and it might come in quite
handy here.

You could do without the new-fangled XInclude and XPointer stuff, by
using [general] external parsed entities and entity references to
organize your documents into physical components.

http://www.w3.org/TR/REC-xml/#sec-physical-struct

--------

C:\dev\XML\entities :: dir /b
AllFunctions.xml
AllFunctions2.xml
function-set.dtd
GroupFunctions.ent
GroupFunctions.xml
PrivateFunctions.ent
PrivateFunctions.xml

C:\dev\XML\entities :: type PrivateFunctions.ent
<function code="FC1000" />
<function code="FC1001" />

C:\dev\XML\entities :: type GroupFunctions.ent
<function code="FC5000" />
<function code="FC5001" />

C:\dev\XML\entities :: type PrivateFunctions.xml
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE function-set [
<!ENTITY PrivateFunctions SYSTEM "PrivateFunctions.ent">
]>
<function-set>
        &PrivateFunctions;
</function-set>

C:\dev\XML\entities :: type GroupFunctions.xml
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE function-set [
<!ENTITY GroupFunctions SYSTEM "GroupFunctions.ent">
]>
<function-set>
        &GroupFunctions;
</function-set>

C:\dev\XML\entities :: type AllFunctions.xml
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE function-set [
<!ENTITY PrivateFunctions SYSTEM "PrivateFunctions.ent">
<!ENTITY GroupFunctions   SYSTEM "GroupFunctions.ent">
]>
<function-set>
        &PrivateFunctions;
        &GroupFunctions;
</function-set>

--------

You could also put all the entity declarations into a DTD and reference
it from your document entities.

C:\dev\XML\entities :: type function-set.dtd
<!ELEMENT function-set (function*)>
<!ELEMENT function EMPTY>
<!ATTLIST function code NMTOKEN #REQUIRED>
<!ENTITY PrivateFunctions SYSTEM "PrivateFunctions.ent">
<!ENTITY GroupFunctions   SYSTEM "GroupFunctions.ent">

C:\dev\XML\entities :: type AllFunctions2.xml
<?xml version="1.0"?>
<!DOCTYPE function-set SYSTEM "function-set.dtd">
<function-set>
        &PrivateFunctions;
        &GroupFunctions;
</function-set>

Michael Ludwig

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XInclude and XPointer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Gareth,

Gareth Western <ga...@garethwestern.com> wrote on 02/04/2009 03:27:02 PM:

> Oh, I spoke too soon. From [1]: "XOM supports XInclude including the
> XPointer element() scheme and bare name XPointers. It does not support
> the XPointer xpointer() scheme." Which I guess means it's in the same
> boat as Xerces with respect to what's supported.

I thought XOM supported more than that. Oh well... :-\

> Perhaps I'm going about this the wrong way. Am I actually using
> XInclude correctly (based on my original example, with several files
> each containing a <function-set> and multiple <function> children and
> trying to use xinclude to compose a single file / <function-set> with
> all <function>s in it)?

What you're trying to do looks perfectly reasonable, though unfortunately
seems like it's not widely supported.

Apache Cocoon [1] apparently also has built-in XInclude support. You might
have better luck with that.

> Right now it looks like XSLT may have to be the way to go after all... =\
>
> On Wed, Feb 4, 2009 at 10:54 AM, Gareth Western
> <ga...@garethwestern.com> wrote:
> > Michael: XOM looks like it might be what I'm looking for. I originally
> > tried to use the old XIncluder project from sourceforge[1] until I
> > realised I'd probably need to use XPointers (which XIncluder does not
> > support either).
> >
> > Joseph: I had considered that, but the situation is already complex
> > enough as it is so I'd rather not introduce XSLT to what we're doing
> > if it can be avoided (sure, XSLT isn't _that_ complicated, but it
> > would add yet another ingredient to the recipe ;-))
> >
> > Thank you both for your replies!
> >
> > Gareth
> >
> > [1] http://xincluder.sourceforge.net/
> >
> > On Tue, Feb 3, 2009 at 10:28 PM,  <ke...@us.ibm.com> wrote:
> >>
> >>> If you need support for other kinds of XPointers then you may want to
> >>> take a look on the net at some of the other XInclude processors that
> >>> are available. e.g. perhaps XOM [4] supports what you're looking for.
> >>
> >> Another quick idea: It's possible to implement an XInclude subsetas an
XSLT
> >> stylesheet. If that approach works for you, you can use Xalan to
> process it.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

[1] http://cocoon.apache.org/2.2/core-modules/core/2.2/985_1_1.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: XInclude and XPointer

Posted by Gareth Western <ga...@garethwestern.com>.
Oop. Forgot to reference my [1] in the other email. It's the XOM
Tutorial @ http://www.xom.nu/tutorial.xhtml#d0e1992

On Wed, Feb 4, 2009 at 8:27 PM, Gareth Western <ga...@garethwestern.com> wrote:
> Oh, I spoke too soon. From [1]: "XOM supports XInclude including the
> XPointer element() scheme and bare name XPointers. It does not support
> the XPointer xpointer() scheme." Which I guess means it's in the same
> boat as Xerces with respect to what's supported.
>
> Perhaps I'm going about this the wrong way. Am I actually using
> XInclude correctly (based on my original example, with several files
> each containing a <function-set> and multiple <function> children and
> trying to use xinclude to compose a single file / <function-set> with
> all <function>s in it)?
>
> Right now it looks like XSLT may have to be the way to go after all... =\
>
> On Wed, Feb 4, 2009 at 10:54 AM, Gareth Western
> <ga...@garethwestern.com> wrote:
>> Michael: XOM looks like it might be what I'm looking for. I originally
>> tried to use the old XIncluder project from sourceforge[1] until I
>> realised I'd probably need to use XPointers (which XIncluder does not
>> support either).
>>
>> Joseph: I had considered that, but the situation is already complex
>> enough as it is so I'd rather not introduce XSLT to what we're doing
>> if it can be avoided (sure, XSLT isn't _that_ complicated, but it
>> would add yet another ingredient to the recipe ;-))
>>
>> Thank you both for your replies!
>>
>> Gareth
>>
>> [1] http://xincluder.sourceforge.net/
>>
>> On Tue, Feb 3, 2009 at 10:28 PM,  <ke...@us.ibm.com> wrote:
>>>
>>>> If you need support for other kinds of XPointers then you may want to
>>>> take a look on the net at some of the other XInclude processors that
>>>> are available. e.g. perhaps XOM [4] supports what you're looking for.
>>>
>>> Another quick idea: It's possible to implement an XInclude subset as an XSLT
>>> stylesheet. If that approach works for you, you can use Xalan to process it.
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XInclude and XPointer

Posted by Gareth Western <ga...@garethwestern.com>.
Oh, I spoke too soon. From [1]: "XOM supports XInclude including the
XPointer element() scheme and bare name XPointers. It does not support
the XPointer xpointer() scheme." Which I guess means it's in the same
boat as Xerces with respect to what's supported.

Perhaps I'm going about this the wrong way. Am I actually using
XInclude correctly (based on my original example, with several files
each containing a <function-set> and multiple <function> children and
trying to use xinclude to compose a single file / <function-set> with
all <function>s in it)?

Right now it looks like XSLT may have to be the way to go after all... =\

On Wed, Feb 4, 2009 at 10:54 AM, Gareth Western
<ga...@garethwestern.com> wrote:
> Michael: XOM looks like it might be what I'm looking for. I originally
> tried to use the old XIncluder project from sourceforge[1] until I
> realised I'd probably need to use XPointers (which XIncluder does not
> support either).
>
> Joseph: I had considered that, but the situation is already complex
> enough as it is so I'd rather not introduce XSLT to what we're doing
> if it can be avoided (sure, XSLT isn't _that_ complicated, but it
> would add yet another ingredient to the recipe ;-))
>
> Thank you both for your replies!
>
> Gareth
>
> [1] http://xincluder.sourceforge.net/
>
> On Tue, Feb 3, 2009 at 10:28 PM,  <ke...@us.ibm.com> wrote:
>>
>>> If you need support for other kinds of XPointers then you may want to
>>> take a look on the net at some of the other XInclude processors that
>>> are available. e.g. perhaps XOM [4] supports what you're looking for.
>>
>> Another quick idea: It's possible to implement an XInclude subset as an XSLT
>> stylesheet. If that approach works for you, you can use Xalan to process it.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XInclude and XPointer

Posted by Gareth Western <ga...@garethwestern.com>.
Michael: XOM looks like it might be what I'm looking for. I originally
tried to use the old XIncluder project from sourceforge[1] until I
realised I'd probably need to use XPointers (which XIncluder does not
support either).

Joseph: I had considered that, but the situation is already complex
enough as it is so I'd rather not introduce XSLT to what we're doing
if it can be avoided (sure, XSLT isn't _that_ complicated, but it
would add yet another ingredient to the recipe ;-))

Thank you both for your replies!

Gareth

[1] http://xincluder.sourceforge.net/

On Tue, Feb 3, 2009 at 10:28 PM,  <ke...@us.ibm.com> wrote:
>
>> If you need support for other kinds of XPointers then you may want to
>> take a look on the net at some of the other XInclude processors that
>> are available. e.g. perhaps XOM [4] supports what you're looking for.
>
> Another quick idea: It's possible to implement an XInclude subset as an XSLT
> stylesheet. If that approach works for you, you can use Xalan to process it.

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XInclude and XPointer

Posted by ke...@us.ibm.com.
> If you need support for other kinds of XPointers then you may want to 
> take a look on the net at some of the other XInclude processors that
> are available. e.g. perhaps XOM [4] supports what you're looking for.

Another quick idea: It's possible to implement an XInclude subset as an 
XSLT stylesheet. If that approach works for you, you can use Xalan to 
process it.

Re: XInclude and XPointer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Gareth,

As you've noticed from the FAQ, Xerces' support for XPointer in XInclude is
limited to the XPointer Framework [1] and XPointer element() scheme [2].
This is the minimum support [3] required for a conforming XInclude
processor. There has been no discussion on expanding/enhancing the XPointer
support so likely what you see is what you're going to get for the
foreseeable future from Xerces. If you need support for other kinds of
XPointers then you may want to take a look on the net at some of the other
XInclude processors that are available. e.g. perhaps XOM [4] supports what
you're looking for.

Thanks.

[1] http://www.w3.org/TR/2003/REC-xptr-framework-20030325/
[2] http://www.w3.org/TR/2003/REC-xptr-element-20030325/
[3] http://www.w3.org/TR/2006/REC-xinclude-20061115/#application
[4] http://www.xom.nu/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Gareth Western <ga...@garethwestern.com> wrote on 02/02/2009 05:20:40 PM:

> Hi,
>
> I have an application which uses Xerces-J (2.9.0) to parse a large xml
> document which I'd like to split into several smaller files just to
> make it easier to manage. The main file looks like this:
>
> <function-set xmlns:xi="http://www.w3.org/2001/XInclude">
>   <xi:include href="PrivateFunctions.xml" />
>   <xi:include href="GroupFunctions.xml" />
>    ...
> </function-set>
>
> Each of the included files is similar to the following:
>
> <function-set>
>   <function code="FC1000" />
>   <function code="FC1001" />
>    ...
> </function-set>
>
> The schema prevents me from including the entire inner file, as that
> would result in nested function-set elements, so ideally i'd like to
> only include the functions from each inner file. XPointer looks like
> it would be the answer to this, changing the main file to look
> something like:
>
> <function-set xmlns:xi="http://www.w3.org/2001/XInclude">
>   <xi:include href="PrivateFunctions.xml" xpointer="/function-set/*" />
>    ...
> </function-set>
>
> ... however according to the Xerces XInclude FAQ only the "element()"
> scheme is supported. Does this mean I can only reference specific
> individual elements from the included file, as opposed to the full
> range of functions?
>
> For example, the following works perfectly, but only includes the
> first function from PrivateFunctions.xml:
>
> <function-set xmlns:xi="http://www.w3.org/2001/XInclude">
>   <xi:include href="PrivateFunctions.xml" xpointer="element(/1/1)" />
> </function-set>
>
> Any suggestions as to how to accomplish what I'm trying to do? Let me
> know if you have any questions / if I haven't explained the situation
> very well.
>
> Thanks!
>
> Gareth
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org