xsl-list
[Top] [All Lists]

Re: Default Rendering of HTML?

2004-11-21 13:42:46
I've have partial success now.

I tried two methods.  First I tried the <xsl:output> like so:

<xsl:output
        method="html"
        version="4.0"
        omit-xml-declaration="yes"
        cdata-section-elements="text"
        indent="yes"
/>

This didn't really make any difference.  Then while researching how to handle 
HTML tags in XML, I came across a reference that used xsl:copy-of, instead of 
value-of.  It occurred to me that what I was trying to do was place the 
entire node into my output, so copy-of was what I should be using.  So, I 
changed the <xsl:value-of select="text"/> line of my XSL to read <xsl:copy-of 
select="text"/> - and suddenly my HTML began to work.

I had two nodes that were to get rendered, but the first (which didn't contain 
HTML tags) didn't.  I resolved this by removing the <xsl:output> tag I had 
tried earlier.

So, I have a working solution.  But, I'm not sure if this is going to be 
suitable in all cases with HTML tags embedded in XML, or if there is a better 
way of doing this.  Any suggestions are appreciated.

Shawn

On Sunday 21 November 2004 13:13, Shawn wrote:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
      <xsl:template match="/news">
              <xsl:apply-templates/>
      </xsl:template>

      <xsl:template match="item">
              <p>
                      <span>
                              <xsl:attribute 
name="class">newsDate</xsl:attribute>
                              <xsl:value-of select="date"/>
                      </span>
                      <br/>
                      <span>
                              <xsl:attribute 
name="class">newsTitle</xsl:attribute>
                              <xsl:value-of select="title"/>
                      </span>
                      <br/>

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--