Best approach to automate insertion of DITA into all topicrefs in a project
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 316
- Joined: Wed Jun 17, 2015 10:19 am
Best approach to automate insertion of DITA into all topicrefs in a project
Post by ann.jensen »
Hi,
I have a section of DITA XML
that I want to insert within all instances of <topicref></topicref> in my project maps.
Some of them might already have some of this XML already there in which case I don't want to overwrite it.
Can you advise the most efficient way to set this up within Oxygen Editor please?
I am thinking
1. Use a Schematron rule but can the fix be auto applied or do I have to manually commit each fix
2. Use a Find/Replace in files with a Regular Expression.
However I am sure there are better solutions available that I am not aware of.
Any advice appreciated,
Regards,
Ann
I have a section of DITA XML
Code: Select all
<topicmeta>
<resourceid appname="abc"/>
</topicmeta>
Some of them might already have some of this XML already there in which case I don't want to overwrite it.
Can you advise the most efficient way to set this up within Oxygen Editor please?
I am thinking
1. Use a Schematron rule but can the fix be auto applied or do I have to manually commit each fix
2. Use a Find/Replace in files with a Regular Expression.
However I am sure there are better solutions available that I am not aware of.
Any advice appreciated,
Regards,
Ann
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Best approach to automate insertion of DITA into all topicrefs in a project
Post by chrispitude »
Hi ann.jensen,
I would do this with a refactoring operation.
Do you want the same identical @appname value in every <topicref>?
I would do this with a refactoring operation.
Do you want the same identical @appname value in every <topicref>?
-
- Posts: 316
- Joined: Wed Jun 17, 2015 10:19 am
Re: Best approach to automate insertion of DITA into all topicrefs in a project
Post by ann.jensen »
Hi yes, if there is no
in a <topicref> then I want to insert this into it
Thanks,
Ann
Code: Select all
<topicmeta><resourceid appname="ABC"/></topicmeta>
Thanks,
Ann
-
- Posts: 316
- Joined: Wed Jun 17, 2015 10:19 am
Re: Best approach to automate insertion of DITA into all topicrefs in a project
Post by ann.jensen »
Hi,
I have created a Schematron rule and quickfix that will insert the XML fragment when detected.
However, the <sqf:add> is also inserting as an attribute of the root XML element in my fragment as follows:
Is there any way I can prevent this from being generated?
Thanks,
Ann
I have created a Schematron rule and quickfix that will insert the XML fragment when detected.
However, the <sqf:add> is also inserting
Code: Select all
xmlns="http://purl.oclc.org/dsdl/schematron"
Code: Select all
<topicmeta xmlns="http://purl.oclc.org/dsdl/schematron">
<resourceid appname="abc"/>
</topicmeta>
Thanks,
Ann
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Best approach to automate insertion of DITA into all topicrefs in a project
Hello Ann,
I am not sure why the Schematron namespace is added. Probably you define the Schematron namespace as default namespace instead of using a prefix, something like xmlns:sch="http://purl.oclc.org/dsdl/schematron".
You can find below an example of Schematron rule that can be applied on your map. It offers also two quick fix actions that allows you to add a topicmeta on the current topicref element or in all topicref elements from the map.
Best Regards,
Octavian
I am not sure why the Schematron namespace is added. Probably you define the Schematron namespace as default namespace instead of using a prefix, something like xmlns:sch="http://purl.oclc.org/dsdl/schematron".
You can find below an example of Schematron rule that can be applied on your map. It offers also two quick fix actions that allows you to add a topicmeta on the current topicref element or in all topicref elements from the map.
Code: Select all
<sch:rule context="topicref">
<sch:assert test="topicmeta" sqf:fix="addTopicmeta addAllTopicmeta">
topicmeta element is missing. </sch:assert>
<sqf:fix id="addTopicmeta">
<sqf:description>
<sqf:title>Add topicmeta element</sqf:title>
</sqf:description>
<sqf:add target="topicmeta" node-type="element">
<topicmeta>
<resourceid appname="abc"/>
</topicmeta>
</sqf:add>
</sqf:fix>
<sqf:fix id="addAllTopicmeta">
<sqf:description>
<sqf:title>Add topicmeta element in all topicref</sqf:title>
</sqf:description>
<sqf:add match="//topicref[not(topicmeta)]">
<topicmeta>
<resourceid appname="abc"/>
</topicmeta>
</sqf:add>
</sqf:fix>
</sch:rule>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 316
- Joined: Wed Jun 17, 2015 10:19 am
Re: Best approach to automate insertion of DITA into all topicrefs in a project
Post by ann.jensen »
Thank you Octavian. Yes, I changed the namespace declaration as you advised and the namespace is not being added to the generated DITA XML now.
Regards,
Ann
Regards,
Ann
Return to “DITA (Editing and Publishing DITA Content)”
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