[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using saxon:parse on processing instructions

Subject: Using saxon:parse on processing instructions
From: "Spencer Tickner spencertickner@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 18 Dec 2017 20:18:10 -0000
 Using saxon:parse on processing instructions
Hello and thanks in advance for the help. I'm scratching my head on trying
to convert a string of serialized xml in a processing instruction back into
XML.

I'm restricted to XSLT 2.0 and am using Saxon 9.1. When I treat the simply
copy and past the xml into the stylesheet everything works (see variable
$s2), but when breaking the string out of the processing instruction the
elements remain serialized:

input:

<?xml version="1.0"?>
<root xmlns:bcl="http://bcl">
<?pi a="&lt;bcl:e&gt;Test&lt;/bcl:e&gt;" ?>
</root>

stylesheet:

<?xml version='1.0'?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bcl="http://bcl"
xmlns:saxon="http://saxon.sf.net/">

<xsl:template match="root">
<test>
<xsl:apply-templates/>
</test>
</xsl:template>

<xsl:template match="processing-instruction('pi')">
<xsl:variable name="s1">&lt;root xmlns:bcl="http://bcl"&gt;<xsl:value-of
select="replace(., '.*a=(.)(.+)?\1.*', '$2')"/>&lt;/root&gt;</xsl:variable>
<xsl:variable name="s2">&lt;root xmlns:bcl="http://bcl
"&gt;&lt;bcl:e&gt;Test&lt;/bcl:e&gt;&lt;/root&gt;</xsl:variable>
<!-- Not Expected: -->
<xsl:copy-of select="saxon:parse($s1)"/>
<!-- Expected: -->
<xsl:copy-of select="saxon:parse($s2)"/>
</xsl:template>

</xsl:stylesheet>


output:

<?xml version='1.0' ?>
<test xmlns:bcl="http://bcl" xmlns:saxon="http://saxon.sf.net/">
<root>&lt;bcl:e&gt;Test&lt;/bcl:e&gt;</root>
<root><bcl:e>Test</bcl:e></root>
</test>



Any help or suggestion would be much appreciated.

Regards,

Spencer

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.