xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xan Gregg <...@tibco.com>
Subject RE: XSL - blank attribute
Date Mon, 18 Nov 2002 13:49:24 GMT
Try using a template for each attribute:
 
 <xsl:template match = "table">
  <table>
   <xsl:apply-templates select = "@width"/>
   <xsl:apply-templates select = "@height"/>
   ...
  </table>
 </xsl:template>

 <xsl:template match = "@width">
  <xsl:attribute name = "width">
   <xsl:value-of select = "."/>
  </xsl:attribute>
 </xsl:template>
 ...
 
xan

-----Original Message-----
From: "Kazmír, Jaroslav" [mailto:jaroslav.kazmir@joanneum.at]
Sent: Friday, November 15, 2002 11:17 AM
To: 'general@xml.apache.org'
Subject: XSL - blank attribute


Hello,
I have a XSL stylesheet like this:
 
...
<xsl:template match="table">
      <table>
         <xsl:attribute name="width">
            <xsl:value-of select="@width" />
         </xsl:attribute>
 
         <xsl:attribute name="height">
            <xsl:value-of select="@height" />
         </xsl:attribute>
 
         <xsl:attribute name="cellspacing">
            <xsl:value-of select="@cellspacing" />
         </xsl:attribute>
 
         <xsl:attribute name="cellpadding">
            <xsl:value-of select="@cellpadding" />
         </xsl:attribute>
 
         <xsl:attribute name="bordercolor">
            <xsl:value-of select="@bordercolor" />
         </xsl:attribute>
 
         <xsl:attribute name="class">
            <xsl:value-of select="@class" />
         </xsl:attribute>
 
         <xsl:for-each select="row">
            <tr>
                <xsl:attribute name="bgcolor">
                   <xsl:value-of select="@bgcolor" />
                </xsl:attribute>
 
               <xsl:for-each select="data">
                  <td>
                     <xsl:attribute name="valign">
                        <xsl:value-of select="@valign" />
                     </xsl:attribute>
 
                     <xsl:attribute name="class">
                        <xsl:value-of select="normalize-space(@class) " />
                     </xsl:attribute>
 
                     <xsl:attribute name="height">
                        <xsl:value-of select="@height" />
                     </xsl:attribute>
 
                     <xsl:attribute name="width">
                        <xsl:value-of select="@width" />
                     </xsl:attribute>
 
                     <xsl:apply-templates />
                  </td>
               </xsl:for-each>
            </tr>
         </xsl:for-each>
      </table>
   </xsl:template>
...
My problem is, that the output looks like with empty attributes:
 
<table .. height="" width="" ...>
 <tr ...bgcolor="">
   <td valign="center" class="">
    .... Some text ...
   </td>
 <tr>
<table>
 
Do you anyone know how could I erase all emty attributes in the output? I
don't want to write conditions into XSL file for every attibute.
Output will be better to see like:
 
<table>
 <tr>
  <td valign="center">
   ... Some text ...
  </td>
 <tr>
</table>
 
Thanx a lot for your help and advice.
 
JayKay
 
----------------------------------------------------------------------------
-----------------
  Jaroslav Kazmir
  Institute of Information Systems & Information Management
  JOANNEUM RESEARCH Forschungsgesellschaft mbH
  Steyrergasse 17, A-8010 Graz, AUSTRIA
 
  phone:  +43-316-876-1140                 fax: +43-316-876-1191
  web:    http://iis.joanneum.at <http://iis.joanneum.at> 
  e-mail: mailto:jaroslav.kazmir@joanneum.at
<mailto:jaroslav.kazmir@joanneum.at> 
----------------------------------------------------------------------------
-----------------
 

Mime
View raw message