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

Re: Find and change an attribute in a Processing Inst

Subject: Re: Find and change an attribute in a Processing Instruction
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Mon, 30 Jan 2006 13:30:24 -0600
processing instruction xsl replace
> 1) The "hide" strings in the processing instructions are not being replaced
> by "show".

<xsl:when test="contains($text, $find)">
   <xsl:value-of select="substring-before($text, $find)"/>
   <xsl:value-of select="$find"/>
... and so on


So this part of your code gets everything before the occurance of
$find, returns that.  Then it returns the value of $find.  It keeps
doing this while there is still a string (I hope, otherwise it won't
terminate).  It might work better to have something like:

<xsl:when test="contains($text, $find)">
   <xsl:value-of select="substring-before($text, $find)"/>
   <xsl:value-of select="$replace"/>
..and so on

which would return all the text before the first occurance of $find,
the the value of $replace, and then do a recursive call on the rest of
the string (everything after the first occurance of $find).


> 2) I am loosing the <? ?> delimiters on the processing instructions.

As far as I can tell you're not "losing them", you never create a new
processing instruction.  Your stylesheet essentially says: when you
see a processing instruction,  generate this text.

I've only skimmed your email, but I would venture you need something like:

<xsl:template match="/processing-instruction()">
 <xsl:processing-instruction>
<xsl:call-template name="do-replace">
   <xsl:with-param name="text" select="."/>
 </xsl:call-template>
</xsl:processing-instruction>
</xsl:template>

Or in other words: when you see a processing instruction in the input
XML, produce a processing instruction that contains the results of the
call-template.


> 3) Lower level processing instructions are not getting written to the
output
> (e.g. <?Fm Condstart Prolog?>).

Just got an email you figured out what's wrong there.



> I am using Saxon 8.5, but my stylesheet needs to be XSLT 1 compatible.
> Thanks in advance for any help you can give.

So why not use Saxon 6.5?  Besides, this looks XSLT 1ish to me.

Jon Gorman

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.