Subject: RE: [xsl] XSL to put node (and kids) into a comment From: Monte Kalisch <MonteK@xxxxxxxxxxxx> Date: Fri, 1 Jun 2001 12:03:58 -0400 |
No problem. All three appear below. Keep in mind that the input.txt file is truly an XML document (SMIL actually), but I'm using ASP to scan the document for a particular node and its children and sending only that node to the XSL for transformation. I'm manually putting in the HTML headers and footers, as well as the form, since they aren't there in the beginning. --------------------------------------INPUT------------------------------ <say end="submit"> <p> <font size="18">Hello, and welcome to our salary survey.</font> </p> <p> <font size="18">What is your title?</font> </p> <p> <input type="group" name="TITLE" title="Title" min="1" errorMessage="Please indicate your title."/> <input type="radio" name="TITLE" value="1"/>Account Executive<br/> <input type="radio" name="TITLE" value="2"/>Account Supervisor<br/> <input type="radio" name="TITLE" value="3"/>Account Manager<br/> <input type="radio" name="TITLE" value="4"/>Account Director<br/> <input type="radio" name="TITLE" value="5"/>Planner<br/> <input type="radio" name="TITLE" value="6"/>Sr. Planner<br/> <input type="radio" name="TITLE" value="7"/>Director of Planning<br/> <input type="radio" name="TITLE" value="8"/>Executive VP<br/> <input type="radio" name="TITLE" value="9"/>President<br/> <input type="radiotext" name="TITLE" value="Other (please specify)"/> </p> <p> <input type="submit" value="Continue"/> </p> </say> --------------------------------------XSL------------------------------ <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="* | text() | @*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <!-- Don't rely on the default transformation because it expands it to <br></br> which is interpreted twice by IE--> <xsl:template match="br"> <br /> </xsl:template> <!-- Comment out any group tags --> <xsl:template match="input[@type = 'group']"> <xsl:comment> <xsl:apply-templates/> </xsl:comment> </xsl:template> <!-- Match radiotext and turn it into a radio button and a textbox --> <xsl:template match="input[@type = 'radiotext']"> <input type="radio"> <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> <xsl:attribute name="value">radiotext:</xsl:attribute> </input> <input type="text"> <xsl:attribute name="name">radiotext:<xsl:value-of select="@name"/></xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute> </input> </xsl:template> <!-- Match checkboxtext and turn it into a checkbox and a textbox --> <xsl:template match="input[@type = 'checkboxtext']"> <input type="checkbox"> <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> <xsl:attribute name="value">checkboxtext:</xsl:attribute> </input> <input type="text"> <xsl:attribute name="name">checkboxtext:<xsl:value-of select="@name"/></xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute> </input> </xsl:template> <!-- Match any submit buttons without values and put a value of "Submit" on them --> <xsl:template match="input[@type = 'submit' and not(@value)]"> <xsl:copy> <xsl:attribute name="value">Submit</xsl:attribute> <xsl:apply-templates select="@*" /> </xsl:copy> </xsl:template> </xsl:stylesheet> --------------------------------------OUTPUT------------------------------ <html> <base href="http://our.contentserver/files"/> <body background=""> <form method="post" action="http://our.processingserver/post?variables=values"> <say end="submit"> <p> <font size="18"> Hello, and welcome to our salary survey. </font> </p> <p> <font size="18"> What is your title? </font> </p> <p> <!----> <input type="radio" name="TITLE" value="1"> </input> Account Executive <br/> <input type="radio" name="TITLE" value="2"> </input> Account Supervisor <br/> <input type="radio" name="TITLE" value="3"> </input> Account Manager <br/> <input type="radio" name="TITLE" value="4"> </input> Account Director <br/> <input type="radio" name="TITLE" value="5"> </input> Planner <br/> <input type="radio" name="TITLE" value="6"> </input> Sr. Planner <br/> <input type="radio" name="TITLE" value="7"> </input> Director of Planning <br/> <input type="radio" name="TITLE" value="8"> </input> Executive VP <br/> <input type="radio" name="TITLE" value="9"> </input> President <br/> <input type="radio" name="TITLE" value="radiotext:"/> <input type="text" name="radiotext:TITLE" value="Other (please specify)"/> </p> <p> <input type="submit" value="Continue"> </input> </p> </say> </form> </body> </html> -------------------------------------------------------------------- -----Original Message----- From: Michael Kay To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Sent: 6/1/01 9:23 AM Subject: RE: [xsl] XSL to put node (and kids) into a comment Your XSLT looks OK to me, perhaps the error is elsewhere? Can you show us a complete input, stylesheet, and output? Mike Kay > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of > Monte Kalisch > Sent: 01 June 2001 14:04 > To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' > Subject: [xsl] XSL to put node (and kids) into a comment > > > I want to translate some of the incoming XML into HTML, but > comment out > certain things that don't make sense in HTML (yet still leave > the original > intact) > > For instance, I want this XML: > > <input type="group" name="age" min="1"/> > > to be transformed into this: > > <!--<input type="group" name="age" min="1"/>--> > > How would I go about doing this? I have this XSL already, > but it doesn't > seem to be working properly. It recognizes the tag in > question, but doesn't > > actually include the contents in the transformation: > > <xsl:template match="* | text() | @*"> > <xsl:copy> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates/> > </xsl:copy> > </xsl:template> > > <xsl:template match="input[@type = 'group']"> > <xsl:comment> > <xsl:apply-templates/> > </xsl:comment> > </xsl:template> > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list <<input.txt>> <<XSL.txt>> <<output.txt>> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSL to put node (and kids, Michael Kay | Thread | Re: [xsl] XSL to put node (and kids, David_N_Bertoni |
Re: XSL history (was RE: [xsl] XSL , G. Ken Holman | Date | RE: [xsl] querystring and character, Jeremy Clarke |
Month |