You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Andreas Veithen (JIRA)" <ji...@apache.org> on 2008/12/18 02:14:44 UTC

[jira] Issue Comment Edited: (WSCOMMONS-121) Handling of xml documents with two top level elements is errorneous

    [ https://issues.apache.org/jira/browse/WSCOMMONS-121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12656974#action_12656974 ] 

veithen edited comment on WSCOMMONS-121 at 12/17/08 5:12 PM:
---------------------------------------------------------------------

Whether or not the error is reported actually depends on how you access the object model. Consider the following code:

OMElement element = AXIOMUtil.stringToOM("<?xml version=\"1.0\"?><foo>jljl</foo><foo>jljl</foo>");
element.serialize(System.out);
((OMDocument)element.getParent()).serialize(System.out);

The first two instructions will indeed not report any parsing error. This is expected because Axiom uses a deferred parsing model. For example, the second instruction will only parse the XML document up to the first "</foo>", so that the underlying StAX parser didn't have a chance to report the duplicate root element. On the other hand, the third instruction will complete the parsing of the document and should report the error. Previously this was not the case because of a problem with the behavior of OMChildrenIterator (described in WSCOMMONS-372). This is now fixed, and Axiom will report the following error at this point: "Illegal to have multiple roots (start tag in epilog?)".


      was (Author: veithen):
    Whether or not the error is reported actually depends on how you access the object model. Consider the following code:

OMElement element = AXIOMUtil.stringToOM("<?xml version=\"1.0\"?><foo>jljl</foo><foo>jljl</foo>");
element.serialize(System.out);
((OMDocument)element.getParent()).serialize(System.out);

The first two instructions will indeed not report any parsing error. This is expected because Axiom uses a deferred parsing model. For example, the second instruction will only parse the XML document up to the first "</foo>", so that the underlying StAX parser didn't have a chance to report the duplicate root element. On the other hand, the third instruction will complete the parsing of the document and should report the error. Previously this was not the case because of a problem with the behavior of OMChildrenIterator (described in WSCOMMONS-372). This is not fixed, and Axiom will report the following error at this point: "Illegal to have multiple roots (start tag in epilog?)".

  
> Handling of xml documents with two top level elements is errorneous
> -------------------------------------------------------------------
>
>                 Key: WSCOMMONS-121
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-121
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>            Reporter: Sameera Jayasoma
>            Assignee: Andreas Veithen
>             Fix For: Axiom 1.2.8
>
>
> I am working on a project called Rhino (Javascript engine written in Java).  I am basically adding xml support to Rhino using axiom (implementing E4X specification ). Therefore I encounter some issues in axiom. 
> Earlier I have mentioned another issue.  WSCOMMONS-115
> Take the follwoing xml document as an example.
> <?xml version="1.0"?>
> <foo>jljl</foo>
> <foo>jljl</foo>
> This is not a well-formed xml document.
> But when parsing this  xml document in axiom it does not give any error instead it returns the first element as the document element.
> Sameera Madushan

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.