Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2008, 02:01 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default regex in xslt

Hi,
can any one help in splitting this string

  <par >
    <picture>
      <par >
        <run>&lt;img src= imgone onClick=OpenImageFile( D:\Corp_Annc_Attachment\Images\red.gif )&gt;&lt;/img&gt;</run>
      </par>
    </picture>
  </par>

this is my xml
i need to xsl transformation ,i need to write an xsl using href and i will show the imgone alone and i need to store D:\Corp_Annc_Attachment\Images\red.gif in a seperate string,so that on clicking the img i will open this gif.

thanks in advance..

 
Old September 29th, 2008, 02:43 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's best not to structure your source documents this way: markup in nested elements should not be escaped. But the damage is done, and the quick way out might be output the image using

<xsl:value-of select="run" disable-output-escaping="yes"/>

The trouble with this is that it doesn't work in all environments (notably Firefox). That's not a bug in Firefox, it's an intrinsic limitation of disable-output-escaping - it's an instruction to the serializer to output text as-is, without escaping, and it has no effect in an environment where the output isn't sent to a serializer.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 29th, 2008, 03:18 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

kay Thanks for the reply
i have used the same one but my question is how to use regular expression for

run>&lt;img src= imgone onClick=OpenImageFile( D:\Corp_Annc_Attachment\Images\red.gif )&gt;&lt;/img&gt;</run>

this run tag and store D:\Corp_Annc_Attachment\Images\red.gif in a variable.





 
Old September 29th, 2008, 04:35 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Writing a regular expression that processes this input, and only this input, is trivial (in fact, you don't even need to look at the input!). What you really want, I'm sure, is to be able to process a range of inputs, and I can't guess what that range of inputs might be from just one example. The key to writing a regular expression is to describe the set of all possible inputs.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 29th, 2008, 11:35 PM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi kay

i have done using substring functions

<xsl:variable name="pathy" select="substring-before(substring-after(picture/par/run,'OpenImageFile('), ')') "/>

<a href="{$pathy}"> <xsl:value-of select="picture/par/run" disable-output-escaping="yes" />
</a>

i got the required result..
Thanks for helping






Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex pendemv JSP Basics 4 December 8th, 2008 08:29 AM
regex mrame XSLT 12 July 25th, 2008 09:37 AM
Regex htran XSLT 2 May 18th, 2005 09:21 AM
More regex help Snib Pro PHP 4 December 16th, 2004 09:56 PM
Regex Help boyer99g General .NET 2 October 8th, 2004 05:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.