[
https://issues.apache.org/jira/browse/AXIOM-533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18135455#comment-18135455
]
Andreas Veithen-Knowles commented on AXIOM-533:
-----------------------------------------------
Thanks for the detailed report and for raising this for discussion before
changing anything. After looking into it, I'm going to close this as *Won't
Fix*, for two reasons.
h3. 1. This is long-standing, intentional behavior
The check that rejects anything other than a lone {{xop:Include}} was added in
July 2009 (as part of the work on WSCOMMONS-485 and WSCOMMONS-488), when XOP
decoding was moved into a dedicated stream wrapper
({{XOPDecodingStreamReader}}), and has been in every release since Axiom 1.2.9.
It was carried over unchanged when the decoding logic was reimplemented on top
of the core stream API ({{AbstractXOPDecodingFilterHandler}}). You're right
that much older versions accepted this input: the builders in Axiom 1.2.8 and
earlier didn't check the siblings of {{xop:Include}} at all, and simply kept
the whitespace as text nodes on either side of the binary content. But that
behavior was replaced more than 15 years ago, and the current behavior has been
the norm ever since.
h3. 2. The input isn't a conforming XOP package
Note that the section quoted in the description is 3.2 (Interpreting XOP
Packages), not 2.3; the error message refers to the correct section. When
reading it, the parts that come before the processing steps are important:
{quote}
This section specifies the means by which the Original XML Infoset can be
reconstructed from a XOP Package that has been prepared according to the rules
of 3.1 Creating XOP Packages.
Note: conventions or error reporting mechanisms to be used in processing
packages that incorrectly purport to be XOP Packages are beyond the scope of
this specification.
{quote}
Section 3.1 says that the content being optimized "MUST NOT contain any
whitespace characters, preceding, inline with or following the non-whitespace
content", and that the element's \[children\] are replaced by the
{{xop:Include}} element. Erratum
[36rec|https://www.w3.org/2005/01/xop10-errata] makes this explicit: "this rule
requires that the \[children\] of the element information item to be optimized
contains only character information items." So a producer that follows the spec
always generates {{xop:Include}} as the sole child.
The {{xop:Include}} can't have been part of the original infoset either:
section 2 says that the infoset "MUST NOT contain any element information item"
with that name. So an {{xop:Include}} with whitespace siblings can't come from
any valid XOP serialization. The message has been modified after it was
created, and it's no longer a valid XOP package. The spec doesn't define how
such packages should be processed, and rejecting them with a clear error is the
safest option. Silently dropping the whitespace would also mean that the
reconstituted infoset differs from the one the sender produced, which matters
in scenarios such as XML signatures.
The right fix is in whatever reindents the message: tools that rewrite the root
part of a XOP/MTOM message must leave the content of the elements containing
{{xop:Include}} unchanged (or, alternatively, operate on the reconstituted
infoset and re-encode it).
> xop:Include handling can't handle surrounding whitespace
> --------------------------------------------------------
>
> Key: AXIOM-533
> URL: https://issues.apache.org/jira/browse/AXIOM-533
> Project: Axiom
> Issue Type: Bug
> Reporter: Andreas Martens
> Priority: Major
> Attachments: Screenshot 2026-10-28 at 17.27.43.png
>
>
> We (well a customer) is getting this exception after their input message has
> been reindented (i.e. an <xop:Include> element has a newline before and
> after):
> {{org.apache.axiom.om.DeferredParsingException:org.apache.axiom.core.stream.StreamException:
> Expected xop:Include as the sole child of an element information item (see
> section 3.2 of http://www.w3.org/TR/xop10/)}}
> {{ at
> org.apache.axiom.om.impl.common.AxiomExceptionTranslator.translate(AxiomExceptionTranslator.java:38)}}
> {{ at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serialize(Unknown
> Source)}}
> {{ at
> org.apache.axiom.om.impl.llom.AxiomContainerImpl.serializeAndSurfaceIOException(Unknown
> Source)}}
> {{ at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serialize(Unknown
> Source)}}
> {{{}Caused by: org.a{}}}pache.axiom.core.stream.StreamException: Expected
> xop:Include as the sole child of an element information item (see section 3.2
> of http://www.w3.org/TR/xop10/)
> at
> org.apache.axiom.core.stream.xop.AbstractXOPDecodingFilterHandler.startElement(AbstractXOPDecodingFilterHandler.java:71)
> at
> org.apache.axiom.core.stream.stax.pull.input.StAXPullReader.processElement(StAXPullReader.java:230)
> at
> org.apache.axiom.core.stream.stax.pull.input.StAXPullReader.proceed(StAXPullReader.java:189)
> at org.apache.axiom.core.impl.builder.BuilderImpl.next(BuilderImpl.java:59)
> at
> org.apache.axiom.om.impl.llom.CoreParentNodeImpl.internalBuildNext(Unknown
> Source)
> at
> org.apache.axiom.om.impl.llom.CoreParentNodeImpl.coreGetFirstChild(Unknown
> Source)
> at org.apache.axiom.core.impl.TreeWalkerImpl.proceed(TreeWalkerImpl.java:146)
> at
> org.apache.axiom.om.impl.llom.CoreParentNodeImpl.internalSerialize(Unknown
> Source)
> at org.apache.axiom.om.impl.llom.AxiomContainerImpl.serialize(Unknown Source)
> ... 6 more '
>
> Looking at the section in question (2.3) in
> [https://www.w3.org/TR/xop10/#interpreting_xop_packages:]
> To create a Reconstituted XML Infoset from a XOP Package:
> # Construct an XML Infoset by parsing the root part of the package as an XML
> document. The document MUST be parsed according to the level of the XML
> Recommendation identified by the XML declaration of that document. If no XML
> declaration is present, then the document MUST be parsed per [[Extensible
> Markup Language (XML) 1.0 (Third Edition)]|https://www.w3.org/TR/xop10/#XML].
> # Using that XML Infoset, for each {_}element information item{_}, E, which
> has, as the sole member of its [children] property, a {{xop:Include}}
> _element information item_ (as defined in [*2.1 xop:Include element
> information item*|https://www.w3.org/TR/xop10/#xop_include]):
> ## Locate the part of the package corresponding to the URI in the {{href}}
> _attribute information item_ of the {{xop:Include}} _element information
> item_ (i.e., corresponding to the URI encoded in the {_}attribute information
> item{_}'s [normalized value]).
> ## Replace the {{xop:Include}} _element information item_ that appears in
> the [children] property of E with _character information items_ representing
> the canonical base64 encoding of the entity body of the identified package
> part (i.e., effectively replace the {{xop:Include}} _element information
> item_ with the data reconstructed from the package part).
> Reading this, I _think_ we could be allowed to be a little lenient, and allow
> *whitespace* around the xop:Include element. In fact, if we took the example
> from the wikipedia page:
> [https://en.wikipedia.org/wiki/XML-binary_Optimized_Packaging:] (example
> attached as image, since it lost a lot in the copy-paste) then that too would
> fail parsing, since that example also has been reindented after writing.
> This *used to* work with an old version of Axiom I believe, but I don't want
> to simply fix it without a discussion here. what do you think, should
> whitespace be allowed?
>
>
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]