Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Begginer question: template for a data type >Thread Next - Re: Begginer question: template for a data type Re: Begginer question: template for a data typeTo: NULL Date: 4/11/2006 2:45:00 AM Hi, You can do that with a schema aware XSLT 2.0 processor like Saxon 8 SA from Saxonica for instance. See below a working sample. test.xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="person"> <xs:sequence> <xs:element name="name"/> </xs:sequence> </xs:complexType> <xs:element name="father" type="person"/> <xs:element name="mother" type="person"/> <xs:element name="test"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:any/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> test.xml <test> <father> <name>test1</name> </father> <mother> <name>test2</name> </mother> </test> test.xsl <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import-schema schema-location="test.xsd"/> <xsl:template match="/"> <result><xsl:apply-templates/></result> </xsl:template> <!-- Match on any element that has the type person --> <xsl:template match="element(*, person)"> <xsl:copy-of select="."></xsl:copy-of> </xsl:template> </xsl:stylesheet> Result: <?xml version="1.0" encoding="UTF-8"?><result><father><name>test1</name></father><mother><name>test2</name></mother></result> Best Regards, George --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger www.---.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
