Hi,
I need to remove the punctuations(,.:;) from the title element . Using the 
following code  in record loader content module:
xquery version "1.0-ml";

declare variable $URI as xs:string external;
declare variable $XML-STRING as xs:string external;
declare variable $NAMESPACE as xs:string external;
declare variable $LANGUAGE as xs:string external;
declare variable $ROLES-EXECUTE as xs:string external;
declare variable $ROLES-INSERT as xs:string external;
declare variable $ROLES-READ as xs:string external;
declare variable $ROLES-UPDATE as xs:string external;
declare variable $COLLECTIONS as xs:string external;
declare variable $SKIP-EXISTING as xs:boolean external;
declare variable $ERROR-EXISTING as xs:boolean external;
declare variable $FORESTS as xs:string external;

declare function common:removepunct($node as node(), $rule as element(rule)) as 
node() {


        for $n in $node return typeswitch ($n)
          case element(title) return element {

            fn:QName(fn:namespace-uri($n), fn:local-name($n) )
          } {
                    $n/@*,
            fn:normalize-space(fn:replace(fn:data($n/title), 
$rule/punctuations/text(), '')),
            common:removepunct($n/node(),$rule) }
          case document-node() return document { common:removepunct($n)/node(), 
$rule) }
  default return $n
};

xdmp:document-insert(
  $URI,
  common:removepunct(xdmp:unquote(
    $XML-STRING, $rule $NAMESPACE,
    if ($LANGUAGE) then concat('default-language=', $LANGUAGE) else ()

  )),
  (
    for $r in tokenize($ROLES-EXECUTE, ',')[. ne '']
    return xdmp:permission($r, 'execute'),
    for $r in tokenize($ROLES-INSERT, ',')[. ne '']
    return xdmp:permission($r, 'insert'),
    for $r in tokenize($ROLES-READ, ',')[. ne '']
    return xdmp:permission($r, 'read'),
    for $r in tokenize($ROLES-UPDATE, ',')[. ne '']
    return xdmp:permission($r, 'update')
  ),
  tokenize($COLLECTIONS, ',')[. ne ''],
  0,
  for $id in tokenize($FORESTS, ',')[. ne '']
  return xs:unsignedLong($id)
)

But this code is not removing the punctuations. Please let me know where I am 
wrong.

Thanks,
Pragya

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not 
to copy, disclose, or distribute this e-mail or its contents to any other 
person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken 
every reasonable precaution to minimize this risk, but is not liable for any 
damage 
you may sustain as a result of any virus in this e-mail. You should carry out 
your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this 
e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to