Subject: RE: How to generate different name using the same rule. From: pbinkley@xxxxxxxxxxxxxxxxxxx Date: Thu, 15 Jun 2000 14:02:50 -0600 |
The easiest way is simply to match condition elements differently depending on their parents: <xsl:template match="products/condition"> ... <xsl:template match="locations/condition"> ... If that doesn't do it (I haven't worked through your example in detail), then the mode attribute should help: you would have two templates for condition: <xsl:template match="condition" mode="loc"> ... <xsl:template match="condition" mode="prod"> ... Then you put the appropriate mode attribute in the apply-templates tags in the locations and products templates. I hope this helps! Peter Peter Binkley Interface Development Coordinator, Campus Alberta Interface email: pbinkley@xxxxxxxxxxxxxxxxxxxxxxx phone: (780) 492-5282 x234 fax: (780) 492-9243 post: Cameron Library 4-40 University of Alberta Edmonton Alberta T6G 2J8 -----Original Message----- From: sivaji [mailto:sivaji@xxxxxxxxx] Sent: June 14, 2000 5:18 PM To: xsl-list@xxxxxxxxxxxxxxxx Subject: How to generate different name using the same rule. HI All, I am in a seriuos problem , I have template rule which will be called from variuos rule , the problem I face is for the same rule being called it should generate different names as per sequence , to be precise In the below xsl rule condition is called by locations & products when it is called by locations the select should have a name like loc-qual-1 , loc-qual-2 , etc.. the same when called by products it should generate prod-qual-1, prod-qual-2 etc.. thanks on advance. sivaji here is the xml : <restrictions> <prodlist> <products> prod1 </products> <products> prod2 </products> <products> prod3 </products> <products> prod4 </products> </prodlist> <locations> <condition> <places> <place> subtree </place> <place> node </place> <place> childof </place> </places> <qualifiers> <qualifier> is </qualifier> <qualifier> has </qualifier> <qualifier> has not </qualifier> </qualifiers> </condition> <condition> <places> <place> subtree </place> <place> node </place> <place> childof </place> </places> <qualifiers> <qualifier> is </qualifier> <qualifier> has </qualifier> <qualifier> has not </qualifier> </qualifiers> </condition> </locations> <products> <condition> <places> <place> subtree </place> <place> node </place> <place> childof </place> </places> <qualifiers> <qualifier> is </qualifier> <qualifier> has </qualifier> <qualifier> has not </qualifier> </qualifiers> </condition> <condition> <places> <place> subtree </place> <place> node </place> <place> childof </place> </places> <qualifiers> <qualifier> is </qualifier> <qualifier> has </qualifier> <qualifier> has not </qualifier> </qualifiers> </condition> </products> </restrictions> and the xsl is <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method = "html"> <xsl:template match="/"> <html> <head></head> <title>Panopticon2</title><LINK rel="stylesheet" href="report.css" type="text/css" /> <body bgcolor="#FFFFFF" text="#000000" link="#CC3333" vlink="#CC3333" alink="#FFFFFF"> <p/><br/> <a href="/"><img src="logo150.gif" width="150" height="21" vspace="2" class="PageHeader" border="0" /></a> <p/> <h3><b><center>Product Display Restrictions</center></b></h3> <p/> <form action="nothing"> <xsl:apply-templates /> <br/><br/><p/> <hr/><br/> <center> <input type="button" value="Change Rule" /> </center> </form> </body> </html> </xsl:template> <xsl:template match="prodlist"> <center> <!--<h3>Rules:</h3><br/>--> <select name="products" size = "5" > <xsl:for-each select="products" > <option value = "{normalize-space()}"> <xsl:value-of select="."/> </option> </xsl:for-each> </select> <br/><br/> <input type="button" value="Add" /> <input type="button" value="Delete" /> </center> </xsl:template> <xsl:template match="locations"> <p/> <hr/> <table> <tr> <td><b>Within locations matching</b></td> <td><input type="radio" name="loc" value="any" /><b><i> any</i></b></td> <td><input type="radio" name="loc" value="any"/><b><i> all</i></b></td> <td><b> of the following: </b></td> </tr> </table> <center> <xsl:apply-templates /> <input type="reset" value="Add Condition" /> <input type="button" value="View Selected" /> </center> </xsl:template> <xsl:template match="products"> <p/> <hr/> <table> <tr> <td><b>show prodcuts matching</b></td> <td><input type="radio" name="loc" value="any" /><b><i> any</i></b></td> <td><input type="radio" name="loc" value="any"/><b><i> all</i></b></td> <td><b> of the following: </b></td> </tr> </table> <center> <xsl:apply-templates /> <input type="reset" value="Add Condition" /> <input type="button" value="View Selected" /> </center> </xsl:template> <xsl:template match ="condition"> <table border="0"> <tr><td> <select name="places"> <xsl:for-each select="places/place" > <option value = "{normalize-space()}"> <xsl:value-of select="."/> </option> </xsl:for-each> </select> </td><td> <select name="qualifiers" > <xsl:for-each select="qualifiers/qualifier" > <option value = "{normalize-space()}"> <xsl:value-of select="."/> </option> </xsl:for-each> </select> </td> <td> <input type="text" size="20" value="Flowers Cards" name="text" /></td> <td><input type="button" value="Browse" /></td> <td><input type="button" value="Delete" /></td> </tr></table> </xsl:template> </xsl:output> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: number formatting...., Khaja, Saif | Thread | RE: How to generate different name , Kay Michael |
Re: Building a tab-delimited file i, Warren Hedley | Date | encoding="iso-8859-1", roland@xxxxxxxxxx |
Month |