Guest_imported
New member
- Jan 1, 1970
- 0
Dear all,
Im in a real fix here !!! My problem is that im using xalan parser to parse the xml file and apply xsl for that xml file.
I want to sort and get distinct SegmentID , but my xsl is only sorting is not getting the distinct segmentID.
<?xml version="1.0"?>
<TC>
<Product>
<BasicProperties>
<Properties>
<PropertyId>RNP139</PropertyId>
<SegmentId>SEG000</SegmentId>
<PropertyType>STRM</PropertyType>
<PropertyValue>
<Language Code="EN">XXX</Language>
<Language Code="JA">XXX</Language>
<Language Code="KO">XXX</Language>
</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code="KO">Çѱ¼À̸§1</Language>
<Language Code="EN">Key Text</Language>
<Language Code="JA">Key Text</Language>
</PropertyName>
</Properties>
</BasicProperties>
<TechProperties>
<Properties>
<PropertyId>RNP139</PropertyId>
<SegmentId>SEG001</SegmentId>
<PropertyType>STRM</PropertyType>
<PropertyValue>
<Language Code="EN">XXXhjgf</Language>
<Language Code="KO">XXX</Language>
<Language Code="JA">XXX</Language>
</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code="KO">Çѱ¼À̸§1</Language>
<Language Code="EN">Key Text</Language>
<Language Code="JA">Key Text</Language>
</PropertyName>
</Properties>
<Properties>
<PropertyId>RNP140</PropertyId>
<SegmentId/>
<PropertyType>ENUM</PropertyType>
<PropertyValue ValueType="Value">10</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code="KO">Çѱ¼À̸§2</Language>
<Language Code="EN">Mounting</Language>
<Language Code="JA">Mounting</Language>
</PropertyName>
</Properties>
</TechProperties>
</Product>
</TC>
________________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl:template match="/TC">
<xsl:copy>
<xsl:for-each select="//SegmentId/text()">
<xsl:sort select="."/>
<xsl:variable name="thisSegment" select="."/>
<xsl:if test="count(preceding::SegmentId[text()=$thisSegment]) = 0">
<xsl:element name="SegmentId">
<xsl:element name="Segment">
<p/><xsl:value-of select="$thisSegment"/>
</xsl:element>
<table>
</table>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
__________________________________________________________
result
SEG000
SEG001
_______________________________________________________
requirement
SEG001
I want the sorted and distinct segmentID of only TechProperties and not BasicProperties but my xsl is fetching segmentId for both TechProperties and BasicProperties..
I hope u guys can help me
bye murali
Im in a real fix here !!! My problem is that im using xalan parser to parse the xml file and apply xsl for that xml file.
I want to sort and get distinct SegmentID , but my xsl is only sorting is not getting the distinct segmentID.
<?xml version="1.0"?>
<TC>
<Product>
<BasicProperties>
<Properties>
<PropertyId>RNP139</PropertyId>
<SegmentId>SEG000</SegmentId>
<PropertyType>STRM</PropertyType>
<PropertyValue>
<Language Code="EN">XXX</Language>
<Language Code="JA">XXX</Language>
<Language Code="KO">XXX</Language>
</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code="KO">Çѱ¼À̸§1</Language>
<Language Code="EN">Key Text</Language>
<Language Code="JA">Key Text</Language>
</PropertyName>
</Properties>
</BasicProperties>
<TechProperties>
<Properties>
<PropertyId>RNP139</PropertyId>
<SegmentId>SEG001</SegmentId>
<PropertyType>STRM</PropertyType>
<PropertyValue>
<Language Code="EN">XXXhjgf</Language>
<Language Code="KO">XXX</Language>
<Language Code="JA">XXX</Language>
</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code="KO">Çѱ¼À̸§1</Language>
<Language Code="EN">Key Text</Language>
<Language Code="JA">Key Text</Language>
</PropertyName>
</Properties>
<Properties>
<PropertyId>RNP140</PropertyId>
<SegmentId/>
<PropertyType>ENUM</PropertyType>
<PropertyValue ValueType="Value">10</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code="KO">Çѱ¼À̸§2</Language>
<Language Code="EN">Mounting</Language>
<Language Code="JA">Mounting</Language>
</PropertyName>
</Properties>
</TechProperties>
</Product>
</TC>
________________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl:template match="/TC">
<xsl:copy>
<xsl:for-each select="//SegmentId/text()">
<xsl:sort select="."/>
<xsl:variable name="thisSegment" select="."/>
<xsl:if test="count(preceding::SegmentId[text()=$thisSegment]) = 0">
<xsl:element name="SegmentId">
<xsl:element name="Segment">
<p/><xsl:value-of select="$thisSegment"/>
</xsl:element>
<table>
</table>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
__________________________________________________________
result
SEG000
SEG001
_______________________________________________________
requirement
SEG001
I want the sorted and distinct segmentID of only TechProperties and not BasicProperties but my xsl is fetching segmentId for both TechProperties and BasicProperties..
I hope u guys can help me
bye murali