  | |  | xinclude funnies | xinclude funnies 2003-08-23 - By Neil Pitman
I'll preface this with "I'm a bit new to digging around in Xerces and XInclude" . (Xerces always worked, but then I wasn't using new, beta features.)
I'm trying to make Saxon 7.6.5 (XSLT) work with Xerces 2.5.0 (tarball not recent cvs) using XInclude and SAX with my own XMLEntityResolvers /EntityResolvers. Saxon has it's own issues but that's for another mailinglist. Once upon a time, I would preprocess my files with Elliot Rusty Harold's Xincluder from SourceForge into a separate XML. Now I'd like to stream it in situ. (that means that the input files are understandable by elharo's implementation so they are less suspect). The trick is to change the OS based file references into arbitrary key references.
Here is what I understand. My questions follow.
Soon after hitting the include element, org.apache.xerces.xinclude .XIncludeHandler.handleIncludeElement(XMLAttributes attributes) is called. He creates a XMLResourceIdentifier with an explicit null public id and an explicit null expanded system id (the literal system id is retrieved from the href and represents a relative "file". This is what I used to use with XIncluder). When he determines that there is, indeed, a resolver, he calls EntityResolverWrapper holding my resolver. First the wrapper checks that the public id and system id (the expanded one) are not null. They are so he exits immediately.
I "fixed" this using XMLEntityManager.expandSystemId() to produce the expanded system id in handleIncludeElement where the XMLResourceIdentifier is first created.
Now with the EntityResolverWrapper getting a reasonable system id, my resolver gets a reasonable id and it attempts to load the first xinclude. The system id 's are now a mixture of my keys and file bases. My entity resolver is completely memory based so the file based URI's are confusing. For example: In the old system running from the file system there were three files file:///c:/work/proj/main.xml file:///c:/work/proj/part1/subpart1/abc.xml file:///c:/work/proj/part1/subpart1/helper.xml
With the elharo xincluder, main.xml had <xi:include href="part1/subpart1/abc .xml"/> and abc.xml contained <xi:include href="methods.xml"/>. My Resolver receives file:///c:/home/npitman/part1/subpart1/abc.xml. It gets the "file:///c :/home/npitman/" part from the running location of the application. XMLEntityManager noticed that the base system id of "main.xml" was null so he assumed that he would need a real URI and that should be based on the current working directory. In the memory-based situation, the hrefs are not so much URI's as keys. I'm expecting just "part1/subpart1/abc.xml".
This is what I find in the literal system id. Unfortunately, this helps little because the first include xincludes a second. This has an href of "helper.xml" . In my key system, I'd expect to see "part1/subpart1/helper.xml".
Questions:
1) What is going on in org.apache.xerces.xinclude.XIncludeHandler .handleIncludeElement? Setting the id's to null can't be right.
2) Is there a way to accept a blank base system id?
I'd like href="part1/subpart1/abc.xml" within "main.xml" to try to resolve "part1/subpart1/abc.xml" and href="helper.xml" within "part1/subpart1/abc.xml" to try to resolve "part1/subpart1/help.xml".
3) Alternately, is the there an extension mechanism, like the EntityResolver, to externalize expandSystemId()?
I suppose that the fallback would be to set the base system id of main.xml to an abitrary scheme like "npitman://" and the look up "npitman://part1/subpart1 /abc.xml" and "npitman://part1/subpart1/helper.xml"
Thanks for your patience in reading. _________________________________________ Neil Pitman neil.pitman@(protected) +1.514.863.5465 ICQ#: 21101052 _________________________________________
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.2800.1170" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2>I'll preface this with "I'm a bit new to digging around in Xerces and XInclude". (Xerces always worked, but then I wasn't using new, beta features.)</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>I'm trying to make Saxon 7.6.5 (XSLT) work with Xerces 2.5.0 (tarball not recent cvs) using XInclude and SAX with my own XMLEntityResolvers/EntityResolvers. Saxon has it's own issues but that's for another mailinglist. Once upon a time, I would preprocess my files with Elliot Rusty Harold's Xincluder from SourceForge into a separate XML. Now I'd like to stream it in situ. (that means that the input files are understandable by elharo's implementation so they are less suspect). The trick is to change the OS based file references into arbitrary key references.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>Here is what I understand. My questions follow.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>Soon after hitting the include element, </FONT><FONT face=Arial size=2>org.apache.xerces.xinclude.XIncludeHandler.</FONT><FONT face=Arial size=2>handleIncludeElement(<FONT color=#0000ff size=2>XMLAttributes</FONT> <FONT size=2> attributes) is called. He creates a </FONT></FONT><FONT face =Arial size=2><FONT size=2><FONT size=2>XMLResourceIdentifier with an explicit null public id and an explicit null expanded system id (the literal system id is retrieved from the href and represents a relative "file". This is what I used to use with XIncluder). </FONT></FONT></FONT><FONT face=Arial size=2><FONT size=2>When he determines that there is, indeed, a resolver, he calls EntityResolverWrapper holding my resolver. First the wrapper checks that the public id and system id (the expanded one) are not null. They are so he exits immediately.</FONT></FONT></DIV> <DIV><FONT face=Arial size=2><FONT size=2></FONT></FONT> </DIV> <DIV><FONT face=Arial size=2><FONT size=2>I "fixed" this using XMLEntityManager.expandSystemId() to produce the expanded system id in handleIncludeElement where the <FONT size=2>XMLResourceIdentifier is first created.</FONT></FONT></FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>Now with the EntityResolverWrapper getting a reasonable system id, my resolver gets a reasonable id and it attempts to load the first xinclude. The system id's are now a mixture of my keys and file bases. My entity resolver is completely memory based so the file based URI's are confusing. For example:</FONT></DIV> <DIV><FONT face=Arial size=2>In the old system running from the file system there were three files</FONT></DIV> <DIV><FONT face=Arial size=2><A href="file:///c:/work/proj/main.xml">file:///c:/work/proj/main.xml</A></FONT>< /DIV> <DIV><FONT face=Arial size=2> <DIV><FONT face=Arial size=2><A href="file:///c:/work/proj/part1/subpart1/abc.xml">file:///c:/work/proj/part1 /subpart1/abc.xml</A>
<DIV><FONT face=Arial size=2><A href="file:///c:/work/proj/part1/subpart1/helper.xml">file:///c:/work/proj /part1/subpart1/helper.xml</A></FONT></DIV></FONT></DIV></FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT size=2><FONT face=Arial>With the elharo xincluder, main.xml had </FONT><FONT color=#0000ff size=1><FONT face=Arial color=#000000 size=2><</FONT></FONT><FONT face=Arial>xi:include href="part1/subpart1/abc.xml<FONT color=#0000ff size=1><FONT color=#000000 size=2>"/> and abc.xml contained <xi:include href="methods.xml<FONT color=#0000ff size=1><FONT color=#000000 size=2>"/>. My Resolver receives <A href="file:///c:/home/npitman/part1/subpart1/abc.xml">file:///c:/home/npitman/ <U><FONT color=#0000ff>part1/subpart1/abc.xml</A></FONT></U></FONT></FONT></FONT></FONT> </FONT></FONT><FONT face=Arial size=2>. It gets the "<A href="file:///c:/home/npitman/part1/subpart1/abc.xml">file:///c:/home/npitman/< /A>" part from the running location of the application. XMLEntityManager noticed that the base system id of "main.xml" was null so he assumed that he would need a real URI and that should be based on the current working directory. In the memory-based situation, the hrefs are not so much URI's as keys. I'm expecting just "part1/subpart1/abc.xml". </FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>This is what I find in the literal system id.  ; Unfortunately, this helps little because the first include xincludes a second. This has an href of "helper.xml". In my key system, I'd expect to see "part1/subpart1/helper.xml".</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>Questions:</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>1) What is going on in org.apache.xerces.xinclude.XIncludeHandler.<FONT face=Arial size=2>handleIncludeElement? Setting the id's to null can't be right.</FONT></FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>2) Is there a way to accept a blank base system id? </FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>I'd like href="part1/subpart1/abc.xml<FONT color=#0000ff size=1><FONT color=#000000 size=2>" within "main.xml" to try to resolve "part1/subpart1/abc.xml" and href="helper.xml" within "part1/subpart1/abc.xml" to try to resolve "part1/subpart1/help.xml". </FONT></FONT></FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>3) Alternately, is the there an extension mechanism, like the EntityResolver, to externalize expandSystemId()? </FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2><FONT color=#0000ff size=1><FONT color=#000000 size=2>I suppose that the fallback would be to set the base system id of main.xml to an abitrary scheme like "npitman://" and the look up "npitman://part1/subpart1/abc.xml" and "npitman://part1/subpart1/helper.xml"</FONT></FONT></FONT></DIV> <DIV><FONT face=Arial size=2><FONT size=2><FONT size=2></FONT></FONT></FONT> </DIV> <DIV><FONT face=Arial size=2><FONT size=2><FONT size=2>Thanks for your patience in reading.</DIV></FONT></FONT></FONT> <DIV><FONT face=Arial size=2>_________________________________________<BR>Neil Pitman<BR></FONT><A href="mailto:neil.pitman@(protected)"><FONT face=Arial size=2>neil.pitman@(protected)</FONT></A><BR><FONT face=Arial size=2>+1.514.863.5465<BR>ICQ#: 21101052<BR>_________________________________________<BR></FONT></DIV></BODY>< /HTML>
|
|
 |