Processing oxy_delete processing instruction
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 116
- Joined: Fri Apr 08, 2011 7:58 am
Processing oxy_delete processing instruction
Hi,
I want to use oxy_delete processing instruction with my XSLT stylesheet.
[Source Document]
[Stylesheet]
This template outputs following message:
Description: [Saxon-PE] author= toshi
Description: [Saxon-PE] timestamp= 20140321T225157+0900
Description: [Saxon-PE] content= <term keyref="KAIKOKU_OPEN"/>
As you can see, '<' , '>' and '"' are doubly escaped in $content.
Are there any ways to restore $content into XML fragment using XSLT stylesheet? I want parse it using parse-xml-fragment() function.
Regards,
Toshihiko Makita
I want to use oxy_delete processing instruction with my XSLT stylesheet.
[Source Document]
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic_v5d_3ly_hn">
<title>Change tracking example</title>
<body>
<p>Mr. Abe's TPP<?oxy_delete author="toshi" timestamp="20140321T225157+0900" content="<term keyref="KAIKOKU_OPEN"/>"?>
<?oxy_insert_start author="toshi" timestamp="20140321T225137+0900"?><term
keyref="KAIKOKU_BREAK"/><?oxy_insert_end?></p>
</body>
</topic>
<?oxy_options track_changes="on"?>
Code: Select all
<xsl:template match="processing-instruction('oxy_delete')" priority="2">
<xsl:variable name="piText" as="xs:string" select="string(.)"/>
<xsl:variable name="regX" as="xs:string" select="'author="(.+)" timestamp="(.+)" content="(.+)"'"/>
<xsl:variable name="author" as="xs:string" select="replace($piText,$regX,'$1')"/>
<xsl:variable name="timeStamp" as="xs:string" select="replace($piText,$regX,'$2')"/>
<xsl:variable name="content" as="xs:string" select="replace($piText,$regX,'$3')"/>
<xsl:message select="'author=',$author"/>
<xsl:message select="'timestamp=',$timeStamp"/>
<xsl:message select="'content=',$content"/>
</xsl:template>
Description: [Saxon-PE] author= toshi
Description: [Saxon-PE] timestamp= 20140321T225157+0900
Description: [Saxon-PE] content= <term keyref="KAIKOKU_OPEN"/>
As you can see, '<' , '>' and '"' are doubly escaped in $content.
Are there any ways to restore $content into XML fragment using XSLT stylesheet? I want parse it using parse-xml-fragment() function.
Regards,
Toshihiko Makita
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Processing oxy_delete processing instruction
Hi Toshihiko,
My colleague George created such a stylesheet a while ago, I'm attaching it below:
It uses XSLT 2.0 and the Saxon 9 specific extension "saxon:parse" (it is used twice to remove that double escaping you noticed):
http://www.saxonica.com/documentation9. ... parse.html
Regards,
Radu
My colleague George created such a stylesheet a while ago, I'm attaching it below:
Code: Select all
<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">
<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>
http://www.saxonica.com/documentation9. ... parse.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 116
- Joined: Fri Apr 08, 2011 7:58 am
Re: Processing oxy_delete processing instruction
Hi Radu,
Thank you!
Regards,
Toshihiko Makita
Nice suggestion(it is used twice to remove that double escaping you noticed):

Thank you!
Regards,
Toshihiko Makita
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.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