Subject: Re: [xsl] Best practices - using vars From: xptm@xxxxxxx Date: Mon, 23 Aug 2004 19:02:24 +0100 |
I think i misunderstood the all thing, and the example isn't good as well... Let me try again: <xsl:variable name="form-base" select="/Formatos/Forms/Form[1]" /> returns a node that i can later use like this: <xsl:variable name="MasterTable" select="$form-base/MasterTable"/> But if i have <xsl:variable name="form-base"> <xsl:value-of select="/Formatos/Forms/Form[1]" /> </xsl:variable> then i have a string representation of the childnodes of /Formatos/Forms/Form[1], and i can't use it to further go down the tree? Quoting xptm@xxxxxxx: > In the particular case of xtabnode i realy want a node to be passed as > argument > to a Java method (that expects a org.w3c.dom.Node). > > In the other cases, tought, you're saying it's best to use > > <xsl:variable name="sqlInsert" select="sql:getStatement($MasterTable, $sql, > $where, $where, $xtabnode, 'I' )" /> > > instead of > > <xsl:variable name="sqlInsert"> > <xsl:value-of select="sql:getStatement($MasterTable, $sql, $where, > $where, > $xtabnode, 'I' )" /> > > because the first returns a string and the second a node with a node text > that > contains a string? > > Did i understand correctly? > > > > Quoting David Carlisle <davidc@xxxxxxxxx>: > > > > > > What is the cost of using vars? I'm doing this, for instance: > > > > higher if you use them as you have with content rather than a select > > attribute. > > > > > > <xsl:variable name="xtabnode"> > > <xsl:value-of > > > select="document(concat('.\DicionarioXml\',$MasterTable,'.xml'))/Estrutura/Ta belas/Tabela[Nome=$MasterTable]"/> > > </xsl:variable> > > > > produces a result tree fragment with a root node and child a text node > > with string value the string you want. When this result tree fragment is > > used, it has to be coerced back to a string. > > > > <xsl:variable name="xtabnode"> > > > > > select="document(concat('.\DicionarioXml\',$MasterTable,'.xml'))/Estrutura/Ta belas/Tabela[Nome=$MasterTable]"/> > > > > > > is less to type and makes the variable have (a pointer to) the Tabela > > node in the specified document. > > > > or perhaps > > > > > > <xsl:variable name="xtabnode"> > > > > > select="string(document(concat('.\DicionarioXml\',$MasterTable,'.xml'))/Estru tura/Tabelas/Tabela[Nome=$MasterTable])"/> > > > > in which case the variable holds the string value itself. > > > > similarly all your other variable declarations should have select= > > > > David > > > > ________________________________________________________________________ > > This e-mail has been scanned for all viruses by Star Internet. The > > service is powered by MessageLabs. For more information on a proactive > > anti-virus service working around the clock, around the globe, visit: > > http://www.star.net.uk > > ________________________________________________________________________ > > > > > > > > > > > > O SAPO ja esta livre de vmrus com a Panda Software, fique vocj tambim! > Clique em: http://antivirus.sapo.pt > > O SAPO ja esta livre de vmrus com a Panda Software, fique vocj tambim! Clique em: http://antivirus.sapo.pt
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Best practices - using va, xptm | Thread | Re: [xsl] Best practices - using va, David Carlisle |
Re: [xsl] Best practices - using va, xptm | Date | Re: [xsl] FO: Forcing a page break/, G. Ken Holman |
Month |