DITA XML elements with class attribute
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 38
- Joined: Thu Oct 28, 2010 5:10 pm
DITA XML elements with class attribute
Hello,
I have just started using oXygen for DITA content editing and was wondering how to make it generate by default all <p>, <li> or <i> elements with a class attribute like: and
.
These attributes are used for further manipulation of the content during transformation.
Thanks
I have just started using oXygen for DITA content editing and was wondering how to make it generate by default all <p>, <li> or <i> elements with a class attribute like:
Code: Select all
<p class="- topic/p ">
<li class="- topic/li ">
Code: Select all
<i class="+ topic/ph hi-d/i ">
These attributes are used for further manipulation of the content during transformation.
Thanks
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: DITA XML elements with class attribute
Hello,
Class attributes are usually only necessary when using a DITA customization. You don't have to explicitly specify the class attributes for the default DITA implementation. The class attributes are already specified as default value attributes in the DITA DTDs and are taken into consideration by the transformation.
For this to work, you nee to have a DITA DOCTYPE declaration in the XML file. If you do, you should see the default values of the class attributes for each element in the Attributes view in Oxygen.
The value of default attributes is represented italic/gray in the Attributes view.
e.g. for a DITA topic
The attributes view looks like this when the caret is inside a paragraph element(p) which doesn't specify the class attribute.

Note the default value for class '- topic/p '.
Let us know if you really need to specify these attributes disregarding the default values from the DTD.
Regards,
Adrian
Class attributes are usually only necessary when using a DITA customization. You don't have to explicitly specify the class attributes for the default DITA implementation. The class attributes are already specified as default value attributes in the DITA DTDs and are taken into consideration by the transformation.
For this to work, you nee to have a DITA DOCTYPE declaration in the XML file. If you do, you should see the default values of the class attributes for each element in the Attributes view in Oxygen.
The value of default attributes is represented italic/gray in the Attributes view.
e.g. for a DITA topic
Code: Select all
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">

Note the default value for class '- topic/p '.
Let us know if you really need to specify these attributes disregarding the default values from the DTD.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 38
- Joined: Thu Oct 28, 2010 5:10 pm
Re: DITA XML elements with class attribute
Thanks Adrian for your reply,
I see that by default the class attribute is already present on the <p> element but does not get created in the content.
I will definitely need the <p> element with the class attribute.
Please let me know how to activate it by default whenever a new paragraph is created.
Thanks
Loralon
I see that by default the class attribute is already present on the <p> element but does not get created in the content.
I will definitely need the <p> element with the class attribute.
Please let me know how to activate it by default whenever a new paragraph is created.
Thanks
Loralon
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: DITA XML elements with class attribute
This isn't something that you can simply activate. To accomplish this there are significant changes that are necessary in the DTDs and Oxygen's Author actions.
To be honest, it's a huge task and I don't see the amount of work involved to accomplish this resulting in any real benefit.
A simpler way to go about this would be to post-process the file afterwards with an XML stylesheet and set the class attributes for the necessary elements.
If I may ask, why do you need these attributes in the content?
Maybe I've mentioned this before, but they are not necessary there. The fact that they are already in the DTD as default attribute values is enough for the transformations to work correctly.
Aren't you using the DITA-OT transformations?
Regards,
Adrian
To be honest, it's a huge task and I don't see the amount of work involved to accomplish this resulting in any real benefit.
A simpler way to go about this would be to post-process the file afterwards with an XML stylesheet and set the class attributes for the necessary elements.
If I may ask, why do you need these attributes in the content?
Maybe I've mentioned this before, but they are not necessary there. The fact that they are already in the DTD as default attribute values is enough for the transformations to work correctly.
Aren't you using the DITA-OT transformations?
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 38
- Joined: Thu Oct 28, 2010 5:10 pm
Re: DITA XML elements with class attribute
Thanks Adrian,
I believe the suggestion for xslt post-processing is the best for now. I only need the class attribute because it is used for further processing of the content when doing transformation to PDF via DITA OT.
If you don't mind can you provide a sample xslt template that can be used for the purpose?
Loralon.
I believe the suggestion for xslt post-processing is the best for now. I only need the class attribute because it is used for further processing of the content when doing transformation to PDF via DITA OT.
If you don't mind can you provide a sample xslt template that can be used for the purpose?
Loralon.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: DITA XML elements with class attribute
I'll try to come up with a stylesheet that does this for you, if you insist.
But I still think you've missed the point of the class attributes. They are meant for DITA specializations, they are not necessary nor are they recommended in the content. The DITA OT transformation stylesheets pick up the class attributes declared in the DTD(referred in the DOCTYPE from each DITA XML document).
Here's a link to the DITA specs, if you want an official source:
http://docs.oasis-open.org/dita/v1.2/os ... l#classatt
Regards,
Adrian
But I still think you've missed the point of the class attributes. They are meant for DITA specializations, they are not necessary nor are they recommended in the content. The DITA OT transformation stylesheets pick up the class attributes declared in the DTD(referred in the DOCTYPE from each DITA XML document).
Here's a link to the DITA specs, if you want an official source:
http://docs.oasis-open.org/dita/v1.2/os ... l#classatt
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 1
- Joined: Wed Mar 06, 2013 3:35 am
Re: DITA XML elements with class attribute
Adrian, you mentioned that it can be done - including the class attribute in the saved DITA file. I do really need that and would love to know what needs to be done so that I can include the attribute.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: DITA XML elements with class attribute
Hello,
If you want all attributes (including class) to be pulled from the DTD into the DITA file, all you need is a copy stylesheet:
Note however that when applying this against the DITA document, the DOCTYPE, comments and processing instructions (including the Oxygen change tracking markers) will be stripped.
To include the DOCTYPE you can either manually re-add it, or change the xsl:output to include the appropriate public/system IDs.
e.g. for a DITA Topic
Also, if you want to strip some of the attribute pulled from the DTD, you can simply add another xsl:template that matches them, but does not forward them to the output.
e.g. This strips down the ditaarch:DITAArchVersion and domains attributes.
Let me know if you need something more specific.
Regards,
Adrian
If you want all attributes (including class) to be pulled from the DTD into the DITA file, all you need is a copy stylesheet:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<!-- Match document -->
<xsl:template match="/">
<xsl:apply-templates mode="copy" select="."/>
</xsl:template>
<!-- Deep copy template -->
<xsl:template match="*|text()|@*" mode="copy">
<xsl:copy>
<xsl:apply-templates mode="copy" select="@*"/>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:template>
<!-- Handle default matching -->
<xsl:template match="*"/>
</xsl:stylesheet>
To include the DOCTYPE you can either manually re-add it, or change the xsl:output to include the appropriate public/system IDs.
e.g. for a DITA Topic
Code: Select all
<xsl:output method="xml" doctype-public="-//OASIS//DTD DITA Topic//EN" doctype-system="http://docs.oasis-open.org/dita/v1.1/OS/dtd/topic.dtd"/>
e.g. This strips down the ditaarch:DITAArchVersion and domains attributes.
Code: Select all
<xsl:template match="@ditaarch:DITAArchVersion|@domains" mode="copy"/>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
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