This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: replace xml element


Thanks Jeni, I'll give that a try but also I was just wondering is there a
possibility of doing some sort of search and replace in xslt, ie. search
through the whole xml doc and replace any occurrence of the tag <break/>
with <br/>?

valerie_liston@omnibility.com
00 353 61 419440

----- Original Message -----
From: "Jeni Tennison" <jeni@jenitennison.com>
To: "valerie liston" <valerie_liston@omnibility.com>
Cc: <XSL-List@lists.mulberrytech.com>
Sent: Wednesday, May 01, 2002 1:47 AM
Subject: Re: [xsl] replace xml element


> Hi Valerie,
>
> > I have a question about replacing xml elements. Here is the problem;
> > I want to output the content of the element <content> and replace
> > the element <break/> with the html tag <br/>. I know this is
> > probably a very basic question but I appreciate your help.
>
> Rather than just getting the *value* of the content (with
> xsl:value-of), apply templates to it:
>
>   <xsl:apply-templates select="item/par/content" />
>
> and then add a template that matches break elements and, when they're
> encountered, inserts a br element to the result instead:
>
> <xsl:template match="break">
>   <br />
> </xsl:template>
>
> When you tell the processor to apply templates to the content element,
> it will search through the templates in your stylesheet to find one
> that matches content elements. If it doesn't find one, it'll use the
> built-in template:
>
> <xsl:template match="*">
>   <xsl:apply-templates />
> </xsl:template>
>
> This tells the processor to apply templates to all the child nodes of
> the matched (content) element -- the text nodes and the break
> elements. When the processor tries to find a template that matches
> text nodes, again it won't find one in your stylesheet, so it'll use
> the built-in one:
>
> <xsl:template match="text()">
>   <xsl:value-of select="." />
> </xsl:template>
>
> so the value of each text node will be added to the result. When the
> processor tries to find a template that matches the break elements, it
> will find the one that you've provided, and add a br element to the
> result for each one.
>
> Applying templates to content and having templates to match different
> bits of that content (a push approach) is the best way of processing
> mixed content such as that in your example.
>
> Cheers,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>



begin 666 InterScan_Disclaimer.txt
M3VUN:6)I;&ET>2!A=71O;6%T:6-A;&QY('-C86YS(&%L;"!I;F)O=6YD(&%N
M9"!O=71B;W5N9"!E+6UA:6P@871T86-H;65N=',N($AO=V5V97(L('=E(&UA
M>2!N;W0@8F4@86)L92!T;R!D971E8W0@;W(@<F5P86ER(&%L;"!V:7)U<V5S
M(&%N9"!V87)I86YT<RX@4&QE87-E(&)E(&%W87)E('1H870@=&AE<F4@:7,@
M82!R:7-K(&EN=F]L=F5D('=H96YE=F5R(&1O=VYL;V%D:6YG(&4M;6%I;"!A
M='1A8VAM96YT<R!T;R!Y;W5R(&-O;7!U=&5R(&]R('-E;F1I;F<@92UM86EL
9(&%T=&%C:&UE;G1S('1O(&]T:&5R<RX-"@  
end


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]