Joris has given you the classic XSLT 1.0 solution based on recursing over
the sibling axis. Since XML Spy has (at least some) XSLT 2.0 support, you
could also use <xsl:for-each-group group-starting-with>. Your problem is
very similar to the example in the spec
Example: Identifying a Group by its Initial Element
at http://www.w3.org/TR/xslt20/#grouping-examples
except that you need to apply the solution to each of several levels.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Rod Coate [mailto:Rod(_dot_)Coate(_at_)forthvalley(_dot_)ac(_dot_)uk]
Sent: 16 September 2005 10:40
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Convert Word XML to Hierarchical XML using XSLT
Hi,
This is my first post on this list and I need a bit of help
with some XSL.
The tools I am using are word 2000 and Altova XML Spy.
I have a series of word documents that are formatted so that
the import function of XML Spy produces xml as per the
example at the end of this post.
I am trying to process this into a specific xml so that I can
then import it into a database. (Target XML sample after the
Word XML sample)
I need a bit of Guidance as to how to approach this problem.
If I was coding in VBA then I could just count and compare
Heading levels, but how do I do this in XSL?
I hope that this makes sense.
Help!
Rod
-------------------------------------------------------------
Word XML
-------------------------------------------------------------
<Word-Document >
<Heading1>
<p>Heading Level One</p>
</Heading1>
<Heading2>
<p>Heading Level Two</p>
</Heading2>
<Heading3>
<p>Category1</p>
</Heading3>
<Normal>
<p>Category 1 Text</p>
...
</Normal>
<Heading3>
<p>Category2</p>
</Heading3>
<Normal>
<p>Category 2 Text</p>
...
</Normal>
...
<Heading2>
...
</Word-Document>
-------------------------------------------------------------
Target XML
-------------------------------------------------------------
<Heading1>
<Title>Heading Level One</Title>
<Data>
<Heading2>Heading Level 2</Heading2>
<Category1>
Category 1 Text
...
</Category1>
<Category2>
Category 2 Text
...
</Category2>
...
<CategoryN>
Category N Text
...
</CategoryN>
</Data>
<Data>
...
</Data>
</Heading1>
-------------------------------------------------------------
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--