objectionary/eo

How to print a small part of XMIR to EO?

volodya-lombrozo opened this issue · 4 comments

I usually have small portions of XMIR:

 <o base=".plus">
    <o base="int" data="bytes" line="1143583134">00 00 00 00 00 00 00 01</o>
    <o base="int" data="bytes" line="1167891236">00 00 00 00 00 00 00 02</o>
 </o>

And I need to convert it to the EO representation:

1.plus 2

How can I do it?

I tried to run the following code:

 new Xmir.Default(new XMLDocument(xml)).toEO();

and got the following exception:

java.lang.IllegalArgumentException: Failed to transform by net.sf.saxon.jaxp.TransformerImpl: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.; SystemID: file:///org/eolang/parser/xmir-to-eo.xsl; Line#: 117; Column#: 19

	at com.jcabi.xml.XSLDocument.transformInto(XSLDocument.java:468)
	at com.jcabi.xml.XSLDocument.transform(XSLDocument.java:420)
	at com.yegor256.xsline.StXSL.lambda$new$1(StXSL.java:45)
	at com.yegor256.xsline.StLambda.apply(StLambda.java:115)
	at com.yegor256.xsline.StEnvelope.apply(StEnvelope.java:61)
	at com.yegor256.xsline.StEnvelope.apply(StEnvelope.java:61)
	at com.yegor256.xsline.Xsline.pass(Xsline.java:85)
	at org.eolang.parser.xmir.Xmir$Default.toEO(Xmir.java:108)
	at it.AgentsIT.verifiesAgents(AgentsIT.java:60)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.LinkedList$LLSpliterator.forEachRemaining(LinkedList.java:1242)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: net.sf.saxon.trans.XPathException: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
	at net.sf.saxon.dom.DOMWriter.characters(DOMWriter.java:234)
	at net.sf.saxon.event.ProxyReceiver.characters(ProxyReceiver.java:158)
	at net.sf.saxon.event.SequenceNormalizer.characters(SequenceNormalizer.java:99)
	at net.sf.saxon.event.RegularSequenceChecker.characters(RegularSequenceChecker.java:182)
	at net.sf.saxon.event.ComplexContentOutputter.characters(ComplexContentOutputter.java:275)
	at net.sf.saxon.expr.instruct.ValueOf$TextNodeOutputStreamer.append(ValueOf.java:485)
	at net.sf.saxon.expr.Literal$LiteralElaborator.lambda$elaborateForPush$1(Literal.java:882)
	at net.sf.saxon.expr.instruct.ValueOf$ValueOfElaborator.lambda$elaborateForPush$1(ValueOf.java:425)
	at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1182)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376)
	at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521)
	at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:655)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895)
	at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.lambda$elaborateForPush$11(Choose.java:1183)
	at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$1(Block.java:853)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376)
	at net.sf.saxon.trans.Mode.handleRuleNotNull(Mode.java:587)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:521)
	at net.sf.saxon.trans.rules.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:72)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:518)
	at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:684)
	at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:430)
	at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:358)
	at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:75)
	at com.jcabi.xml.XSLDocument.transformInto(XSLDocument.java:458)
	... 40 more
Caused by: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
	at java.xml/com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(ParentNode.java:359)
	at java.xml/com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:286)
	at java.xml/com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.insertBefore(CoreDocumentImpl.java:447)
	at java.xml/com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(NodeImpl.java:230)
	at net.sf.saxon.dom.DOMWriter.characters(DOMWriter.java:231)
	... 65 more

@maxonfjvipon Could you help here, please?

@volodya-lombrozo thanks for the report, here is a feedback:

Problems

  • Clear Title: The bug report's title lacks clarity. Instead of succinctly stating the issue, it poses a question and fails to indicate the nature of the error or the affected module.
  • Reproduction Steps: The report lacks comprehensive, step-by-step instructions to replicate the bug. Although the user has shared the code they executed, they haven't clarified the conditions or sequence in which they did so.
  • Expected vs. Actual Results: The user has described the error message but has not specified the expected outcome. It can be inferred from their question, but it isn't explicitly stated.

I would recommend adding explicit expected and actual results in the report to better understand the discrepancies.

Please fix the bug report in order it to get resolved faster.
Analyzed with gpt-4

As I understand the simplest workaround is to wrap each XMIR snippet with program and objects elements:

<program>
   <objects>
       <o base=".plus">
          <o base="int" data="bytes" line="1676053583">00 00 00 00 00 00 00 01</o>
          <o base="int" data="bytes" line="2086624173">00 00 00 00 00 00 00 02</o>
       </o>
   </objects>
</program>

Since there are many concerns about this functionality, I close this issue