INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

XSLT Code for complex XML document

XSLT Code for complex XML document

(OP)
I have an xml document and I want to transform it to add an extra node element depending on some condition. Example given in the attachment. I want to write an .xsl program for the requirement "If a does not have , use the of the immediate one level up". Basically I want to add node if does not have one, and that value should be of the person one above it in my case. The values for

Tommy Trojans - Engineering
Ronald Jackson - Engineering
Justin Jones - Marketing

Can anyone please advice on how to do this??

Thanks,
Ace

RE: XSLT Code for complex XML document

(OP)
I am a new user so I did not know about the attachment problem.
The code is below


<?xml version="1.0" encoding="UTF-8"?>
-<Data> -<People> -<Person id="1"> <name>John Taylor</name> <title>Manager</title> <department>Engineering</department> -<reports> -<report id="2"> <name>Tommy Trojans</name> <title>Engineer</title> </report> -<report id="3"> <name>Mike Lee</name> <title>Designer</title> <department>UI/UX</department> </report> -<report id="4"> <name>Ronald Jackson</name> <title>Engineer</title> </report> </reports> </Person> -<Person id="16"> <name>Maria Sanchez</name> <title>CEO</title> </Person> -<Person id="10"> <name>Matt Jones</name> <title>Director</title> <department>Marketing</department> -<reports> -<report id="9"> <name>Justin Jones</name> <title>Manager</title> </report> </reports> </Person> </People> -<Departments> -<Department> <name>Engineering</name> <rate max="100" min="10" type="hourly"/> <rate max="12000" min="1000" type="monthly"/> </Department> -<Department> <name>UI/UX</name> <rate max="50" min="12" type="hourly"/> <rate max="9000" min="1500" type="monthly"/> <rate max="2000" min="300" type="weekly"/> <rate max="100000" min="25000" type="yearly"/> </Department> -<Department> <name>Marketing</name> <rate max="90000" min="30000" type="yearly"/> <rate max="5000" min="500" type="weekly"/> </Department> </Departments> </Data>

Sorry for the in convenience.

RE: XSLT Code for complex XML document

Ok, I have cleaned up your input file (using the 'code' markup). Please be a bit more specific about your desired output.

CODE --> XML

<?xml version="1.0" encoding="UTF-8"?>
<Data>
    <People>
        <Person id="1">
            <name>John Taylor</name>
            <title>Manager</title>
            <department>Engineering</department>
            <reports>
                <report id="2">
                    <name>Tommy Trojans</name>
                    <title>Engineer</title>
                </report>
                <report id="3">
                    <name>Mike Lee</name>
                    <title>Designer</title>
                    <department>UI/UX</department>
                </report>
                <report id="4">
                    <name>Ronald Jackson</name>
                    <title>Engineer</title>
                </report>
            </reports>
        </Person>
        <Person id="16">
            <name>Maria Sanchez</name>
            <title>CEO</title>
        </Person>
        <Person id="10">
            <name>Matt Jones</name>
            <title>Director</title>
            <department>Marketing</department>
            <reports>
                <report id="9">
                    <name>Justin Jones</name>
                    <title>Manager</title>
                </report>
            </reports>
        </Person>
    </People>
    <Departments>
        <Department>
            <name>Engineering</name>
            <rate max="100" min="10" type="hourly"/>
            <rate max="12000" min="1000" type="monthly"/>
        </Department>
        <Department>
            <name>UI/UX</name>
            <rate max="50" min="12" type="hourly"/>
            <rate max="9000" min="1500" type="monthly"/>
            <rate max="2000" min="300" type="weekly"/>
            <rate max="100000" min="25000" type="yearly"/>
        </Department>
        <Department>
            <name>Marketing</name>
            <rate max="90000" min="30000" type="yearly"/>
            <rate max="5000" min="500" type="weekly"/>
        </Department>
    </Departments>
</Data> 

Tom Morrison
Hill Country Software

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close