Subject: Very Basic Generic Filtering Question From: Arvind Bassi <arvind_bassi@xxxxxxxxxxx> Date: Thu, 10 Jun 2004 23:06:28 +0100 (BST) |
I haven't done XSLT for quite some time, and its amazing how much l have forgotten. I have a very simple problem of having to filter out a specific xml element. In the example below, it is <Header>, but it should be able to be passed down as a parameter. From memory, l need to use the name function and test it against the current node, but l have tried doing this but to no avail. How can the following xml document be filtered in a generic manner? <?xml version="1.0" encoding="UTF-8"?> <AddressBook> <Header> <ElementOne id="1">hello</ElementOne> <ElementTwo id="2"> why not</ElementTwo> </Header> <People value="3"> <Name number="3"> <FirstName> Simon</FirstName> <LastName>Says</LastName> </Name> <Name number="3"> <FirstName> Simon</FirstName> <LastName>Says</LastName> </Name> <Name number="3"> <FirstName> Simon</FirstName> <LastName>Says</LastName> </Name> <Name number="3"> <FirstName> Simon</FirstName> <LastName>Says</LastName> </Name> </People> <Mary> <Had a="little"> lamb</Had> </Mary> </AddressBook> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" version="1.0"/> <xsl:param name="filterElement">Header</xsl:param> <xsl:template match="/"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="???????"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="????????"/> </xsl:stylesheet> Any help that can be provided would be gratefully appreciated. Thanks. Arvind. ___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Basic string parsing/spli, Passin, Tom | Thread | RE: [xsl] Very Basic Generic Filter, M. David Peterson |
RE: [xsl] Basic string parsing/spli, Passin, Tom | Date | RE: [xsl] Very Basic Generic Filter, M. David Peterson |
Month |