Link to home
Start Free TrialLog in
Avatar of ShaileshShinde
ShaileshShindeFlag for India

asked on

XPTY0004: A sequence of more than one item is not allowed as the first argument of string-length()

Hello Expert,

I am getting an error for the xsl code..

<xsl:if test="string-length($destination) &gt; 0"> where destination contains like...("mx.events.AIREvent.APPLICATION...", "mx.events.AIREvent.APPLICATION...", ...)

While processing it gives an error...

XPTY0004: A sequence of more than one item is not allowed as the first argument of string-length().

can you pls suggest the alternative for the line of code?

Thanks,
Shailesh
Avatar of ShaileshShinde
ShaileshShinde
Flag of India image

ASKER

Hello Expert,

There is one more query with the same xslt...

the code is like...

<xsl:variable name="product" select="./@product|./@class | ./@outputclass"/>
            <xsl:if test="string-length($product)=0 or not($product=concat($hiddenProductName,'only'))">
                  <xsl:value-of disable-output-escaping="yes" select="'&lt;b&gt;'"/>
                  <xsl:call-template name="processTags"/>
                  <xsl:value-of disable-output-escaping="yes" select="'&lt;/b&gt;'"/>
            </xsl:if>

The error is appearing for <xsl:variable name="product" select="./@product|./@class | ./@outputclass"/>
as it contains more than one sequence...

Can you pls suggest the what change will required for the same?

Thanks,
Shailesh
Avatar of Gertone (Geert Bormans)
always the same problem,
If you have a selection of nodes, there is no automatic concatenation,
and a string-length requires one single string-type (XPath2 is very tricky about types)
If you want a concatenation, you should use string-join
<xsl:variable name="product" select="string-join((./@product|./@class | ./@outputclass), '')"/>

I don't like the disable-output-encoding here
                  <xsl:value-of disable-output-escaping="yes" select="'&lt;b&gt;'"/>
                  <xsl:call-template name="processTags"/>
                  <xsl:value-of disable-output-escaping="yes" select="'&lt;/b&gt;'"/>

why don't you do this?
                  <b>
                      <xsl:call-template name="processTags"/>
                  </b>


your first example could be done the same way,

cheers

Geert
Hello expert,

Is this applicable for ...<xsl:variable name="firstPassToken" select="substring-before($dest,concat('.',$lastToken))"/>

Thanks,
Shailesh
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello expert,

<xsl:variable name="firstPassToken" select="substring-before(string-join($dest ,concat('.',$lastToken), ''))"/> gives an error saying string-join() must have two arguments.

Thanks,
Shailesh
this seems more like it
<xsl:variable name="firstPassToken" select="substring-before(string-join($dest , ''),concat('.',$lastToken))"/>