7.7 Browsers and XSL

7.6 FileMaker Pro Value Lists and XSL

The FMPXMLRESULT with the -view action can return the value lists used for a field on a layout if you make an HTTP request. You can use the results to create a dynamic value list with XSL. The template will match the name of a list. The XML is shown below, followed by the XSL stylesheet to transform it into HTML.

Listing 7.10: Value list in XML

start example
 <VALUELIST NAME="list"> <VALUE>one</VALUE> <VALUE>two</VALUE> <VALUE>three</VALUE> <VALUE>four</VALUE> <VALUE>longword</VALUE> <VALUE>five</VALUE> <VALUE>six</VALUE> <VALUE>longerwordhere</VALUE> </VALUELIST> 
end example

Listing 7.11: XSL to use value list

start example
 <xsl:template match="fm:VALUELIST/@NAME=list">       <select name="myfield">             <option value="">-choose-</option>       <xsl:for-each select="fm:VALUE">             <option>                   <xsl:attribute name="value">                         <xsl:value-of select="." />                   </xsl:attribute>                   <xsl:value-of select="." />             </option>       </xsl:for-each>       </select> </xsl:template> 
end example

Listing 7.12: HTML select list

start example
 <select name="myfield">       <option value="">-choose-</option>       <option value="one">one</option>       <option value="two">two</option>       <option value="three">three</option>       <option value="four">four</option>       <option value="longword">longword</option>       <option value="five">five</option>       <option value="six">six</option>       <option value="longerwordhere">longerwordhere</option> </select> 
end example

Listing 7.13: XSL to create check boxes

start example
 <xsl:template match="fm:VALUELIST/@NAME=list">       <xsl:for-each select="fm:VALUE">             <input type="checkbox" name="myfield" />                   <xsl:attribute name="value">                         <xsl:value-of select="." />                   </xsl:attribute>                   <xsl:text> </xsl:text>                   <xsl:value-of select="." /><br />       </xsl:for-each> </xsl:template> 
end example

You can create dynamic value lists based on the returned field contents, as well. For example, you may return a found set of records with FMPXMLRESULT and use the first field (fm:COL[1]) in each record (fm:ROW) as the value for the pop-up list, but the second field (fm:COL[2]) is the displayed text. Create your value list with XSL:

Listing 7.14: Value list with found set

start example
 <xsl:template match="fm:RESULTSET">       <select name="myfield">             <option value="">-choose-</option>       <xsl:for-each select="fm:ROW">             <option>                   <xsl:attribute name="value">                         <xsl:value-of select="fm:COL[1]" />                   </xsl:attribute>                   <xsl:value-of select="fm:COL[2]" />             </option>       </xsl:for-each>       </select> </xsl:template> 
end example



Filemaker Pro 6 Developer's Guide to XML(s)XSL
FileMaker Pro 6 Developers Guide to XML/XSL (Wordware Library for FileMaker)
ISBN: 155622043X
EAN: 2147483647
Year: 2003
Pages: 100
Authors: Beverly Voth

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net