[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Help please on a select statement.


Subject: [xsl] Help please on a select statement.
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx (by way of Mulberry Technologies List Owner)
Date: Sat, 24 Mar 2001 15:04:28 -0500

From: Wolfgang Bogacz <wbogacz@xxxxxxxxxxx>
To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Help please on a select statement.
Date: Fri, 23 Mar 2001 15:10:20 -0500
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Content-Type: text/plain;
	charset="iso-8859-1"

Given this type of input:

<g id="ProcessData_0001" >
   <text style="font-family:Arial; font-size:21; fill:#EF82EF; " x="980"
y="504">
      <CS3000GR:dataFormat type="string" digit="3,0" zeroReading="yes"
unit="yes"/>
      <CS3000GR:processData data="F01226.LOOP"/>
   </text>
</g>
<g id="ProcessData_0002" >
   <text style="font-family:Arial; font-size:21; fill:#EF82EF; " x="334"
y="652">
      <dataFormat type="string" digit="3,0" zeroReading="yes" unit="yes"/>
      <processData data="T01096.LOOP"/>
   </text>
</g>
<g id="ProcessData_0003" >
   <text style="font-family:Arial; font-size:21; fill:#00FF00; " x="155"
y="657">
      <CS3000GR:dataFormat type="numeric" digit="4,1" zeroReading="yes"
unit="yes"/>
      <CS3000GR:processData data="F01212.PV"/>
   </text>
</g>
<g id="ProcessData_0004" >
   <text style="font-family:Arial; font-size:21; fill:#00FF00; " x="155"
y="657">
      <dataFormat type="numeric" digit="4,1" zeroReading="yes" unit="yes"/>
      <processData data="F01213.PV"/>
   </text>
</g>

And this stylesheet:

<xsl:template match="g">
  <xsl:copy>
    <xsl:if test="string-length(normalize-space(@id)) != 0">
      <xsl:attribute name="id"><xsl:value-of
select="normalize-space(@id)"/></xsl:attribute>
    </xsl:if>
    <xsl:choose>
      <xsl:when test="count(descendant::CS3000GR:dataFormat[@digit]) != 0">
        <xsl:choose>
          <xsl:when test="count(./text/CS3000GR:dataFormat) != 0">
            <xsl:choose>
              <xsl:when
test="substring(normalize-space(./text/CS3000GR:dataFormat[@digit]),string-l
ength(normalize-space(./text/CS3000GR:dataFormat[@digit])),1)='0'">
                <xsl:attribute name="ProcessBook:NumberFormat"><xsl:value-of
select="'#,##0'"/></xsl:attribute>
              </xsl:when>
              <xsl:otherwise>
                <xsl:attribute name="ProcessBook:NumberFormat"><xsl:value-of
select="'#,##0.00'"/></xsl:attribute>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
        </xsl:choose>
      </xsl:when>
      <xsl:when test="count(descendant::dataFormat[@digit]) != 0">
         Block of the same logic as just above with ./CS3000GR instead of
./text/CS3000GR
      </xsl:when>
    </xsl:choose>
    <xsl:choose>
      <xsl:when test="count(descendant::CS3000GR:processData[@data]) != 0">
        <xsl:choose>
          <xsl:when test="count(./text/CS3000GR:processData) != 0">
            <xsl:attribute name="ProcessBook:PtTagName"><xsl:value-of
select="./text/CS3000GR:processData[@data]"/></xsl:attribute>
          </xsl:when>
          <xsl:when test="count(./text/processData) != 0">
            <xsl:attribute name="ProcessBook:PtTagName"><xsl:value-of
select="./text/processData[@data]"/></xsl:attribute>
          </xsl:when>
        </xsl:choose>
      </xsl:when>
    </xsl:choose>
  </xsl:copy>
  <!--<xsl:apply-templates/>-->
</xsl:template>

(Note that the namespace CS3000GR is not always used, and
<emph>sometimes</emph> CS3000GR:dataFormat and CS3000GR:processData exist
outside a text element,
hence the circuitous logic there)

This is my desired lines for my output which elevates the 'data' from
processData to PtTagName, and
determines if the NumberFormat should be integer, based on ',0' in 'digit'
from dataFormat, or decimal.

<g id="ProcessData_0001" ProcessBook:NumberFormat="#,##0"
ProcessBook:PtTagName="F01226.LOOP" />
<g id="ProcessData_0002" ProcessBook:NumberFormat="#,##0"
ProcessBook:PtTagName="T01096.LOOP" />
<g id="ProcessData_0003" ProcessBook:NumberFormat="#,##0.00"
ProcessBook:PtTagName="F01212.PV" />
<g id="ProcessData_0004" ProcessBook:NumberFormat="#,##0.00"
ProcessBook:PtTagName="F01213.PV" />

But I always get "#,##0.00" (decimal, the otherwise) for NumberFormat , and
"" (nothing) for PtTagName.
I hope someone can provide some insight on the desired selects.

Thanks, and sorry about the length of this message.

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



Current Thread