Can I save the DOCTYPE declaration to a variable?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 71
- Joined: Sat Jan 07, 2017 1:23 am
Can I save the DOCTYPE declaration to a variable?
I'd like to write a single XSL transformation that can process instances of different (but similar) doctypes. I also want to include the input doctype declaration in the output, so I can't write specific values into an <xsl:output> element.
Is there a way to capture the content of the doctype declaration in a variable, which I could then output between the XML declaration and the root element?
Is there a way to capture the content of the doctype declaration in a variable, which I could then output between the XML declaration and the root element?
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Can I save the DOCTYPE declaration to a variable?
Hi,
The original DOCTYPE declaration is not accessible to the XSLT stylesheet.
What we do for our Oxygen custom XSLT-based refactoring operations:
https://www.oxygenxml.com/doc/versions/ ... tools.html
is that we extract the DOCTYPE declaration separately using Java code, then apply the XSLT over the XML which no longer has the DOCTYPE and then assemble the DOCTYPE back later on.
Another approach is to have some kind of pre-processing which applies a regular expression on each file so that the DOCTYPE declaration is replaced by an equivalent XML comment, then apply the XSLT then convert the XML comment back to a DOCTYPE by applying another regexp, like in this small ANT build file:
https://github.com/oxygenxml/dita-refac ... /build.xml
Regards,
Radu
The original DOCTYPE declaration is not accessible to the XSLT stylesheet.
What we do for our Oxygen custom XSLT-based refactoring operations:
https://www.oxygenxml.com/doc/versions/ ... tools.html
is that we extract the DOCTYPE declaration separately using Java code, then apply the XSLT over the XML which no longer has the DOCTYPE and then assemble the DOCTYPE back later on.
Another approach is to have some kind of pre-processing which applies a regular expression on each file so that the DOCTYPE declaration is replaced by an equivalent XML comment, then apply the XSLT then convert the XML comment back to a DOCTYPE by applying another regexp, like in this small ANT build file:
https://github.com/oxygenxml/dita-refac ... /build.xml
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service