[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] substitute with
RE: [xsl] substitute with
Subject: RE: [xsl] substitute with <br/> From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Thu, 7 Aug 2003 17:01:55 +0100 |
> Hello Andrew, > > Andrew Welch wrote: > >> Hello Alexander, > >> > >> this is probably a FAQ. It's also an XML topic not an XSLT one. > >> > >> Look to 2.11 "End-Of-Line Handling" in the XML spec. > > > >No, it's an html issue. Carriage returns are normalised to a single > >space (I think) so to recreate their behaviour you need to use <br /> > ><div /> <p /> etc. > > No, the original issue is clearly an XML one, as he wrote: > "I thought of doing it with entities in the source XML > like <!ENTITY #13 "<br/>">, but that doesn't work." But why was he trying to replace &_#13; with <br />? Because in html &_#13; doesn't cause a carriage return, a <br /> does. He could learn all of the possible line endings in xml and still not have the answer. > >I think your best plan of action is to modify your xml to replace &_#13; > >with <br /> (Im assuming that as you can insert entities this shouldn't > >be too much trouble). > This was exactly what Alexander was trying, without success. (or do > you mean: manually, with a text editor?) Inserting entity declarations is not the same as replacing &_#13; with <br /> with some tool... How would the parser distinguish between &_#13; the character reference and &_#13; the entity? > >If however that breaks a DTD or is not possible, you will have to use a > >recursive named template that gets called from you text() matching > >template. This can then use substring-before() and substring-after() to > >recursively replace what you need. > > &_#13; cannot be matched or replaced with XSLT functions, as it has > been deleted by the XML parser. Yeah it can - it hasn't been deleted by the parser, its just been resolved. You can still check if a string contains it, just like you can check if a string contains &_#120; (the letter 'x'). As DC always says 'the reference and the character are one and the same thing' - you could write your entire xml file in character references (if you were mad). As long as you cover all your bases with all possible line endings (iirc, the parser can choose which kind of line ending to produce, but theres still only a few) then a recursive template is the usual technique. Or for performance, if you were using java you could write a sax filter that coverted the value on its way into the trasform, then write a template to deal with whatever you has converted line endings to. Or, of course, to save all the hassle just wrap the text that contains the line endings in html's <pre>...</pre> which will render the text as is (if it fits your needs). cheers andrew XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] substitute with <br, Andrew Welch | Thread | RE: [xsl] substitute with <br, David Carlisle |
[xsl] <xsl:if>, AROSO Jose Antonio | Date | RE: [xsl] XPATH question, Andrew Welch |
Month |