1

I am trying to filter xml data using xslt version 2.0

Here some example xml data (my data follow this schema)

<Messages>
  <Message time="2015-08-06 22:00:11" type="Success">A</Message>
  <Message time="2015-08-07 22:00:07" type="Success">B</Message>
  <Message time="2015-08-07 22:00:15" type="Success">C</Message>
</Messages>

I tried using this solution XPath query filtering by date which suggested I use translate to convert the dates into number but I am getting an error message (in Visual Studio) that says

Missing required whitespace

Here is my code:

<xsl:for-each select="Messages/Message[translate(@time, "- :", "") > translate('2015-08-06 22:00:11', "- :", "")]">
Community
  • 1
  • 1
dikokob
  • 85
  • 3
  • 12

2 Answers2

1

You are getting an error because you are trying to use double quotes inside double quotes. Try changing:

<xsl:for-each select="Messages/Message[translate(@time, "- :", "") > translate('2015-08-06 22:00:11', "- :", "")]">

to:

<xsl:for-each select="Messages/Message[translate(@time, '- :', '') > translate('2015-08-06 22:00:10', '- :', '')]">

P.S. If you're using XSLT 2.0, why aren't you comparing the values as date-times?

michael.hor257k
  • 113,275
  • 6
  • 33
  • 51
  • How do you compare the values as data-times in XSLT 2.0, do you have a link? – Dan Dec 05 '15 at 16:36
  • 1
    @Dan See: http://www.w3.org/TR/xpath20/#id-value-comparisons and also http://www.w3.org/TR/xpath-functions/#func-dateTime-equal and following. If this doesn't answer your question, post it independently of this one. – michael.hor257k Dec 05 '15 at 17:35
0

I ran into a similar issue trying to use the following:

 <xsl:variable select="userCSharp:StringConcat("00")" name="var:v1"/>

It threw the "Missing required whitespace" error. For me the following solution worked:

 <xsl:variable select="userCSharp:StringConcat(&quot;00&quot;)" name="var:v1"/>

It cleared up the error and let my code compile.

TBAN65
  • 3
  • 3