Subject: Re: [xsl] Dumping a variable From: Aidan Lister <aidanis@xxxxxxxxx> Date: Mon, 6 Dec 2004 14:06:22 +1100 |
Hi Michael, Dump has certain connotations to a programmer, forgive me for not explaining it better. Dump is a term we use, mainly for debugging, where the raw contents of something are "dumped" or displayed to the screen. My variable contains a nodeset. I want to view the nodeset it contains as if it were XML, I don't want the nodeset to be transformed (this is what I meant by parsed, sorry). I tried using message and copy-of, however only the text and not the nodeset were displayed. Hi Marian, Thanks for your invaluable advice, however variable-dump doesn't seem to do anything! Kind Regards, Aidan On Sun, 5 Dec 2004 18:49:48 -0800 (PST), Marian Olteanu <mou_softwin@xxxxxxxxx> wrote: > > > > --- Michael Kay <mike@xxxxxxxxxxxx> wrote: > > > > > > > I have a variable, I'd like to dump the XML contained in that variable > > > without applying any parsing (debugging purposes). > > > > I assume "dump" means "display" rather than "delete"? > > > > What do you mean by saying that the variable contains XML? In XSLT 1.0 a > > variable can contain a node-set, or it can contain a string. In both cases > > you can display the value of the variable using > > > > <xsl:message><xsl:copy-of select="$var"/></xsl:message> > > > > and no parsing will be involved. In fact, there is no way to invoke XML > > parsing from standard XSLT, so I don't understand your concern. > > > > Michael Kay > > http://www.saxonica.com/ > > > Note that the result of xsl:message differs from implementation to implementation. For example, > MSXML silently discards your xsl:message that has no terminate="yes", so this solution would work > only if you use it like: > <xsl:message terminate="yes"><xsl:copy-of select="$var"/></xsl:message> > This thing is stated at > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmrefxslmessageelement.asp > : > <<Attributes > terminate > Specifies whether the transformation should terminate upon executing this instruction. This > attribute can have one of two string values: "yes" or "no". When the terminate attribute is set to > "yes", the content of the element is displayed as the part of the system-level error message, and > the transformation terminates. When it is set to "no", the transformation proceeds, ignoring the > error message. The default value is "no". >> > > Another solution: dump your variable in the output file (if you output XML, not text): > <variable-dump name="$var1"><xsl:copy-of select="$var1"/></variable-dump> > ... > <variable-dump name="$var2"><xsl:copy-of select="$var2"/></variable-dump> > > so later you can look into the output file and look for variable-dump elements. > I recomend you to use this method conditionally: set a parameter of your XSLT file (i.e.: debug) > and use like this: > <xsl:if test="$debug"> > <variable-dump name="$var1"><xsl:copy-of select="$var1"/></variable-dump> > </xsl:if> > This way, you can switch easily between debug mode and production mode. > > ===== > Marian > http://www.utdallas.edu/~mgo031000/ > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - You care about security. So do we. > http://promotions.yahoo.com/new_mail
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Dumping a variable, Marian Olteanu | Thread | Re: [xsl] Dumping a variable, Marian Olteanu |
RE: [xsl] Dumping a variable, Marian Olteanu | Date | [xsl] Dictionary Headers, tsterlin |
Month |