Default rowsep/colsep/frame in transformation if not set
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 9
- Joined: Thu Jul 21, 2022 4:07 pm
Default rowsep/colsep/frame in transformation if not set
Hi,
I want to define the default setting for frame, rowsep and colsep to true, when nothing is set. We use a merged2mergedExtention.xsl as described here: https://www.oxygenxml.com/doc/versions/ ... plate.html
So I thought it would be great to add the default settings there, but I'm totally stuck.
I managed to insert rowsep and colsep when both is missing (I assume that it is only a misstake when both aren't set, don't know if this makes sense):
But when I add the frame with an <xsl:if>, it doesn't work:
Can anybody help me out and tell me where my mistake is?
Thank you!
Heidi
I want to define the default setting for frame, rowsep and colsep to true, when nothing is set. We use a merged2mergedExtention.xsl as described here: https://www.oxygenxml.com/doc/versions/ ... plate.html
So I thought it would be great to add the default settings there, but I'm totally stuck.
I managed to insert rowsep and colsep when both is missing (I assume that it is only a misstake when both aren't set, don't know if this makes sense):
Code: Select all
<xsl:template match="table[(not(@colsep)) and (not(@rowsep))]">
<table>
<xsl:attribute name="colsep">1</xsl:attribute>
<xsl:attribute name="rowsep">1</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</table>
</xsl:template>
Code: Select all
<xsl:template match="table[((not(@colsep)) and (not(@rowsep))) or (not(@frame))]">
<xsl:if table="(not(@colsep)) and (not(@rowsep))">
<table>
<xsl:attribute name="colsep">1</xsl:attribute>
<xsl:attribute name="rowsep">1</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</table>
</xsl:if>
<xsl:if table="not(@frame)">
<table>
<xsl:attribute name="frame">all</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</table>
</xsl:if>
</xsl:template>
Thank you!
Heidi
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Default rowsep/colsep/frame in transformation if not set
Post by chrispitude »
Hi Heidi,
I have a similar request here, but for authoring (being able to specify the defaults for new table insertions):
Have parameters for new tables default to <unspecified>
I thought I would point it out in case it was also interesting to you.
I have a similar request here, but for authoring (being able to specify the defaults for new table insertions):
Have parameters for new tables default to <unspecified>
I thought I would point it out in case it was also interesting to you.
-
- Posts: 9
- Joined: Thu Jul 21, 2022 4:07 pm
Re: Default rowsep/colsep/frame in transformation if not set
Dear chrispitude,
thank you for your reply. Your post is absolutely relevant for the future and I'm with you, that everything should stay empty except you want something different from your standard. I wonder why my default setting is different from yours (frame=all, rowsep and colsep undefined). Maybe it depends on what oxygen version you first installed. That makes everything even worse. We have at least two different default settings in the company. It should be able to set the default settings for new tables in the settings.
But my problem is one step earlier: I have something wrong in my code to set the default (for not defined attributes) and I cant't get the transformation to run.
Best regards
Heidi
thank you for your reply. Your post is absolutely relevant for the future and I'm with you, that everything should stay empty except you want something different from your standard. I wonder why my default setting is different from yours (frame=all, rowsep and colsep undefined). Maybe it depends on what oxygen version you first installed. That makes everything even worse. We have at least two different default settings in the company. It should be able to set the default settings for new tables in the settings.
But my problem is one step earlier: I have something wrong in my code to set the default (for not defined attributes) and I cant't get the transformation to run.

Best regards
Heidi
Last edited by Heidi on Fri Jul 22, 2022 11:55 am, edited 2 times in total.
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Default rowsep/colsep/frame in transformation if not set
Post by chrispitude »
Hi Heidi,
I don't know if this would help you, but I could provide a refactoring operation that modifies your existing DITA source to use a certain separator/frame convention. That's not the same as modifying it during transformation, but perhaps the better solution is to fix the source anyway.
Would that be useful?
I don't know if this would help you, but I could provide a refactoring operation that modifies your existing DITA source to use a certain separator/frame convention. That's not the same as modifying it during transformation, but perhaps the better solution is to fix the source anyway.
Would that be useful?
-
- Posts: 9
- Joined: Thu Jul 21, 2022 4:07 pm
Re: Default rowsep/colsep/frame in transformation if not set
Hi chrispitude,
thanks a lot for the offer, but I prefer to customize it in the transformation.
The error ist found and we deceided to split rowsep and colsep too. Here is the correct code for the merged2mergedExtention.xsl, if somebody needs it:
thanks a lot for the offer, but I prefer to customize it in the transformation.
The error ist found and we deceided to split rowsep and colsep too. Here is the correct code for the merged2mergedExtention.xsl, if somebody needs it:
Code: Select all
<xsl:template match="table[((not(@colsep)) or (not(@rowsep))) or (not(@frame))]">
<xsl:if test="not(@colsep)">
<table>
<xsl:attribute name="colsep">1</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</table>
</xsl:if>
<xsl:if test="not(@rowsep)">
<table>
<xsl:attribute name="rowsep">1</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</table>
</xsl:if>
<xsl:if test="not(@frame)">
<table>
<xsl:attribute name="frame">all</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</table>
</xsl:if>
</xsl:template>
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Default rowsep/colsep/frame in transformation if not set
Post by chrispitude »
Hi Heidi,
I think that might result in multiple <table> elements if multiple attributes are missing, with each table produced having only one of the missing attributes.
You could also consider the following approach:
which takes advantage of the fact that if the same attribute is defined twice for the same element, XSLT keeps the last value. So in this case, we set all our desired default attributes, then <xsl:apply-templates> replaces any of them as needed.
I think that might result in multiple <table> elements if multiple attributes are missing, with each table produced having only one of the missing attributes.
You could also consider the following approach:
Code: Select all
<xsl:template match="table">
<xsl:copy>
<xsl:attribute name="colsep" select="'1'"/> <!-- default -->
<xsl:attribute name="rowsep" select="'1'"/> <!-- default -->
<xsl:attribute name="frame" select="'all'"/> <!-- default -->
<xsl:apply-templates select="@*|node()"/> <!-- overrides defaults if specified -->
</xsl:copy>
</xsl:template>
-
- Posts: 9
- Joined: Thu Jul 21, 2022 4:07 pm
Re: Default rowsep/colsep/frame in transformation if not set
Hi chrispitude,
I had a stupid test case so I didn't saw the duplication of the tables
Thank you so much for helping me out. Now it works perfectly and its very elegant
I had a stupid test case so I didn't saw the duplication of the tables

Thank you so much for helping me out. Now it works perfectly and its very elegant

-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Default rowsep/colsep/frame in transformation if not set
Post by chrispitude »
Hi Heidi,
I made similar mistakes when I was starting out with XSLT. I am better now, but I still have a lot to learn.
Here is a good place to experiment and learn:
https://xsltfiddle.liberty-development.net/
Delete everything after the <xsl:mode> (you don't want HTML settings or the default templates), then put some DITA content in the top-left side and experiment. The output on the bottom-left will update as you make changes to the XSLT code. It's a great way to experiment, learn, and get the syntax and logic right.
I made similar mistakes when I was starting out with XSLT. I am better now, but I still have a lot to learn.

Here is a good place to experiment and learn:
https://xsltfiddle.liberty-development.net/
Delete everything after the <xsl:mode> (you don't want HTML settings or the default templates), then put some DITA content in the top-left side and experiment. The output on the bottom-left will update as you make changes to the XSLT code. It's a great way to experiment, learn, and get the syntax and logic right.
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