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

RE: [xsl] Problem with converting to XSLT 2.0


Subject: RE: [xsl] Problem with converting to XSLT 2.0
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 2 Mar 2005 21:30:17 -0000

After some trivial corrections to your stylesheet (like the unfinished
<xsl:template match="/"> template) I'm getting the output

 
  CFCK  DPARK  slots.t11  pots.t11
 
which looks right.

I think you're hitting bugs in the processor rather than language problems
with XSLT 2.0. Given that you seem to be using a processor that allows  

href="..\text\text.justify.xslt"

in a place where the spec requires a URI, I don't think you're using Saxon.

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


> -----Original Message-----
> From: Heckel, Matt , Ctr, OSD-PA&E 
> [mailto:Matthew.Heckel.ctr@xxxxxxx] 
> Sent: 02 March 2005 20:38
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Problem with converting to XSLT 2.0
> 
> Classification: UNCLASSIFIED
> 
> Hi,
> 
> I've managed to turn a seemingly simple task into a major 
> time kill.  All I
> wanted to do was convert my template to version 2.0 (from 
> version 1.0) to
> take advantage of its nifty grouping functionality.  But no.. 
> after nailing
> the complicated grouping stuff, I ran into a problem using a 
> simple utility
> template, text.justify.xslt,  from Sal Mangano's Cookbook 
> that worked fine
> in V. 1.0.  From what I've observed, the <xsl:choose> element in
> text.justify.xslt is now acting more like an <xsl:if> 
> element.  That is, all
> of the <when> conditions are being tested for, including 
> <otherwise>, even
> though the first test of the group is true.  I should be 
> getting the one
> data element in my source file but instead I'm getting the 
> string "INVALID
> ALIGN" printed out after each attribute.
> 
> I'm not sure if my problem lies with the new <sequence> 
> element for choose
> (doubt it) or something to do with XSLT V. 2.0 only allowing 
> 1 node being
> used in value-of calls as opposed to a nodeset which was ok 
> in V. 1.0.  I
> think this is an ez one for someone other then my newbie self.  MUCH
> appreciation~  Matt
> 
> Source Doc:
>  <?xml version="1.0" encoding="UTF-8" ?> 
> <CASTDataset> 
> <ETL_KV_1 BLUE_THTR_CMD_NM="CFCK" KV_POT_FILE_NM="pots.t11"
> KV_SLOT_FILE_NM="slots.t11" RED_THTR_CMD_NM="DPARK" THTR_ID="1" /> 
> </CASTDataset>
> Main Template:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> 	xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:fn="http://www.w3.org/2004/07/xpath-functions"
> 	xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes">
> 	<xsl:output method="text" version="1.0" encoding="UTF-8"
> indent="yes"/>
> 	<xsl:include href="..\text\text.justify.xslt"/>
> 	<xsl:variable name="endline" select="'&#x0a;'"/>
> 	<xsl:template match="/">
> 	<xsl:template match="CASTDataset/ETL_KV_1">
> 		<xsl:call-template name="text_justify">
> 			<xsl:with-param name="value" select="concat('
> ',@BLUE_THTR_CMD_NM)"/>
> 			<xsl:with-param name="width" select="14"/>
> 			<xsl:with-param name="align" select=" 'left' "/>
> 		</xsl:call-template>
> 		<xsl:text>  </xsl:text>
> 		<xsl:call-template name="text_justify">
> 			<xsl:with-param name="value" select="concat('
> ',@RED_THTR_CMD_NM)"/>
> 			<xsl:with-param name="width" select="12"/>
> 			<xsl:with-param name="align" select=" 'left' "/>
> 		</xsl:call-template>
> 		<xsl:text>  </xsl:text>
> 		<xsl:call-template name="text_justify">
> 			<xsl:with-param name="value" select="concat('
> ',@KV_SLOT_FILE_NM)"/>
> 			<xsl:with-param name="width" select="30"/>
> 			<xsl:with-param name="align" select=" 'left' "/>
> 		</xsl:call-template>
> 		<xsl:text>  </xsl:text>
> 		<xsl:call-template name="text_justify">
> 			<xsl:with-param name="value" select="concat('
> ',@KV_POT_FILE_NM)"/>
> 			<xsl:with-param name="width" select="30"/>
> 			<xsl:with-param name="align" select=" 'left' "/>
> 		</xsl:call-template>
> 		<xsl:value-of select="$endline"/>
> 	</xsl:template>	
> </xsl:stylesheet>
> 
> Utility Template:  (I've abbreviated the code from the Cookbook for
> readability)
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!--<xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings"
>   xmlns:text="http://www.ora.com/XSLTCookbook/namespaces/text"
> extension-element-prefixes="text">   -->
>   <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:fn="http://www.w3.org/2004/07/xpath-functions"
> xmlns:text="http://www.ora.com/XSLTCookbook/namespaces/text"
> extension-element-prefixes="text">
> 
> <xsl:template name="text_justify">
>   <xsl:param name="value" /> 
>   <xsl:param name="width" select="10"/>
>   <xsl:param name="align" select=" 'left' "/>
>   <xsl:variable name="output" select="substring($value,1,$width)"/>
>   <xsl:choose>
>     <xsl:when test="$align = 'left'">
>       <xsl:value-of select="$output"/>
>     </xsl:when>
>     <xsl:when test="$align = 'right'">
>       <xsl:value-of select="$output"/>
>     </xsl:when>
>     <xsl:when test="$align = 'center'">
>       <xsl:value-of select="$output"/>
>     </xsl:when>
>     <xsl:otherwise>INVALID ALIGN</xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>


Current Thread
Keywords