[ 
https://issues.apache.org/jira/browse/XERCESJ-1694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16466946#comment-16466946
 ] 

Radu Coravu commented on XERCESJ-1694:
--------------------------------------

The problem is that the "XPointerParserConfiguration" has both an xiinclude and 
a xpointer component added to the pipeline.
So when parsing "a.xml", the "XPointerParserConfiguration" will be used to 
parse "b.xml". The XPointerHandler will identify the part which is pointed to 
and issue SAX events for it but the XIncludeHandler will continue to be used 
and receive events for the entire contents of the b.xml document, including the 
"xi:include" back to "a.xml", thus creating a stack overflow.
As a possible solution, the XIncludeHandler added to the 
"XPointerParserConfiguration" needs to know about the "XPointerHandler" and if 
the XPointerHandler has found its target, the XIncludeHandler needs to start 
ignoring xi:include elements because it no longer needs to expand them.


> Avoid stack overflow when using xpointer between two resources
> --------------------------------------------------------------
>
>                 Key: XERCESJ-1694
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1694
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: SAX
>            Reporter: Radu Coravu
>            Priority: Major
>
> Let' say I have two documents:
> 1) "a.xml":
> {code}<book xmlns="http://docbook.org/ns/docbook";
>     xmlns:xlink="http://www.w3.org/1999/xlink";
>     xmlns:xi="http://www.w3.org/2001/XInclude";
>     xml:id="a-book"
>     version="5.0">
>     <title>A</title>
>     <chapter xml:id="a-chapter">
>         <title>a chapter</title>
>         <para>foo</para>
>     </chapter>
>     <xi:include href="b.xml" xpointer="b-chapter"/>
> </book>{code}
> 2) "b.xml":
> {code}<book xmlns="http://docbook.org/ns/docbook";
>     xmlns:xlink="http://www.w3.org/1999/xlink";
>     xmlns:xi="http://www.w3.org/2001/XInclude";
>     xml:id="b-book"
>     version="5.0">
>     <title>B</title>
>     <chapter xml:id="b-chapter">
>         <title>b chapter</title>
>         <para>foo</para>
>     </chapter>
>     <xi:include href="a.xml" xpointer="a-chapter"/>
> </book>{code}
> When using a SAX parser to parse "a.xml" a stack overflow occurs although 
> according to the XInclude specs this is a legal situation, the xpointer parts 
> to a part of b.xml.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to