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 July 7th, 2006, 04:30 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem transforming unbounded types.

I'm having some problems transforming an XML file into HTML.

An example of the XML:
Code:
<transmissionPolicy><methodPolicy>
        <method>
            <className>X</className>
            <argumentType>Z1</argumentType>
            <argumentType>Z2</argumentType>
            <argumentType>Z3</argumentType>
        </method>
    </methodPolicy>
</transmissionPolicy>
The problem comes when I try to list the values in 'argumentType'. Only the first value will display. The potential number of argument types is unbounded.

The XSLT i am using looks like this:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="html"/>

  <xsl:template match="transmissionPolicy">
    <html>
      <body>
        <h3>Method Policy</h3>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="methodPolicy">

    <h4>Method</h4>
    <table border="0">
      <xsl:apply-templates/>
    </table>

  </xsl:template>

  <xsl:template match="method">
    <tr>
      <td>
      <xsl:value-of select="argumentType"/>
      </td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
Does anyone know how I can correctly disply all 'argumentTypes'?

Any help is much appreciated.

 
Old July 7th, 2006, 04:45 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

xsl:value-of, in version 1.0, gives the value of the first node you select. You don't say what you actually want to show but perhaps:
Code:
  <xsl:template match="method">
    <tr>
      <xsl:apply-templates select="argumentType"/>
    </tr>
  </xsl:template>
  <xsl:template match="argumentType">
    <td>
      <xsl:value-of select="."/>
    </td>
  </xsl:template>
--

Joe (Microsoft MVP - XML)
 
Old July 7th, 2006, 04:53 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Replace

<xsl:value-of select="argumentType"/>

by

<xsl:for-each select="argumentType">
  <xsl:value-of select="."/>
</xsl:for-each>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 8th, 2006, 04:18 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that works perfectly.

Quote:
quote:Originally posted by mhkay
 Replace

<xsl:value-of select="argumentType"/>

by

<xsl:for-each select="argumentType">
  <xsl:value-of select="."/>
</xsl:for-each>

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
A programming problem for Data Types code_lover Intro Programming 1 May 13th, 2008 06:42 AM
transforming types derived by extension? whelanj XSLT 4 April 12th, 2008 06:50 AM
problem transforming XML using xslt micky3248 XSLT 7 August 18th, 2006 03:52 AM
Error trying to search for value in unbounded form method Access 0 June 19th, 2005 05:33 PM
Unbounded fields cjordan Crystal Reports 1 January 1st, 2004 01:41 AM





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