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

Re: xsl-list Digest 28 Feb 2007 06:10:00 -0000 Issue 1

Subject: Re: xsl-list Digest 28 Feb 2007 06:10:00 -0000 Issue 1062
From: Andy Carr1 <CARRA@xxxxxxxxxx>
Date: Mon, 5 Mar 2007 16:31:15 +0000
 Re: xsl-list Digest 28 Feb 2007 06:10:00 -0000 Issue 1
Hey drkm

Thanks for helping me with this. I have a couple of additional problems 
though, one is with the NumberedText the other is when a w:tbl element is 
at the same level as the w:p element but still needs to be a child of the 
Heading.

When there is a numbered list, all the items in the list should be wrapped 
in an encompassing <List> tag like this

<List>
   <ListItem>Item 1</ListItem>
   <ListItem>Item 2</ListItem>
   <ListItem>Item 3</ListItem>
</List> 

I am currently getting

<List>
   <ListItem>Item 1</ListItem>
</List>
<List>
   <ListItem>Item 2</ListItem>
</List>
<List>
   <ListItem>Item 3</ListItem>
</List>

I got this working with a test xml file using the following

  <xsl:template match="/">
    <Body>
      <xsl:apply-templates /> 
    </Body>
  </xsl:template>

  <xsl:template match w:body>
    <xsl:for-each-group select="w:p" group starting 
with="w:p[w:pPr/w:listPr/wx:t[@wx:val='1.']]"  --- Groups by the list 
number when list num is 1
      <List>
        <xsl:apply-templates select="current-group()" mode="List" />
      </List> 
    </xsl:for-each-group> 
  </xsl:template>

  <xsl:template match="w:p" mode="List">
    <ListItem>
      <xsl:value-of select="w:r/w:t"/>
    </ListItem>
  </xsl:template>

This however wouldn't fit into the solution you provided. Do you know of a 
way that I could incorporate something like the above sample into your 
solution as your solution works really well and I don't want to change it 
unless absolutely necessary.

The second problem is this:

As you know the w:p tag is applied to all text entries in a Word document 
and when a table is created the w:tbl tag is applied at the same level. In 
a previous solution to my issue you had the w:tbl tag inserted with an 
"or" into the <xsl:for-each-group> statement which worked, but it doesn't 
appear to work in the current solution, although I may be getting the 
syntax wrong. The bold bits represent the changes I made ..

Any more help would be greatly appreciated. 

  <xsl:function name="my:p-style" as="xs:string">
    <xsl:param name="p" as="element()"/>
    <xsl:sequence select="$p/w:pPr/w:pStyle/@w:val"/>
  </xsl:function>

  <xsl:template match="ns0:Body">
    <Body>
      <xsl:call-template name="my:grouping">
        <xsl:with-param name="p"     select="w:p"/>
        <xsl:with-param name="level" select="1"/>
      </xsl:call-template>
    </Body>
  </xsl:template>

  <xsl:template match="w:p[my:p-style(.) eq 'NumberedText']">
    <List>
      <ListItem>
        <xsl:value-of select="w:r/w:t"/>
      </ListItem>
    </List>
  </xsl:template>

  <xsl:template match="w:tbl">
    <Table>
      TABLE STRUCTURE IN HERE ...
    </Table>
  </xsl:template> 

  <xsl:template name="my:grouping">
    <xsl:param name="p"     as="element(w:p)+"/>
    <xsl:param name="level" as="xs:integer"/>
    <xsl:for-each-group select="$p or w:tbl" 
group-starting-with="w:p[my:p-style(.) eq concat('Heading',$level)]">
      <xsl:choose>
        <xsl:when test="my:p-style(.) eq concat('Heading', $level)">
          <Section>
            <xsl:call-template name="my:grouping">
              <xsl:with-param name="p"     select="current-group()"/>
              <xsl:with-param name="level" select="$level + 1"/>
            </xsl:call-template>
          </Section>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select="current-group()"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each-group>
  </xsl:template>

</xsl:stylesheet>


Regards
Andy

Andy Carr
IT Specialist
Tel: Internal - 298037 External - 01252 558037
Mail Point  M1C IBM Application Services
Meudon House, Meudon Avenue, Farnborough, GU14 7NB
(Notes) Andy Carr1/UK/IBM@IBMGB 
(Internet)CARRA@xxxxxxxxxx






Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

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.