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

Re: Problem with Positional Grouping from MSXML

Subject: Re: Problem with Positional Grouping from MSXML
From: Florent Georges <darkman_spam@xxxxxxxx>
Date: Thu, 1 Feb 2007 11:00:10 +0100 (CET)
Re:  Problem with Positional Grouping from MSXML
Andy Carr1 wrote:

  Hi

> I am using XSL 2.0 with XML Spy 2007- I would appreciate some
> help as my head is about to explode :-/

  You need xsl:for-each-group and its @group-starting-with:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:ns0="ns0"
                xmlns:w="w"
                xmlns:my="my:andy.xsl"
                exclude-result-prefixes="my ns0 w xs"
                version="2.0">

  <xsl:output indent="yes"/>

  <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:for-each-group
          select="w:p"
          group-starting-with="w:p[my:p-style(.) eq 'BodyHeading']">
        <Section>
          <xsl:apply-templates select="current-group()"/>
        </Section>
      </xsl:for-each-group>
    </Body>
  </xsl:template>

  <xsl:template match="w:p[my:p-style(.) eq 'BodyHeading']">
    <Title>
      <xsl:value-of select="w:r/w:t"/>
    </Title>
  </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:p[my:p-style(.) eq 'Text']">
    <Para>
      <xsl:value-of select="w:r/w:t"/>
    </Para>
  </xsl:template>

</xsl:stylesheet>

  With your previous input, running with Saxon gives:

<?xml version="1.0" encoding="UTF-8"?>
<Body>
   <Section>
      <Title>Heading Text</Title>
      <List>
         <ListItem>Some list text</ListItem>
      </List>
      <Para>Some text</Para>
   </Section>
   <Section>
      <Title>Another Heading Text</Title>
      <Para>Some more text</Para>
      <List>
         <ListItem>Some more list text</ListItem>
      </List>
   </Section>
</Body>

  I'm not sure you can have several ListItem in List.  If so, you'll
have to group them after having defined how (all adjacent NumberedText,
all NumberedText between two BodyHeading, ...?).

  Regards,

--drkm
























	

	
		
___________________________________________________________________________ 
Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions ! 
Profitez des connaissances, des opinions et des expiriences des internautes sur Yahoo! Questions/Riponses 
http://fr.answers.yahoo.com

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.