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

Rename attributes and nodes maybe using variables

Subject: Rename attributes and nodes maybe using variables
From: "Kai Lienemann" <Xenum81@xxxxxx>
Date: Wed, 9 Jul 2003 01:05:31 +0200
xslt rename attribute
Hello again,

I'm not really fit in writing stylesheets but I need two for my programme!
The one must form the XML-File so, my plugin can work with them, and the
second has to undo the transformation of the first.

Lets describe the first:

In the XML-File are nodes with the name "IMAGE" and the first attribute
should reflect the name and the second attribute the location of the image.
The name of these attribute is not fix, but in the result the furst
attribute should be named "name" and the second "url" and the old name
should be stored in attribute so in the second transformation these
attributes get there old name.
In other parts of the File are Nodes with the node-name REGIONSET and the
attribute "image". But in this attribute "image" I need not the name, but
the location where I can find the file.
So this attribute has to be replaced with the url of the node IMAGE where
the value of the "image" and "name" are the same. (Maybe saving the url of
the images in variables with the name of the image should be helpful) In the
second stylesheet I want to undo this replacing and so the original name
should be stored in the attribute "oldvalue". There can be more than one
IMAGE-node and in more than one  REGIONSET-nodes can be used the same image.
But at the first step of the transformation nodes like PHOTO, BILDCHEN, IMG,
FOTO should be renamed with the name IMAGE and the old name should be stored
in the attribute "oldname" (I asked this some mails before but in this case
it is more difficult for me so I can't use it). All other nodes and
attributes should be copied and not changed!

Input-Example:

<Collection>
    <PHOTOS>
        <FOTO label="test1" place="/vol/pictures/test1.jpg"/>
        <PHOTO name="test2" url="/vol/pictures/test2.jpg"/>
        <BILDCHEN name="test3" url="/vol/pictures/test3.jpg"/>
        <IMG name="test4" url="/vol/pictures/test4.jpg"/>
        <IMAGE name="test5" url="/vol/pictures/test5.jpg"/>
    </PHOTOS>
    <REGIONSET image="test2">
        <RECT x="10" y="20" z="50" h="70">
        Cup
        </RECT>
        <RECT x="20" y="30" z="60" h="20">
        Sword
        </RECT>
    </REGIONSET>
</COLLECTION>


Output Example:

<Collection>
    <PHOTOS>
        <IMAGE name="test1" url="/vol/pictures/test1.jpg" oldname="FOTO"
old_atr_name="label" old _atr_url="location"/>
        <IMAGE  name="test2" url="/vol/pictures/test2.jpg"oldname="PHOTO"/>
        <IMAGE  name="test3" url="/vol/pictures/test3.jpg"
oldname="BILDCHEN"/>
        <IMAGE  name="test4" url="/vol/pictures/test4.jpg" oldname="IMG"/>
        <IMAGE  name="test5" url="/vol/pictures/test5.jpg"/>
    </PHOTOS>
    <REGIONSET image="/vol/pictures/test2.jpg" oldvalue="test2">
        <RECT x="10" y="20" z="50" h="70">
        Cup
        </RECT>
        <RECT x="20" y="30" z="60" h="20">
        Sword
        </RECT>
    </REGIONSET>
</COLLECTION>


The second stylesheet:

The second should undo all, the first stylesheet did. So rename ever changed
node and attribute with the original stored name and value and delete the
new created attributes.

I think it is really hard to write these stylesheets and I don't know, if it
is possible! So would be nice if anybody could help me or give some hints so
I can solve this problem. I dont believe I could manage to solve this
problem alone so help would be very welcome!!!!



 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.