Re: [xsl] variable question

Subject: Re: [xsl] variable question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 31 Aug 2004 13:33:08 +0100
Hi Bruce,

> I'm getting the following error on the below:
> 	An empty sequence is not allowed as the first argument of 
> mods:reftype()
> What does this mean in this context?  That the function is getting 
> confused trying to find the right node?

Sorry, my fault. You'd indicated that you have two kinds of
<mods:titleInfo> elements: ones with <mods:relatedItem> parents and
ones without. You wanted the different <mods:titleInfo> elements
treated differently. I'd given you XSLT 1.0 code to deal with that,
but when I transposed it to XSLT 2.0, I'd overlooked the fact that the
parameter you were passing into the mods:reftype() function might be
an empty sequence. (This didn't matter in the XSLT 1.0 code because
you never declare types in XSLT 1.0.)

One solution is to declare the parameter of the function so that it
accepts an empty sequence. Instead of:

  <xsl:param name="relatedItem" as="element(mods:relatedItem)" />

which says that $relatedItem must be one-and-only-one
<mods:relatedItem> element, use:

  <xsl:param name="relatedItem" as="element(mods:relatedItem)?" />

which says that $relatedItem must be zero-or-one <mods:relatedItem>

Another solution would be not to call the function if the parent of
the <mods:titleInfo> element isn't a <mods:relatedItem> element.


Jeni Tennison

Current Thread