Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
XML
How filter data from XML to XML
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Dimitre Novatchev, post: 770215"] This transformation: <xsl:stylesheet version="1.0" xmlns:xsl="[URL]http://www.w3.org/1999/XSL/Transform[/URL]"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="ROOT"> <xsl:copy> <xsl:apply-templates select="PRODUCTS-LIST"/> </xsl:copy> </xsl:template> <xsl:template match="PRODUCTS-LIST"> <xsl:copy> <xsl:apply-templates select="CAT[@ID = /*/*/*/RULE/CAT/@ID]"/> </xsl:copy> </xsl:template> <xsl:template match="CAT"> <xsl:copy-of select= "PROD[@ID = /*/*/*/RULE/CAT [@ID = current()/@ID]/PRO/@ID]"/> </xsl:template> </xsl:stylesheet> when applied on your source.xml: <ROOT> <PAGE NAME="homepage" URL="HP.html"> <RULES> <RULE> <CAT ID="1"> <PRO ID="3"></PRO> <PRO ID="6"></PRO> </CAT> <CAT ID="3"> <PRO ID="2"></PRO> <PRO ID="10"></PRO> </CAT> </RULE> </RULES> </PAGE> <PRODUCTS-LIST> <CAT ID="1"> <PROD ID="12"> <NAME>Prod. name</NAME> <DESC><![CDATA[ Html desc ]]></DESC> </PROD> <PROD ID="6"> <NAME>Prod. name</NAME> <DESC><![CDATA[ Html desc ]]></DESC> </PROD> <PROD ID="3"> <NAME>Prod. name</NAME> <DESC><![CDATA[ Html desc ]]></DESC> </PROD> </CAT> <CAT ID="2"> <PROD ID="7"> <NAME>Prod. name</NAME> <DESC><![CDATA[ Html desc ]]></DESC> </PROD> </CAT> <CAT ID="3"> <PROD ID="10"> <NAME>Prod. name</NAME> <DESC><![CDATA[ Html desc ]]></DESC> </PROD> <PROD ID="1"> <NAME>Prod. name</NAME> <DESC><![CDATA[ Html desc ]]></DESC> </PROD> <PROD ID="2"> <NAME>Prod. name</NAME> <DESC><![CDATA[ Html desc ]]></DESC> </PROD> </CAT> </PRODUCTS-LIST> </ROOT> produces the wanted result: <ROOT> <PRODUCTS-LIST> <PROD ID="6"> <NAME>Prod. name</NAME> <DESC> Html desc </DESC> </PROD> <PROD ID="3"> <NAME>Prod. name</NAME> <DESC> Html desc </DESC> </PROD> <PROD ID="10"> <NAME>Prod. name</NAME> <DESC> Html desc </DESC> </PROD> <PROD ID="2"> <NAME>Prod. name</NAME> <DESC> Html desc </DESC> </PROD> </PRODUCTS-LIST> </ROOT> ===== Cheers, Dimitre Novatchev. [URL]http://fxsl.sourceforge.net/[/URL] -- the home of FXSL [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
XML
How filter data from XML to XML
Top