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

Re: Asymmetric string handling with processing-instru

Subject: Re: Asymmetric string handling with processing-instructions
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Sep 2023 16:08:41 -0000
Re:  Asymmetric string handling with  processing-instru
On 14.09.2023 17:27, Martin Honnen martin.honnen@xxxxxx wrote:
>
>
> On 14.09.2023 16:05, Michael Mueller-Hillebrand
> michael.mueller-hillebrand@xxxxxxxxx wrote:
>>
>> My bottom line: If you want to use saxon:get-pseudo-attribute(),
>> because it is elegant and efficient, and it could be possible you
>> have user content in processing instruction, you have two additional
>> tasks:
>>
>> * When using xsl:processing-instruction or other ways to create
>> processing instructions, make sure to escape the five XML characters
>>
>> * When accessing PI string values without saxon:get-pseudo-attribute,
>> add an unescaping routine to avoid double escaped content.
>>
>> How do you deal with this asymmetry?
>>
>
> For the escaping in your sample, one way to ensure the ampersand is
> escaped could be
>
>
> B B B  <xsl:template match="p">
>
> B B B B B B B  <xsl:processing-instruction name="my" select="'value=&quot;'
> || string() => serialize(map { 'method' : 'xml' }) || '&quot;'"/>
>
> B B B  </xsl:template>
>
> Should also work for the less than sign but probably not for double
> quotes.
>

For the string value using `parse-xml-fragment` should help e.g.

 B B  <xsl:template match="processing-instruction(my)">

 B B B B B B B  <p>

 B B B B B B B B B B B  <xsl:text>String: </xsl:text>

 B B B B B B B B B B B  <xsl:value-of select="string(.) =>
parse-xml-fragment()"/>

 B B B B B B B  </p>

gives


<p>String: value="Marks &amp; Spencer PI"</p>

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.