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 March 22nd, 2007, 05:35 PM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nesting tags / function calls possible?

Hi everyone,

I did a few searches to see if I could find an example to help me out, but so far haven't had any luck. This I turn myself over to you for a little assistance here.

I'm working with Ecrion's 2007 Rendering suite and we've been looking into the xChart features that are a part of it. The basic layout and structure is the same, just a custom set of tags for defining datapoint and other types of graph information.

The syntax for a graph looks something like this:


<xc:graph x="5pt" y="5pt" width="8.00 in" height="3.0in">
   <xc:value-axis orientation="vertical" min="0" max="100">
      <xc:title font-weight="bold">Y Axis</xc:title>
   </xc:value-axis>
   <xc:category-axis orientation="horizontal">
      <xc:title font-weight="bold">X Axis</xc:title>
   </xc:category-axis>
   <xc:plot-area>
      <xc:serie stroke-color="yellow" stroke-width="1.0pt">
         <xc:data-point category="1993" value="30"/>
         <xc:data-point category="1995" value="50"/>
         <xc:data-point category="1997" value="10"/>
         <xc:data-point category="2000" value="20"/>
      </xc:serie>
   </xc:plot-area>
</xc:graph>


This will give me a nice little line graph and everything is good. Now the problem I'm running into is that I don't want hardcoded values in my plot-area. I want to be able to read through an XML file and create my points dynamically. I've tried several different ways to do this, and haven't hit upon something that works just yet. The most logical to me seemed to be the following:


   .
   .
   .
   <xc:serie stroke-color="yellow" stroke-width="1.0pt">
         <xsl:for-each select="ROW">
            <xc:data-point>
               category="<xsl:value-of select="YEAR"/>"
               value="<xsl:value-of select="VALUE"/>"
            </xc:data-point>
         </xsl:for-each>
   </xc:serie>
   .
   .
   .


Now, this doesn't work and I was wondering if there is a way to somehow embed a value-of call inside another set of tags. Something like this:

<xc:data-point category="<xsl:value-of select="YEAR"/>" value="xsl:value-of select="VALUE""/>

I'm at a bit of a loss to get this kind of thing working, and without it the entire graphing suite is useless. Any kind of help or suggestions would be greatly appreciated. Thanks! :)
 
Old March 22nd, 2007, 06:30 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can't have elements inside attributes:

category="<xsl:value-of select="YEAR"/>"
               value="<xsl:value-of select="VALUE"/>"


you want attribute value templates:

category="{YEAR}"
value="{VALUE}"

I'd suggest you need a better approach to learning XSLT than "finding an example to help me out". It's a fairly complicated language and you're gonig to find it very frustrating if you try to learn it by trial and error. Wrox do some good books.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 23rd, 2007, 10:32 AM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've been working with this stuff for a few months, and yes, it can be very frustrating. Having reference books is great, true enough, but they're not much help when you're not sure exactly what you're LOOKING for. Attribute value templates look very promising, thanks for pointing me in the right direction.

I will have to disagree with you on learning via example though. I find that's the best way to learn new things. It can also lead you in new directions you'd have never thought of by simply looking things up in a book.
 
Old March 23rd, 2007, 10:39 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I will have to disagree with you on learning via example though.

Well, everyone has their own style. I find the approach very frustrating because you end up developing your own theories as to how something works, and then you try something new based on that theory (as you did in this posting) and then you dont understand why it doesn't work. Another classic example is where people try to write code that outputs start tags and end tags independently of each other - that's a clear result of the consequences of building a faulty mental model. I much prefer start by doing some reading to discover the underlying concepts.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 30th, 2007, 03:46 PM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The attribute value templates worked like a charm. Thanks very much. I don't know that I'd have found it on my own. :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Nesting queries??? giffordpinchot Access 0 September 20th, 2006 09:58 AM
VB code that calls a function mikefemi Beginning VB 6 1 January 11th, 2006 06:12 AM
function calls ricmar Access VBA 3 September 24th, 2004 09:15 AM
Subreports nesting svenvandevelde Crystal Reports 2 February 4th, 2004 12:20 PM
XSL calls java function - prob vetrikam XSLT 2 October 9th, 2003 10:33 PM





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