[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: RE: variable assignment and disable-output-escapin
HI, Using C++ I do add a document as parameter and refer to it in XSL as: <xslt:param name="data"/> ... <xslt:value-of select="$data//field[ @id = current()/subform[ @id = 'request' ]/@subjectid ]"/> Don't know whether node-set sis expected or a single node (doc-root) Michel On Mon, Apr 11, 2011 at 8:26 PM, OHalloran, Martin <Martin.OHalloran@xxxxxxxxx> wrote: > Michael , > Thank you for your detailed response .I had tried to pass the Document Node on my first attempt and then went on to try what I had posted but > when I pass the Document Node .I get a conversion error . > > ERROR: 'Invalid conversion from 'com.sun.org.apache.xerces.internal.dom.Deferre > dElementImpl' to 'node-set'.' > javax.xml.transform.TransformerException: java.lang.RuntimeException: Invalid co > nversion from 'com.sun.org.apache.xerces.internal.dom.DeferredElementImpl' to 'n > ode-set'. > at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transfor > m(TransformerImpl.java:651) > > I also applied the exsl:node-set to the variable but same Exception . > <xsl:for-each select="exsl:node-set($tp)//select/option"> > > <xsl:text>Printing value</xsl:text> > <xsl:value-of select="."/> > <xsl:value-of select="@value"/> > > </xsl:for-each> > > I have seen a few postings on this error but I have seen no solution . > > Thanks again for your help . > > > > -----Original Message----- > From: Michael Kay [mailto:mike@xxxxxxxxxxxx] > Sent: Monday, April 11, 2011 2:14 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: RE: variable assignment and disable-output-escaping > > On 11/04/2011 04:05, OHalloran, Martin wrote: >> Hi thanks for reading . >> I have the following xml which is passed as a parameter to my xsl file for transformation from a jsp . >> tradingPartnerXML = >> "<select>"+ >> "<option value='711'>711: Compression Disabled</option>"+ >> "<option value='729'>729: Compression Enable</option>"+ >> "</select>"; > It sounds as if you are passing this as a string, not as an XML document. >> when I receive it the tags< > are replaced with< and> . > That's because no-one has told the XSLT processor that this string is to be treated as XML. It thinks the "<" and ">" are ordinary characters, and therefore need to be escaped. >> I then do the following and it looks good . >> <xsl:message>Trading partner xml is:<xsl:value-of >> select="$tradingPartnerXML" >> disable-output-escaping="yes"/></xsl:message> > The output of xsl:message is very processor dependent, so this doesn't prove very much; but it's not unreasonable that this should cause the serializer used by the xsl:message instruction to output "<" as "<" > instead of as "<". >> I then want to create another variable from the contents of the tradingPartnerXML so I do the following . >> <xsl:variable name="tradingPartner"> >> <xsl:text disable-output-escaping="yes"> >> >> <xsl:copy-of select="$tradingPartnerXML"/> >> >> </xsl:text> >> </xsl:variable> > This isn't going to work. disable-output-escaping is an instruction to the serializer, and it only works when you are serializing. (Well, there's more to it than that. There was an infamous erratum to the XSLT 1.0 specification than said disable-output-escaping was "sticky", i.e. > if you applied it to a character and held that character in a variable, then this property of the character would be remembered when the time came to serialize. However, the property won't affect a test like (contains($tradingPartner, '>')), and it probably won't be copied when you copy the variable to another variable. And this erratum was effectively rescinded in XSLT 2.0). > >> Thanks again for you help .If there is another soulution I would like to hear it . >> > The answer is perfectly simple: parse the XML before you pass it to the XSLT processor. Pass it an XML document node, not a string containing lexical XML with angle brackets. > > Michael Kay > Saxonica > > > This communication is the property of Qwest and may contain confidential or > privileged information. Unauthorized use of this communication is strictly > prohibited and may be unlawful. If you have received this communication > in error, please immediately notify the sender by reply e-mail and destroy > all copies of the communication and any attachments.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|