[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPTY0004: A sequence of more than one item is not

Subject: Re: XPTY0004: A sequence of more than one item is not allowed as the second argument of concat()
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 09 Aug 2010 15:23:12 +0100
Re:  XPTY0004: A sequence of more than one item is not
Change

concat(./normalize-space(),./following-sibling::text()[normalize-space()])

to

concat(./normalize-space(),./following-sibling::text()[normalize-space()][1])

So you only select the first following sibling.

Michael Kay
Saxonica



On 09/08/2010 15:04, Jack Bush wrote:
Hi All,
I am getting the following error message when trying to transform a worldcup.xml
using worldcup.xsl stylesheet:

  Error on line 166
   XPTY0004: A sequence of more than one item is not allowed as the second
argument of concat()
   at xsl:for-each (#165) processing /html/body[1]/div[2]/p[11]/a[1]
   at xsl:apply-templates (#84) processing /html/body[1]/div[2]/p[11]
   at xsl:apply-templates (#20) processing /html/body[1]/div[2]
   at xsl:for-each (#19) processing
/html/body[1]/div[2]/table[1]/tr[1]/td[1]/a[1]
SEVERE: null
; SystemID: ; Line#: 166; Column#: -1
net.sf.saxon.trans.XPathException: A sequence of more than one item is not
allowed as the second argument of concat()

Below is the worldcup.xsl:


<xsl:template match="/"> <worldcup> <xsl:apply-templates select="document(concat(Spain.xml)/ns:html/ns:body/ns:div[@id='content']"> </xsl:apply-templates> </worldcup> </xsl:template> <xsl:template match="/ns:html/ns:body/ns:div[@id='content']"> <xsl:variable name="worldcup-team" select="//ns:p[ns:strong='World Cup Team:']"/> <xsl:apply-templates select="$ worldcup-team"/> <xsl:if test="empty($worldcup-team)"> <team>Unknown</team> </xsl:if> <xsl:template match="ns:p[ns:strong=''World Cup Team:']"> <xsl:for-each select="ns:a"> <team><xsl:value-of select="concat(./normalize-space(),./following-sibling::text()[normalize-space()])"/></team>

</xsl:for-each>
</xsl:template>
<xsl:template match="ns:p"/>
</xsl:stylesheet>
The snippet of worldcup.xml are as follows:


<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml">
<head>
b&b&
</head>
<body onload="loadMapLocation(-46.1240, 149.543, 49, 1); setClockTime(2008, 01,
19, 12, 36, 01); setInterval('updateTime()', 2000);" onunload="GUnload();">
<a shape="rect" name="top" />
<div id="content">
<hr/>
<h1>World Cup Competition</h1>
<p>
</p>
<p>
<strong>World Cup Team:</strong>
<br clear="none" />
<a shape="rect" href="http://www.abc.com/team/spain.html?aid=427231">Spain</a>


(30 goals)
<br clear="none" />
<a shape="rect" href=" www.abc.com/team/denmark.html?aid=427231">Denmark</a>
(25 goals)
<br clear="none" />
<a shape="rect" href=" www.abc.com/team/Germany.html?aid=427231">Germany</a>
(22 goals)
<br clear="none" />
<a shape="rect" href=" www.abc.com/team/england.html?aid=427231">United
Kingdom</a>
(15 goals)
<br clear="none" />
b&b&
</p>
<p>
</p>
</div>
</body>
The desire output would be:


  <team>Spain(30 goals)<team>
  <team>Denmark(25 goals)<team>
  <team>Germany(22 goals)<team>
  <team>United Kingdom (15 goals)<team>


Worldcup.xsl has been successful in transforming worldcup.xml, if it was loaded as a main document in the past.

I am using JDOM and Saxon 9.1 to carry out the transformation on Windows XP.
Thanks in advance,


Jack

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.