Dijkgraaf

msg:4480382 | 1:34 am on Jul 31, 2012 (gmt 0) |
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:java="http://xml.apache.org/xslt/java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="java" version="1.0"> <xsl:output media-type="text/xml" method="xml"/> <!-- Filters refdoc based on condition and data --> <xsl:template match="/"> <Rowsets> <xsl:for-each select="/Rowsets/Rowset"> <Rowset> <xsl:copy-of select="Columns"/> <xsl:for-each select="Row[CategoryID = '1'] | Row[CategoryID = '2']"> <xsl:copy-of select="."/> </xsl:for-each> </Rowset> </xsl:for-each> </Rowsets> </xsl:template> </xsl:stylesheet>
|
sotu

msg:4480701 | 8:58 pm on Jul 31, 2012 (gmt 0) |
Well, unfortunately this XSLT wont serve the purpose. From, original XML, I need all <Row> where CategoryID is 2 only. But this category ID "2" should be converted to 1 in the transform XML. Your XSLT gives me <Row> with category ID "1" or "2" which is not my requirement.
|
Dijkgraaf

msg:4480717 | 10:03 pm on Jul 31, 2012 (gmt 0) |
Ok, sorry I misread your requirements. Rather than using <xsl:copy-of select="."/> you need to select the individual elements and write your own Category ID e.g. <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0"> <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" /> <xsl:template match="/"> <xsl:apply-templates select="/Rowsets" /> </xsl:template> <xsl:template match="/Rowsets"> <Rowsets> <Rowset> <xsl:for-each select="Rowset/Row"> <xsl:if test="CategoryID = '2'"> <Row> <CategoryID> <xsl:text>1</xsl:text> </CategoryID> <Name> <xsl:value-of select="Name/text()" /> </Name> <City> <xsl:value-of select="City/text()" /> </City> <Phone> <xsl:value-of select="Phone/text()" /> </Phone> </Row> </xsl:if> </xsl:for-each> </Rowset> </Rowsets> </xsl:template> </xsl:stylesheet>
|
|