How To Eliminate multi Entries in XSL--Please Help
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 4
- Joined: Sat Jun 11, 2005 2:25 pm
How To Eliminate multi Entries in XSL--Please Help
Post by xp_pratibha »
Hi All ,
I am a newbie to XSL . I am not sure where I am going wrong ?
My XML Data is like this and it has multiple duplicate entries:
<Employees>
<Accountant>
<Employee name="varsha">
<Empdetails id="100" age="23"/>
<comment/>
<Empaddress addr="sdlklklk"/>
</Employee>
</Accountant>
</Employees>
The only thing that is unique is "id".I need to eliminate the duplicate entries based on this...
Here goes my XSL :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<?xml-stylesheet type="text/xsl" href="xslt_example_param.xsl"?>
<xsl:output method="text" />
<xsl:template match="/Employees/Accountant">
<xsl:for-each select="Employee/Empdetails[not(@id= preceding-sibling::FirewallRule/@id)]">
<xsl:value-of select="@id"/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I couldn't find what is wrong with my XSL ...Can anyone please help me to solve this or any alternate solution.
Thanks,
Pratibha

I am a newbie to XSL . I am not sure where I am going wrong ?
My XML Data is like this and it has multiple duplicate entries:
<Employees>
<Accountant>
<Employee name="varsha">
<Empdetails id="100" age="23"/>
<comment/>
<Empaddress addr="sdlklklk"/>
</Employee>
</Accountant>
</Employees>
The only thing that is unique is "id".I need to eliminate the duplicate entries based on this...
Here goes my XSL :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<?xml-stylesheet type="text/xsl" href="xslt_example_param.xsl"?>
<xsl:output method="text" />
<xsl:template match="/Employees/Accountant">
<xsl:for-each select="Employee/Empdetails[not(@id= preceding-sibling::FirewallRule/@id)]">
<xsl:value-of select="@id"/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I couldn't find what is wrong with my XSL ...Can anyone please help me to solve this or any alternate solution.
Thanks,
Pratibha

-
- Posts: 4
- Joined: Sat Jun 11, 2005 2:25 pm
Post by xp_pratibha »
Hi one correction :here is the XSL I used..Please help me..Thanks.
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<?xml-stylesheet type="text/xsl" href="xslt_example_param.xsl"?>
<xsl:output method="text" />
<xsl:template match="/Employees/Accountant">
<xsl:for-each select="Employee/Empdetails[not(@id= preceding-sibling::Employee/Empdetails/@id)]">
<xsl:value-of select="@id"/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
(not tested)
Hope that helps,
George
The problem seems to be the fact that you are looking for preceding siblings of the Empdetails node, and that has no Employee sibling, you shold go one step up to the parent of Empdetails and there look for preceding siblings:Employees/Accountant">
<xsl:for-each select="Employee/Empdetails[not(@id= preceding-sibling::Employee/Empdetails/@id)]
Code: Select all
Employees/Accountant">
<xsl:for-each select="Employee/Empdetails[not(@id= ../preceding-sibling::Employee/Empdetails/@id)]
Hope that helps,
George
-
- Posts: 4
- Joined: Sat Jun 11, 2005 2:25 pm
Post by xp_pratibha »
Thanks George ...
But Still its not working even after in-corporating ur changes.
I need one clarification ..Can I use preceding-siblings on attribute axis.
I read if I use preceding-sibling on attribute axis it will be empty. Is this apply to my case.
Is there any alternative to perform this ??
Thanks again George.
Thanks,
Pratibha
But Still its not working even after in-corporating ur changes.
I need one clarification ..Can I use preceding-siblings on attribute axis.
I read if I use preceding-sibling on attribute axis it will be empty. Is this apply to my case.
Is there any alternative to perform this ??
Thanks again George.
Thanks,
Pratibha
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Pratibha,
Here it is a funtional sample:
gives as output:
Best Regards,
George
Here it is a funtional sample:
Code: Select all
<Employees>
<Accountant>
<Employee name="varsha">
<Empdetails id="100" age="23"/>
<comment/>
<Empaddress addr="sdlklklk"/>
</Employee>
<Employee name="varsha">
<Empdetails id="101" age="23"/>
<comment/>
<Empaddress addr="sdlklklk"/>
</Employee>
<Employee name="varsha">
<Empdetails id="100" age="23"/>
<comment/>
<Empaddress addr="sdlklklk"/>
</Employee>
</Accountant>
</Employees>
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<?xml-stylesheet type="text/xsl" href="xslt_example_param.xsl"?>
<xsl:output method="text"/>
<xsl:template match="/Employees/Accountant">
<xsl:for-each select="Employee/Empdetails[not(@id= ../preceding-sibling::Employee/Empdetails/@id)]">
<xsl:value-of select="@id"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Code: Select all
100
101
George
-
- Posts: 4
- Joined: Sat Jun 11, 2005 2:25 pm
Post by xp_pratibha »
Hi George,
Thank you So Much
It helped me a lot.
Thanks again.
Regards,
X.P.Pratibha
Thank you So Much

It helped me a lot.
Thanks again.
Regards,
X.P.Pratibha
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service