Ok,
here is a simplified version of the xml:
<?xml version="1.0" encoding="utf-8"?>
<document>
<body>
<paragraph>
<text>This is some text that is not in a list.</text>
</paragraph>
<paragraph>
<paraProperties>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
0
</ilvl>
<numId>
1
</numId>
</numPr>
</paraProperties>
<text>This is the first point at the highest level 0</text>
</paragraph>
<paragraph>
<paraProperties>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
1
</ilvl>
<numId>
1
</numId>
</numPr>
</paraProperties>
<text>This is the first point at a nested level 1</text>
</paragraph>
<paragraph>
<paraProperties>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
1
</ilvl>
<numId>
1
</numId>
</numPr>
</paraProperties>
<t>This is the second point at a nested level 1</t>
</paragraph>
<paragraph>
<paraProperteis>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
0
</ilvl>
<numId>
1
</numId>
</numPr>
</paraProperties>
<text>This is the second point at highest level 0</text>
</paragraph>
<paragraph>
<text>This is some more text that is not in a list, and the list has now ended.</text>
</paragraph>
<paragraph>
<text>Here is some more text in another paragraph. The paragraphs can be put anywhere really.</text>
</paragraph>
<paragraph>
<paraProperties>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
0
</ilvl>
<numId>
2
</numId>
</numPr>
</paraProperties>
<text>This is the first point of list number 2 at the highest level 0</text>
</paragraph>
<paragraph>
<paraProperties>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
0
</ilvl>
<numId>
2
</numId>
</numPr>
</paraProperties>
<text>This is the 2nd point of list number 2 at the highest level 0</text>
</paragraph>
<paragraph>
<paraProperties>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
0
</ilvl>
<numId>
2
</numId>
</numPr>
</paraProperties>
<text>This is the 3rd point of list number 2 at the highest level 0</text>
</paragraph>
<paragraph>
<paraProperties>
<paraStyle>
ListParagraph
</paraStyle>
<numPr>
<ilvl>
1
</ilvl>
<numId>
2
</numId>
</numPr>
</paraProperties>
<text>This is a nested point of list number 2 at the level 1</text>
</paragraph>
</body>
</document>
It should output something like this:
This is some text that is not in a list.
-
- This is the first point at the highest level 0
-
- This is the first point at a nested level 1
- This is the second point at a nested level 1
- This is the second point at highest level 0
This is some more text that is not in a list, and the list has now ended.
Here is some more text in another paragraph. The paragraphs can be put anywhere really.
-
- This is the first point of list number 2 at the highest level 0
- This is the 2nd point of list number 2 at the highest level 0
- This is the 3rd point of list number 2 at the highest level 0
-
- This is a nested point of list number 2 at the level 1
End of out put.
Now there are a couple of things I need to point out:
1) The lists are differentiated by their numId, so the 1st had the numId of 1, and the 2nd list had the numId of 2.
2) In the XML the lists are stored in a flat format, there nodes are all at the same level, the hierarchy is only held by the values in the ilvl node.
So far I have worked on processing all lists in a document.
My main template has some html formatting code and in the body it has the following xslt:
<xsl:call-template name="doLists"/>
and doLists has the following:
<xsl:template name="doLists">
<xsl:for-each-group select="*" group-by="w:pPr/w:numPr/w:numId/@w:val">
<xsl:call-template name="processItem">
<xsl:with-param name="lvl" select="number(w:pPr/w:numPr/w:ilvl/@w:val)-1"/>
<xsl:with-param name="pos" select="0"/>
</xsl:call-template>
</xsl:for-each-group>
</xsl:template>
process item, is then called recursively from inside itself and it processes each item in the group.
Now the end goal, is to be able to take a word docx file and tranform it into html.
I have an xslt that does this, but it neglects the lists.
So far I have been able to find all the lists, process them into html, and diplay them in the right hierarchichal structure (with the correct format as well, so if it was a number, its a number, if it was a roman numeral, it is a roman numeral in the html, etc).
I need to make my xslt process the lists in place though. At the moment it just finds all the lists and processes them.
I guess what I need the xslt to be able do is:
1) go thru the xml document, and do the transformations it already has until it finds the first list item.
2) process the whole list (even though it only has the first item)
3) skip the rest of the list
4) continue processing the rest of the xml with the existing templates until it finds another list item
I hope this is clearer.
If you would actually like to see the whole xslt I wrote to process the lists in place, message me ur email address and I'll send you the xslt, and the xml I'm working with.
Thanks for your patience,
Mikey