[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to map XML to XML according to element values

Subject: Re: How to map XML to XML according to element values
From: Jörg Heinicke <joerg.heinicke@xxxxxx>
Date: Mon, 26 Nov 2001 21:50:11 +0100
map.xml
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:apply-templates select="node()[name() != 'Employees']"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Department">
        <xsl:copy>
            <xsl:apply-templates select="node()"/>
            <xsl:apply-templates select="/Company/Employees/Employee[Dept =
current()/DeptCode]"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Employee">
        <xsl:copy>
            <xsl:apply-templates select="node()[name() != 'Dept']"/>
        </xsl:copy>
    </xsl:template>

Regards,

Joerg

----- Original Message -----
From: <Roy_Lu@xxxxxxxxxxxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, November 26, 2001 7:25 PM
Subject:  How to map XML to XML according to element values


> Hi, I am new to the list and I have searched the archive but couldn't find
> an answer.
>
> 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>
>
> Can someone give me an advice? Thanks a lot.
>
> Roy
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.