Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Push Processing

From: "Philip Vallone" <philip.vallone@----------->
To:
Date: 3/2/2009 3:06:00 PM
Thanks Michael,

Unfortunately I am using 1.0 - So I will have to rework the table.

As for your 2.0 suggestion, I look forward to updating my stylesheets to
2.0.

Thanks,

Phil

 

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] 
Sent: Monday, March 02, 2009 9:30 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Push Processing

Well, you can't apply templates to a node that isn't there, so you need to
find another way.

In XSLT 2.0 you could try this:

<xsl:function name="f:expand" as="element()">
  <xsl:param name="item" as="element(item)"/>
  <xsl:param name="child" as="element()?"/>
  <xsl:choose>
    <xsl:when test="exists($child)">
      <xsl:sequence select="$child"/>
    </xsl:when>
    <xsl:otherwise>
      <emptyCell/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>

then

<xsl:apply-templates select="f:expand(.,label), f:expand(.,code),
f:expand(.,no), ..."/>

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Philip Vallone [mailto:philip.vallone@xxxxxxxxxxx]
> Sent: 02 March 2009 14:14
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Push Processing
> 
> Hi List,
> 
> I am using push processing to output a resulting FO file. I use 
> apply-templates to build a table row and its cells.
> Normally I would build the table by using a pull philosophy, but it 
> would require a lot of rework to the stylesheet. My problem occurs 
> when I have an optional element. Using apply-templates, my output my 
> leave out a cell, causing my cell alignment to be off. The below is a 
> dumb-down version for example:
> 
> <item-entry>
> 	<item>
> 		<label>1</label>
> 		<code>234</code>
> 		<no>12345</no>
> 		<partno>12-3456-0981-1</partno>
> 		<name>Widget</name>
> 		<qty>3</qty>
> 	</item>
> </item-entry>
> 
> Suppose I am missing <nsn>, I need to apply an empty cell. 
> How can I do this using push processing?
> 
> 	<xsl:template match="item-entry">
> 		<xsl:apply-templates/>
> 	</xsl:template>
> 	<xsl:template match="item">
> 		<fo:table-row>
> 			<xsl:apply-templates/>
> 		</fo:table-row>
> 	</xsl:template>
> 	<xsl:template match="label">
> 		<fo:table-cell>
> 			<fo:block>
> 				<xsl:value-of select="."/>
> 			</fo:block>
> 		</fo:table-cell>
> 	</xsl:template>
> 	<xsl:template match="code">
> 		<fo:table-cell>
> 			<fo:block>
> 				<xsl:value-of select="."/>
> 			</fo:block>
> 		</fo:table-cell>
> 	</xsl:template>
> 	<xsl:template match="nsn">
> 		<fo:table-cell>
> 			<fo:block>
> 				<xsl:value-of select="."/>
> 			</fo:block>
> 		</fo:table-cell>
> 	</xsl:template>
> 	<xsl:template match="partno">
> 		<fo:table-cell>
> 			<fo:block>
> 				<xsl:value-of select="."/>
> 			</fo:block>
> 		</fo:table-cell>
> 	</xsl:template>
> 	<xsl:template match="name">
> 		<fo:table-cell>
> 			<fo:block>
> 				<xsl:value-of select="."/>
> 			</fo:block>
> 		</fo:table-cell>
> 	</xsl:template>
> 	<xsl:template match="qty">
> 		<fo:table-cell>
> 			<fo:block>
> 				<xsl:value-of select="."/>
> 			</fo:block>
> 		</fo:table-cell>
> 	</xsl:template>
> 
> Thanks,
> 
> Phil


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent