[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Could not select the text() of both parent & child nodes simultaneously


Subject: Re: [xsl] Could not select the text() of both parent & child nodes simultaneously
From: Jack Bush <netbeansfan@xxxxxxxxxxxx>
Date: Thu, 17 Jun 2010 07:23:05 -0700 (PDT)

Hi David,
B 
( A )<xsl:template match="ns:p[ns:strong='World Cup
Competition:']">
B B B B B B B  <xsl:for-each select="text()|ns:a">
B B B B B B B B B  <team><xsl:value-of select="normalize-space()"/></team>
B B B B B B B B </xsl:for-each> 
B B B B B  </xsl:template> 
B Output
<team>Brasil<team>
<team>(30 goals)<team>
<team>Argentina<team>
<team>(25
goals)<team>
<team>Germany<team>
<team>(22 goals)<team>
<team>USA<team>
<team>(15 goals)<team>
c
( B ) <xsl:template match="ns:p[ns:strong='World
Cup Competition:']">
B B B B B B B B  <xsl:for-each
select="text()[normalize-space() != '']">
B B B B B B B B B B  <xsl:if
test="ns:a/text()[normalize-space() != '']">
B B B B B B B B B B B B 
<team><xsl:value-of select="concat(ns:a/normalize-space(),
normalize-space())"/></team>
B B B B B B B B B B B </xsl:if>
B B B B B B B B 
</xsl:for-each> 
B B B B B B  </xsl:template>
B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B
 B B B B B B B B  or
( C ) <xsl:template match="ns:p[ns:strong='World Cup
Competition:']">
B B B B B B B B  <xsl:for-each
select="text()[normalize-space() != '']">
B B B B B B B B B B  <xsl:if
test="not(empty(ns:a/text()))">
B B B B B B B B B B B B  <team><xsl:value-of
select="concat(ns:a/normalize-space(), normalize-space())"/></team>
B B B B B B B B B B  </xsl:if>
B B B B B B B B B </xsl:for-each> 
B B B B B B 
</xsl:template>
B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B
 B B B B B B B B B B B B B B B B B B B B  or
( D ) <xsl:template
match="ns:p[ns:strong='World Cup Competition:']">
B B B B B B B B 
<xsl:for-each select="text()[normalize-space() != '']">
B B B B B B B B B B 
<xsl:if test="not(empty(ns:a))">
B B B B B B B B B B B B  <team><xsl:value-of
select="concat(ns:a/normalize-space(), normalize-space())"/></team>
B B B B B B B B B B  </xsl:if>
B B B B B B B B B </xsl:for-each> 
B B B B B B 
</xsl:template> Output
Warning: on line 291 
The child axis starting at a text
node will never select anything
B 
Example ( A ) found the data but they need
to be at the same time. ie needs to reference <a> relative to <p> for each
iteration. ( B ), ( C) and ( D ) are attempts to lookup <a> relative to <p>
without success.
B 
I did provide the XML input document to this stylesheet
from my last response.
B 
Michael, any suggestion from yourself? You have been
very helpful in the past. Hope there will be some progress soon after so many
correspondences.
B 
Thanks,
B Jack



----- Original Message ----
From: David
Carlisle <davidc@xxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: Jack Bush
<netbeansfan@xxxxxxxxxxxx>
Sent: Thu, 17 June, 2010 12:34:38 AM
Subject: Re:
[xsl] Could not select the text() of both parent & child nodes simultaneously
On 16/06/2010 15:19, Jack Bush wrote:
> Hi David&B  Michael,
>
>> I am very
new to XML development, not to mention about XSLT and hesitates to move to
version 2.0 for 3 reasons:
>>
>> ( i ) 1.0 is sufficient for what I need to do
but there is bound to be better ways to do it in 2.0.
>
> <Saxon 9 never
executes XSLT 1, It only executes XSLT 2. If you give it an XSLt 1 stylesheet
it tries to emulate XSLT 1, but that is not the same thing.<Furthermore the
stylesheet you posted was inconsistent as it claimed at the top to be XSLT 1
but it used XSLT2 constructs which would generate an error<if used with an
XSLT 1 processor.
>
> Looks like I am using XSLT 2 processor without realizing
but not making use of its new functionalities yet.

You are using them though.
Your sample code has
../ns:a/normalize-space()
which is an XPath 2 expression,
It would be a syntax error to have a 
function call in that position in XPath
1.


>
>> ( ii ) XPath&B  XSLT 2.0 comes at a cost for recent release of Saxon
licensing models.
>
> <No it does not. The system you are using is free, open
source, and implements XSLT 2. The last version of saxon to implement xslt 1
was saxon 6.5.
>
> My understanding on recent installation manual was the open
source version (saxonhe9-2-0-5j.zip - Saxon9 Home Edition?
> ) does not
support XPath/XSLT features. This download does not have Path/XSLT jars such
as saxon9-xpath.jar, saxon9-jdom.jar supplied in Saxon 9.1. Otherwise, please
provide the correct link to download Saxon9 Home Edition.
>


It is not schmea
aware, but that is not the same as saying it does not 
implement xslt2 the
xslt 2 spec explitly defines two types of processors 
schema aware and basic.
Also (from 9.2 onwards, as a purely commercial 
aspect unrelated to which
language level is implemented the free one 
(now called home edition as you
say) doesn't support extension functions 
to the same extent as the commercial
version (or earlier versions of 
saxon's open source release such as 9.1)
>>B  ( iii ) Believes that a schema/DTD is required by the stylesheet. Not
familiar with how to set it up yet.
>
> <I'm not sure what you mean by this,
but probably it is a misunderstanding.
>
> How to turn off type checking in
XSLT 2.0 by updating<xsl:stylesheet version="2.0" (line 2) to prevent the
following exception from occurring:
>
>B  B  Error on line 83
>B  B  XPTY0004:
Cannot compare java-type:definition.Sport to xs:string

How did you get a java
typed value into xpath in the first place? You 
must have been using some
saxon-specifc API.

>
> The type checking did not take place
when<xsl:stylesheet version="1.0".
>
> This is a Java Application and would
like to keep as much core definition in Java and only use XSLT for
transformation purposes.
>
>>
>> Back to the original question, what is the
XPath statement in XSLT to get the content of both<a>B  (team) and<p>B 
(goals) at the sametime?
>>
>
> <As I said in my first reply, the source that
you posted is clearly not the source you used (as it is not XML) so I can not
guess what code you need to<process your original source. The source you
posted<would generate a fatal XML parse error before the XSLT engine started.
> <If you post a well formed XML source and say what you want it to be
converted to, then I'm sure someone will tell you the code you need.
>
> Here
goes the actual code as best as I could put it:

this version is well formed
9apart from the missing </html> but all the 
team names are inB  a so you just
want <xsl:for-each select="ns:a"> 
again it's hard to gues swhat code you need
given no example input but 
judging by earlier commenst it seems sometimes the
team isn't in a so 
perhaps you want
<xsl:for-each
select="ns:p/text()|ns:p/ns:a">

together with an xsl;strip-space
eleements="*" to get rid of indentation 
space for you. But that is only a
guess, given no input to test it on.

David
________________________________________________________________________
The
Numerical Algorithms Group Ltd is a company registered in England
and Wales
with company number 1249803. The registered office is:
Wilkinson House, Jordan
Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for
all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________


Current Thread
Keywords