Subject: Re: [xsl] How to overrite default rendering toretain name=value attribute pairs From: "Karlmarx Rajangam" <karlmarx.rajangam@xxxxxxxxxxxxxxxxxx> Date: Tue, 19 Jun 2007 08:56:27 -0400 |
Thanks Mr.David. I tried what your suggested but could not really make it to work. 1) On >It should be selected=selected (which may be serialised >as just selected in html) Actually my first try was with selected=selected, after failing with it, tried selected=true. I both cases, the resultant output got serialized to output <option selected> > that is a bug in your XSLT engine. If so, any alternative way possible? We work in php environment. Sorry, so far I am unable to get more info of the xsl engine. >If you are using the XML output type <xsl:output method="xml"/> >which is what you want to use, given your requirement to >generate well formed xml) then this attribute minimisation > should never happen So far we used <xsl:output method="html"/>, but just tried with output=xml option but still it gets serialized to output without =true. By the way, we may have to use output=html for other reasons. > if you are using the html output.... but > <option selected = "true"> should be > serialised as <option selected = "true"> This seems not happening. > (selected=true) a selected="true" is not valid >html or xhtml (although xslt will generate it if you want). As you said, we would like xslt to generate this way <option selected="true">. Pls can you suggest how we can force it to get this? Sample XML code: <ANSWER QTYPE="MATCH"> <CHOICE ID="1"> <CONTENT TYPE="text/html"><![CDATA[glove]]></CONTENT> <OPTION SELECTED="true"><![CDATA[head]]></OPTION> <OPTION><![CDATA[hand]]></OPTION> <OPTION><![CDATA[foot]]></OPTION> </CHOICE> <CHOICE ID="2"> <CONTENT TYPE="text/html"><![CDATA[sock]]></CONTENT> <OPTION><![CDATA[head]]></OPTION> <OPTION><![CDATA[hand]]></OPTION> <OPTION><![CDATA[foot]]></OPTION> </CHOICE> <CHOICE ID="3"> <CONTENT TYPE="text/html"><![CDATA[hat]]></CONTENT> <OPTION><![CDATA[head]]></OPTION> <OPTION SELECTED="true"><![CDATA[hand]]></OPTION> <OPTION><![CDATA[foot]]></OPTION> </CHOICE> </ANSWER> Desired output: (for each choice group) <script type="text/javascript"> inputXML += '<CHOICE id="answer_xx">\n'; inputXML += '<option SELECTED="TRUE">head</option>\n'; inputXML += '<option>hand</option>\n'; inputXML += '<option>foot</option>\n'; inputXML += '</CHOICE>\n'; </script> Pls ignore any type error / case sensitive mistakes. Thanks in adv. karl ------------------------------ Date: Fri, 15 Jun 2007 13:43:06 +0100 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx From: David Carlisle <davidc@xxxxxxxxx> Subject: Re: [xsl] How to overrite default rendering toretain name=value attribute pairs Message-Id: <200706151243.l5FCh66H011089@xxxxxxxxxxxxxxxxxxx> > (selected=true) a selected="true" is not valid html or xhtml (although xslt will generate it if you want). It should be selected=selected (shich may be serialised as just selected in html) > Results in <option selected>xxx</option>, without ="TRUE" thereby > becoming an INVALID XML that is a bug in your XSLT engine. If you are using the XML output type <xsl:output method="xml"/> which is what you want to use, given your requirement to generate well formed xml) then this attribute minimisation should never happen. if you are using the html output <xsl:output method="html"/> then <option selected="selected"> may be (and probably would be) serialised as <option selected> but <option selected = "true"> should be serialised as <option selected = "true"> David Date: Fri, 15 Jun 2007 08:35:19 -0400 To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> From: "Karlmarx Rajangam" <karlmarx.rajangam@xxxxxxxxxxxxxxxxxx> Subject: How to overrite default rendering toretain name=value attribute pairs Message-ID: <6B219F1619B1EB449A246CFA95A8CA29AC0432@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx > I have a problem. Basically I want to get an output with = selected=3D"true" for <option/>, instead of WITHOUT "true". Even though <option selected/> is a valid html, I need to get name=3Dvalue pair (selected=3Dtrue) as we = try to form & pass an XML input for some other validation.=20 We must create something like, <choice> <option selected =3D "true">cc</option> <!-- NOT THIS WAY <option selected>cc</option> --> <option>bbb</option> </choice> Tried 2 ways:(A) <xsl:for-each select=3D"OPTION"> inputXML +=3D '<option> <xsl:if test=3D"@SELECTED=3D'true'"><xsl:attribute name=3D"Selected">true</xsl:attribute></xsl:if><xsl:value-of = select=3D"."/> </option>\n'; </xsl:for-each> Results in <option selected>xxx</option>, without =3D"TRUE" thereby becoming an INVALID XML So, I tried (B),=20 <xsl:for-each select=3D"OPTION"> <xsl:choose> <xsl:when test=3D"@SELECTED=3D'true'">inputXML +=3D '<option selected=3D"true"><xsl:value-of select=3D"."/></option>\n';</xsl:when> <xsl:otherwise>inputXML +=3D '<option><xsl:value-of select=3D"."/></option>\n';</xsl:otherwise> </xsl:choose> </xsl:for-each>=09 thinking < will be rendered a <, but resulted only as=20 <option selected=3D"true">xxx</option> Any suggestion how I can fix this? =20 Thanks in advance, karl =20
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Error recovery from casti, Michael Kay | Thread | [xsl] XSLT / programmer position Ma, James Fuller |
Re: [xsl] Dynamic pipelining in XSL, Dimitre Novatchev | Date | Re: [xsl] Dynamic pipelining in XSL, Florent Georges |
Month |