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 June 23rd, 2008, 07:02 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default NOT WELL FORMATTED

Hi,

I am using XSLT 1.0 and MSXML.

For some reason the HTML I am producing with the XLST below is not well formatted. The input tags are not being closed even though I have closed them. When I see the HTML output the input tag looks like this:

<input type="Radio" name="gb" id='{@name}' align='middle' class='fti'>


Could someone please help me to figure out what is wrong?

Cheers

P


XML
___


<?xml version="1.0"?>
<Audiences title="description" xmlns="">
  <Audience name="All Adults" expr="( total() )" factor="100.00"/>
  <Audience name="MALE" expr="( MALE )" factor="100.00"/>
  <Audience name="FEMALE" expr="( FEMALE )" factor="100.00"/>
</Audiences>


XSLT
____


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" omit-xml-declaration="yes" />

  <xsl:param name="SurveyReference"/>
  <xsl:template match="/Audiences">

    <div style='padding : 5px 5px 0px 5px;'>
    Choose a filter
    </div>

    <ul class='FilterList' id='ul{$SurveyReference}' style='padding : 5px 15px 15px 15px;'>
      <xsl:call-template name="ResultsBody" />
    </ul>
  </xsl:template>

  <xsl:template name="ResultsBody">
    <xsl:for-each select="Audience">

<li style="background: url('../images/0068_green_box.png') left no-repeat; height : 20px;">
            #xa0;#xa0;#xa0;#xa0;#xa0;#xa0;

<input type="Radio" name="{$SurveyReference}" id='{@name}' align='middle' class='fti'>
            <xsl:attribute name='onclick'>
              RecordFilter('<xsl:value-of select="$SurveyReference" />','<xsl:value-of select="@name" />','<xsl:value-of select="@expr" />','<xsl:value-of select="@factor" />')
            </xsl:attribute>
</input>

        <xsl:value-of select="@name"/>
    </li>
  </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>



CURRENT HTML OUTPUT - INPUT TAG NOT BEING CLOSED
-------------------------------------------------

<div style="padding : 5px 5px 0px 5px;">
    Choose a filter
</div>

<ul class="FilterList" id="ul" style="padding : 5px 15px 15px 15px;">

<li style="background: url('../images/0068_green_box.png') left no-repeat; height : 20px;">
<input type="Radio" name="" id="All Adults" align="middle" class="fti" onclick="#xA; RecordFilter('','All Adults','( total() )','100.00')#xA; ">All Adults
</li>

<li style="background: url('../images/0068_green_box.png') left no-repeat; height : 20px;"><input type="Radio" name="" id="MALE" align="middle" class="fti" onclick="#xA; RecordFilter('','MALE','( MALE )','100.00')#xA; ">MALE
</li>

<li style="background: url('../images/0068_green_box.png') left no-repeat; height : 20px;"><input type="Radio" name="" id="FEMALE" align="middle" class="fti" onclick="#xA; RecordFilter('','FEMALE','( FEMALE )','100.00')#xA; ">FEMALE
</li>

</ul>
 
Old June 24th, 2008, 01:50 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

That is well-formed html, if you want xhtml you will have to use xsl:output method="xml" and do a few workarounds or better still use an XSLT 2.0 processor and use the xhtml output method.

--

Joe (Microsoft MVP - XML)
 
Old June 24th, 2008, 05:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Hi Joe,

Thanks for your reply.

I thought the input should have a closing tag like this:

<input type="Radio" name="gb" id='{@name}' align='middle' class='fti'></input>

or

<input type="Radio" name="gb" id='{@name}' align='middle' class='fti'/>


But it doesn't.
 
Old June 24th, 2008, 06:00 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not in HTML. I'm not sure if it's illegal or just not normal but certainly the unclosed form is legitimate.

--

Joe (Microsoft MVP - XML)
 
Old June 24th, 2008, 06:00 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Please read the previous reply very carefully - what your XSLT processor is outputting is valid HTML. You are specifying HTML as your output method.

HTML is not always well formed XML, so perhaps this is your confusion. If you are trying to process this HTML again as if it was valid XML then you perhaps need to be using XHTML instead.

/- Sam Judson : Wrox Technical Editor -/
 
Old June 24th, 2008, 07:13 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Thanks Sam and Joe for your help.

The problem I am having with the list items generated by this XSLT is that it is not showing inside the containing Div. For some reason the second and third list item is being displayed outside the containing Div. I thought that the not closing of the input tag could be causing this behaviour but it might be something else then.

Cheers

Claudio
 
Old June 24th, 2008, 08:03 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The only DIV element I see starts and ends on lines 8 and 10 - and only contains a text element.

/- Sam Judson : Wrox Technical Editor -/
 
Old June 24th, 2008, 04:45 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

yeap, you are right but this is only part of the mark up. There is another DIV that contains the whole code including the UL.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Try It Out - Adding Formatted Text p. 54 gerry789 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 October 29th, 2011 11:17 AM
Recursive Query for Formatted Output Itech SQL Server 2005 11 June 12th, 2008 04:32 PM
Emails not formatted correctly. mcarol44 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 9 November 9th, 2007 03:53 AM
Storing and Displaying Formatted Strings anubhav.kumar Classic ASP Professional 17 October 26th, 2004 10:17 PM
Formatted/HTML text pkgal79 HTML Code Clinic 2 June 18th, 2003 02:18 AM





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