[ESW Wiki] Update of "its0505ReqUniqueID" by fsasaki

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "ESW Wiki" for change notification.

The following page has been changed by fsasaki:
http://esw.w3.org/topic/its0505ReqUniqueID


------------------------------------------------------------------------------
  
   * Using URIs, where the in-document ID is a fragment identifier.
  
+ The requirement can be fulfiled by the following XQuery user defined function:
+ 
+ {{{
+ query version "1.0";
+ declare namespace eg = "http://example.com#";
+ declare function eg:checkUniqueness  
+ ($inputSequence as item()*) as item()*
+ {
+ for $node in $inputSequence//element()
+ for $comparedNodes in $inputSequence//element() except $node
+ where $comparedNodes/@id = $node/@id
+ return "Error! ID is already defined!"
+ };
+ }}}
+ 
+ The same function can be defined in XSLT:
+ 
+ {{{
+ <xsl:function name="eg:checkUniqueness" as="item()*">
+  <xsl:param name="inputSequence" as="item()*"/>
+   <xsl:for-each select="$inputSequence//element()">
+   <xsl:variable name="node" select="."/>
+  <xsl:variable name="comparedNodes" select="$inputSequence//element() except $node"/>
+  <xsl:for-each select="$comparedNodes[@id = $node/@id]">
+  <xsl:text>Error! ID is already defined!</xsl:text>  
+  </xsl:for-each>
+  </xsl:for-each>
+ </xsl:function> 
+ }}}
+ 

Received on Thursday, 21 July 2005 07:11:46 UTC