Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Trouble creating a table with multiple named templates

From: "Jay Bryant" <jay@------------>
To:
Date: 5/3/2005 12:11:00 AM
Hi, Max,

Welcome to the list.

I can't say much about your problem without a better view of your XML
structure. I THINK the problem comes from having a template that matches
directory/staffTitle/Position and another that matches directory. When the
processor hits the directory template, it won't apply the other template
without an apply-templates command. So, you can try adding
<xsl:apply-templates select="staffTitle/Position"/> within the directory
template.

Note that I didn't say anything about the names of the templates. A great
deal of XSL processing can be done without named templates, and I bet yours
is one of those cases. The match and apply method works very well and meets
many needs.

Anyway, please post a small but complete XML source file and a sample of
your desired output. Then we can help you get to a solution. Oftentimes,
folks ask a question about a fragment of their XSL, only to return later
with more questions because they should have shown us a bigger sample to
start with.

Happy XSLing.

Jay Bryant
Bryant Communication Services

----- Original Message ----- 
From: "Max Bronsema" <max.bronsema@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, May 02, 2005 5:51 PM
Subject: [xsl] Trouble creating a table with multiple named templates


Hi all,

First post. The problem I am having is creating a table using
templates. Currently my named templates out put the results in a table
format. I would like to have a master template that outputs all the
data at once, thus I have control of what the table looks like. I
currently have three XML documents merged together by ASP into one XML
document with the root node of directory. From this XML document I
have been able to pull out all the data I need using templates
specific to the nodes I am trying to acess. For example:

<xsl:template name="staffTitle" match="//directory/staffTitle/Position">
        <table>
                <tbody>
                        <td><xsl:value-of select="Phone"/></td>
                        <td><xsl:value-of select="pEmail"/></td>
                        <td><xsl:value-of select="Title"/></td>
                </tbody>
        </table>
</xsl:template>

Where I am running into trouble is when I try to create the master
template to include all of the named templates information. I have
experimented using a template such as:

<xsl:template name="master" match="//directory">
<table>
        <tbody>
                <tr>
                        <td><xsl:value-of select="dptFull"/></td>
                </tr>
                <tr>
                        <td>Location: <xsl:value-of select="Location"/></td>
                        <td>Phone: <xsl:value-of select="Phone" /></td>
                        <td>Fax: <xsl:value-of select="Fax"/></td>
                        <td>Box: <xsl:value-of select="oBox"/></td>
                </tr>
etc...

but this does not return the data in the nodes. The real question is,
is it possible to combine these named templates into a template that
can access all of their data? The master template being a table
structure using <xsl:value-of select=""/> as the way to acess data. It
works well with my named templates acessing specific parts of the XML
document. What is the hangup with going to a larger scale? I know
nesting is not a option and have read some info about using Modes but
that does not seem like it will work for what I am trying to do. I am
getting a book on Wednesday but am hoping for some help from this
wealth of knowledge. Please ask for more details or more code if that
is what you need.

Thank you,

I appreciate the help.

Max Bronsema


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent