Subject: Re: [xsl] How to map XML to XML according to element values From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 26 Nov 2001 15:43:02 -0500 |
<xsl:template match="Employee"> <xsl:copy> <xsl:copy-of select="EmpNo | Name"/> <!-- this time we copy the EmpNo and Name children, but leave out the Dept for the obvious reasons. --> </xsl:copy> </xsl:template>
Cheers, Wendell
I have the following XML,
<Company> <Departments> <Department> <DeptCode>D1</DeptCode> <Name>Engineering</Id> </Department> <Department> <DeptCode>D2</DeptCode> <Name>Custom Support</Name> </Department> </Departments> <Employees> <Employee> <EmpNo>E1</EmpNo> <Name>John Smith</Name> <Dept>D1</Dept> </Employee> <Employee> <EmpNo>E2</EmpNo> <Name>Mary Johnson</Name> <Dept>D2</Dept> </Employee> <Employee> <EmpNo>E3</EmpNo> <Name>Tom Baker</Name> <Dept>D1</Dept> </Employee> </Employees> </Company>
I would like to transform it into another XML, by matching <DeptCode> in <Department> to <Dept> in <Employee>. The output XML should look like:
<Company> <Departments> <Department> <DeptCode>D1</DeptCode> <Name>Engineering</Id> <Employee> <EmpNo>E1</EmpNo> <Name>John Smith</Name> </Employee> <Employee> <EmpNo>E3</EmpNo> <Name>Tom Baker</Name> </Employee> </Department> <Department> <DeptCode>D2</DeptCode> <Name>Custom Support</Name> <Employee> <EmpNo>E2</EmpNo> <Name>Mary Johnson</Name> </Employee> </Department> </Departments> </Company>
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to map XML to XML accordi, Roy_Lu | Thread | Re: [xsl] How to map XML to XML acc, Jörg Heinicke |
[xsl] Creating a container?, Michael Müller-Hille | Date | Re: [xsl] How to map XML to XML acc, Jörg Heinicke |
Month |