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

RE: Re: Search and Replace Help

Subject: RE: Re: Search and Replace Help
From: cknell@xxxxxxxxxx
Date: Sun, 20 May 2007 11:41:56 -0400
RE: Re:  Search and Replace Help
When you say that you are relying on the XSLT processors supplied as part of the web browser, then you will either have to: 

1) Write a least-common-denominator stylesheet. That is to say one that relies only on features common to all processors. That is most likely an XSLT 1.0 processor with no extension functions.

2) Write a different stylesheet for each browser, using the features available for each browser's XSLT engine.

XSLT 1.0's string handling features are fairly basic. That's why I suggested XSLT 2.0 and the regex functions.

One could, of course pound the strings to death with the primitive XSLT 1.0 string handling functions in order to get what you need. After all, you could pull your own bad tooth yourself with a pair of pliers, but I wouldn't.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Matthew Ebbertt <mje004@xxxxxxxx>
Sent:     Sun, 20 May 2007 10:27:11 -0400
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  Re:  Search and Replace Help

First off, thanks for the reply, I learned quite a bit.  And now, because of
that, I can refine my question a bit.

The XML is output from vBulletin as is when someone downloads their Private
Messages, I can't change that.  My intention is to create an XSLT to format
the output so that it is easier for users to read instead of them just
looking at the raw XML.  Because of that, my intent is for this to be viewed
in a normal web browsers (I am using FF 2.0 for this).

1) Thanks for explaining the <![CDATA[]] tag to me, that explains why I see
the <br /> tag instead of it doing what I expected it to.  Is there some way
to get the same effect as an XHTML/HTML <br /> within a <![CDATA[]] element?
The search replace template that I found is replacing any linefeeds it finds
with the <br />, but even with just the linefeeds it doesn't actually do a
linefeed.

2) I'll keep looking around for a way to replace [QUOTE=name] [/QUOTE] with
the correct XHTML/HTML, but unless I find a way around the <![CDATA[]]
limitation, it won't matter.

Thanks for the help so far, this is fun.


On 5/20/07 9:59 AM, "cknell@xxxxxxxxxx" <cknell@xxxxxxxxxx> wrote:

> It seems that the list is very quiet on the weekends.
> 
> First, "[quote=name]...[/quote]" is not XML. So it is unreasonable to expect
> to be able to use XSLT to do anything with them except reproduce it as is or
> operate on it with string methods.
> 
> You have a "message" element. It appears between the opening and closing
> (<message></message>) tags.
> 
> The entire content of the message element is enclosed in <![CDATA[]]>. This is
> an instruction to the XSLT processor to treat the enclosed bytes as text, not
> markup. As far as the stylesheet is concerned, there is no structure between
> <![CDATA[ and ]]>, it's just a collection of bytes.
> 
> There is some evidence that you are working in this way, but since you say
> that you are new to XSLT, and since it is a frequent error by newcomers to
> assume that because they see a structure inside the <![CDATA[]]> tag, that the
> XSLT processor must therefore also see it.
> 
> So, on to your specific complaints.
> ========================= > 1) it is writing out/displaying <br /> instead
> of doing a line break
> 
> You are getting a break element (<br/>) because that's what you told the
> stylesheet to output:
> e.g.,
> <xsl:text>To: </xsl:text> <xsl:value-of select="touser"/><br />
> 
> What constitutes a "line break" depends on what your platform is. In an HTML
> browser, the "<br/>" element is a line break. In Windows, you need a carriage
> return character and a linefeed character. In Linux/Unix you need only the
> linefeed, on the Mac OS (up to version 9), it was only the carriage return.
> 
> If you could identify what your target is (apparently not an HTML browser) you
> could instruct the XSLT processor to output the ASCII character or characters
> to produce a newline by inserting that/those characters in the stylesheet
> where you now have the <br/> element.
> 
> The linefeed is & #10; and the carriage return is & #13; (I've inserted a
> space between the ampersand and the # to prevent any possible literal
> interpretation by your mail reader as instructions. When you use them in your
> stylesheet, be sure that no space appears there.
> 
> 2) I need to replace [QUOTE=jack] & [QUOTE=john]
> with <blockquote><i>Originally posted by: <b>jack (or john)</b></i> (while
> allowing for the fact that there may be a mary, jake, etc.) and [/QUOTE]
> with </blockquote>.
> 
> As I said earlier, this is not XML markup and XSLT templates won't process
> them as if it were. If you are using an XSLT 2.0 processor, you could use the
> regex functions to process this string data and create the elements.
> Alternatively, you could use Java or perl or C# or C or VB (well, you get the
> idea) to create a pre-processor that would create the elements before you fed
> it into the stylesheet.

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.