954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

distinct values using xpath

1. I want to take unique district values from the below xml. How to do it in XPATH?
2. I want to take unique taluk values and district name="xyz". what is the xpath expression?

XML structure:

<?xml version="1.0" encoding="utf-8"?>
1001Mel Sittamur001_001_001.jpg07-09-2008VillupuramSenjiJain Temple, Sri ParsvanadhaTowerYet to Provide the data 2001Mel Sittamur001_001_002.jpg07-09-2008VillupuramSenjiJain Temple, Sri ParsvanadhaTower detailYet to Provide the data 3001Mel Sittamur001_001_003.jpg07-09-2008xyzSenjiJain Temple, Sri ParsvanadhaSaraswatiYet to Provide the data

.....

iswariak
Newbie Poster
4 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

I'm not sure if I have understood your question correctly. Try the below:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:output method="xml"/>

<xsl:template match="imageData">
<xsl:for-each-group select="row" group-by="district">
<p><xsl:value-of select="current-grouping-key()"/></p>
<xsl:for-each-group select="current-group()" group-by="taluk">
<p><xsl:value-of select="current-grouping-key()"/></p>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>

If this is not what you expect, then post the expected output here.

mrame
Light Poster
37 posts since Feb 2011
Reputation Points: 10
Solved Threads: 4
 

I want to access the result using xpath and xml dom.. Just i need the xpath expressions to retrieve the results.

thanks.

I'm not sure if I have understood your question correctly. Try the below:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:output method="xml"/>

<xsl:template match="imageData">
<xsl:for-each-group select="row" group-by="district">
<p><xsl:value-of select="current-grouping-key()"/></p>
<xsl:for-each-group select="current-group()" group-by="taluk">
<p><xsl:value-of select="current-grouping-key()"/></p>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>

If this is not what you expect, then post the expected output here.

iswariak
Newbie Poster
4 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Below xpath function would help:

<xsl:value-of select="distinct-values(//row/district)"/>

Just use the "distinct-values(//row/district)"

mrame
Light Poster
37 posts since Feb 2011
Reputation Points: 10
Solved Threads: 4
 

Below xpath function would help:

<xsl:value-of select="distinct-values(//row/district)"/>

Just use the "distinct-values(//row/district)"

thanks for the expression.

I want to take unique taluk values and district name="xyz". what is the xpath expression?

iswariak
Newbie Poster
4 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Unique taluk values:

distinct-values(//row/taluk)


I still dont understand your question. Okay tell what would be the output from your question (I want to take unique taluk values and district name="xyz"). is it Senji, or ...

mrame
Light Poster
37 posts since Feb 2011
Reputation Points: 10
Solved Threads: 4
 

Unique taluk values:

distinct-values(//row/taluk)

I still dont understand your question. Okay tell what would be the output from your question (I want to take unique taluk values and district name="xyz"). is it Senji, or ...

distinct-values(//row/taluk) will give all distinct taluk values irrespective of the district name.

But I want,

When a user selects a district, I have to query the xml to get the distinct taluk values of the selected district.

iswariak
Newbie Poster
4 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Would the below work:

<xsl:value-of select="distinct-values(//row/taluk[preceding-sibling::district[.='xyz'][1]])"/>
mrame
Light Poster
37 posts since Feb 2011
Reputation Points: 10
Solved Threads: 4
 

Ask Jeeves a question and Jeeves will answer it.
Britain's leading question-and-answer
service is as ready
for your questions as ever.Try it now.
http://ask.co.uk

zaibi403
Newbie Poster
1 post since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: