• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Question about pulling distinct using XSL

 
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All ,
I have this XML


I want to pull the distinct value of just yyyy-mm using XSL/XPath .
The existing code is already in XSL so using XSL is what I got to go ahead and use .
I need some XPath which can help me identify all the distinct yyyy-mm in this document.
Thanks
Dhiren
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>I need some XPath which can help me identify all the distinct yyyy-mm in this document.

I don't think there would be any straight forward approach for this. You can achieve the same by manipulating each field.

<xsl:for-each select="response/info/records/field">
<xsl:variable name="test" select="."/>
<xsl:variable name="year" select="substring($test,5,1)"/>
<xsl:variable name="month" select="substring($test,8,1)"/>
//check here that value of year and month are "-". If these variables does not contains "-" then it is not is yyyy-mm format.
</xsl:for-each>

hope this would help.

regards,
Ranjan
 
Dhiren Joshi
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to hold on to each distinct variable of yyyy-mm after the </xsl:for-each>
What would need to be done for that .

<xsl:for-each select="response/info/records/field">
<xsl:variable name="test" select="."/>
<xsl:variable name="year" select="substring($test,5,1)"/>
<xsl:variable name="month" select="substring($test,8,1)"/>
//check here that value of year and month are "-". If these variables does not contains "-" then it is not is yyyy-mm format.
</xsl:for-each>

Thanks
Dhiren
 
You don't like waffles? Well, do you like this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic