Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL problem

Status
Not open for further replies.

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=&quot;1.0&quot;?>
<TC>
<Product>

<BasicProperties>
<Properties>
<PropertyId>RNP139</PropertyId>
<SegmentId>SEG000</SegmentId>
<PropertyType>STRM</PropertyType>
<PropertyValue>
<Language Code=&quot;EN&quot;>XXX</Language>
<Language Code=&quot;JA&quot;>XXX</Language>
<Language Code=&quot;KO&quot;>XXX</Language>
</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code=&quot;KO&quot;>Çѱ¼À̸§1</Language>
<Language Code=&quot;EN&quot;>Key Text</Language>
<Language Code=&quot;JA&quot;>Key Text</Language>
</PropertyName>
</Properties>

</BasicProperties>
<TechProperties>
<Properties>
<PropertyId>RNP139</PropertyId>
<SegmentId>SEG001</SegmentId>
<PropertyType>STRM</PropertyType>
<PropertyValue>
<Language Code=&quot;EN&quot;>XXXhjgf</Language>
<Language Code=&quot;KO&quot;>XXX</Language>
<Language Code=&quot;JA&quot;>XXX</Language>
</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code=&quot;KO&quot;>Çѱ¼À̸§1</Language>
<Language Code=&quot;EN&quot;>Key Text</Language>
<Language Code=&quot;JA&quot;>Key Text</Language>
</PropertyName>
</Properties>
<Properties>
<PropertyId>RNP140</PropertyId>
<SegmentId/>
<PropertyType>ENUM</PropertyType>
<PropertyValue ValueType=&quot;Value&quot;>10</PropertyValue>
<Group/>
<Grade/>
<PropertyName>
<Language Code=&quot;KO&quot;>Çѱ¼À̸§2</Language>
<Language Code=&quot;EN&quot;>Mounting</Language>
<Language Code=&quot;JA&quot;>Mounting</Language>
</PropertyName>
</Properties>

</TechProperties>

</Product>
</TC>

________________________________________________________

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:template match=&quot;/TC&quot;>
<xsl:copy>
<xsl:for-each select=&quot;//SegmentId/text()&quot;>
<xsl:sort select=&quot;.&quot;/>
<xsl:variable name=&quot;thisSegment&quot; select=&quot;.&quot;/>

<xsl:if test=&quot;count(preceding::SegmentId[text()=$thisSegment]) = 0&quot;>
<xsl:element name=&quot;SegmentId&quot;>
<xsl:element name=&quot;Segment&quot;>

<p/><xsl:value-of select=&quot;$thisSegment&quot;/>
</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
 
hi,
I read your XSL Template but I don't really can't understand your match criteria. can you be more specific? what do you want to select at all? which html-code (and not output) are you expecting to become?

by the way, the XSL could be better written.


Regards,

El Ekeko
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top