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

Re: finding the position of the parent element XSLT 1.

Subject: Re: finding the position of the parent element XSLT 1.0
From: JBryant@xxxxxxxxx
Date: Tue, 28 Jun 2005 12:07:41 -0500
xslt position 1
A little testing revealed that just

          <b>
            <xsl:number count="question"/>
            <xsl:text>. </xsl:text>
            <xsl:value-of select="."/>
          </b>

gets the job done.

Here's the whole stylesheet that I used to test (yours trimmed a bit).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

  <xsl:template match="question">
    <table width="100%" cellpadding="3px" bgcolor="#c1e8e6" 
cellspacing="1">
      <xsl:apply-templates/>
    </table>
  </xsl:template>

  <xsl:template match="q">
    <thead align="left">
      <tr>
        <th class="qt">
          <b>
            <xsl:number count="question"/>
            <xsl:text>. </xsl:text>
            <xsl:value-of select="."/>
          </b>
        </th>
      </tr>
    </thead>
  </xsl:template>

</xsl:stylesheet>

Tested with Saxon 8.4 and Xalan-J 2.4.1 (since you wanted XSLT 1.0).

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




JBryant@xxxxxxxxx 
06/28/2005 11:50 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
Re:  finding the position of the parent element XSLT 1.0






Hi, Nadia,

I didn't test this, but it should be something like:

<xsl:number count="question" level="any" from="KMCust_survey"/>

So
<b>
  <xsl:value-of select="?????"/> <!--need
to know what to put here-->
  <xsl:text>. </xsl:text>
  <xsl:value-of select="."/>
</b>

would be 
<b>
  <xsl:text>Question </xsl:text><xsl:number count="question" level="any" 
from="KMCust_survey"/>
  <xsl:text>. </xsl:text>
  <xsl:value-of select="."/>
</b>

It's untested, so you may need to tinker some to get it exactly right, but 

the idea should work.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




Nadia.Swaby@xxxxxx 
06/28/2005 11:40 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
 finding the position of the parent element XSLT 1.0






Hi all

I have XML input structured like this:

<KMCust_survey>
      <question>
            <q>For which purpose do you use the Engineering Intranet
site?</q>
            <answer></answer>
      </question>
      <question>
            <q>How often are you using the following:</q>
            <answer>
            </answer>
      </question>
      <question>
            <q>How satisfy are you with the overall functionality of the
following:</q>
            <answer>
            </answer>
      </question>
</KMCust_survey>

And a stylesheet that looks like this:

<xsl:template match="question">
            <table width="100%" cellpadding="3px" bgcolor="#c1e8e6"
cellspacing="1">
                  <xsl:call-template name="gencols"/>
                  <xsl:apply-templates></xsl:apply-templates>
            </table>
      </xsl:template>
      <xsl:template match="q">
            <xsl:variable name="colspan">
                  <!--some code here that works-->
            </xsl:variable>
            <thead align="left">
                  <tr>
                        <th colspan="{$colspan}" class="qt">
                              <b>
                                    <xsl:value-of select="?????"/> 
<!--need
to know what to put here-->
                                    <xsl:text>. </xsl:text>
                                    <xsl:value-of select="."/>
                              </b>
                        </th>
                  </tr>
            </thead>
            <xsl:apply-templates/>
      </xsl:template>

I need it each question to be numbered

1. Question 1
2. Question 2
etc.

How do I find out the position of the 'question' element from template for
the 'q' element?


I hope some one can understand my problem :)

TIA

Nadia

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.