You received several answers to your first enquiry on this subject. If
you didn't understand the answers, please explain where you are having
difficulty. You can't expect us to help you again without knowing why
the previous help was unhelpful!
Michael Kay
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Kai Lienemann
Sent: 09 July 2003 00:06
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Rename attributes and nodes maybe using variables
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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list