Re: [xsl] How would I create this derived field in XML from different XML fields

Subject: Re: [xsl] How would I create this derived field in XML from different XML fields
From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 29 Oct 2014 20:09:37 -0000
On 29.10.2014 20:44, Catherine Wilbur cwilbur@xxxxxxxxxxx wrote:
*_Below in my xsl code am getting a syntax error on the following line_*

<xsl:variable name="CurrDateTimeValue"
select="format-dateTime(current-dateTime(),"[Y0001][M01][D01][H01][m01]")"/>

Use single quotes to delimit the picture string when you used double quotes for the select attribute.


select="format-dateTime(current-dateTime(),'[Y0001][M01][D01][H01][m01]')"


Element type "xsl:variable" must be followed by either attribute specifications, ">" or "/>".


b& b&


<xsl:choose> <xsl:when test="contains-case-insensitive($InvoicePOLineOwner, 'Law')"> <xsl:variable name="POOwnerType" select="W'" /> </xsl:when> <xsl:otherwise> <xsl:variable name="POOwnerType" select="L" /> </xsl:otherwise> </xsl:choose>

This wonbt work because
a) the scope of the variable declarations will be limited to the xsl:when and xsl:otherwise branches, respectively. There wonbt be a variable $POOwnerType outside of them.
b) the strings 'W' and 'L' arenbt properly delimited
c) there is no function contains-case-insensitive()


Use this for the variable declaration:

<xsl:variable name="POOwnerType" as="xs:string">
  <xsl:choose>
    <xsl:when test="matches($InvoicePOLineOwner, 'Law', 'i')">
      <xsl:sequence select="'W'"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:sequence select="'L'"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

or shorter

<xsl:variable name="POOwnerType" as="xs:string"
  select="if (matches($InvoicePOLineOwner, 'Law', 'i'))
          then 'W' else 'L'"/>

If you use an editor such as oXygen it will make you aware of all these issues, thanks to the embedded Saxon processor.

Because the XML input lacks essential parts, I was unable to validate the remainder of your XSLTbs functionality. If you want me to check it, you may send me a complete input off-list. Of course you might ask the next question on the list when you encounter the next hurdle. Keep on exploring XSLT 2, itbs totally worth it!

Gerrit

Current Thread