RE: [xsl] Example to checkbox in XSL

Subject: RE: [xsl] Example to checkbox in XSL
From: "Abel Braaksma (online)" <abel.online@xxxxxxxxx>
Date: Tue, 7 Aug 2007 00:41:41 +0200 (CEST)
Hi Joanne,

It seems to me, from following this thread, that there's some need
for a basic understanding of what HTML is, what XSLT, what XML is
(or can be) and how they relate to each other, and, considering the
example below, how a PI (process instruction) works.

Mike told you what XSLT can do for you (it takes input of XML and
produces output of XML / HTML / TEXT). You use a PI. That means that
the browser will transform the XML you showed partially below to
some layout that, internally, resembles the HTML of your page. The
instructions for how to get to this HTML are in the XSLT file.

To learn to understand this process (and next, to do some
modifications with it) the best thing to do is take your XML and the
XSLT and transform them on the commandline using any of the many
XSLT 1.0 processors available.

Alternatively, you can also load your page in Firefox and use the
DOM viewer or any other plugin that can show you the rendered source
chart (but beware, this is not necessary equal to how the HTML would
look like, it is how Firefox 'sees' it).

If this all sounds rather daunting, I suggest you first read through
the introduction pages of XSLT on http://www.w3schools.org, they
only take you an hour and will provide you the basics, especially if
you try their examples yourself.

Cheers,
-- Abel Braaksma

PS: your original inquiry, a checkbox in HTML, made by XSLT, can be
done in a 1000 ways of which this is one (of course, you'll need to
replace the matching patterns and the selections to the ones that
match your requirements):

<xsl:template match="YOURINPUTNODE">
   <input type="checkbox" >
      <xsl:apply-templates select="selection-for-selected-checkbox" />
   </input>
</xsl:template>

<xsl:template match="match-pattern-for-selected-cb">
   <xsl:attribute name="selected">selected</xsl:attribute>
</xsl:template>


Similar approaches work for radio buttons or selection lists where
one or more must be selected.
> Thanks Mike,
> So when I right click on the page and view source I have seen this
> XML
> text as below:
> 	?xml version="1.0" encoding="ISO-8859-1" ?>
> <?xml-stylesheet type="text/xsl"
> href="/vsconsole/xsl/AMTestVoIP.xsl"?>
> <AUTOMON_TEST>
> 		<ACTION>EDIT</ACTION>
> 		<TESTID>1</TESTID>
> 		<SUITEID>1</SUITEID>
>
> So I didn't see how to view/generate the html file on this page.
> -Thanks,
> Jp

Current Thread