How to replace entire document, including prolog
Here should go questions about transforming XML with XSLT and FOP.
How to replace entire document, including prolog
I have an XSLT conversion that takes an instance of one DTD (NLM Journal Publishing 3.0) and converts it to an instance of another DTD (JATS 1.2). When I run this conversion in a transformation scenario, it works as expected.
However, I want to build this conversion into an Action to be used in the framework for the first DTD. The action is defined as an XSLTOperation with these parameters:
I assume this is happening because the conversion creates an entire new document, including the prolog (XML declaration and doctype declaration) and root element. But the XSLTOperation simply replaces the old root element, which results in two prologs.
Is there a way to configure an action to replace the entire document, including the prolog?
However, I want to build this conversion into an Action to be used in the framework for the first DTD. The action is defined as an XSLTOperation with these parameters:
- sourceLocation: /article
- targetLocation: /article
- action: Replace
I assume this is happening because the conversion creates an entire new document, including the prolog (XML declaration and doctype declaration) and root element. But the XSLTOperation simply replaces the old root element, which results in two prologs.
Is there a way to configure an action to replace the entire document, including the prolog?
-
- Posts: 102
- Joined: Tue Aug 19, 2014 12:04 pm
Re: How to replace entire document, including prolog
Post by Martin Honnen »
I would try whether sourceLocation allows you to provide solely / instead of /article. The same for targetLocation. But I haven't tested whether oXygen allows/supports that.
-
- Site Admin
- Posts: 124
- Joined: Wed Dec 12, 2018 5:33 pm
Re: How to replace entire document, including prolog
Post by Cosmin Duna »
Hi,
Indeed, this action should replace the entire content.
What about creating a refactoring operation based on XSLT (https://www.oxygenxml.com/doc/versions/ ... tions.html) and storing it in your framework: https://www.oxygenxml.com/doc/versions/ ... operations ?
Best regards,
Cosmin
Indeed, this action should replace the entire content.
What about creating a refactoring operation based on XSLT (https://www.oxygenxml.com/doc/versions/ ... tions.html) and storing it in your framework: https://www.oxygenxml.com/doc/versions/ ... operations ?
Best regards,
Cosmin
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: How to replace entire document, including prolog
Just to be clear about what I'm trying to accomplish--I begin with a document like this:
and I want to replace it with a document like this (note the different doctype declaration):
My stylesheet includes
I tried Martin's suggestion, so that the XSLTOperation has the following parameters:
When I had sourceLocation and targetLocation specified as "/article", I could tell that the conversion was running (because diagnostic messages appeared in the Messages tab), but apparently the replacement of the source <article> failed because the conversion output includes the XML declaration and doctype declaration as well as the new <article> element.
I have read the "Custom Refactoring Operations" page that Cosmin recommended, but as far as I can tell, it doesn't allow replacing the prolog as well as the root element, and in this case replacing the prolog is essential.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "journalpublishing3.dtd">
<article article-type="research-article" dtd-version="3.0" xml:lang="en"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:atict="http://www.arbortext.com/namespace/atict">
...
</article>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD UCP JATS (Z39.96) Journal Publishing DTD with OASIS Tables with MathML3 v1.2 20190208//EN" "JATS-journalpublishing-oasis-article1-mathml3.ucp.dtd">
<article article-type="research-article" dtd-version="1.2" xml:lang="en"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML">
...
</article>
Code: Select all
<xsl:output method="xml" indent="no" cdata-section-elements="tex-math"
doctype-public="-//NLM//DTD UCP JATS (Z39.96) Journal Publishing DTD with OASIS Tables with MathML3 v1.2 20190208//EN"
doctype-system="JATS-journalpublishing-oasis-article1-mathml3.ucp.dtd"/>
- sourceLocation: /
- targetLocation: /
- script: ${framework}/xslt/ucp-jp2ucp-jats.xsl
- action: Replace
- caretPosition: First editable position
- expandEditorVariables: true
- suspendTrackChanges: false
- externalParams: [not specified]
- alwaysPreserveTrackedChangesBeforeProcessing: [not specified]
When I had sourceLocation and targetLocation specified as "/article", I could tell that the conversion was running (because diagnostic messages appeared in the Messages tab), but apparently the replacement of the source <article> failed because the conversion output includes the XML declaration and doctype declaration as well as the new <article> element.
I have read the "Custom Refactoring Operations" page that Cosmin recommended, but as far as I can tell, it doesn't allow replacing the prolog as well as the root element, and in this case replacing the prolog is essential.
-
- Site Admin
- Posts: 124
- Joined: Wed Dec 12, 2018 5:33 pm
Re: How to replace entire document, including prolog
Post by Cosmin Duna »
Hi,
The doctype can be changed using a custom refactoring operation.
For example, in Oxygen we have a refactoring operation that converts a DITA bookmap to a DITA map. The XSL file that makes this conversion is located here:
Oxygen_install_dir\frameworks\dita\map_refactoring\convertDITABookmapToMap.xsl and the template that change the doctype( <xsl:template name="convert-header">) is located here Oxygen_install_dir\frameworks\dita\refactoring\dita-files-conversion-stylesheets\handle-schema-conversion.xsl
The documentation for modifying content outside the root element is here: https://www.oxygenxml.com/doc/versions/ ... w_custom_r
Best regards,
Cosmin
The doctype can be changed using a custom refactoring operation.
For example, in Oxygen we have a refactoring operation that converts a DITA bookmap to a DITA map. The XSL file that makes this conversion is located here:
Oxygen_install_dir\frameworks\dita\map_refactoring\convertDITABookmapToMap.xsl and the template that change the doctype( <xsl:template name="convert-header">) is located here Oxygen_install_dir\frameworks\dita\refactoring\dita-files-conversion-stylesheets\handle-schema-conversion.xsl
The documentation for modifying content outside the root element is here: https://www.oxygenxml.com/doc/versions/ ... w_custom_r
Best regards,
Cosmin
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: How to replace entire document, including prolog
Thanks, Cosmin. I set up the custom refactoring operation, and it's working as intended.
At the moment, I can invoke it by clicking the XML Refactoring icon in the Toolbar, or by right-clicking inside the document in Author View and selecting 'Refactoring' and then the name of the custom operation. Is there a way to invoke the operation more directly, by linking it to an icon in the Toolbar? If not, I'd like to suggest that as a feature for future versions, so that refactoring operations can be treated similarly to Author Actions.
At the moment, I can invoke it by clicking the XML Refactoring icon in the Toolbar, or by right-clicking inside the document in Author View and selecting 'Refactoring' and then the name of the custom operation. Is there a way to invoke the operation more directly, by linking it to an icon in the Toolbar? If not, I'd like to suggest that as a feature for future versions, so that refactoring operations can be treated similarly to Author Actions.
-
- Site Admin
- Posts: 124
- Joined: Wed Dec 12, 2018 5:33 pm
Re: How to replace entire document, including prolog
Post by Cosmin Duna »
Hi,
Unfortunately, you cannot directly add a specific XML Refactoring operation on the toolbar or menus. We already have an internal issue for this improvement and I added your request to it for increasing its priority.
Best regards,
Cosmin
Unfortunately, you cannot directly add a specific XML Refactoring operation on the toolbar or menus. We already have an internal issue for this improvement and I added your request to it for increasing its priority.
Best regards,
Cosmin
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 918
- Joined: Thu May 02, 2019 2:32 pm
Re: How to replace entire document, including prolog
Post by chrispitude »
Please also add my name to this request. It would be nice to configure toolbar buttons or menu/submenu items that directly run certain common refactoring operations.
-
- Site Admin
- Posts: 124
- Joined: Wed Dec 12, 2018 5:33 pm
Re: How to replace entire document, including prolog
Post by Cosmin Duna »
Hi Chris,
Sure. I added your feedback to the internal improvement request.
Best regards,
Cosmin
Sure. I added your feedback to the internal improvement request.
Best regards,
Cosmin
Cosmin Duna
<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