You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by James Cook <ji...@iname.com> on 2000/10/11 17:58:28 UTC

Interesting XSL Question

Assume that I am in an <xsl:template> tag that has successfully matched a node
in my XML doc. I want to produce HTML output of a checkbox input field. If an
element of my matched node contains a boolean value of 'true', I want the form
checkbox to appear as checked, otherwise it should be clear.

XML
===
<node>
    <Control>
        true
    </Control>
</node>

XSL
===
<input type="checkbox" name="checkbox" value="true">
    <xsl:value-of select="Control=true">
        <xsl:attribute name="checked"/>
    </xsl:value-of>
</input>

I get a SAX parse exception at the end of the <xsl:attribute> tag, for some
reason. Any thoughts on how I might accomplish this?

thanks,
jim



Re: Interesting XSL Question

Posted by James Cook <ji...@iname.com>.
I am assuming that XSL does not allow me to put an <xsl:attibute> tag inside an
<xsl:value-of> tag. If this is the case, is there another approach that will
accomplish my needs?

jim


----- Original Message -----
From: "James Cook" <ji...@iname.com>
To: <xa...@xml.apache.org>
Sent: Wednesday, October 11, 2000 12:33 PM
Subject: Re: Interesting XSL Question


> Fergus,
>
> Thanks for that insight on the whitespace. I could of spent a great deal of
time
> debugging that, but I can't even get Xerces to parse the XSL. I get a SAX
> Exception while parsing:
>
> <input type="checkbox" name="checkbox" value="true">
>     <xsl:value-of select="normalize-space(Control)='true'">
>         <xsl:attribute name="checked"/>
>     </xsl:value-of>
> </input>
>
> at the end of the line: <xsl:attribute name="checked"/>
>
> Any ideas?
> jim
>
> ----- Original Message -----
> From: "Fergus Gallagher" <Fe...@OrbisUK.com>
> To: <xa...@xml.apache.org>
> Sent: Wednesday, October 11, 2000 12:07 PM
> Subject: Re: Interesting XSL Question
>
>
> > You probably want
> >          select="normalize-space(Control)='true'".
> >
> > The text node is "<whitespace>true<whitespace>" unless you have some other
> > space-trimming options set.  'true' is not a boolean.  There is a function
> > boolean("string") but that is true if "string" is non-empty, so that
> > boolean("false") is true.
> >
> > Fergus
> >
> >
> > At 11:58 11/10/00 -0400, James Cook wrote:
> > >Assume that I am in an <xsl:template> tag that has successfully matched a
> node
> > >in my XML doc. I want to produce HTML output of a checkbox input field. If
an
> > >element of my matched node contains a boolean value of 'true', I want the
> form
> > >checkbox to appear as checked, otherwise it should be clear.
> > >
> > >XML
> > >===
> > ><node>
> > >     <Control>
> > >         true
> > >     </Control>
> > ></node>
> > >
> > >XSL
> > >===
> > ><input type="checkbox" name="checkbox" value="true">
> > >     <xsl:value-of select="Control=true">
> > >         <xsl:attribute name="checked"/>
> > >     </xsl:value-of>
> > ></input>
> > >
> > >I get a SAX parse exception at the end of the <xsl:attribute> tag, for some
> > >reason. Any thoughts on how I might accomplish this?
> > >
> > >thanks,
> > >jim
> >
> > --
> > Fergus Gallagher
> > Orbis
> > http://www.orbisuk.com/
> > +44-(0)20-8987 0717
> >
>
>


Re: Interesting XSL Question

Posted by James Cook <ji...@iname.com>.
Thanks, Fergus! That did the trick.

jim

----- Original Message -----
From: "Fergus Gallagher" <Fe...@OrbisUK.com>
To: <xa...@xml.apache.org>
Cc: <xa...@xml.apache.org>
Sent: Wednesday, October 11, 2000 12:47 PM
Subject: Re: Interesting XSL Question


> Try this
>
> <input type="checkbox" name="checkbox" value="true">
>      <xsl:if test="normalize-space(Control)='true'">
>          <xsl:attribute name="checked"/>
>      </xsl:if>
> </input>
>
> Fergus
>
> At 12:33 11/10/00 -0400, James Cook wrote:
> >Fergus,
> >
> >Thanks for that insight on the whitespace. I could of spent a great deal
> >of time
> >debugging that, but I can't even get Xerces to parse the XSL. I get a SAX
> >Exception while parsing:
> >
> ><input type="checkbox" name="checkbox" value="true">
> >     <xsl:value-of select="normalize-space(Control)='true'">
> >         <xsl:attribute name="checked"/>
> >     </xsl:value-of>
> ></input>
> >
> >at the end of the line: <xsl:attribute name="checked"/>
> >
> >Any ideas?
> >jim
> >
> >----- Original Message -----
> >From: "Fergus Gallagher" <Fe...@OrbisUK.com>
> >To: <xa...@xml.apache.org>
> >Sent: Wednesday, October 11, 2000 12:07 PM
> >Subject: Re: Interesting XSL Question
> >
> >
> > > You probably want
> > >          select="normalize-space(Control)='true'".
> > >
> > > The text node is "<whitespace>true<whitespace>" unless you have some other
> > > space-trimming options set.  'true' is not a boolean.  There is a function
> > > boolean("string") but that is true if "string" is non-empty, so that
> > > boolean("false") is true.
> > >
> > > Fergus
> > >
> > >
> > > At 11:58 11/10/00 -0400, James Cook wrote:
> > > >Assume that I am in an <xsl:template> tag that has successfully matched a
> >node
> > > >in my XML doc. I want to produce HTML output of a checkbox input
> > field. If an
> > > >element of my matched node contains a boolean value of 'true', I want the
> >form
> > > >checkbox to appear as checked, otherwise it should be clear.
> > > >
> > > >XML
> > > >===
> > > ><node>
> > > >     <Control>
> > > >         true
> > > >     </Control>
> > > ></node>
> > > >
> > > >XSL
> > > >===
> > > ><input type="checkbox" name="checkbox" value="true">
> > > >     <xsl:value-of select="Control=true">
> > > >         <xsl:attribute name="checked"/>
> > > >     </xsl:value-of>
> > > ></input>
> > > >
> > > >I get a SAX parse exception at the end of the <xsl:attribute> tag, for
> > some
> > > >reason. Any thoughts on how I might accomplish this?
> > > >
> > > >thanks,
> > > >jim
> > >
> > > --
> > > Fergus Gallagher
> > > Orbis
> > > http://www.orbisuk.com/
> > > +44-(0)20-8987 0717
> > >
>
> --
> Fergus Gallagher
> Orbis
> http://www.orbisuk.com/
> +44-(0)20-8987 0717
>


Re: Interesting XSL Question

Posted by Fergus Gallagher <Fe...@OrbisUK.com>.
Try this

<input type="checkbox" name="checkbox" value="true">
     <xsl:if test="normalize-space(Control)='true'">
         <xsl:attribute name="checked"/>
     </xsl:if>
</input>

Fergus

At 12:33 11/10/00 -0400, James Cook wrote:
>Fergus,
>
>Thanks for that insight on the whitespace. I could of spent a great deal 
>of time
>debugging that, but I can't even get Xerces to parse the XSL. I get a SAX
>Exception while parsing:
>
><input type="checkbox" name="checkbox" value="true">
>     <xsl:value-of select="normalize-space(Control)='true'">
>         <xsl:attribute name="checked"/>
>     </xsl:value-of>
></input>
>
>at the end of the line: <xsl:attribute name="checked"/>
>
>Any ideas?
>jim
>
>----- Original Message -----
>From: "Fergus Gallagher" <Fe...@OrbisUK.com>
>To: <xa...@xml.apache.org>
>Sent: Wednesday, October 11, 2000 12:07 PM
>Subject: Re: Interesting XSL Question
>
>
> > You probably want
> >          select="normalize-space(Control)='true'".
> >
> > The text node is "<whitespace>true<whitespace>" unless you have some other
> > space-trimming options set.  'true' is not a boolean.  There is a function
> > boolean("string") but that is true if "string" is non-empty, so that
> > boolean("false") is true.
> >
> > Fergus
> >
> >
> > At 11:58 11/10/00 -0400, James Cook wrote:
> > >Assume that I am in an <xsl:template> tag that has successfully matched a
>node
> > >in my XML doc. I want to produce HTML output of a checkbox input 
> field. If an
> > >element of my matched node contains a boolean value of 'true', I want the
>form
> > >checkbox to appear as checked, otherwise it should be clear.
> > >
> > >XML
> > >===
> > ><node>
> > >     <Control>
> > >         true
> > >     </Control>
> > ></node>
> > >
> > >XSL
> > >===
> > ><input type="checkbox" name="checkbox" value="true">
> > >     <xsl:value-of select="Control=true">
> > >         <xsl:attribute name="checked"/>
> > >     </xsl:value-of>
> > ></input>
> > >
> > >I get a SAX parse exception at the end of the <xsl:attribute> tag, for 
> some
> > >reason. Any thoughts on how I might accomplish this?
> > >
> > >thanks,
> > >jim
> >
> > --
> > Fergus Gallagher
> > Orbis
> > http://www.orbisuk.com/
> > +44-(0)20-8987 0717
> >

-- 
Fergus Gallagher
Orbis
http://www.orbisuk.com/
+44-(0)20-8987 0717


Re: Interesting XSL Question

Posted by James Cook <ji...@iname.com>.
Fergus,

Thanks for that insight on the whitespace. I could of spent a great deal of time
debugging that, but I can't even get Xerces to parse the XSL. I get a SAX
Exception while parsing:

<input type="checkbox" name="checkbox" value="true">
    <xsl:value-of select="normalize-space(Control)='true'">
        <xsl:attribute name="checked"/>
    </xsl:value-of>
</input>

at the end of the line: <xsl:attribute name="checked"/>

Any ideas?
jim

----- Original Message -----
From: "Fergus Gallagher" <Fe...@OrbisUK.com>
To: <xa...@xml.apache.org>
Sent: Wednesday, October 11, 2000 12:07 PM
Subject: Re: Interesting XSL Question


> You probably want
>          select="normalize-space(Control)='true'".
>
> The text node is "<whitespace>true<whitespace>" unless you have some other
> space-trimming options set.  'true' is not a boolean.  There is a function
> boolean("string") but that is true if "string" is non-empty, so that
> boolean("false") is true.
>
> Fergus
>
>
> At 11:58 11/10/00 -0400, James Cook wrote:
> >Assume that I am in an <xsl:template> tag that has successfully matched a
node
> >in my XML doc. I want to produce HTML output of a checkbox input field. If an
> >element of my matched node contains a boolean value of 'true', I want the
form
> >checkbox to appear as checked, otherwise it should be clear.
> >
> >XML
> >===
> ><node>
> >     <Control>
> >         true
> >     </Control>
> ></node>
> >
> >XSL
> >===
> ><input type="checkbox" name="checkbox" value="true">
> >     <xsl:value-of select="Control=true">
> >         <xsl:attribute name="checked"/>
> >     </xsl:value-of>
> ></input>
> >
> >I get a SAX parse exception at the end of the <xsl:attribute> tag, for some
> >reason. Any thoughts on how I might accomplish this?
> >
> >thanks,
> >jim
>
> --
> Fergus Gallagher
> Orbis
> http://www.orbisuk.com/
> +44-(0)20-8987 0717
>


Re: Interesting XSL Question

Posted by Fergus Gallagher <Fe...@OrbisUK.com>.
You probably want
         select="normalize-space(Control)='true'".

The text node is "<whitespace>true<whitespace>" unless you have some other 
space-trimming options set.  'true' is not a boolean.  There is a function 
boolean("string") but that is true if "string" is non-empty, so that
boolean("false") is true.

Fergus


At 11:58 11/10/00 -0400, James Cook wrote:
>Assume that I am in an <xsl:template> tag that has successfully matched a node
>in my XML doc. I want to produce HTML output of a checkbox input field. If an
>element of my matched node contains a boolean value of 'true', I want the form
>checkbox to appear as checked, otherwise it should be clear.
>
>XML
>===
><node>
>     <Control>
>         true
>     </Control>
></node>
>
>XSL
>===
><input type="checkbox" name="checkbox" value="true">
>     <xsl:value-of select="Control=true">
>         <xsl:attribute name="checked"/>
>     </xsl:value-of>
></input>
>
>I get a SAX parse exception at the end of the <xsl:attribute> tag, for some
>reason. Any thoughts on how I might accomplish this?
>
>thanks,
>jim

-- 
Fergus Gallagher
Orbis
http://www.orbisuk.com/
+44-(0)20-8987 0717