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

Using values from one node tree to iterate/recurse ove

Subject: Using values from one node tree to iterate/recurse over another set of nodes. (Newbie Question)
From: Richard Dyce <subscriptions@xxxxxxxx>
Date: Wed, 27 Feb 2008 15:01:21 +0000
 Using values from one node tree to iterate/recurse ove

I'm just hoping for someone to give me a nudge in the right direction (given that I'm so far out of my depth, that a snorkel isn't going to help...)

I have a simple XML fragment:

<?xml version="1.0"?>
<view action="list" controller="story" display="list">
<record_list begin_record="1" end_record="2" last_page="1" page_number="1" page_size="10" total_found="2" type="story">
<field label="ID" name="id" type="id">id</field>
<field label="Headline" name="headline" type="name">headline</ field>
<field label="Bodycopy" name="bodycopy" type="textarea">bodycopy</field>
<field label="Picture" name="picture" type="image">picture</field>
<record sig="47c44488b7a614.15734104" type="story">
<headline>Fog in Channel, Europe Cut Off</headline>
<bodycopy>There was fog in the channel. No French cheese for us.</bodycopy>
<record sig="47c44488bb80e5.13211401" type="story">
<headline>Man Bites Dog</headline>
<bodycopy>Today a man bit a dog</bodycopy>

and I want to use the <structure> element as field definitions to format the <record> elements as rows in an HTML table.

What I have so far is:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />

<xsl:template match="/">
 <xsl:call-template name="head" />
   <xsl:apply-templates select="//view" />

<xsl:template match="view[@display='list']">
 <xsl:variable name="rec_type" select="record_list/@type"/>
 <xsl:variable name="total_found" select="record_list/@total_found"/>
 <xsl:variable name="page_size" select="record_list/@page_size"/>
 <xsl:variable name="page_number" select="record_list/@page_number"/>
 <xsl:variable name="last_page" select="record_list/@last_page"/>
 <xsl:variable name="structure" select="record_list/structure"/>

<h2><xsl:value-of select="$rec_type"/> Listing</h2>
<p>Showing <xsl:value-of select="record_list/@begin_record"/> to <xsl:value-of select="record_list/@end_record" /> of <xsl:value-of select="$total_found" /> records</p>
<xsl:apply-templates select="record_list/record">
<xsl:with-param name="structure" select="$structure" />

<xsl:template match="record">
 <xsl:param name="structure"/>

 <!-- newbie problem !!!! -->
 <xsl:value-of select="$structure" />
 <xsl:value-of select="." />



What I want to be able to do is recurse through the structure, pulling the definitions from the attributes, and the values from each record.

At least, that's what I *think* I want to do, but I'm at the very bottom of the steep learning curve, and, well, any general pointers would be greatly appreciated.

(I'm using XSLT 1.0 I'm afraid)

Richard Dyce MA (Cantab.) MBCS MIET

Current Thread


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.
First Name
Last Name
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.