0

Given XML:

<issueDate day="30" month="09" year="2015"/>

I wanted to build a string that output: 2015-09-30

This worked:

<xsl:variable name="issueDate" as="xs:string">
    <xsl:value-of select="concat(//issueDate/@year,'-',//issueDate/@month,'-',//issueDate/@day)" />
</xsl:variable>

...

<xsl:value-of select="$issueDate"/>

But this threw an error (expected EOF, found ','):

<xsl:value-of select="//issueDate/@year,//issueDate/@month,//issueDate/@day" separator="-" />

What is the syntax to select more than one value using separator attribute?

Caroline
  • 167
  • 1
  • 11
  • 1
    Are you sure you are using an XSLT 2.0 processor like Saxon 9, XmlPrime or AltovaXML? The `separator` attribute of `xsl:value-of` and the sequence operator `,` are part of XSLT/XPath 2.0 and are not supported with XSLT 1.0 processors. – Martin Honnen Jun 25 '16 at 09:29
  • I'm using Antenna House, it's possible it's 1.0, thank you. – Caroline Jun 26 '16 at 05:13
  • If you have a version that works, why are you wasting your time asking question about an alternative that does not work? – Phil Blackburn Jun 26 '16 at 23:17
  • 1
    I wanted to know how to select more than one attribute at a time without using concat. I apologize for wasting anyone's time, I don't consider it a waste of my time because I learned something. – Caroline Jun 27 '16 at 14:39

1 Answers1

0

If you can use XPath-2.0/XSLT-2.0, you could use string-join:

<xsl:for-each select="//issueDate">
  <xsl:value-of select="string-join( (@year, @month, @day), '-')" />
  <xsl:text>&#10;</xsl:text>   <!-- just for pretty output -->
</xsl:for-each>
zx485
  • 28,498
  • 28
  • 50
  • 59