This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
XML -> XML and generate position in attribute problem
- To: <XSL-List at lists dot mulberrytech dot com>
- Subject: [xsl] XML -> XML and generate position in attribute problem
- From: m dot vanrootseler at chello dot nl
- Date: Fri, 15 Jun 2001 17:51:05 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
I’ve got the following prob that’s kept me busy all week. I want to convert
one XML file into another in order to save me from having to write difficult
macros in Word. The original XML looks something like this:
<root>
<line lineID="1">Hello there. World</line>
<line lineID="2">one two, testing</line>
etc. etc. etc.
</root>
What I want to do is wrap a <word>-tag around all words within <line>-tags,
plus automatically generate something like 'wordID="x"' as well. The output
of the sample above should look like this (underscores are spaces in this
example):
<root>
<line lineID="1">
<word wordID="1">Hello</word>_<word wordID="2">there</word>._<word
wordID="3">World</word>
</line>
<line lineID="2">
<word wordID="1">one</word>_<word wordID="2">two</word>,_<word
wordID="3">testing</word>
</line>
</root>
I know I can use <copy> to copy the original tags (with their attributes?)
and probably use position() to work out the wordID (or am I wrong here?) but
I simply can’t figure out how to do this. Plus I also have to look out for
full stops and commas and exclude them from getting into the <word>-tags.
Has anyone got any clues, ideas, tips (or totally-ready-made code) for me?
Much appreciated.
Mick
m.vanrootseler@chello.nl
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list