You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by jo...@duploclique.com on 2003/05/10 17:09:42 UTC
XSL problem...again :(
I've tried to sent this email to the XSL list (XSL-List@lists.mulberrytech.com) but with no sucess...The mail does not appears in the list, I've sucessufly registered at that list :|
If anyone here could help that would be much appreciated
Thanks everyone
_____________________________
First of all I would like to the creators of this mailing list :)
I have this XSL code and I would like to parse an authors tag of a XML document. The source file is like this:
<DocSum>
<Id>12673722</Id>
(...)
<Item Name="Authors" Type="String">Kahle B, Hoffend J, Wacker J, Hartschuh W</Item>
(...)
</DocSum>
I want to parse the Athors parameter, and get something like that:
<authors>
<name>Kahle B</name>
<name>Hoffend J</name>
<name>Wacker J</name>
(...)
</authors>
For that I'm doing this: to each ID from the a list of ID's we're getting the ID value and that grab the parameter that contains "Kahle B, Hoffend J, Wacker J, Hartschuh W"
like the above example.
<authors>
<xsl:for-each select="idlist/id">
<xsl:variable name="aux"><xsl:value-of select="."/></xsl:variable>
<name><xsl:value-of select="/DocSum[Id=$aux]/Item[@Name='Authors']"/></name>
<xsl:for-each/>
</authors>
The problem is that the $aux variable isn't working inside the XPath expression :|
Can anyone tell me why?
After we grab the variable containing all the author's name, is it possible to parse the variable using just XSL?
Many Thanks
Joao Cesar
joaocesar@duploclique.com
Computer Science Student @ Universidade de Lisboa, PORTUGAL
Re: XSL problem...again :(
Posted by João César <jo...@duploclique.com>.
It's everything working :)
It was our problem because we weren't giving the right source data to have
the wanted results :| So the use of $aux was ok. We changed the constructor
althought... :)
Many thanks again :)
Joao Cesar
joaocesar@duploclique.com
Computer Science Student @ Universidade de Lisboa, PORTUGAL
----- Original Message -----
From: <jo...@duploclique.com>
To: <co...@xml.apache.org>
Sent: Saturday, May 10, 2003 5:30 PM
Subject: Re: XSL problem...again :(
> Many many many thanks :)
>
> The code you supllied worked just fine, without any changes!
>
> > I don't understand your logic behind this code. What says you that $aux
> > is not working? In general don't use the variable construct as above,
> > but use <xsl:variable name="aux" select=."/>.
>
> Yes that's the problem we're not getting the $aux value, we will try that
> constructor althought.
>
> >Otherwise you create a
> > Result Tree Fragment, which can't be handled like a node-set
> > (http://www.w3.org/TR/xslt#section-Result-Tree-Fragments). Maybe this or
> > an explicit string conversion ( [string(Id) = string($aux)] ) already
> > solves your problem.
>
> We're trying to fix that, and we're reviewing our XML source data because
> it's a little bit confusing...
>
> I'll do some testing and I'll report it here
>
> thanks again!
>
> Joao Cesar
> joaocesar@duploclique.com
>
> Computer Science Student @ Universidade de Lisboa, PORTUGAL
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: XSL problem...again :(
Posted by jo...@duploclique.com.
Many many many thanks :)
The code you supllied worked just fine, without any changes!
> I don't understand your logic behind this code. What says you that $aux
> is not working? In general don't use the variable construct as above,
> but use <xsl:variable name="aux" select=."/>.
Yes that's the problem we're not getting the $aux value, we will try that
constructor althought.
>Otherwise you create a
> Result Tree Fragment, which can't be handled like a node-set
> (http://www.w3.org/TR/xslt#section-Result-Tree-Fragments). Maybe this or
> an explicit string conversion ( [string(Id) = string($aux)] ) already
> solves your problem.
We're trying to fix that, and we're reviewing our XML source data because
it's a little bit confusing...
I'll do some testing and I'll report it here
thanks again!
Joao Cesar
joaocesar@duploclique.com
Computer Science Student @ Universidade de Lisboa, PORTUGAL
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: XSL problem...again :(
Posted by Joerg Heinicke <jo...@gmx.de>.
joaocesar@duploclique.com wrote:
> I've tried to sent this email to the XSL list
> (XSL-List@lists.mulberrytech.com
> <ma...@lists.mulberrytech.com>) but with no sucess...The mail
> does not appears in the list, I've sucessufly registered at that list :|
http://www.mulberrytech.com/xsl/xsl-list/, at the end of the page.
> I have this XSL code and I would like to parse an authors tag of a XML
> document. The source file is like this:
>
> <DocSum>
> <Id>12673722</Id>
> (...)
> <Item Name="Authors" Type="String">Kahle B, Hoffend J, Wacker J,
> Hartschuh W</Item>
> (...)
> </DocSum>
>
> I want to parse the Athors parameter, and get something like that:
>
> <authors>
> <name>Kahle B</name>
> <name>Hoffend J</name>
> <name>Wacker J</name>
> (...)
> </authors>
<xsl:template match="Item[@Name='Authors']">
<authors>
<xsl:call-template name="getAuthors">
<xsl:with-param name="AuthorString" select="normalize-space()"/>
</xsl:call-template>
</authors>
</xsl:template>
<xsl:template name="getAuthors">
<xsl:param name="AuthorString" select="''"/>
<xsl:choose>
<xsl:when test="contains($AuthorString, ',')">
<name>
<xsl:value-of select="substring-before($AuthorString, ',')"/>
</name>
<xsl:call-template name="getAuthors">
<xsl:with-param name="AuthorString"
select="substring-after($AuthorString, ',')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<name>
<xsl:value-of select="$AuthorString"/>
</name>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
> For that I'm doing this: to each ID from the a list of ID's we're
> getting the ID value and that grab the parameter that contains "Kahle
> B, Hoffend J, Wacker J, Hartschuh W"
> like the above example.
>
> <authors>
> <xsl:for-each select="idlist/id">
> <xsl:variable name="aux"><xsl:value-of
> select="."/></xsl:variable>
> <name><xsl:value-of
> select="/DocSum[Id=$aux]/Item[@Name='Authors']"/></name>
> <xsl:for-each/>
> </authors>
>
> The problem is that the $aux variable isn't working inside the XPath
> expression :|
I don't understand your logic behind this code. What says you that $aux
is not working? In general don't use the variable construct as above,
but use <xsl:variable name="aux" select=."/>. Otherwise you create a
Result Tree Fragment, which can't be handled like a node-set
(http://www.w3.org/TR/xslt#section-Result-Tree-Fragments). Maybe this or
an explicit string conversion ( [string(Id) = string($aux)] ) already
solves your problem.
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org