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

Re: Required item type of value of variable $images is

Subject: Re: Required item type of value of variable $images is element(); supplied value has item type text()
From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 31 Mar 2019 19:28:11 -0000
Re:  Required item type of value of variable $images is
Thatbs not how the as attribute is supposed to work. It serves as as a "treat as" assertion, not so much as a filter that drops nodes from a sequence.

You can filter out unwanted whitespace-only text nodes in at least 3 ways:

1. by declaring xsl:strip-space for certain contexts

2. by defining "empty" templates in ac:image mode that match text()[not(normalize-space())] in certain contexts

3. or by doing something like this:
<xsl:variable name="prelim" as="item()*">
  <xsl:apply-templates mode="ac:image"/>
</xsl:variable>
<xsl:variable name="images"as="element()*" select="$prelim/self::*"/>

Gerrit


On 31.03.2019 21:00, Martynas JuseviD ius martynas@xxxxxxxxxxxxx wrote:
Hi,

I have a simple snippet like this

         <xsl:variable name="images" as="element()*">
             <xsl:apply-templates mode="ac:image"/>
         </xsl:variable>

Sometimes the ac:image templates will return an <img> element,
sometimes nothing.

In the case where there are no elements in the variable, I get an error

     Required item type of value of variable $images is element();
supplied value has item type text()

When I output the text, it's just whitespace.

The element() cardinality is *, so why can't the processor just
suppress the whitespace and treat the variable content as zero
elements?

The processor is Saxon-CE BTW.

Martynas
atomgraph.com



-- Gerrit Imsieke GeschC$ftsfC<hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

GeschC$ftsfC<hrer / Managing Directors:
Gerrit Imsieke, Svea Jelonek, Thomas Schmidt

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.