Let me give you some backgroud: see:
http://www.docx4java.org/forums/docx-java-f6/creating-xml-from-docx-t1347.htmlI have made a copy of org.docx4j.convert.out.html and created org.docx4j.convert.out.xml because we have a requirement to generate XML from the docx4j document the users author. We used a overly complicated XML which is out of my control but I have re-written add new methods to HtmlExporterNG2.java (now called XmlExporterNG2.java). I know create many different custom XML tags based on various styled w:p tags (i.e. ListParagraph).
That being said I have done the following using the original code from the org.docx4j.convert.out.html package.
in the XSL I do something similar to this....
- Code: Select all
<xsl:variable name="otherVariable select="'testvalue'"/>
<xsl:variable name="endnotes" select="java:org.docx4j.convert.out.Converter.getEndnotes($conversionContext)" />
<!-- this gives me the text from the endnote part
<xsl:variable name="sourceRef" select="$endnotes//w:endnote[@w:id = $currentID]"/>
<xsl:value-of select="java:our.custom.class.TestClass.returnXML($otherVariable, $sourceRef)"/>
This would typically return: (Our custom method returns a w3c Node)
- Code: Select all
<SourceGroup>
<SourceText>testvalue</SourceText>
<EndNoteRef ism:producer="CNN" ism:date="somedate">Some information about the source</EndNoteRef>
</SourceGroup>
As part of the <apply-templates/> on the <w:r> tag in docx2xhtml-core.xslt
This is called:
- Code: Select all
<xsl:copy-of select="java:org.docx4j.convert.out.html.HtmlExporterNG2.createBlockForRPr(
$conversionContext, $pStyleVal, $rPrNode, $childResults)" />
Which in turn calls this:
What happens in Docx4j when I used HtmlExporterNG2.java the createBlock does a XmlUtils.treeCopy and looses the "ism" namespace prefixes which we need.
- Code: Select all
<SourceGroup>
<SourceText>testvalue</SourceText>
<EndNoteRef producer="CNN" date="somedate">Some information about the source</EndNoteRef>
</SourceGroup>
When I output the above value in the as some custom xml thats not called by any template the namespace prefixes are visible in the transformed document.
I hope this is enough information.