Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2010, 03:23 AM
Registered User
 
Join Date: Dec 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to apply template for the first w:p in w:tbl?

Regardless of the nesting level in that particular w:tbl. For example:
Code:
<w:p w:rsidR="AAAAAA">
</w:p>
...
<w:tbl>
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
            </w:tblGrid>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    
                    <w:p w:rsidR="000000000" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C11</w:t>
                        </w:r>
                    </w:p>

                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="11111111" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C12</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C13</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C14</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C21</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C22</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C23</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C24</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>

In that case <w:p w:rsidR="11111111"> should be ignored as well as all consequentive <w:p>s inside of w:tbl at any nesting level. But <w:p w:rsidR="AAAAAA"> and <w:p w:rsidR="000000000" > must be processed. How to write it in select expression for xsl:template?
 
Old January 30th, 2010, 05:23 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Provide the output xml needed.
__________________
Rummy
 
Old January 30th, 2010, 12:13 PM
Registered User
 
Join Date: Dec 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
<w:p w:rsidR="AAAAAA">
<ADDED></ADDED>
</w:p>
...
<w:tbl>
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
            </w:tblGrid>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    
                    <w:p w:rsidR="000000000" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
<ADDED></ADDED>
                        <w:r>
                            <w:t>C11</w:t>
                        </w:r>
                    </w:p>

                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="11111111" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C12</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C13</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C14</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C21</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C22</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C23</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C24</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
</w:tbl>

...

<w:p w:rsidR="BBBBBBB">
<ADDED></ADDED>
</w:p>

I want my template to add those BOLD nodes to the output. Just for example.
 
Old January 30th, 2010, 12:32 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If the input is
Code:
<w:tbl xmlns:w="http://example.com/w">
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
            </w:tblGrid>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    
                    <w:p w:rsidR="000000000" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C11</w:t>
                        </w:r>
                    </w:p>

                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="11111111" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C12</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C13</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C14</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C21</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C22</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C23</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C24</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
</w:tbl>
then the stylesheet
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:w="http://example.com/w"
  version="1.0">
  
  <xsl:template match="w:tbl//w:p">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:variable name="n">
        <xsl:number from="w:tbl" level="any"/>
      </xsl:variable>
      <xsl:if test="$n = 1">
        <ADDED></ADDED>
      </xsl:if>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
creates the result
Code:
<?xml version="1.0" encoding="utf-8"?><w:tbl xmlns:w="http://example.com/w">
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
            </w:tblGrid>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    
                    <w:p w:rsidR="000000000" w:rsidRDefault="003A0CBE" w:rsidP="0015368C"><ADDED/>
                        <w:r>
                            <w:t>C11</w:t>
                        </w:r>
                    </w:p>

                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="11111111" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C12</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C13</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C14</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C21</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C22</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C23</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C24</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
</w:tbl>
Is that what you want, at least for the descendants of the 'w:tbl' elements?
I can't suggest code for the elements outside of the w:tbl element, you will need to provide more context like the parent element.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old January 30th, 2010, 12:54 PM
Registered User
 
Join Date: Dec 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My input XML:
Code:
<?xml version="1.0" encoding="utf-8"?>
<w:document  xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >

    <w:body>

        <w:p w:rsidR="AAAAAAAA">
            <w:pPr>
                <w:pStyle w:val="Heading1"/>
            </w:pPr>
            <w:r>
                <w:t>Heading 1</w:t>
            </w:r>
        </w:p>

<w:tbl xmlns:w="http://example.com/w">
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
            </w:tblGrid>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    
                    <w:p w:rsidR="000000000" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C11</w:t>
                        </w:r>
                    </w:p>

                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="11111111" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C12</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C13</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C14</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C21</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C22</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C23</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C24</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
</w:tbl>

        <w:p w:rsidR="BBBB">
            <w:pPr>
                <w:pStyle w:val="Heading2"/>
            </w:pPr>
            <w:r>
                <w:t>Heading 2</w:t>
            </w:r>
        </w:p>
    </w:body>
</w:document>
I want to add those ADDDED nodes for all that <w:p>s out of w:tbl and to the first in any w:tbl via single template. Do you have any idea how to do it?
 
Old January 30th, 2010, 01:05 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I would use two templates, one for each type of 'w:p' element so with the stylesheet being
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
  version="1.0">
  
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="w:tbl//w:p">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:variable name="n">
        <xsl:number from="w:tbl" level="any"/>
      </xsl:variable>
      <xsl:if test="$n = 1">
        <ADDED></ADDED>
      </xsl:if>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="w:p[not(ancestor::w:tbl)]">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <ADDED/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
and the input being
Code:
<w:document  xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >

    <w:body>

        <w:p w:rsidR="AAAAAAAA">
            <w:pPr>
                <w:pStyle w:val="Heading1"/>
            </w:pPr>
            <w:r>
                <w:t>Heading 1</w:t>
            </w:r>
        </w:p>

<w:tbl>
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
            </w:tblGrid>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    
                    <w:p w:rsidR="000000000" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C11</w:t>
                        </w:r>
                    </w:p>

                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="11111111" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C12</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C13</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C14</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C21</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C22</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C23</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C24</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
</w:tbl>

        <w:p w:rsidR="BBBB">
            <w:pPr>
                <w:pStyle w:val="Heading2"/>
            </w:pPr>
            <w:r>
                <w:t>Heading 2</w:t>
            </w:r>
        </w:p>
    </w:body>
</w:document>
the result is
Code:
<?xml version="1.0" encoding="utf-8"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">

    <w:body>

        <w:p w:rsidR="AAAAAAAA"><ADDED/>
            <w:pPr>
                <w:pStyle w:val="Heading1"/>
            </w:pPr>
            <w:r>
                <w:t>Heading 1</w:t>
            </w:r>
        </w:p>

<w:tbl>
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
                <w:gridCol w:w="2394"/>
            </w:tblGrid>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    
                    <w:p w:rsidR="000000000" w:rsidRDefault="003A0CBE" w:rsidP="0015368C"><ADDED/>
                        <w:r>
                            <w:t>C11</w:t>
                        </w:r>
                    </w:p>

                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="11111111" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C12</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C13</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C14</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
            <w:tr w:rsidR="0065563E" w:rsidTr="0065563E">
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C21</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C22</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C23</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="2394" w:type="dxa"/>
                    </w:tcPr>
                    <w:p w:rsidR="0065563E" w:rsidRDefault="003A0CBE" w:rsidP="0015368C">
                        <w:r>
                            <w:t>C24</w:t>
                        </w:r>
                    </w:p>
                </w:tc>
            </w:tr>
</w:tbl>

        <w:p w:rsidR="BBBB"><ADDED/>
            <w:pPr>
                <w:pStyle w:val="Heading2"/>
            </w:pPr>
            <w:r>
                <w:t>Heading 2</w:t>
            </w:r>
        </w:p>
    </w:body>
</w:document>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old January 30th, 2010, 01:14 PM
Registered User
 
Join Date: Dec 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for getting you info drop by drop but inside of this ADDED node I have to have counter. I used the following XSL code to have its value :

Code:
<xsl:variable name="COUNTER2" select="concat($FILEID, concat('-', count(preceding-sibling::*) + 1 + $COUNTER1))" />


<ADDED>
<xsl:value-of select="$COUNTER2"/>
</ADDED>

So all w:ps must have a single conseuentive numeration. How to implement it with your 2 templates?
 
Old January 30th, 2010, 01:24 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I don't understand what you want to achieve but if you have XSLT code for your counter then use it, I don't see why you can't count preceding sibling elements in each template.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old January 30th, 2010, 01:27 PM
Registered User
 
Join Date: Dec 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is when I have the last generated number in one subset (covered with the first template) I'd like to have the first w:p from the second template with these number + 1. How to do it?
 
Old January 30th, 2010, 01:40 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Can you post the output you want to create? It is not clear to me.
Or if you post the working code you have then show a minimal but complete sample that I can run to see the output you want. I can't tell from that snippet you posted what you are doing.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner help: <xsl:apply-template> spits out everything then does the correct match makks XSLT 4 December 21st, 2009 11:05 AM
Question on Apply Template vvenk XSLT 7 July 10th, 2008 12:21 PM
apply-template from included xslt stylesheet chobo XSLT 9 April 16th, 2008 05:25 PM
Difference between call-template ,apply-templates vikkiefd XSLT 4 March 12th, 2008 05:09 AM
Apply Custom template & import data from text file shampabera Excel VBA 2 August 8th, 2005 07:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.