Reputation: 97
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', "- :", "")]">
Upvotes: 1
Views: 1191
Reputation: 3
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("00")" name="var:v1"/>
It cleared up the error and let my code compile.
Upvotes: 0
Reputation: 117073
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?
Upvotes: 1