xsl-list
[Top] [All Lists]

RE: output unterminated tags

2003-04-05 13:31:18
This is the standard problem of arranging data in multiple columns, you
will find the answer at
http://www.dpawson.co.uk/xsl/sect2/N7450.html#d7608e13

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
jm
Sent: 05 April 2003 19:52
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] output unterminated tags


hi,

this is a part of my xml-file (the table data)

<table columns="3">
      <cell>row1</cell>
      <cell>row1</cell>
      <cell>row1</cell>
      <cell>row2</cell>
      <cell>row2</cell>
      <cell>row2</cell>
      ....
</table>

and this is the part from my xslt-file so far:

<xsl:template match="table">
      <table border="1">
              <xsl:apply-templates select="cell"/>
      </table>
</xsl:template>

<xsl:template match="cell">
      <xsl:choose>
              <xsl:when test="position()=1">
              <xsl:message><test></xsl:message>
                      <tr>                                    
      <!-- here seems to be my problem -->
              </xsl:when>
      </xsl:choose>
      
      <td>
              <xsl:value-of select="."/>
      </td>
      
      <xsl:choose>
              <xsl:when test="((position() mod 3) = 0) and 
(position()!=1) and (position() != last())">
                      </tr><tr>                               
       <!-- here seems to be my problem -->
              </xsl:when>
              <xsl:when test="position() = last()">
                      </tr>                                   
      <!-- here seems to be my problem -->
              </xsl:when>
      </xsl:choose>
</xsl:template>


thanks,
jm


On Sat, 5 Apr 2003 11:50:45 -0600
bix_xslt(_at_)hotmail(_dot_)com wrote:

Jim,

This is a common problem for those of us who have just 
started delving 
into XML.  What may be beneficial for you is if you could provide a 
sample XML and XSLT sheet so that those of us on the list 
can show you 
how to work with the XSL language.  I have a feeling that 
you need to 
shift your viewpoint from a pure html line by line thought process 
into a more functional programming viewpoint.  By providing the 
samples, we'll be able to help you see how to use the XSL 
in a better 
manner.

Any time you need to output a particular type of element, such as 
'tr', you want the xsl processor to create an html node or 
element.  
Using CDATA as you have shown below creates a string that 
looks like a 
node element, but only after the HTML has been processed 
(as you have 
seen with your output). The way I typically do this is 
think about my 
problem in this manner:

make the table tag,
   for every row I need,
      add a start tr tag,
        apply all the templates for the individual td tags
      end the tr tag
   end the for each
end the table tag

Hopefully that makes some sense.  Again, providing the xml and xslt 
would allow us to help you more. bix




----- Original Message -----
From: "jm" <mailinglist(_at_)DiabAnalyst(_dot_)de>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Saturday, April 05, 2003 11:38 AM
Subject: [xsl] output unterminated tags


hi all,

i want to output unterminated tags with my xslt-stylesheet for 
(html)table-construction.

so i want to be able to print just

<tr>
or
</tr><tr>
or
</tr>

i tried it with <![CDATA[<tr>]]> but this put just

&lt;tr&gt;

in my html-file

thanks
jm

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



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


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



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



<Prev in Thread] Current Thread [Next in Thread>