Rendering oxy_delete Processing Instructions
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 37
- Joined: Tue Nov 30, 2010 7:34 pm
Rendering oxy_delete Processing Instructions
This isn't exactly an OxygenXML issue, but I'm hoping someone can help me. Basically I'm trying to render the content attribute of the Oxygen delete processing instruction to PDF. My ultimate objective is to render deleted content with strikethru styling. Here's the rule I'm trying:
And then I wrote a set of templates to match the nodes:
This "almost" works, but the exslt:node-set($contents) is interpretting all the encoded markup as a single string. I can't figure out a good way to decode the < and > markup before it gets to that function so that node-set will interpret it as a set of matchable nodes instead of a single string.I had hoped the disable-output-escaping would do it, but no luck.
Any tips or suggestions are very appreciated. Thanks.
Brian
Code: Select all
<xsl:variable name="contents"><xsl:value-of disable-output-escaping="yes" select="substring-before(substring-after(.,'content="'), '"')"/></xsl:variable>
<xsl:for-each select="exslt:node-set($contents)">
<xsl:apply-templates select="." mode="deleted"/>
</xsl:for-each>
Code: Select all
<xsl:template match="p" mode="deleted" >
<xsl:message>delete::para hit</xsl:message>
<fo:inline color="blue" text-decoration="line-through">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="text()" mode="deleted" >
<xsl:message>delete::text() hit</xsl:message>
<fo:inline color="red" text-decoration="line-through">
<xsl:value-of select="."/>
</fo:inline>
</xsl:template>
Any tips or suggestions are very appreciated. Thanks.
Brian
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Rendering oxy_delete Processing Instructions
Hi Brian,
I sent you a reply already on the dita-users list. Here it is again that stylesheet that converts the delete PIs to XML elements. You may change that to covert to whatever markup you need.
Please make sure you set Saxon 9 PE or EE as your XSLT processor.
I sent you a reply already on the dita-users list. Here it is again that stylesheet that converts the delete PIs to XML elements. You may change that to covert to whatever markup you need.
Please make sure you set Saxon 9 PE or EE as your XSLT processor.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xd saxon"
version="2.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Feb 11, 2011</xd:p>
<xd:p><xd:b>Author:</xd:b> george</xd:p>
<xd:p></xd:p>
</xd:desc>
</xd:doc>
<xsl:template match="processing-instruction()[name()='oxy_delete']">
<xsl:variable name="c" select="substring-after(., 'content=')"/>
<xsl:variable name="clen" select="string-length($c) - 2"/>
<xsl:variable name="content">
<xsl:text><tmp></xsl:text>
<xsl:value-of select="substring($c, 2 , $clen)"/>
<xsl:text></tmp></xsl:text>
</xsl:variable>
<xsl:variable name="xmlContent">
<xsl:text><deleted </xsl:text>
<xsl:value-of select="substring-before(.,
'content=')"></xsl:value-of>
<xsl:text>></xsl:text>
<xsl:value-of select="saxon:parse($content)"/>
<xsl:text></deleted></xsl:text>
</xsl:variable>
<xsl:element name="trackchange">
<xsl:attribute name="revisionflag">deleted</xsl:attribute>
<xsl:copy-of select="saxon:parse($xmlContent)/*/node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
George Cristian Bina
-
- Posts: 37
- Joined: Tue Nov 30, 2010 7:34 pm
Re: Rendering oxy_delete Processing Instructions
Thanks so much. I look forward to trying this in the morning.george wrote:Hi Brian,
I sent you a reply already on the dita-users list. Here it is again that stylesheet that converts the delete PIs to XML elements. You may change that to covert to whatever markup you need.
Please make sure you set Saxon 9 PE or EE as your XSLT processor.
Brian
-
- Posts: 37
- Joined: Tue Nov 30, 2010 7:34 pm
Re: Rendering oxy_delete Processing Instructions
George's solution above partially worked, but it still left the content encoded so that in my rendered output I was getting:
To fix this, the solution I finally came up with was to do a simple search and replace on the tag encoding and replace them with < and > symbols like so:
And then the code to handle the processing instruction looks like:
I had tried this originally and it didn't work so I suspect saxon's parsing is doing a better job than my original parser (exslt:node). Thanks so much to George for pointing me in the right direction.
Here's the final output:

Code: Select all
<p>Here's a deleted paragraph</p>
Code: Select all
<xsl:template name="escape">
<xsl:param name="text"/>
<xsl:value-of select="replace(replace($text,'>','>'),'<','<')"/>
</xsl:template>
Code: Select all
<xsl:template match="processing-instruction('oxy_delete')">
<xsl:variable name="c" select="substring-after(.,'content=')" />
<xsl:variable name="clen" select="string-length($c) - 2" />
<xsl:variable name="content">
<xsl:text><tmp></xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="text" select="substring($c,2,$clen)"></xsl:with-param>
</xsl:call-template>
<xsl:text></tmp></xsl:text>
</xsl:variable>
<fo:change-bar-begin change-bar-class="C20040405-4" change-bar-style="solid"
change-bar-color="black" change-bar-offset="2mm" change-bar-placement="end" />
<xsl:apply-templates mode="deleted" select="saxon:parse($content)" />
<fo:change-bar-end change-bar-class="C20040405-4" />
</xsl:template>
Here's the final output:

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)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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