RE: [xsl] Example to checkbox in XSL

Subject: RE: [xsl] Example to checkbox in XSL
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 06 Aug 2007 21:43:55 +0100
An XSLT stylesheet typically takes XML as input and HTML as output. The
browser takes the HTML as input and produces a particular effect on the
screen. So if you want to produce a particular effect on the screen, you
first have to work out what HTML will create this effect, and then you have
to work out how to create this HTML from your XML (by using XSLT).

XSLT is a programming language, and as with any program, you shouldn't start
coding until you know (at least in outline) what output you want it to
produce, which in this case means the HTML.

You can't automatically generate the XSLT from the HTML - but in simple
cases, having done an HTML mockup of your page, you can ask yourself "which
fields in the HTML depend on which fields in the source XML", and then you
can work backwards by replacing parts of the HTML with bits of XSLT code,
for example changing

<tr><td>green</td><td>230</td></tr>

to

<xsl:template match="product">
  <tr>
    <td><xsl:value-of select="color"/></td>
    <td><xsl:value-of select="height"/></td>
  </tr>
</xsl:template>

- something I call "fill-in-the-blanks" coding, and which accounts for the
name "template".

Of course once you get the hang of this you won't usually need to write the
HTML down first - but it's important to have it clearly in your head as your
code your XSLT. Certainly the design approach of working backwards from your
output (rather than forwards from your input) is important when working with
XSLT, because if ever there's a structure clash between the input and the
output, your XSLT code will need to follow the output structure rather than
the input.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Pham, Joanne (Joanne) [mailto:jpham@xxxxxxxxxxxxxxxxxx] 
> Sent: 06 August 2007 21:08
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Example to checkbox in XSL
> 
> Thanks Mike,
> I am very new to XSLT world. So we can convert to XSL from 
> HTML. If I have the HTML file I can generate the XSL using 
> HTML file? Could you please provide more detail how to 
> convert the HTML to xsl.
> Thanks a ton,
> JP
> 
> -----Original Message-----
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Sent: Monday, August 06, 2007 12:35 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Example to checkbox in XSL
> 
> 
> Are you asking what the HTML should look like to achieve this 
> appearance
> on
> the screen, or are you asking how to generate this HTML using XSLT?
> Don't
> start to think about the XSLT coding until you know what HTML you want
> your
> stylesheet to generate. Ideally, write the HTML "by hand" 
> first. If you
> need
> help writing HTML, then someone here might advise you, but it's
> off-topic
> for this list.
> 
> Michael Kay
> http://www.saxonica.com/ 
> 
> > -----Original Message-----
> > From: Pham, Joanne (Joanne) [mailto:jpham@xxxxxxxxxxxxxxxxxx] 
> > Sent: 06 August 2007 20:28
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Cc: Pham, Joanne (Joanne)
> > Subject: [xsl] Example to checkbox in XSL
> > 
> > 
> > Hi All,
> > I would like to have an example how to hide the text fields 
> > in xsl. For example I have the following GUI
> > 
> >             Application
> >                         <Radio Checkbox> User following dial 
> > connection
> >                                     User name
> >                                     Password
> >                                     Domainname
> >                                     .....
> > 
> > 
> >                         <Radio checkbox> Use a default connection
> > 
> > In this case I would like to have all  field Username, 
> > Password, DomainName are hidden unless the < Radio Checkbox> 
> > User following dial connection is check So in the GUI it only shows
> >             
> >                         Application
> >                         <Radio Checkbox> User following dial 
> > connection
> >                         <Radio checkbox> Use a default 
> > connection When the <Radio Checkbox> User following dial 
> > connection is check the field Username, Password, DomainName 
> > are showing on GUI but not otherwise.
> > Thanks,
> > JP

Current Thread