[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Could not select the text() of both parent & child
Hi David & 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. > ( ii ) XPath& 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. B 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. >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 XPTY0004: Cannot compare java-type:definition.Sport to xs:string The type checking did not take place when <xsl:stylesheet version="1.0". B 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> (team) and<p> (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: <html xmlns="http://www.w3.org/1999/xhtml"B xmlns:html="http://www.w3.org/1999/xhtml" > <head> B b&b& </head> <body onload="loadMapLocation(-46.1240, 149.543, 49, 1); setClockTime(2008, 01, 19, 12, 36, 01); setInterval('updateTime()', 2000);"B onunload="GUnload();" > <a shape="rect"B name="top" /> <div id="container" > <div id="header" > <div id="postmark" /> <a shape="rect"B class="imglink"B href="http://www.abc.com/" > <img id="logoimg"B src="http://www.abc.com/images/world-cup.gif"B width="192"B height="33"B alt="World Cup Logo" /> </a> <hr/> </div> <h1>World Cup Competition</h1> <p> </p> <p> <strong>World Cup Team:</strong> <br clear="none" /> <a shape="rect"B href="http://www.abc.com/team/brasil.html?aid=427231" >Brasil</a> (30 goals) <br clear="none" /> <a shape="rect"B href=" www.abc.com/team/argentina.html?aid=427231" >Argentina</a>(25 goals) <br clear="none" /> <a shape="rect"B href=" www.abc.com/team/Germany.html?aid=427231" >Germany</a>(22 goals) <br clear="none" /> <a shape="rect"B href=" www.abc.com/team/usa.html?aid=427231" >United States of America</a>(15 goals) <br clear="none" /> b&b& </p> <p> </p> </div> </body> B <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="ns"> B <xsl:template match="/"> <group> b&b&.. <xsl:template match="ns:p[ns:strong='World Cup Team:']"> B <xsl:for-each select="text()[normalize-space() != '']"> B B B <team><xsl:value-of select="concat(../ns:a/normalize-space(), normalize-space())"/></team> B </xsl:for-each> </xsl:template> b&b&b& </group> B <xsl:template match="ns:p"/> B </xsl:stylesheet> B </html> B Thanks, B Jack ----- Original Message ---- From: David Carlisle <davidc@xxxxxxxxx> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Cc: Jack Bush <netbeansfan@xxxxxxxxxxxx> Sent: Wed, 16 June, 2010 6:47:03 PM Subject: Re: Could not select the text() of both parent & child nodes simultaneously On 16/06/2010 09:30, Jack Bush wrote: > Hi David, > > 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. > ( 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. > ( 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. > > 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. 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. ________________________________________________________________________
|
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
|