Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 14th, 2005, 02:37 PM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default calling one template in other template

Hi,
    I plead ignorance, new to xml xslt.

I want the provider list dropdown to be used in
<xsl:template match="subclass[@name='assigneeDateOfServiceList']">

the way it is working in
<xsl:template match="subclass[@name='noFaultProviderList']">

Thanks for your efforts
xsl file and xml file are as follows

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

    Provider list

    -->
    <xsl:template match="subclass[@name='noFaultProviderList']">
        <div class="boxContain741" id="assigneeAssocUtil">

            <table width="100%" border="1" bordercolor="blue" cellspacing="0" cellpadding="0" id="form">
                <tr>
                    <td width="80">
                        <strong>This Assignee is associated with the following Provider(s):</strong>
                    </td>
                    <td>
                        <xsl:call-template name="ShowProviderList">
                            <xsl:with-param name="Providers" select="."/>
                        </xsl:call-template>
                    </td>
                </tr>
            </table>


        </div>
    </xsl:template>

    <xsl:template match="subclass[@name='assigneeDateOfServiceList']">
        <table>
            <tr>
                <td>
                    <input type="text" class="sm-medium" maxlength="10">
                        <xsl:attribute name="onChange">oPage.setChangeFlag()</xsl:attribute>
                        <xsl:attribute name="onblur">if(validateField(this,'shortDate')){ oPage.cacheChangeInXml('/class/subclass[@name=\'assigneeDateOfServiceList\']/subclass[@name=\'<xsl:value-of select="$ID"/>\']/property[@name=\'startDate\']',this, '/class/property[@name=\'dateOfServiceIsChanged\']')}</xsl:attribute>
                        <xsl:attribute name="name"><xsl:value-of select="concat('assigneeDateOfServiceList.', $ID, '.startDate')"/></xsl:attribute>
                        <xsl:attribute name="value"><xsl:value-of select="property[@name='startDate']"/></xsl:attribute>
                    </input>
                </td>
                <td>
                    <input type="text" class="sm-medium" maxlength="10">
                        <xsl:attribute name="onChange">oPage.setChangeFlag()</xsl:attribute>
                        <xsl:attribute name="onblur">if(validateField(this,'shortDate')){ oPage.cacheChangeInXml('/class/subclass[@name=\'assigneeDateOfServiceList\']/subclass[@name=\'<xsl:value-of select="$ID"/>\']/property[@name=\'endDate\']',this, '/class/property[@name=\'dateOfServiceIsChanged\']')}</xsl:attribute>
                        <xsl:attribute name="name"><xsl:value-of select="concat('assigneeDateOfServiceList.', $ID, '.endDate')"/></xsl:attribute>
                        <xsl:attribute name="value"><xsl:value-of select="property[@name='endDate']"/></xsl:attribute>
                    </input>
                </td>
                <td>

                        <xsl:call-template name="ShowProviderList">
                            <xsl:with-param name="Providers" select="."/>
                        </xsl:call-template>

                </td>
            </tr>
        </table>
    </xsl:template>

    <xsl:template name="ShowProviderList">
        <xsl:param name="Providers"/>
        <select muliple="yes" size="1" name="providerList">
            <xsl:attribute name="onChange">oPage.setChangeFlag()</xsl:attribute>
            <xsl:attribute name="onBlur">oPage.multiSelectCacheChangeInXml('/class/subclass[@name=\'noFaultProviderList\']', this, 'property[@name=\'associated\']')</xsl:attribute>
            <xsl:for-each select="$Providers/subclass">
                <xsl:variable name="ID" select="property[@name='id']"/>
                <option>
                    <xsl:attribute name="value"><xsl:value-of select="property[@name='id']"/></xsl:attribute>
                    <xsl:if test="property[@name='associated'] != '0'">
                        <xsl:attribute name="selected">true</xsl:attribute>
                    </xsl:if>
                    <xsl:value-of select="property[@name='lastName']"/>
                    <xsl:if test="string-length( property[@name='firstName'] )">, <xsl:value-of select="property[@name='firstName']"/>
                    </xsl:if>
                </option>
            </xsl:for-each>
        </select>
    </xsl:template>

</stylesheet>


==== this is xml file ===================
- <class name="AssigneeOfNoFault">
  <property name="className" required="false">AssigneeOfNoFault</property>
- <subclass name="requiredList">
  <property name="0" required="false">lastName</property>
  </subclass>
  <property name="id" required="false">1</property>
  <property name="noFaultID" required="false">1</property>
  <property name="summonsNumber" required="false">555XXX</property>
  <property name="psNumber" required="false">111PPP</property>
  <property name="firstName" required="false">Dan</property>
  <property name="lastName" required="true">Quale</property>
  <property name="noticeOfTrial" required="false">test notice of trial</property>
  <property name="motionToStrike" required="false">yo motion</property>
  <property name="juryDemandID" required="false">2</property>
  <property name="noteOfIssueServed" required="false">go</property>
  <property name="verdict" required="false">verdict dunno</property>
  <property name="amountInDispute" required="false">amt in dispute</property>
  <property name="reasonDeniedID" required="false">3</property>
  <property name="reasonDeniedOther" required="false">whatever 3 is</property>
  <property name="dateOfLoss" required="false">loss date</property>
  <property name="amountPaidOut" required="false">how much paid?</property>
  <property name="timely" required="false">1</property>
- <subclass name="address">
  <property name="id" required="false">4321</property>
  <property name="suite" required="false" />
  <property name="street" required="false" />
  <property name="city" required="false" />
  <property name="state" required="false" />
  <property name="zip" required="false" />
  <property name="homePhone" required="false" />
  <property name="officePhone" required="false">(718) 803-4325</property>
  <property name="cellPhone" required="false" />
  <property name="beeper" required="false" />
  <property name="fax" required="false" />
  <property name="email" required="false" />
  </subclass>
- <subclass name="assigneeDateOfServiceList">
- <subclass name="2">
  <property name="id" required="false">2</property>
  <property name="date" required="false">4/1/2002</property>
  <property name="amount" required="false">0</property>
  </subclass>
- <subclass name="1">
  <property name="id" required="false">1</property>
  <property name="date" required="false">2/1/2003</property>
  <property name="amount" required="false">200</property>
  </subclass>
  </subclass>
  <property name="assigneeDateOfServiceTotal" required="false">200</property>
- <subclass name="assigneeInsuredInfoList">
- <subclass name="1">
  <property name="id" required="false">1</property>
  <property name="firstName" required="false">Tony</property>
  <property name="lastName" required="false">Batofuko</property>
  <property name="street" required="false">333 brook ave</property>
  <property name="city" required="false">Brooklyn</property>
  <property name="state" required="false">NY</property>
  <property name="zip" required="false">10003</property>
  </subclass>
- <subclass name="2">
  <property name="id" required="false">2</property>
  <property name="firstName" required="false">Jimmy</property>
  <property name="lastName" required="false">Stack</property>
  <property name="street" required="false">333 1st street</property>
  <property name="city" required="false">New York</property>
  <property name="state" required="false">NY</property>
  <property name="zip" required="false">12211</property>
  </subclass>
  </subclass>
- <subclass name="providerList">
  <property name="0" required="false">1</property>
  <property name="1" required="false">2</property>
  </subclass>
- <subclass name="noFaultProviderList">
- <subclass name="1">
  <property name="id" required="false">1</property>
  <property name="firstName" required="false">Ken</property>
  <property name="lastName" required="false">Gilmer</property>
  <property name="associated">0</property>
  </subclass>
- <subclass name="2">
  <property name="id" required="false">2</property>
  <property name="firstName" required="false">Jon</property>
  <property name="lastName" required="false">Shmidt</property>
  <property name="associated">0</property>
  </subclass>
- <subclass name="2">
  <property name="id" required="false">2</property>
  <property name="firstName" required="false">Sam</property>
  <property name="lastName" required="false">Mathews</property>
  <property name="associated">1</property>
  </subclass>
- <subclass name="2">
  <property name="id" required="false">2</property>
  <property name="firstName" required="false">Generic</property>
  <property name="lastName" required="false">Person</property>
  <property name="associated">1</property>
  </subclass>
  </subclass>
- <subclass name="LookupHandler">
- <subclass name="assignee">
  <property name="2" required="false">Hilfiger, Tommy</property>
  <property name="1" required="false">Quale, Dan</property>
  </subclass>
- <subclass name="reasonsDenied">
  <property name="1" required="false">Too Fast</property>
  <property name="2" required="false">Not Enough Money</property>
  <property name="3" required="false">Doesn't Know How To Write</property>
  <property name="4" required="false">Too Expensive</property>
  <property name="5" required="false">Wintertime Rules</property>
  </subclass>
  </subclass>
  </class>

Reply With Quote
  #2 (permalink)  
Old September 14th, 2005, 06:21 PM
mhkay's Avatar
Wrox Author
Points: 18,274, Level: 58
Points: 18,274, Level: 58 Points: 18,274, Level: 58 Points: 18,274, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,932
Thanks: 0
Thanked 282 Times in 277 Posts
Default

Try to cut down your example so that the source document and stylesheet each fit on one screen (preferably the same screen). With luck the problem will then stare out at you, but if it doesn't it will probably stare out at me.

It's also useful to say what you're trying to achieve (a bit of sample output).

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old September 15th, 2005, 10:32 AM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,
            Thanks for pointing in the right direction, here is the modified version. xsl file and xml file.
GOAL: TO have a drop down list in template('assigneeDateOfServiceList') by calling template(ShowProviderList).

Thanks
Vijay

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

    <xsl:template match="subclass[@name='assigneeDateOfServiceList']">
    <table>
    <tr>
        <td>
            <input type="text" class="sm-medium" maxlength="10">
                <xsl:attribute name="name"><xsl:value-of select="concat('assigneeDateOfServiceList.', $ID, '.startDate')"/></xsl:attribute>
                <xsl:attribute name="value"><xsl:value-of select="property[@name='startDate']"/></xsl:attribute>
            </input>
        </td>
        <td>

                <xsl:call-template name="ShowProviderList">
                    <xsl:with-param name="Providers" select="."/>
                </xsl:call-template>

        </td>
    </tr>
    </table>
    </xsl:template>

    <xsl:template name="ShowProviderList">
        <xsl:param name="Providers"/>
        <select muliple="yes" size="1" name="providerList">
        <xsl:for-each select="$Providers/subclass">
            <xsl:variable name="ID" select="property[@name='id']"/>
            <option>
                <xsl:attribute name="value"><xsl:value-of select="property[@name='id']"/></xsl:attribute>
                <xsl:if test="property[@name='associated'] != '0'">
                    <xsl:attribute name="selected">true</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="property[@name='lastName']"/>
                <xsl:if test="string-length( property[@name='firstName'] )">, <xsl:value-of select="property[@name='firstName']"/>
                </xsl:if>
            </option>
        </xsl:for-each>
        </select>
    </xsl:template>

</stylesheet>
--===================== xml file =====================
- <subclass name="assigneeDateOfServiceList">
- <subclass name="2">
  <property name="id" required="false">2</property>
  <property name="date" required="false">4/1/2002</property>
  <property name="amount" required="false">0</property>
  </subclass>
  </subclass>
- <subclass name="noFaultProviderList">
- <subclass name="1">
  <property name="id" required="false">1</property>
  <property name="firstName" required="false">Ken</property>
  <property name="lastName" required="false">Gilmer</property>
  <property name="associated">0</property>
  </subclass>
- <subclass name="2">
  <property name="id" required="false">2</property>
  <property name="firstName" required="false">Jon</property>
  <property name="lastName" required="false">Shmidt</property>
  <property name="associated">0</property>
  </subclass>
  </subclass>



Reply With Quote
  #4 (permalink)  
Old September 15th, 2005, 12:12 PM
mhkay's Avatar
Wrox Author
Points: 18,274, Level: 58
Points: 18,274, Level: 58 Points: 18,274, Level: 58 Points: 18,274, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,932
Thanks: 0
Thanked 282 Times in 277 Posts
Default

OK, I'm not quite sure what your problem is. Here's a log of what I did.

1. Fix the xsl namespace declaration.

2. line 9, variable $ID isn't declared. Not sure what you had in mind here, I just took it out of the concat().

3. It complains saying the XML file isn't well-formed. The <subclass> tags aren't properly nested. I don't know how to correct it, but I'll try putting a <class> element around the whole thing.

4. I now get an output, which looks wrong, but I don't know what output you wanted so it's hard to correct. An obvious fault is that the value attribute is empty. Can't see what you intended here, because there's no property whose name is "startdate". Perhaps you meant date. Incidentally, 4/1/2002 is a bad way to write a date - do you mean 4th Jan or 1st April? Use 2002-01-04.

5. The other obvious problem is that there's no template to match the subclass named "noFaultProviderList", so the text is getting splatted into the output (that's what the default template does). I added a template rule <xsl:template match="subclass"/> to prevent this.

6. I also added <xsl:output method="html" indent="yes"/> so I can see better what's going on, and because you seem to be trying to output HTML.

7. I'm now getting output that looks like this:

<table>
   <tr>
      <td><input type="text" class="sm-medium" maxlength="10" name="assigneeDateOfServiceList..startDate" value=""></td>
      <td><select muliple="yes" size="1" name="providerList">
            <option value="2"></option></select></td>
   </tr>
</table>

Can't really do any more, because I don't know how that differs from the output you actually want.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
calling template with javascript smys123 XSLT 3 November 22nd, 2007 04:13 AM
template calling kgoldvas XSLT 1 August 1st, 2007 11:20 AM
template calling kgoldvas XSLT 1 July 10th, 2007 08:16 AM
CALLING A TEMPLATE WITHIN JAVA SCRIPT SOMANATHAN10 XSLT 6 February 14th, 2007 02:10 AM
calling template from a href bergs77 XSLT 4 January 9th, 2006 01:11 PM



All times are GMT -4. The time now is 03:20 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.