[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Need help combing two elements

Subject: Re: Need help combing two elements
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Sun, 29 Mar 2009 23:05:02 -0400
Re:  Need help combing two elements
> and my XSL is the following (well a snippet of it, ...

Actually, it would probably be easier to provide advice if you sent
the entire XSLT (or a pointer to it), as it is quite difficult to
test what you sent, as we don't have access to $reportType,
LabHeaderCell, etc.

I've got your input:

 <Row Type="Data">
  <Cell>Mar 23, 2006</Cell>
  <Cell>08:44</Cell>
 </Row>

But what do you want the output to look like?


While we're here, though, some thoughts follow.

>       <xsl:for-each select="Row">
>        <xsl:if test="@Type='Header'">
>          <xsl:for-each select="Cell">
>            <fo:table-column/>
>          </xsl:for-each>
>        </xsl:if>
>      </xsl:for-each>

Couldn't this be expressed a bit more simply as

      <xsl:for-each select="Row[@Type='Header']/Cell">
        <fo:table-column/>
      </xsl:for-each>

?

>     <xsl:choose>
>      <xsl:when test="@Status='Panic'">
>        <fo:table-cell color="red" background-color="white" border="1pt solid
>          black" wrap-option="wrap" overflow="hidden">
>          <fo:block font-size="8pt" padding="1mm" margin-left=".25mm"
>            overflow="hidden" language="ru" hyphenate="true">
>            <xsl:value-of select="."/>
>          </fo:block>
>        </fo:table-cell>
>      </xsl:when>
>      <xsl:otherwise>
>        <fo:table-cell color="black" background-color="white" border="1pt solid
>          black" wrap-option="wrap" overflow="hidden">
>          <fo:block font-size="8pt" padding="1mm" margin-left=".25mm"
>            overflow="hidden" language="ru" hyphenate="true">
>            <xsl:value-of select="."/>
>          </fo:block>
>        </fo:table-cell>
>      </xsl:otherwise>
>    </xsl:choose>

Since most of the content of the <when> and the <otherwise> are the
same, I'd be inclined to factor out the similarities:

  <xsl:template name="LabDataCell">
    <xsl:variable name="color">
      <xsl:choose>
        <xsl:when test="@Status='Panic'">red</xsl:when>
        <xsl:otherwise>black</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <fo:table-cell color="{$color}" background-color="white"
      border="1pt solid black" wrap-option="wrap" overflow="hidden">
      <fo:block font-size="8pt" padding="1mm" margin-left=".25mm"
        overflow="hidden" language="ru" hyphenate="true">
        <xsl:value-of select="."/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>


I'm sure others on the list will point out if & where I'm wrong.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.