xsl-list
[Top] [All Lists]

Re: [xsl] question about generate-id()

2010-08-07 11:57:15

I don't follow your argument, Dave.  An input document's identifiers
have *no* relationship to generate-id().
Lets agree to differ on that one then Ken.


Well, Ken is saying what the spec says, and Dave is saying what he would like it to say instead, and it's not logically inconsistent that these two things should be different.

There are certainly use cases where a function generate-new-id() specified as Dave would like might be useful. You could code it like this:

<xsl:function name="generate-new-id" as="xs:string">
<xsl:param name="node" as="node()"/>
<xsl:sequence select="generate-new-id(0)"/>
</xsl:function>

<xsl:function name="generate-new-id" as="xs:string">
<xsl:param name="node" as="node()"/>
<xsl:param name="seq" as="xs:integer"/>
<xsl:variable name="gid" select="concat(generate-id($node), '-', $seq)"/>
<xsl:sequence select="if (exists($node/id($gid))) then generate-new-id($node, $seq+1) else $gid"/>
</xsl:function>

If you want that function, you are welcome to use it. If you prefer the generate-id() that's in the standard function library, then use that.

Michael Kay
Saxonica
<xsl:sequence select="generate-unique-id(0)"/>
</xsl:function>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--