You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(57) |
Apr
(103) |
May
(164) |
Jun
(139) |
Jul
(173) |
Aug
(196) |
Sep
(221) |
Oct
(333) |
Nov
(214) |
Dec
(88) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(163) |
Feb
(165) |
Mar
(98) |
Apr
(93) |
May
(199) |
Jun
(118) |
Jul
(200) |
Aug
(212) |
Sep
(185) |
Oct
(297) |
Nov
(437) |
Dec
(272) |
2006 |
Jan
(542) |
Feb
(329) |
Mar
(267) |
Apr
(332) |
May
(267) |
Jun
(130) |
Jul
(161) |
Aug
(348) |
Sep
(166) |
Oct
(305) |
Nov
(173) |
Dec
(173) |
2007 |
Jan
(199) |
Feb
(118) |
Mar
(133) |
Apr
(200) |
May
(208) |
Jun
(146) |
Jul
(198) |
Aug
(146) |
Sep
(187) |
Oct
(182) |
Nov
(181) |
Dec
(83) |
2008 |
Jan
(252) |
Feb
(124) |
Mar
(124) |
Apr
(101) |
May
(143) |
Jun
(122) |
Jul
(129) |
Aug
(60) |
Sep
(80) |
Oct
(89) |
Nov
(54) |
Dec
(112) |
2009 |
Jan
(88) |
Feb
(145) |
Mar
(105) |
Apr
(164) |
May
(123) |
Jun
(154) |
Jul
(374) |
Aug
(341) |
Sep
(219) |
Oct
(137) |
Nov
(373) |
Dec
(240) |
2010 |
Jan
(197) |
Feb
(270) |
Mar
(253) |
Apr
(150) |
May
(102) |
Jun
(51) |
Jul
(300) |
Aug
(512) |
Sep
(254) |
Oct
(258) |
Nov
(288) |
Dec
(143) |
2011 |
Jan
(238) |
Feb
(179) |
Mar
(253) |
Apr
(332) |
May
(248) |
Jun
(255) |
Jul
(216) |
Aug
(282) |
Sep
(146) |
Oct
(77) |
Nov
(86) |
Dec
(69) |
2012 |
Jan
(172) |
Feb
(234) |
Mar
(229) |
Apr
(101) |
May
(212) |
Jun
(267) |
Jul
(129) |
Aug
(210) |
Sep
(239) |
Oct
(271) |
Nov
(368) |
Dec
(220) |
2013 |
Jan
(179) |
Feb
(155) |
Mar
(59) |
Apr
(47) |
May
(99) |
Jun
(158) |
Jul
(185) |
Aug
(16) |
Sep
(16) |
Oct
(7) |
Nov
(20) |
Dec
(12) |
2014 |
Jan
(21) |
Feb
(17) |
Mar
(18) |
Apr
(13) |
May
(27) |
Jun
(15) |
Jul
(19) |
Aug
(22) |
Sep
(30) |
Oct
(16) |
Nov
(19) |
Dec
(16) |
2015 |
Jan
(14) |
Feb
(24) |
Mar
(33) |
Apr
(41) |
May
(14) |
Jun
(80) |
Jul
(53) |
Aug
(8) |
Sep
(7) |
Oct
(15) |
Nov
(13) |
Dec
(2) |
2016 |
Jan
(22) |
Feb
(12) |
Mar
(30) |
Apr
(6) |
May
(33) |
Jun
(16) |
Jul
(8) |
Aug
(20) |
Sep
(12) |
Oct
(18) |
Nov
(12) |
Dec
(11) |
2017 |
Jan
(24) |
Feb
(26) |
Mar
(47) |
Apr
(23) |
May
(19) |
Jun
(14) |
Jul
(28) |
Aug
(30) |
Sep
(17) |
Oct
|
Nov
|
Dec
|
2019 |
Jan
(1) |
Feb
(73) |
Mar
(90) |
Apr
(42) |
May
(116) |
Jun
(90) |
Jul
(127) |
Aug
(103) |
Sep
(56) |
Oct
(42) |
Nov
(95) |
Dec
(58) |
2020 |
Jan
(102) |
Feb
(31) |
Mar
(93) |
Apr
(60) |
May
(57) |
Jun
(45) |
Jul
(29) |
Aug
(32) |
Sep
(44) |
Oct
(86) |
Nov
(51) |
Dec
(71) |
2021 |
Jan
(44) |
Feb
(25) |
Mar
(78) |
Apr
(130) |
May
(64) |
Jun
(74) |
Jul
(21) |
Aug
(64) |
Sep
(40) |
Oct
(43) |
Nov
(21) |
Dec
(99) |
2022 |
Jan
(154) |
Feb
(64) |
Mar
(45) |
Apr
(95) |
May
(62) |
Jun
(48) |
Jul
(73) |
Aug
(37) |
Sep
(71) |
Oct
(27) |
Nov
(40) |
Dec
(65) |
2023 |
Jan
(89) |
Feb
(130) |
Mar
(124) |
Apr
(50) |
May
(93) |
Jun
(46) |
Jul
(45) |
Aug
(68) |
Sep
(62) |
Oct
(71) |
Nov
(108) |
Dec
(82) |
2024 |
Jan
(53) |
Feb
(76) |
Mar
(64) |
Apr
(75) |
May
(36) |
Jun
(54) |
Jul
(98) |
Aug
(137) |
Sep
(58) |
Oct
(177) |
Nov
(84) |
Dec
(52) |
2025 |
Jan
(70) |
Feb
(53) |
Mar
(72) |
Apr
(47) |
May
(88) |
Jun
(49) |
Jul
(86) |
Aug
(41) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Wolfgang M. M. <wol...@us...> - 2004-09-26 14:41:49
|
Update of /cvsroot/exist/jEditAdapter/src/existadapter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31737/src/existadapter Log Message: Directory /cvsroot/exist/jEditAdapter/src/existadapter added to the repository |
From: Wolfgang M. M. <wol...@us...> - 2004-09-26 14:41:48
|
Update of /cvsroot/exist/jEditAdapter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31737/src Log Message: Directory /cvsroot/exist/jEditAdapter/src added to the repository |
From: Wolfgang M. M. <wol...@us...> - 2004-09-26 14:39:58
|
Update of /cvsroot/exist/jEditAdapter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31207/jEditAdapter Log Message: Directory /cvsroot/exist/jEditAdapter added to the repository |
From: Luigi B. <fi...@us...> - 2004-09-24 20:04:11
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20524/src/org/exist/xquery/functions/xmldb Modified Files: XMLDBCreateUser.java Log Message: Fixed the treatment of "extra groups" when adding a new user. Index: XMLDBCreateUser.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBCreateUser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBCreateUser.java 24 Sep 2004 14:00:21 -0000 1.1 --- XMLDBCreateUser.java 24 Sep 2004 20:04:00 -0000 1.2 *************** *** 86,91 **** LOG.info("Attempting to create user "+user+" in group "+group); ! for (int x = 3; x < args.length; x++) ! userObj.addGroup(args[x].getStringValue()); try { --- 86,93 ---- LOG.info("Attempting to create user "+user+" in group "+group); ! Sequence otherGroups = args[3]; ! int len = otherGroups.getLength(); ! for (int x = 0; x < len; x++) ! userObj.addGroup(otherGroups.itemAt(x).getStringValue()); try { |
From: Giulio V. <gva...@us...> - 2004-09-24 15:10:53
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28395/src/org/exist/xquery/functions/xmldb Modified Files: XMLDBGetResourceCollections.java Log Message: Change the name of get-resource-collections into get-child-resources how suggest by Luigi Index: XMLDBGetResourceCollections.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBGetResourceCollections.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBGetResourceCollections.java 24 Sep 2004 13:21:52 -0000 1.1 --- XMLDBGetResourceCollections.java 24 Sep 2004 15:10:40 -0000 1.2 *************** *** 46,50 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-resource-collections", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns the resource of collection", new SequenceType[] { --- 46,50 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-child-resources", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns the resource of collection", new SequenceType[] { |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 14:13:35
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15253/src/org/exist/xquery/value Modified Files: DecimalValue.java FloatValue.java StringValue.java DoubleValue.java Log Message: Index: StringValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/StringValue.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StringValue.java 23 Sep 2004 22:00:12 -0000 1.8 --- StringValue.java 24 Sep 2004 14:13:23 -0000 1.9 *************** *** 452,455 **** --- 452,456 ---- */ public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { + System.out.println("Comparing " + value + " > " + other.getStringValue()); if (Type.subTypeOf(other.getType(), Type.STRING)) return Collations.compare(collator, value, ((StringValue) other).value) > 0 ? this : other; Index: FloatValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/FloatValue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FloatValue.java 24 Sep 2004 10:42:49 -0000 1.5 --- FloatValue.java 24 Sep 2004 14:13:23 -0000 1.6 *************** *** 262,267 **** else if (target == Boolean.class) return Boolean.valueOf(effectiveBooleanValue()); - else if (target == Object.class) - return new Double(value); throw new XPathException( --- 262,265 ---- Index: DecimalValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DecimalValue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DecimalValue.java 24 Sep 2004 10:42:49 -0000 1.5 --- DecimalValue.java 24 Sep 2004 14:13:23 -0000 1.6 *************** *** 285,290 **** else if (target == Boolean.class) return Boolean.valueOf(effectiveBooleanValue()); - else if (target == Object.class) - return value; throw new XPathException( --- 285,288 ---- Index: DoubleValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DoubleValue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DoubleValue.java 24 Sep 2004 10:42:49 -0000 1.5 --- DoubleValue.java 24 Sep 2004 14:13:23 -0000 1.6 *************** *** 366,371 **** else if (target == Boolean.class) return Boolean.valueOf(effectiveBooleanValue()); - else if (target == Object.class) - return new Double(value); throw new XPathException( --- 366,369 ---- |
From: Luigi B. <fi...@us...> - 2004-09-24 14:02:28
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/ant In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13277/src/org/exist/ant Modified Files: XMLDBQueryTask.java Log Message: Added a debug option to print out the outgoing Query before it is submitted. With "ant -d" this allows a developer to confirm that variable substitutions are taking place correctly. Index: XMLDBQueryTask.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/ant/XMLDBQueryTask.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBQueryTask.java 17 Nov 2003 09:27:31 -0000 1.1 --- XMLDBQueryTask.java 24 Sep 2004 14:02:17 -0000 1.2 *************** *** 58,61 **** --- 58,63 ---- if (query == null) throw new BuildException("you have to specify a query"); + + log("XQuery is:\n"+query, org.apache.tools.ant.Project.MSG_DEBUG); registerDatabase(); |
From: Luigi B. <fi...@us...> - 2004-09-24 14:00:38
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12803/src/org/exist/xquery/functions/xmldb Modified Files: XMLDBModule.java Added Files: XMLDBAbstractCollectionManipulator.java XMLDBChmodCollection.java XMLDBChmodResource.java XMLDBCollectionExists.java XMLDBCreateUser.java XMLDBDeleteUser.java XMLDBSetCollectionPermissions.java XMLDBSetResourcePermissions.java Log Message: Adding some utility functions for manipulating Collections, Resources, and Users. --- NEW FILE: XMLDBAbstractCollectionManipulator.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Modifications Copyright (C) 2004 Luigi P. Bai * fi...@us... * Licensed as below under the LGPL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package org.exist.xquery.functions.xmldb; import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; import org.exist.xmldb.LocalCollection; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.JavaObjectValue; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.exist.xquery.value.StringValue; import java.util.Iterator; public abstract class XMLDBAbstractCollectionManipulator extends BasicFunction { public XMLDBAbstractCollectionManipulator(XQueryContext context, FunctionSignature signature) { super(context, signature); } /* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) * */ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { if (args.length == 0) throw new XPathException("Expected a collection as the first argument."); // If the incoming is a collection object, use it: Collection collection = null; Object o = args[0].itemAt(0); if (o instanceof JavaObjectValue) { o = ((JavaObjectValue) o).getObject(); if (o instanceof Collection) collection = (Collection) o; } if (collection == null) { // Otherwise, just extract the name as a string: String collectionURI = args[0].getStringValue(); try { collection = new LocalCollection(context.getUser(), context.getBroker().getBrokerPool(), collectionURI); collection.getName(); } catch (XMLDBException xe) { XPathException xpe = new XPathException("Could not locate collection "+collectionURI); xpe.initCause(xe); throw xpe; } } return evalWithCollection(collection, args, contextSequence); } abstract protected Sequence evalWithCollection(Collection c, Sequence[] args, Sequence contextSequence) throws XPathException; } --- NEW FILE: XMLDBSetCollectionPermissions.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Modifications Copyright (C) 2004 Luigi P. Bai * fi...@us... * Licensed as below under the LGPL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package org.exist.xquery.functions.xmldb; import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; import org.exist.xmldb.UserManagementService; import org.exist.security.Permission; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.exist.xquery.value.ValueSequence; import org.exist.xquery.value.StringValue; import org.exist.xquery.value.IntegerValue; import java.util.Iterator; public class XMLDBSetCollectionPermissions extends XMLDBAbstractCollectionManipulator { public final static FunctionSignature signature = new FunctionSignature( new QName("set-collection-permissions", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Sets the permissions of the specified Collection. Required: user, group, mode (as xs:integer). "+ "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); public XMLDBSetCollectionPermissions(XQueryContext context) { super(context, signature); } /* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) * */ public Sequence evalWithCollection(Collection collection, Sequence[] args, Sequence contextSequence) throws XPathException { try { UserManagementService ums = (UserManagementService) collection.getService("UserManagementService", "1.0"); ums.setPermissions(collection, new Permission(args[1].getStringValue(), args[2].getStringValue(), ((IntegerValue) args[3].convertTo(Type.INTEGER)).getInt())); } catch (XMLDBException xe) { throw new XPathException(getASTNode(), "Unable to change collection permissions", xe); } return Sequence.EMPTY_SEQUENCE; } } Index: XMLDBModule.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBModule.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLDBModule.java 24 Sep 2004 13:21:02 -0000 1.2 --- XMLDBModule.java 24 Sep 2004 14:00:21 -0000 1.3 *************** *** 5,8 **** --- 5,12 ---- * http://exist.sourceforge.net * + * Some modifications Copyright (C) 2004 Luigi P. Bai + * fi...@us... + * Licensed as below under the LGPL. + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License *************** *** 51,55 **** new FunctionDef(XMLDBOwner.signature, XMLDBOwner.class), new FunctionDef(XMLDBGetChildCollections.signature, XMLDBGetChildCollections.class), ! new FunctionDef(XMLDBGetResourceCollections.signature, XMLDBGetResourceCollections.class) }; --- 55,66 ---- new FunctionDef(XMLDBOwner.signature, XMLDBOwner.class), new FunctionDef(XMLDBGetChildCollections.signature, XMLDBGetChildCollections.class), ! new FunctionDef(XMLDBGetResourceCollections.signature, XMLDBGetResourceCollections.class), ! new FunctionDef(XMLDBSetCollectionPermissions.signature, XMLDBSetCollectionPermissions.class), ! new FunctionDef(XMLDBSetResourcePermissions.signature, XMLDBSetResourcePermissions.class), ! new FunctionDef(XMLDBCreateUser.signature, XMLDBCreateUser.class), ! new FunctionDef(XMLDBDeleteUser.signature, XMLDBDeleteUser.class), ! new FunctionDef(XMLDBChmodCollection.signature, XMLDBChmodCollection.class), ! new FunctionDef(XMLDBChmodResource.signature, XMLDBChmodResource.class), ! new FunctionDef(XMLDBCollectionExists.signature, XMLDBCollectionExists.class), }; --- NEW FILE: XMLDBCreateUser.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Modifications Copyright (C) 2004 Luigi P. Bai * fi...@us... * Licensed as below under the LGPL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: XMLDBCreateUser.java,v 1.1 2004/09/24 14:00:21 finder Exp $ */ package org.exist.xquery.functions.xmldb; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.JavaObjectValue; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; import org.exist.security.User; import org.exist.xmldb.LocalCollection; import org.exist.xmldb.UserManagementService; /** * @author wolf */ public class XMLDBCreateUser extends BasicFunction { public final static FunctionSignature signature = new FunctionSignature( new QName("create-user", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Create a new user in the database. Requires username, password, and at least one group name.", new SequenceType[]{ new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.ZERO_OR_MORE), }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); /** * @param context * @param signature */ public XMLDBCreateUser(XQueryContext context) { super(context, signature); } /* * (non-Javadoc) * * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, * org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) */ public Sequence eval(Sequence args[], Sequence contextSequence) throws XPathException { String user = args[0].getStringValue(); String pass = args[1].getStringValue(); String group = args[2].getStringValue(); User userObj = new User(user, pass, group); LOG.info("Attempting to create user "+user+" in group "+group); for (int x = 3; x < args.length; x++) userObj.addGroup(args[x].getStringValue()); try { Collection collection = new LocalCollection(context.getUser(), context.getBroker().getBrokerPool(), "/db"); UserManagementService ums = (UserManagementService) collection.getService("UserManagementService", "1.0"); ums.addUser(userObj); } catch (XMLDBException xe) { throw new XPathException(getASTNode(), "Failed to create new user " + user, xe); } return Sequence.EMPTY_SEQUENCE; } } --- NEW FILE: XMLDBChmodResource.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Modifications Copyright (C) 2004 Luigi P. Bai * fi...@us... * Licensed as below under the LGPL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package org.exist.xquery.functions.xmldb; import org.xmldb.api.base.Collection; import org.xmldb.api.base.Resource; import org.xmldb.api.base.XMLDBException; import org.exist.xmldb.UserManagementService; import org.exist.security.Permission; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.exist.xquery.value.ValueSequence; import org.exist.xquery.value.StringValue; import org.exist.xquery.value.IntegerValue; import java.util.Iterator; public class XMLDBChmodResource extends XMLDBAbstractCollectionManipulator { public final static FunctionSignature signature = new FunctionSignature( new QName("chmod-resource", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Sets the mode of the specified Resource. Required: collection, resource, mode (as xs:integer). "+ "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); public XMLDBChmodResource(XQueryContext context) { super(context, signature); } /* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) * */ public Sequence evalWithCollection(Collection collection, Sequence[] args, Sequence contextSequence) throws XPathException { try { Resource res = collection.getResource(args[1].getStringValue()); if (res != null) { UserManagementService ums = (UserManagementService) collection.getService("UserManagementService", "1.0"); ums.chmod(res, ((IntegerValue) args[2].convertTo(Type.INTEGER)).getInt()); } else { throw new XPathException(getASTNode(), "Unable to locate resource "+args[1].getStringValue()); } } catch (XMLDBException xe) { throw new XPathException(getASTNode(), "Unable to change resource permissions", xe); } return Sequence.EMPTY_SEQUENCE; } } --- NEW FILE: XMLDBChmodCollection.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Modifications Copyright (C) 2004 Luigi P. Bai * fi...@us... * Licensed as below under the LGPL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package org.exist.xquery.functions.xmldb; import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; import org.exist.xmldb.UserManagementService; import org.exist.security.Permission; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.exist.xquery.value.ValueSequence; import org.exist.xquery.value.StringValue; import org.exist.xquery.value.IntegerValue; import java.util.Iterator; public class XMLDBChmodCollection extends XMLDBAbstractCollectionManipulator { public final static FunctionSignature signature = new FunctionSignature( new QName("chmod-collection", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Sets the mode of the specified Collection. Required: collection, mode (as xs:integer). "+ "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); public XMLDBChmodCollection(XQueryContext context) { super(context, signature); } /* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) * */ public Sequence evalWithCollection(Collection collection, Sequence[] args, Sequence contextSequence) throws XPathException { try { UserManagementService ums = (UserManagementService) collection.getService("UserManagementService", "1.0"); ums.chmod(((IntegerValue) args[1].convertTo(Type.INTEGER)).getInt()); } catch (XMLDBException xe) { throw new XPathException(getASTNode(), "Unable to change collection mode", xe); } return Sequence.EMPTY_SEQUENCE; } } --- NEW FILE: XMLDBSetResourcePermissions.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Modifications Copyright (C) 2004 Luigi P. Bai * fi...@us... * Licensed as below under the LGPL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package org.exist.xquery.functions.xmldb; import org.xmldb.api.base.Collection; import org.xmldb.api.base.Resource; import org.xmldb.api.base.XMLDBException; import org.exist.xmldb.UserManagementService; import org.exist.security.Permission; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.exist.xquery.value.ValueSequence; import org.exist.xquery.value.StringValue; import org.exist.xquery.value.IntegerValue; import java.util.Iterator; public class XMLDBSetResourcePermissions extends XMLDBAbstractCollectionManipulator { public final static FunctionSignature signature = new FunctionSignature( new QName("set-resource-permissions", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Sets the permissions of the specified Resource. Required: user, group, mode (as xs:integer). "+ "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); public XMLDBSetResourcePermissions(XQueryContext context) { super(context, signature); } /* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) * */ public Sequence evalWithCollection(Collection collection, Sequence[] args, Sequence contextSequence) throws XPathException { try { Resource res = collection.getResource(args[1].getStringValue()); if (res != null) { UserManagementService ums = (UserManagementService) collection.getService("UserManagementService", "1.0"); ums.setPermissions(res, new Permission(args[2].getStringValue(), args[3].getStringValue(), ((IntegerValue) args[4].convertTo(Type.INTEGER)).getInt())); } else { throw new XPathException(getASTNode(), "Unable to locate resource "+args[1].getStringValue()); } } catch (XMLDBException xe) { throw new XPathException(getASTNode(), "Unable to change resource permissions", xe); } return Sequence.EMPTY_SEQUENCE; } } --- NEW FILE: XMLDBCollectionExists.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Changes to this file are: * Copyright (C) 2004 by Luigi P. Bai * fi...@us... * and are licensed under the GNU Lesser General Public License as below. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: XMLDBCollectionExists.java,v 1.1 2004/09/24 14:00:21 finder Exp $ */ package org.exist.xquery.functions.xmldb; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.BooleanValue; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; public class XMLDBCollectionExists extends BasicFunction { public final static FunctionSignature signature = new FunctionSignature( new QName("collection-exists", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns true as xs:boolean if there is a collection "+ "with the same name as the first argument as xs:string.", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE)}, new SequenceType(Type.BOOLEAN, Cardinality.EXACTLY_ONE)); /** * @param context * @param signature */ public XMLDBCollectionExists(XQueryContext context) { super(context, signature); } /* (non-Javadoc) * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) */ public Sequence eval( Sequence args[], Sequence contextSequence) throws XPathException { String collectionURI = args[0].getStringValue(); Collection collection = null; try { collection = DatabaseManager.getCollection(collectionURI); } catch (XMLDBException e) { LOG.debug(e.getMessage(), e); throw new XPathException(getASTNode(), "exception while retrieving collection: " + e.getMessage(), e); } return (null == collection) ? BooleanValue.FALSE : BooleanValue.TRUE; } } --- NEW FILE: XMLDBDeleteUser.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * Modifications Copyright (C) 2004 Luigi P. Bai * fi...@us... * Licensed as below under the LGPL. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: XMLDBDeleteUser.java,v 1.1 2004/09/24 14:00:21 finder Exp $ */ package org.exist.xquery.functions.xmldb; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.JavaObjectValue; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; import org.exist.security.User; import org.exist.xmldb.LocalCollection; import org.exist.xmldb.UserManagementService; /** * @author wolf */ public class XMLDBDeleteUser extends BasicFunction { public final static FunctionSignature signature = new FunctionSignature( new QName("delete-user", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Deletes an existing user in the database. Requires username. Does not delete the user's home collection.", new SequenceType[]{ new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); /** * @param context * @param signature */ public XMLDBDeleteUser(XQueryContext context) { super(context, signature); } /* * (non-Javadoc) * * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, * org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) */ public Sequence eval(Sequence args[], Sequence contextSequence) throws XPathException { String user = args[0].getStringValue(); try { Collection collection = new LocalCollection(context.getUser(), context.getBroker().getBrokerPool(), "/db"); UserManagementService ums = (UserManagementService) collection.getService("UserManagementService", "1.0"); User userObj = ums.getUser(user); ums.removeUser(userObj); } catch (XMLDBException xe) { throw new XPathException(getASTNode(), "Failed to create new user " + user, xe); } return Sequence.EMPTY_SEQUENCE; } } |
From: Giulio V. <gva...@us...> - 2004-09-24 13:22:04
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4401/src/org/exist/xquery/functions/xmldb Added Files: XMLDBGetResourceCollections.java Log Message: Add get-resource-collections --- NEW FILE: XMLDBGetResourceCollections.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package org.exist.xquery.functions.xmldb; import org.exist.collections.Collection; import org.exist.dom.DocumentImpl; import org.exist.dom.QName; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; import org.exist.xquery.value.ValueSequence; import org.exist.xquery.value.StringValue; import org.exist.util.Lock; import org.exist.storage.DBBroker; import java.util.Iterator; public class XMLDBGetResourceCollections extends BasicFunction { public final static FunctionSignature signature = new FunctionSignature( new QName("get-resource-collections", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns the resource of collection", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) }, new SequenceType(Type.STRING, Cardinality.ZERO_OR_MORE)); public XMLDBGetResourceCollections(XQueryContext context) { super(context, signature); } /* (non-Javadoc) * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) * */ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { DBBroker broker = null; broker =context.getBroker(); String collectionURI = args[0].getStringValue(); Collection collection = null; collection = broker.openCollection(collectionURI, Lock.READ_LOCK); ValueSequence r = new ValueSequence(); if (collection == null) { throw new XPathException(getASTNode(), "Collection " + collectionURI + " does not exist"); } String resource; int p; for (Iterator i = collection.iterator(broker); i.hasNext(); ) { resource = ((DocumentImpl) i.next()).getFileName(); p = resource.lastIndexOf('/'); r.add(new StringValue(p < 0 ? resource : resource.substring(p + 1))); } collection.release(); return r; } } |
From: Giulio V. <gva...@us...> - 2004-09-24 13:21:18
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4172/src/org/exist/xquery/functions/xmldb Modified Files: XMLDBModule.java Log Message: Add get-resource-collections Index: XMLDBModule.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBModule.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBModule.java 12 Sep 2004 09:25:16 -0000 1.1 --- XMLDBModule.java 24 Sep 2004 13:21:02 -0000 1.2 *************** *** 50,54 **** new FunctionDef(XMLDBGroup.signature, XMLDBGroup.class), new FunctionDef(XMLDBOwner.signature, XMLDBOwner.class), ! new FunctionDef(XMLDBGetChildCollections.signature, XMLDBGetChildCollections.class) }; --- 50,55 ---- new FunctionDef(XMLDBGroup.signature, XMLDBGroup.class), new FunctionDef(XMLDBOwner.signature, XMLDBOwner.class), ! new FunctionDef(XMLDBGetChildCollections.signature, XMLDBGetChildCollections.class), ! new FunctionDef(XMLDBGetResourceCollections.signature, XMLDBGetResourceCollections.class) }; |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 10:42:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32072/src/org/exist/xquery/value Modified Files: DecimalValue.java FloatValue.java DoubleValue.java Log Message: The toJavaObject method of some numeric types doesn't handle Long. Patch supplied by Piotr. Index: FloatValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/FloatValue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FloatValue.java 23 Sep 2004 22:00:12 -0000 1.4 --- FloatValue.java 24 Sep 2004 10:42:49 -0000 1.5 *************** *** 247,251 **** else if (target == Float.class || target == float.class) return new Float(value); ! else if (target == Integer.class || target == int.class) { IntegerValue v = (IntegerValue) convertTo(Type.INT); return new Integer((int) v.getValue()); --- 247,253 ---- else if (target == Float.class || target == float.class) return new Float(value); ! else if (target == Long.class || target == long.class) { ! return new Long( ((IntegerValue) convertTo(Type.LONG)).getValue() ); ! } else if (target == Integer.class || target == int.class) { IntegerValue v = (IntegerValue) convertTo(Type.INT); return new Integer((int) v.getValue()); Index: DecimalValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DecimalValue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DecimalValue.java 23 Sep 2004 22:00:12 -0000 1.4 --- DecimalValue.java 24 Sep 2004 10:42:49 -0000 1.5 *************** *** 270,274 **** else if (target == Float.class || target == float.class) return new Float(value.floatValue()); ! else if (target == Integer.class || target == int.class) { IntegerValue v = (IntegerValue) convertTo(Type.INT); return new Integer((int) v.getValue()); --- 270,276 ---- else if (target == Float.class || target == float.class) return new Float(value.floatValue()); ! else if (target == Long.class || target == long.class) { ! return new Long( ((IntegerValue) convertTo(Type.LONG)).getValue() ); ! } else if (target == Integer.class || target == int.class) { IntegerValue v = (IntegerValue) convertTo(Type.INT); return new Integer((int) v.getValue()); Index: DoubleValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DoubleValue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DoubleValue.java 23 Sep 2004 22:00:12 -0000 1.4 --- DoubleValue.java 24 Sep 2004 10:42:49 -0000 1.5 *************** *** 351,355 **** else if (target == Float.class || target == float.class) return new Float(value); ! else if (target == Integer.class || target == int.class) { IntegerValue v = (IntegerValue) convertTo(Type.INT); return new Integer((int) v.getValue()); --- 351,357 ---- else if (target == Float.class || target == float.class) return new Float(value); ! else if (target == Long.class || target == long.class) { ! return new Long( ((IntegerValue) convertTo(Type.LONG)).getValue() ); ! } else if (target == Integer.class || target == int.class) { IntegerValue v = (IntegerValue) convertTo(Type.INT); return new Integer((int) v.getValue()); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 10:38:52
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31157/src/org/exist/util Modified Files: Collations.java Log Message: Handle default setting for collation strength. Index: Collations.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/Collations.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Collations.java 23 Sep 2004 22:00:16 -0000 1.2 --- Collations.java 24 Sep 2004 10:38:38 -0000 1.3 *************** *** 17,20 **** --- 17,21 ---- import org.apache.log4j.Logger; import org.exist.xquery.XPathException; + import org.exist.xquery.XQueryContext; /** *************** *** 54,58 **** * @throws XPathException */ ! public final static Collator getCollationFromURI(String uri) throws XPathException { if(uri.startsWith(EXIST_COLLATION_URI) || uri.startsWith("?")) { URI u = null; --- 55,59 ---- * @throws XPathException */ ! public final static Collator getCollationFromURI(XQueryContext context, String uri) throws XPathException { if(uri.startsWith(EXIST_COLLATION_URI) || uri.startsWith("?")) { URI u = null; *************** *** 63,88 **** } String query = u.getQuery(); - if(query == null) - return getCollationFromParams(null, null, null); - String lang = null; String strength = null; ! String decomposition = null; ! StringTokenizer queryTokenizer = new StringTokenizer(query, ";&"); ! while (queryTokenizer.hasMoreElements()) { ! String param = queryTokenizer.nextToken(); ! int eq = param.indexOf('='); ! if (eq > 0 && eq < param.length()-1) { ! String kw = param.substring(0, eq); ! String val = param.substring(eq + 1); ! if (kw.equals("lang")) { ! lang = val; ! } else if (kw.equals("strength")) { ! strength = val; ! } else if (kw.equals("decomposition")) { ! decomposition = val; } ! } ! } ! return getCollationFromParams(lang, strength, decomposition); } else // unknown collation --- 64,98 ---- } String query = u.getQuery(); String strength = null; ! /* ! * Check if the db broker is configured to be case insensitive. ! * If yes, we assume "primary" strength unless the user specified ! * something different. ! */ ! if(!context.getBroker().isCaseSensitive()) ! strength = "primary"; ! if(query == null) { ! return getCollationFromParams(null, strength, null); ! } else { ! String lang = null; ! String decomposition = null; ! StringTokenizer queryTokenizer = new StringTokenizer(query, ";&"); ! while (queryTokenizer.hasMoreElements()) { ! String param = queryTokenizer.nextToken(); ! int eq = param.indexOf('='); ! if (eq > 0) { ! String kw = param.substring(0, eq); ! String val = param.substring(eq + 1); ! if (kw.equals("lang")) { ! lang = val; ! } else if (kw.equals("strength")) { ! strength = val; ! } else if (kw.equals("decomposition")) { ! decomposition = val; ! } } ! } ! return getCollationFromParams(lang, strength, decomposition); ! } } else // unknown collation *************** *** 240,244 **** else if("tertiary".equals(strength)) collator.setStrength(Collator.TERTIARY); ! else if("identical".equals(strength)) collator.setStrength(Collator.IDENTICAL); else --- 250,255 ---- else if("tertiary".equals(strength)) collator.setStrength(Collator.TERTIARY); ! else if(strength.length() == 0 || "identical".equals(strength)) ! // the default setting collator.setStrength(Collator.IDENTICAL); else *************** *** 251,255 **** else if("full".equals(decomposition)) collator.setDecomposition(Collator.FULL_DECOMPOSITION); ! else if("standard".equals(decomposition)) collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION); else --- 262,267 ---- else if("full".equals(decomposition)) collator.setDecomposition(Collator.FULL_DECOMPOSITION); ! else if(decomposition.length() == 0 || "standard".equals(decomposition)) ! // the default setting collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION); else |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 10:38:52
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31157/src/org/exist/xquery Modified Files: XQueryContext.java Log Message: Handle default setting for collation strength. Index: XQueryContext.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XQueryContext.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** XQueryContext.java 22 Sep 2004 21:50:07 -0000 1.25 --- XQueryContext.java 24 Sep 2004 10:38:39 -0000 1.26 *************** *** 130,134 **** --- 130,141 ---- private String defaultFunctionNamespace = Module.BUILTIN_FUNCTION_NS; + /** + * The default collation URI + */ private String defaultCollation = Collations.CODEPOINT; + + /** + * Default Collator. Will be null for the default unicode codepoint collation. + */ private Collator defaultCollator = null; *************** *** 271,274 **** --- 278,288 ---- } + /** + * Set the default collation to be used by all operators and functions on strings. + * Throws an exception if the collation is unknown or cannot be instantiated. + * + * @param uri + * @throws XPathException + */ public void setDefaultCollation(String uri) throws XPathException { if(uri.equals(Collations.CODEPOINT) || uri.equals(Collations.CODEPOINT_SHORT)) { *************** *** 276,280 **** defaultCollator = null; } ! defaultCollator = Collations.getCollationFromURI(uri); defaultCollation = uri; } --- 290,294 ---- defaultCollator = null; } ! defaultCollator = Collations.getCollationFromURI(this, uri); defaultCollation = uri; } *************** *** 287,291 **** if(uri == null) return defaultCollator; ! return Collations.getCollationFromURI(uri); } --- 301,305 ---- if(uri == null) return defaultCollator; ! return Collations.getCollationFromURI(this, uri); } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 10:06:04
|
Update of /cvsroot/exist/eXist-1.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24946 Modified Files: build.xml Log Message: Set source="1.4" in the javac task or the compiler complains about the "assert" used by Piotr. Index: build.xml =================================================================== RCS file: /cvsroot/exist/eXist-1.0/build.xml,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** build.xml 22 Sep 2004 08:43:03 -0000 1.57 --- build.xml 24 Sep 2004 10:05:52 -0000 1.58 *************** *** 111,115 **** <javac debug="${build.debug}" deprecation="${build.deprecation}" destdir="${build.classes}" encoding="UTF-8" ! optimize="${build.optimize}" srcdir="${src}" > <!-- jmv target="1.4" --> <include name="org/**"/> --- 111,116 ---- <javac debug="${build.debug}" deprecation="${build.deprecation}" destdir="${build.classes}" encoding="UTF-8" ! optimize="${build.optimize}" srcdir="${src}" ! source="1.4"> <!-- jmv target="1.4" --> <include name="org/**"/> *************** *** 282,285 **** --- 283,287 ---- </test> <test fork="yes" name="org.exist.xupdate.test.AllTests" todir="${junit.reports}"/> + <test fork="yes" name="org.exist.xquery.test.AllTests" todir="${junit.reports}"/> <!-- Execute all other tests except those that have to be called manually. |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 09:49:43
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21573/src/org/exist/xquery/test Modified Files: AllTests.java XPathQueryTest.java Added Files: DeepEqualTest.java Log Message: Added fn:deep-equal implementation (by Piotr) Index: XPathQueryTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/XPathQueryTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XPathQueryTest.java 23 Sep 2004 12:41:18 -0000 1.6 --- XPathQueryTest.java 24 Sep 2004 09:49:32 -0000 1.7 *************** *** 202,206 **** assertEquals(1, result.getSize()); Resource r = result.getResource(0); ! assertEquals("false", r.getContent().toString()); result = --- 202,206 ---- assertEquals(1, result.getSize()); Resource r = result.getResource(0); ! assertEquals("true", r.getContent().toString()); result = *************** *** 208,214 **** "strings.xml", "/test/string[not(@id)]"); ! assertEquals(1, result.getSize()); r = result.getResource(0); ! assertEquals("false", r.getContent().toString()); } catch (XMLDBException e) { System.out.println("testStrings(): XMLDBException: "+e); --- 208,214 ---- "strings.xml", "/test/string[not(@id)]"); ! assertEquals(3, result.getSize()); r = result.getResource(0); ! assertEquals("<string>Hello World!</string>", r.getContent().toString()); } catch (XMLDBException e) { System.out.println("testStrings(): XMLDBException: "+e); --- NEW FILE: DeepEqualTest.java --- package org.exist.xquery.test; import org.exist.xmldb.CollectionManagementServiceImpl; import org.exist.xmldb.RemoteCollectionManagementService; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.*; import org.xmldb.api.base.Database; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.*; import org.xmldb.api.modules.CollectionManagementService; import org.xmldb.api.modules.XMLResource; import junit.framework.TestCase; import junit.textui.TestRunner; public class DeepEqualTest extends TestCase { private final static String URI = "xmldb:exist:///db"; private final static String DRIVER = "org.exist.xmldb.DatabaseImpl"; private XPathQueryService query; private Collection c; public static void main(String[] args) { TestRunner.run(DeepEqualTest.class); } public DeepEqualTest(String name) { super(name); } public void testAtomic1() throws XMLDBException { assertQuery(true, "deep-equal('hello', 'hello')"); } public void testAtomic2() throws XMLDBException { assertQuery(false, "deep-equal('hello', 'goodbye')"); } public void testAtomic3() throws XMLDBException { assertQuery(true, "deep-equal(42, 42)"); } public void testAtomic4() throws XMLDBException { assertQuery(false, "deep-equal(42, 17)"); } public void testAtomic5() throws XMLDBException { assertQuery(false, "deep-equal(42, 'hello')"); } public void testEmptySeq() throws XMLDBException { assertQuery(true, "deep-equal((), ())"); } public void testDiffLengthSeq1() throws XMLDBException { assertQuery(false, "deep-equal((), 42)"); } public void testDiffLengthSeq2() throws XMLDBException { assertQuery(false, "deep-equal((), (42, 'hello'))"); } public void testDiffKindNodes1() throws XMLDBException { createDocument("test", "<test key='value'>hello</test>"); assertQuery(false, "deep-equal(/test, /test/@key)"); } public void testDiffKindNodes2() throws XMLDBException { createDocument("test", "<test key='value'>hello</test>"); assertQuery(false, "deep-equal(/test, /test/text())"); } public void testDiffKindNodes3() throws XMLDBException { createDocument("test", "<test key='value'>hello</test>"); assertQuery(false, "deep-equal(/test/@key, /test/text())"); } public void testSameNode1() throws XMLDBException { createDocument("test", "<test key='value'>hello</test>"); assertQuery(true, "deep-equal(/test, /test)"); } public void testSameNode2() throws XMLDBException { createDocument("test", "<test key='value'>hello</test>"); assertQuery(true, "deep-equal(/test/@key, /test/@key)"); } public void testSameNode3() throws XMLDBException { createDocument("test", "<test key='value'>hello</test>"); assertQuery(true, "deep-equal(/test/text(), /test/text())"); } public void testDocuments1() throws XMLDBException { createDocument("test1", "<test key='value'>hello</test>"); createDocument("test2", "<test key='value'>hello</test>"); assertQuery(true, "deep-equal(document('test1'), document('test2'))"); } public void testDocuments2() throws XMLDBException { createDocument("test1", "<test key='value'>hello</test>"); createDocument("test2", "<notatest/>"); assertQuery(false, "deep-equal(document('test1'), document('test2'))"); } public void testText1() throws XMLDBException { createDocument("test", "<test><g1><a>1</a><b>2</b></g1><g2><c>1</c><d>2</d></g2></test>"); assertQuery(true, "deep-equal(//a/text(), //c/text())"); } public void testText2() throws XMLDBException { createDocument("test", "<test><g1><a>1</a><b>2</b></g1><g2><c>1</c><d>2</d></g2></test>"); assertQuery(false, "deep-equal(//a/text(), //b/text())"); } public void testText3() throws XMLDBException { createDocument("test", "<test><g1><a>1</a><b>2</b></g1><g2><c>1</c><d>2</d></g2></test>"); assertQuery(true, "deep-equal(//g1/text(), //g2/text())"); } public void testText4() throws XMLDBException { createDocument("test", "<test><a>12</a><b>1<!--blah-->2</b></test>"); assertQuery(false, "deep-equal(//a/text(), //b/text())"); } public void testAttributes1() throws XMLDBException { createDocument("test", "<test><e1 a='1'/><e2 a='1' b='2' c='1'/><e3 a='2'/></test>"); assertQuery(true, "deep-equal(//e1/@a, //e2/@a)"); } public void testAttributes2() throws XMLDBException { createDocument("test", "<test><e1 a='1'/><e2 a='1' b='2' c='1'/><e3 a='2'/></test>"); assertQuery(false, "deep-equal(//e1/@a, //e2/@b)"); } public void testAttributes3() throws XMLDBException { createDocument("test", "<test><e1 a='1'/><e2 a='1' b='2' c='1'/><e3 a='2'/></test>"); assertQuery(false, "deep-equal(//e1/@a, //e2/@c)"); } public void testAttributes4() throws XMLDBException { createDocument("test", "<test><e1 a='1'/><e2 a='1' b='2' c='1'/><e3 a='2'/></test>"); assertQuery(false, "deep-equal(//e1/@a, //e3/@a)"); } public void testNSAttributes1() throws XMLDBException { createDocument("test", "<test xmlns:n='urn:blah' xmlns:p='urn:foo' xmlns:q='urn:blah'><e1 n:a='1'/><e2 n:a='1' p:a='1' p:b='1'/><e3 n:a='2'/><e4 q:a='1'/></test>"); assertQuery(true, "declare namespace n = 'urn:blah'; declare namespace p = 'urn:foo'; declare namespace q = 'urn:blah'; deep-equal(//e1/@n:a, //e2/@n:a)"); } public void testNSAttributes2() throws XMLDBException { createDocument("test", "<test xmlns:n='urn:blah' xmlns:p='urn:foo' xmlns:q='urn:blah'><e1 n:a='1'/><e2 n:a='1' p:a='1' p:b='1'/><e3 n:a='2'/><e4 q:a='1'/></test>"); assertQuery(true, "declare namespace n = 'urn:blah'; declare namespace p = 'urn:foo'; declare namespace q = 'urn:blah'; deep-equal(//e1/@q:a, //e4/@n:a)"); } public void testNSAttributes3() throws XMLDBException { createDocument("test", "<test xmlns:n='urn:blah' xmlns:p='urn:foo' xmlns:q='urn:blah'><e1 n:a='1'/><e2 n:a='1' p:a='1' p:b='1'/><e3 n:a='2'/><e4 q:a='1'/></test>"); assertQuery(false, "declare namespace n = 'urn:blah'; declare namespace p = 'urn:foo'; declare namespace q = 'urn:blah'; deep-equal(//e1/@n:a, //e2/@p:a)"); } public void testNSAttributes4() throws XMLDBException { createDocument("test", "<test xmlns:n='urn:blah' xmlns:p='urn:foo' xmlns:q='urn:blah'><e1 n:a='1'/><e2 n:a='1' p:a='1' p:b='1'/><e3 n:a='2'/><e4 q:a='1'/></test>"); assertQuery(false, "declare namespace n = 'urn:blah'; declare namespace p = 'urn:foo'; declare namespace q = 'urn:blah'; deep-equal(//e1/@n:a, //e2/@p:b)"); } public void testNSAttributes5() throws XMLDBException { createDocument("test", "<test xmlns:n='urn:blah' xmlns:p='urn:foo' xmlns:q='urn:blah'><e1 n:a='1'/><e2 n:a='1' p:a='1' p:b='1'/><e3 n:a='2'/><e4 q:a='1'/></test>"); assertQuery(false, "declare namespace n = 'urn:blah'; declare namespace p = 'urn:foo'; declare namespace q = 'urn:blah'; deep-equal(//e1/@n:a, //e3/@n:a)"); } public void testElements1() throws XMLDBException { createDocument("test", "<test><a/><a/></test>"); assertQuery(true, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements2() throws XMLDBException { createDocument("test", "<test><a/><b/></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements3() throws XMLDBException { createDocument("test", "<test><a a='1' b='2'/><a b='2' a='1'/></test>"); assertQuery(true, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements4() throws XMLDBException { createDocument("test", "<test><a a='1'/><a b='2' a='1'/></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements5() throws XMLDBException { createDocument("test", "<test><a a='1' c='2'/><a b='2' a='1'/></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements6() throws XMLDBException { createDocument("test", "<test><a a='1' b='2'/><a a='2' b='2'/></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements7() throws XMLDBException { createDocument("test", "<test><a>hello</a><a>hello</a></test>"); assertQuery(true, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements8() throws XMLDBException { createDocument("test", "<test><a>hello</a><a>bye</a></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements9() throws XMLDBException { createDocument("test", "<test><a><!--blah--></a><a/></test>"); assertQuery(true, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements10() throws XMLDBException { createDocument("test", "<test><a><b/><!--blah-->hello</a><a><b/>hello</a></test>"); assertQuery(true, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements11() throws XMLDBException { createDocument("test", "<test><a><b/>hello</a><a>hello</a></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements12() throws XMLDBException { createDocument("test", "<test><a><b/></a><a>hello</a></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testElements13() throws XMLDBException { createDocument("test", "<test><a><b/></a><a><b/>hello</a></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } public void testNSElements1() throws XMLDBException { createDocument("test", "<test xmlns:p='urn:foo' xmlns:q='urn:foo'><p:a/><q:a/></test>"); assertQuery(true, "deep-equal(/test/*[1], /test/*[2])"); } public void testNSElements2() throws XMLDBException { createDocument("test", "<test xmlns:p='urn:foo' xmlns:q='urn:bar'><p:a/><q:a/></test>"); assertQuery(false, "deep-equal(/test/*[1], /test/*[2])"); } private void assertQuery(boolean expected, String q) throws XMLDBException { ResourceSet rs = query.query(q); assertEquals(1, rs.getSize()); assertEquals(Boolean.toString(expected), rs.getResource(0).getContent()); } private XMLResource createDocument(String name, String content) throws XMLDBException { XMLResource res = (XMLResource) c.createResource(name, XMLResource.RESOURCE_TYPE); res.setContent(content); c.storeResource(res); return res; } private Collection setupTestCollection() throws XMLDBException { Collection root = DatabaseManager.getCollection(URI, "admin", ""); CollectionManagementService rootcms = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); Collection c = root.getChildCollection("test"); if(c != null) rootcms.removeCollection("test"); rootcms.createCollection("test"); c = DatabaseManager.getCollection(URI+"/test", "admin", ""); assertNotNull(c); return c; } protected void setUp() { try { // initialize driver Database database = (Database) Class.forName(DRIVER).newInstance(); database.setProperty("create-database", "true"); DatabaseManager.registerDatabase(database); c = setupTestCollection(); query = (XPathQueryService) c.getService("XPathQueryService", "1.0"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("failed setup", e); } } protected void tearDown() { try { if (c != null) c.close(); } catch (XMLDBException e) { throw new RuntimeException("failed teardown", e); } } } Index: AllTests.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/AllTests.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AllTests.java 23 Sep 2004 12:41:18 -0000 1.4 --- AllTests.java 24 Sep 2004 09:49:32 -0000 1.5 *************** *** 40,43 **** --- 40,44 ---- suite.addTestSuite(XPathQueryTest.class); suite.addTestSuite(LexerTest.class); // jmv: Note: LexerTest needs /db/test created by XPathQueryTest + suite.addTestSuite(DeepEqualTest.class); // suite.addTestSuite(XQueryUseCasesTest.class); //$JUnit-END$ |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 09:49:43
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21573/src/org/exist/xquery/functions Modified Files: ModuleImpl.java Added Files: FunDeepEqual.java Log Message: Added fn:deep-equal implementation (by Piotr) --- NEW FILE: FunDeepEqual.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: FunDeepEqual.java,v 1.1 2004/09/24 09:49:32 wolfgang_m Exp $ */ package org.exist.xquery.functions; import org.exist.dom.NodeProxy; import org.exist.dom.QName; import org.exist.memtree.AttributeImpl; import org.exist.xquery.*; import org.exist.xquery.value.*; import org.w3c.dom.*; import org.w3c.dom.Attr; import org.w3c.dom.Node; /** * Implements the fn:deep-equal library function. * * @author <a href="mailto:pi...@id...">Piotr Kaminski</a> */ public class FunDeepEqual extends Function { public final static FunctionSignature signature = new FunctionSignature( new QName("deep-equal", Module.BUILTIN_FUNCTION_NS), new SequenceType[] { new SequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE), new SequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE) }, new SequenceType(Type.BOOLEAN, Cardinality.ONE)); public FunDeepEqual(XQueryContext context) { super(context, signature); } public int getDependencies() { return Dependency.CONTEXT_SET | Dependency.CONTEXT_ITEM; } public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { Sequence[] args = getArguments(contextSequence, contextItem); int length = args[0].getLength(); if (length != args[1].getLength()) return BooleanValue.FALSE; for (int i=0; i<length; i++) { if (!deepEquals(args[0].itemAt(i), args[1].itemAt(i))) return BooleanValue.FALSE; } return BooleanValue.TRUE; } private boolean deepEquals(Item a, Item b) { try { if (Type.subTypeOf(a.getType(), Type.ATOMIC) || Type.subTypeOf(b.getType(), Type.ATOMIC)) { if (!Type.subTypeOf(a.getType(), Type.ATOMIC) || !Type.subTypeOf(b.getType(), Type.ATOMIC)) return false; return a.atomize().compareTo(context.getDefaultCollator(), b.atomize()) == 0; } else { assert Type.subTypeOf(a.getType(), Type.NODE); assert Type.subTypeOf(b.getType(), Type.NODE); if (a.getType() != b.getType()) return false; NodeValue nva = (NodeValue) a, nvb = (NodeValue) b; if (nva.equals(nvb)) return true; // shortcut! Node na, nb; switch(a.getType()) { case Type.DOCUMENT: // NodeValue.getNode() doesn't seem to work for document nodes na = nva instanceof Node ? (Node) nva : ((NodeProxy) nva).getDocument(); nb = nvb instanceof Node ? (Node) nvb : ((NodeProxy) nvb).getDocument(); return compareContents(na, nb); case Type.ELEMENT: na = nva.getNode(); nb = nvb.getNode(); return compareElements(na, nb); case Type.ATTRIBUTE: na = nva.getNode(); nb = nvb.getNode(); return compareNames(na, nb) && safeEquals(na.getNodeValue(), nb.getNodeValue()); case Type.PROCESSING_INSTRUCTION: case Type.NAMESPACE: na = nva.getNode(); nb = nvb.getNode(); return safeEquals(na.getNodeName(), nb.getNodeName()) && safeEquals(nva.getStringValue(), nvb.getStringValue()); case Type.TEXT: case Type.COMMENT: return safeEquals(nva.getStringValue(), nvb.getStringValue()); default: throw new RuntimeException("unexpected item type " + Type.getTypeName(a.getType())); } } } catch (XPathException e) { return false; } } private boolean compareElements(Node a, Node b) { return compareNames(a, b) && compareAttributes(a, b) && compareContents(a, b); } private boolean compareContents(Node a, Node b) { a = findNextTextOrElementNode(a.getFirstChild()); b = findNextTextOrElementNode(b.getFirstChild()); while(!(a == null || b == null)) { if (a.getNodeType() != b.getNodeType()) return false; switch(a.getNodeType()) { case Node.TEXT_NODE: if (!safeEquals(a.getNodeValue(), b.getNodeValue())) return false; break; case Node.ELEMENT_NODE: if (!compareElements(a, b)) return false; break; default: throw new RuntimeException("unexpected node type " + a.getNodeType()); } a = findNextTextOrElementNode(a.getNextSibling()); b = findNextTextOrElementNode(b.getNextSibling()); } return a == b; // both null } private Node findNextTextOrElementNode(Node n) { while (n != null && !(n.getNodeType() == Node.ELEMENT_NODE || n.getNodeType() == Node.TEXT_NODE)) { n = n.getNextSibling(); } return n; } private boolean compareAttributes(Node a, Node b) { NamedNodeMap nnma = a.getAttributes(), nnmb = b.getAttributes(); if (nnma.getLength() != nnmb.getLength()) return false; for (int i=0; i<nnma.getLength(); i++) { Node ta = nnma.item(i); Node tb = ta.getLocalName() == null ? nnmb.getNamedItem(ta.getNodeName()) : nnmb.getNamedItemNS(ta.getNamespaceURI(), ta.getLocalName()); if (tb == null || !safeEquals(ta.getNodeValue(), tb.getNodeValue())) return false; } return true; } private boolean compareNames(Node a, Node b) { if (a.getLocalName() != null || b.getLocalName() != null) { return safeEquals(a.getNamespaceURI(), b.getNamespaceURI()) && safeEquals(a.getLocalName(), b.getLocalName()); } else { return safeEquals(a.getNodeName(), b.getNodeName()); } } private boolean safeEquals(Object a, Object b) { return a == null ? b == null : a.equals(b); } } Index: ModuleImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/ModuleImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ModuleImpl.java 29 Jun 2004 14:21:23 -0000 1.4 --- ModuleImpl.java 24 Sep 2004 09:49:32 -0000 1.5 *************** *** 48,51 **** --- 48,52 ---- new FunctionDef(FunCurrentTime.signature, FunCurrentTime.class), new FunctionDef(FunData.signature, FunData.class), + new FunctionDef(FunDeepEqual.signature, FunDeepEqual.class), new FunctionDef(FunDistinctValues.signature, FunDistinctValues.class), new FunctionDef(FunDoc.signature, FunDoc.class), |
From: Wolfgang M. M. <wol...@us...> - 2004-09-24 09:23:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16782/src/org/exist/xupdate Modified Files: Append.java Log Message: Appending an attribute that is already present in an element will no longer throw an exception. Instead, the new attribute value will simply overwrite the old one. Index: Append.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Append.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Append.java 23 Sep 2004 19:44:24 -0000 1.19 --- Append.java 24 Sep 2004 09:23:27 -0000 1.20 *************** *** 40,43 **** --- 40,46 ---- * Implements an XUpate append statement. * + * Note: appending an attribute that is already present in + * an element will overwrite the old attribute value. + * * @author Wolfgang Meier */ |
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25835/src/org/exist/xquery/value Modified Files: IntegerValue.java AtomicValue.java NumericValue.java DurationValue.java TimeValue.java AnyURIValue.java UntypedAtomicValue.java DoubleValue.java ComputableValue.java DateValue.java StringValue.java DecimalValue.java QNameValue.java DateTimeValue.java YearMonthDurationValue.java JavaObjectValue.java DayTimeDurationValue.java FloatValue.java BooleanValue.java Log Message: More string functions modified to support collations. Index: UntypedAtomicValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/UntypedAtomicValue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UntypedAtomicValue.java 22 Sep 2004 21:50:06 -0000 1.4 --- UntypedAtomicValue.java 23 Sep 2004 22:00:12 -0000 1.5 *************** *** 144,151 **** */ public int compareTo(Collator collator, AtomicValue other) throws XPathException { ! if(collator == null) ! return value.compareTo(other.getStringValue()); ! else ! return collator.compare(value, other.getStringValue()); } --- 144,148 ---- */ public int compareTo(Collator collator, AtomicValue other) throws XPathException { ! return Collations.compare(collator, value, other.getStringValue()); } *************** *** 153,164 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return value.compareTo(((StringValue) other).value) > 0 ? this : other; else ! return value.compareTo(((StringValue) other.convertTo(Type.STRING)).value) ! > 0 ! ? this ! : other; } --- 150,160 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return Collations.compare(collator, value, ((StringValue) other).value) > 0 ? this : other; else ! return Collations.compare(collator, value, ((StringValue) other.convertTo(getType())).value) > 0 ! ? this ! : other; } *************** *** 166,175 **** * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return value.compareTo(((StringValue) other).value) < 0 ? this : other; else ! return value.compareTo(((StringValue) other.convertTo(Type.STRING)).value) ! < 0 ? this : other; --- 162,170 ---- * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return Collations.compare(collator, value, ((StringValue) other).value) < 0 ? this : other; else ! return Collations.compare(collator, value, ((StringValue) other.convertTo(getType())).value) < 0 ? this : other; Index: FloatValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/FloatValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FloatValue.java 28 May 2004 10:54:10 -0000 1.3 --- FloatValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 24,27 **** --- 24,29 ---- package org.exist.xquery.value; + import java.text.Collator; + import org.exist.xquery.XPathException; *************** *** 193,208 **** * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.FLOAT)) return new FloatValue(Math.max(value, ((FloatValue) other).value)); else ! return ((FloatValue) convertTo(other.getType())).max(other); } ! public AtomicValue min(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.FLOAT)) return new FloatValue(Math.min(value, ((FloatValue) other).value)); else ! return ((FloatValue) convertTo(other.getType())).min(other); } --- 195,210 ---- * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.FLOAT)) return new FloatValue(Math.max(value, ((FloatValue) other).value)); else ! return ((FloatValue) convertTo(other.getType())).max(collator, other); } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.FLOAT)) return new FloatValue(Math.min(value, ((FloatValue) other).value)); else ! return ((FloatValue) convertTo(other.getType())).min(collator, other); } Index: DecimalValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DecimalValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DecimalValue.java 28 May 2004 10:54:10 -0000 1.3 --- DecimalValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 25,28 **** --- 25,29 ---- import java.math.BigDecimal; + import java.text.Collator; import org.exist.xquery.XPathException; *************** *** 209,213 **** * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (other.getType() == Type.DECIMAL) { return new DecimalValue(value.max(((DecimalValue) other).value)); --- 210,214 ---- * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DECIMAL) { return new DecimalValue(value.max(((DecimalValue) other).value)); *************** *** 217,221 **** } ! public AtomicValue min(AtomicValue other) throws XPathException { if (other.getType() == Type.DECIMAL) { return new DecimalValue(value.min(((DecimalValue) other).value)); --- 218,222 ---- } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DECIMAL) { return new DecimalValue(value.min(((DecimalValue) other).value)); Index: DoubleValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DoubleValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DoubleValue.java 28 May 2004 10:54:10 -0000 1.3 --- DoubleValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- import java.math.BigDecimal; + import java.text.Collator; import org.exist.xquery.XPathException; *************** *** 296,300 **** * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.DOUBLE)) return new DoubleValue(Math.max(value, ((DoubleValue) other).value)); --- 297,301 ---- * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.DOUBLE)) return new DoubleValue(Math.max(value, ((DoubleValue) other).value)); *************** *** 304,308 **** } ! public AtomicValue min(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.DOUBLE)) return new DoubleValue(Math.min(value, ((DoubleValue) other).value)); --- 305,309 ---- } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.DOUBLE)) return new DoubleValue(Math.min(value, ((DoubleValue) other).value)); Index: NumericValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/NumericValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NumericValue.java 22 Sep 2004 21:50:06 -0000 1.3 --- NumericValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 82,86 **** public abstract NumericValue mod(NumericValue other) throws XPathException; public abstract NumericValue abs() throws XPathException; ! public abstract AtomicValue max(AtomicValue other) throws XPathException; ! public abstract AtomicValue min(AtomicValue other) throws XPathException; } --- 82,86 ---- public abstract NumericValue mod(NumericValue other) throws XPathException; public abstract NumericValue abs() throws XPathException; ! public abstract AtomicValue max(Collator collator, AtomicValue other) throws XPathException; ! public abstract AtomicValue min(Collator collator, AtomicValue other) throws XPathException; } Index: AtomicValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/AtomicValue.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AtomicValue.java 22 Sep 2004 21:50:06 -0000 1.6 --- AtomicValue.java 23 Sep 2004 22:00:12 -0000 1.7 *************** *** 55,73 **** public abstract int compareTo(Collator collator, AtomicValue other) throws XPathException; ! public abstract AtomicValue max(AtomicValue other) throws XPathException; ! public abstract AtomicValue min(AtomicValue other) throws XPathException; ! public boolean startsWith(AtomicValue other) throws XPathException { throw new XPathException("Cannot call starts-with on value of type " + Type.getTypeName(getType())); } ! public boolean endsWith(AtomicValue other) throws XPathException { throw new XPathException("Cannot call ends-with on value of type " + Type.getTypeName(getType())); } ! public boolean contains(AtomicValue other) throws XPathException { throw new XPathException("Cannot call contains on value of type " + Type.getTypeName(getType())); --- 55,73 ---- public abstract int compareTo(Collator collator, AtomicValue other) throws XPathException; ! public abstract AtomicValue max(Collator collator, AtomicValue other) throws XPathException; ! public abstract AtomicValue min(Collator collator, AtomicValue other) throws XPathException; ! public boolean startsWith(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("Cannot call starts-with on value of type " + Type.getTypeName(getType())); } ! public boolean endsWith(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("Cannot call ends-with on value of type " + Type.getTypeName(getType())); } ! public boolean contains(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("Cannot call contains on value of type " + Type.getTypeName(getType())); *************** *** 277,281 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { return this; } --- 277,281 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { return this; } *************** *** 297,301 **** * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { return this; } --- 297,301 ---- * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { return this; } Index: ComputableValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/ComputableValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ComputableValue.java 22 Sep 2004 21:50:06 -0000 1.3 --- ComputableValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 55,64 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public abstract AtomicValue max(AtomicValue other) throws XPathException; /* (non-Javadoc) * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public abstract AtomicValue min(AtomicValue other) throws XPathException; public abstract ComputableValue minus(ComputableValue other) throws XPathException; --- 55,64 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public abstract AtomicValue max(Collator collator, AtomicValue other) throws XPathException; /* (non-Javadoc) * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public abstract AtomicValue min(Collator collator, AtomicValue other) throws XPathException; public abstract ComputableValue minus(ComputableValue other) throws XPathException; Index: YearMonthDurationValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/YearMonthDurationValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** YearMonthDurationValue.java 22 Sep 2004 21:50:07 -0000 1.3 --- YearMonthDurationValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 239,243 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (other.getType() == Type.YEAR_MONTH_DURATION) return compareTo(null, other) > 0 ? this : other; --- 239,243 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.YEAR_MONTH_DURATION) return compareTo(null, other) > 0 ? this : other; *************** *** 251,255 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { if (other.getType() == Type.YEAR_MONTH_DURATION) return compareTo(null, other) < 0 ? this : other; --- 251,255 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.YEAR_MONTH_DURATION) return compareTo(null, other) < 0 ? this : other; Index: IntegerValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/IntegerValue.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IntegerValue.java 12 Jul 2004 17:17:40 -0000 1.7 --- IntegerValue.java 23 Sep 2004 22:00:12 -0000 1.8 *************** *** 23,26 **** --- 23,27 ---- import java.math.BigDecimal; import java.math.BigInteger; + import java.text.Collator; import org.exist.xquery.XPathException; *************** *** 391,399 **** * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { return new IntegerValue( value.max( ((IntegerValue) other).value) ); } ! public AtomicValue min(AtomicValue other) throws XPathException { return new IntegerValue( value.min( ((IntegerValue) other).value) ); } --- 392,400 ---- * @see org.exist.xquery.value.NumericValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { return new IntegerValue( value.max( ((IntegerValue) other).value) ); } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { return new IntegerValue( value.min( ((IntegerValue) other).value) ); } Index: JavaObjectValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/JavaObjectValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JavaObjectValue.java 22 Sep 2004 21:50:07 -0000 1.3 --- JavaObjectValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 85,93 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: cannot compare Java objects"); } ! public AtomicValue min(AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: cannot compare Java objects"); } --- 85,93 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: cannot compare Java objects"); } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: cannot compare Java objects"); } Index: AnyURIValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/AnyURIValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AnyURIValue.java 22 Sep 2004 21:50:06 -0000 1.3 --- AnyURIValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 117,121 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { throw new XPathException("max is not supported for values of type xs:anyURI"); } --- 117,121 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("max is not supported for values of type xs:anyURI"); } *************** *** 124,128 **** * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { throw new XPathException("min is not supported for values of type xs:anyURI"); } --- 124,128 ---- * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("min is not supported for values of type xs:anyURI"); } Index: StringValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/StringValue.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** StringValue.java 22 Sep 2004 21:50:06 -0000 1.7 --- StringValue.java 23 Sep 2004 22:00:12 -0000 1.8 *************** *** 255,263 **** switch (truncation) { case Constants.TRUNC_BOTH : ! return value.indexOf(otherVal) > -1; case Constants.TRUNC_LEFT : ! return value.startsWith(otherVal); case Constants.TRUNC_RIGHT : ! return value.endsWith(otherVal); case Constants.TRUNC_NONE : return Collations.equals(collator, value, otherVal); --- 255,263 ---- switch (truncation) { case Constants.TRUNC_BOTH : ! return Collations.indexOf(collator, value, otherVal) > -1; case Constants.TRUNC_LEFT : ! return Collations.startsWith(collator, value, otherVal); case Constants.TRUNC_RIGHT : ! return Collations.endsWith(collator, value, otherVal); case Constants.TRUNC_NONE : return Collations.equals(collator, value, otherVal); *************** *** 291,298 **** */ public int compareTo(Collator collator, AtomicValue other) throws XPathException { ! if(collator == null) ! return value.compareTo(other.getStringValue()); ! else ! return collator.compare(value, other.getStringValue()); } --- 291,295 ---- */ public int compareTo(Collator collator, AtomicValue other) throws XPathException { ! return Collations.compare(collator, value, other.getStringValue()); } *************** *** 301,306 **** * @see org.exist.xquery.value.AtomicValue#startsWith(org.exist.xquery.value.AtomicValue) */ ! public boolean startsWith(AtomicValue other) throws XPathException { ! return value.startsWith(other.getStringValue()); } --- 298,303 ---- * @see org.exist.xquery.value.AtomicValue#startsWith(org.exist.xquery.value.AtomicValue) */ ! public boolean startsWith(Collator collator, AtomicValue other) throws XPathException { ! return Collations.startsWith(collator, value, other.getStringValue()); } *************** *** 309,314 **** * @see org.exist.xquery.value.AtomicValue#endsWith(org.exist.xquery.value.AtomicValue) */ ! public boolean endsWith(AtomicValue other) throws XPathException { ! return value.endsWith(other.getStringValue()); } --- 306,311 ---- * @see org.exist.xquery.value.AtomicValue#endsWith(org.exist.xquery.value.AtomicValue) */ ! public boolean endsWith(Collator collator, AtomicValue other) throws XPathException { ! return Collations.endsWith(collator, value, other.getStringValue()); } *************** *** 317,322 **** * @see org.exist.xquery.value.AtomicValue#contains(org.exist.xquery.value.AtomicValue) */ ! public boolean contains(AtomicValue other) throws XPathException { ! return value.indexOf(other.getStringValue()) > -1; } --- 314,319 ---- * @see org.exist.xquery.value.AtomicValue#contains(org.exist.xquery.value.AtomicValue) */ ! public boolean contains(Collator collator, AtomicValue other) throws XPathException { ! return Collations.indexOf(collator, value, other.getStringValue()) > -1; } *************** *** 454,471 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return value.compareTo(((StringValue) other).value) > 0 ? this : other; else ! return value.compareTo(((StringValue) other.convertTo(getType())).value) > 0 ? this : other; } ! public AtomicValue min(AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return value.compareTo(((StringValue) other).value) < 0 ? this : other; else ! return value.compareTo(((StringValue) other.convertTo(getType())).value) < 0 ? this : other; --- 451,468 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return Collations.compare(collator, value, ((StringValue) other).value) > 0 ? this : other; else ! return Collations.compare(collator, value, ((StringValue) other.convertTo(getType())).value) > 0 ? this : other; } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (Type.subTypeOf(other.getType(), Type.STRING)) ! return Collations.compare(collator, value, ((StringValue) other).value) < 0 ? this : other; else ! return Collations.compare(collator, value, ((StringValue) other.convertTo(getType())).value) < 0 ? this : other; Index: BooleanValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/BooleanValue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BooleanValue.java 22 Sep 2004 21:50:07 -0000 1.5 --- BooleanValue.java 23 Sep 2004 22:00:12 -0000 1.6 *************** *** 128,132 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (other.getType() == Type.BOOLEAN) { boolean otherValue = ((BooleanValue) other).value; --- 128,132 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.BOOLEAN) { boolean otherValue = ((BooleanValue) other).value; *************** *** 138,142 **** } ! public AtomicValue min(AtomicValue other) throws XPathException { if (other.getType() == Type.BOOLEAN) { boolean otherValue = ((BooleanValue) other).value; --- 138,142 ---- } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.BOOLEAN) { boolean otherValue = ((BooleanValue) other).value; Index: DateTimeValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DateTimeValue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DateTimeValue.java 22 Sep 2004 21:50:07 -0000 1.4 --- DateTimeValue.java 23 Sep 2004 22:00:12 -0000 1.5 *************** *** 269,273 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (other.getType() == Type.DATE_TIME) return date.compareTo(((DateTimeValue) other).date) > 0 ? this : other; --- 269,273 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DATE_TIME) return date.compareTo(((DateTimeValue) other).date) > 0 ? this : other; *************** *** 279,283 **** * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { if (other.getType() == Type.DATE_TIME) return date.compareTo(((DateTimeValue) other).date) < 0 ? this : other; --- 279,283 ---- * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DATE_TIME) return date.compareTo(((DateTimeValue) other).date) < 0 ? this : other; Index: DateValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DateValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DateValue.java 22 Sep 2004 21:50:06 -0000 1.3 --- DateValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 222,226 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (other.getType() == Type.DATE) return date.compareTo(((DateValue) other).date) > 0 ? this : other; --- 222,226 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DATE) return date.compareTo(((DateValue) other).date) > 0 ? this : other; *************** *** 234,238 **** * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { if (other.getType() == Type.DATE) return date.compareTo(((DateValue) other).date) < 0 ? this : other; --- 234,238 ---- * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DATE) return date.compareTo(((DateValue) other).date) < 0 ? this : other; Index: TimeValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/TimeValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TimeValue.java 22 Sep 2004 21:50:06 -0000 1.3 --- TimeValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 250,254 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (other.getType() == Type.TIME) return date.compareTo(((TimeValue) other).date) > 0 ? this : other; --- 250,254 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.TIME) return date.compareTo(((TimeValue) other).date) > 0 ? this : other; *************** *** 262,266 **** * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { if (other.getType() == Type.TIME) return date.compareTo(((TimeValue) other).date) < 0 ? this : other; --- 262,266 ---- * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.TIME) return date.compareTo(((TimeValue) other).date) < 0 ? this : other; Index: QNameValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/QNameValue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** QNameValue.java 22 Sep 2004 21:50:06 -0000 1.5 --- QNameValue.java 23 Sep 2004 22:00:12 -0000 1.6 *************** *** 122,130 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: QName"); } ! public AtomicValue min(AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: QName"); } --- 122,130 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: QName"); } ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("Invalid argument to aggregate function: QName"); } Index: DayTimeDurationValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DayTimeDurationValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DayTimeDurationValue.java 22 Sep 2004 21:50:07 -0000 1.3 --- DayTimeDurationValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 282,286 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { if (other.getType() == Type.DAY_TIME_DURATION) return compareTo(null, other) > 0 ? this : other; --- 282,286 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DAY_TIME_DURATION) return compareTo(null, other) > 0 ? this : other; *************** *** 294,298 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { if (other.getType() == Type.DAY_TIME_DURATION) return compareTo(null, other) < 0 ? this : other; --- 294,298 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.DAY_TIME_DURATION) return compareTo(null, other) < 0 ? this : other; Index: DurationValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/DurationValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DurationValue.java 22 Sep 2004 21:50:06 -0000 1.3 --- DurationValue.java 23 Sep 2004 22:00:12 -0000 1.4 *************** *** 259,263 **** * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(AtomicValue other) throws XPathException { throw new XPathException("xs:duration values cannot be compared. Use xdt:yearMonthDuration or xdt:dayTimeDuration instead"); } --- 259,263 ---- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("xs:duration values cannot be compared. Use xdt:yearMonthDuration or xdt:dayTimeDuration instead"); } *************** *** 266,270 **** * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(AtomicValue other) throws XPathException { throw new XPathException("xs:duration values cannot be compared. Use xdt:yearMonthDuration or xdt:dayTimeDuration instead"); } --- 266,270 ---- * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) */ ! public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { throw new XPathException("xs:duration values cannot be compared. Use xdt:yearMonthDuration or xdt:dayTimeDuration instead"); } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-23 22:00:57
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25835/src/org/exist/storage Modified Files: DBBroker.java NativeBroker.java Log Message: More string functions modified to support collations. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** NativeBroker.java 19 Sep 2004 16:02:57 -0000 1.102 --- NativeBroker.java 23 Sep 2004 22:00:14 -0000 1.103 *************** *** 26,29 **** --- 26,30 ---- import java.io.IOException; import java.io.UnsupportedEncodingException; + import java.text.Collator; import java.util.ArrayList; import java.util.Iterator; *************** *** 78,81 **** --- 79,83 ---- import org.exist.util.ByteArrayPool; import org.exist.util.ByteConversion; + import org.exist.util.Collations; import org.exist.util.Configuration; import org.exist.util.Lock; *************** *** 285,294 **** } ! private final boolean compare(String o1, String o2, int relation) { ! int cmp; ! if (!isCaseSensitive()) ! cmp = o1.compareToIgnoreCase(o2); ! else ! cmp = o1.compareTo(o2); switch (relation) { case Constants.LT : --- 287,292 ---- } ! private final boolean compare(Collator collator, String o1, String o2, int relation) { ! int cmp = Collations.compare(collator, o1, o2); switch (relation) { case Constants.LT : *************** *** 1495,1499 **** DocumentSet docs, int relation, ! String expr) { // long start = System.currentTimeMillis(); // NodeSet temp; --- 1493,1498 ---- DocumentSet docs, int relation, ! String expr, ! Collator collator) { // long start = System.currentTimeMillis(); // NodeSet temp; *************** *** 1512,1516 **** if (!isCaseSensitive()) expr = expr.toLowerCase(); ! NodeSet result = scanSequential(context, docs, relation, truncation, expr); // LOG.debug( // "searching " --- 1511,1515 ---- if (!isCaseSensitive()) expr = expr.toLowerCase(); ! NodeSet result = scanSequential(context, docs, relation, truncation, expr, collator); // LOG.debug( // "searching " *************** *** 2273,2277 **** int relation, int truncation, ! String expr) { ArraySet resultNodeSet = new ArraySet(context.getLength()); NodeProxy p; --- 2272,2277 ---- int relation, int truncation, ! String expr, ! Collator collator) { ArraySet resultNodeSet = new ArraySet(context.getLength()); NodeProxy p; *************** *** 2310,2326 **** switch (truncation) { case Constants.TRUNC_LEFT : ! if (cmp.endsWith(expr)) resultNodeSet.add(p); break; case Constants.TRUNC_RIGHT : ! if (cmp.startsWith(expr)) resultNodeSet.add(p); break; case Constants.TRUNC_BOTH : ! if (-1 < cmp.indexOf(expr)) resultNodeSet.add(p); break; case Constants.TRUNC_NONE : ! if (compare(cmp, expr, relation)) resultNodeSet.add(p); break; --- 2310,2326 ---- switch (truncation) { case Constants.TRUNC_LEFT : ! if (Collations.endsWith(collator, cmp, expr)) resultNodeSet.add(p); break; case Constants.TRUNC_RIGHT : ! if (Collations.startsWith(collator, cmp, expr)) resultNodeSet.add(p); break; case Constants.TRUNC_BOTH : ! if (-1 < Collations.indexOf(collator, cmp, expr)) resultNodeSet.add(p); break; case Constants.TRUNC_NONE : ! if (compare(collator, cmp, expr, relation)) resultNodeSet.add(p); break; Index: DBBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/DBBroker.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** DBBroker.java 16 Aug 2004 19:47:11 -0000 1.43 --- DBBroker.java 23 Sep 2004 22:00:14 -0000 1.44 *************** *** 28,31 **** --- 28,32 ---- import java.io.FileOutputStream; import java.io.IOException; + import java.text.Collator; import java.util.Iterator; import java.util.Observable; *************** *** 363,367 **** DocumentSet docs, int relation, ! String expr); /** --- 364,369 ---- DocumentSet docs, int relation, ! String expr, ! Collator collator); /** |
From: Wolfgang M. M. <wol...@us...> - 2004-09-23 22:00:57
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25835/src/org/exist/util Modified Files: Collations.java Log Message: More string functions modified to support collations. Index: Collations.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/Collations.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Collations.java 22 Sep 2004 21:50:07 -0000 1.1 --- Collations.java 23 Sep 2004 22:00:16 -0000 1.2 *************** *** 9,13 **** --- 9,15 ---- import java.net.URI; import java.net.URISyntaxException; + import java.text.CollationElementIterator; import java.text.Collator; + import java.text.RuleBasedCollator; import java.util.Locale; import java.util.StringTokenizer; *************** *** 102,105 **** --- 104,219 ---- } + public final static boolean startsWith(Collator collator, String s1, String s2) { + if(collator == null) + return s1.startsWith(s2); + else { + final RuleBasedCollator rbc = (RuleBasedCollator)collator; + final CollationElementIterator i1 = rbc.getCollationElementIterator(s1); + final CollationElementIterator i2 = rbc.getCollationElementIterator(s2); + return collationStartsWith(i1, i2); + } + } + + public final static boolean endsWith(Collator collator, String s1, String s2) { + if(collator == null) + return s1.endsWith(s2); + else { + final RuleBasedCollator rbc = (RuleBasedCollator)collator; + final CollationElementIterator i1 = rbc.getCollationElementIterator(s1); + final CollationElementIterator i2 = rbc.getCollationElementIterator(s2); + return collationContains(i1, i2, null, true); + } + } + + public final static boolean contains(Collator collator, String s1, String s2) { + if(collator == null) + return s1.indexOf(s2) > -1; + else { + final RuleBasedCollator rbc = (RuleBasedCollator)collator; + final CollationElementIterator i1 = rbc.getCollationElementIterator(s1); + final CollationElementIterator i2 = rbc.getCollationElementIterator(s2); + return collationContains(i1, i2, null, false); + } + } + + public final static int indexOf(Collator collator, String s1, String s2) { + if(collator == null) + return s1.indexOf(s2); + else { + final int offsets[] = new int[2]; + final RuleBasedCollator rbc = (RuleBasedCollator)collator; + final CollationElementIterator i1 = rbc.getCollationElementIterator(s1); + final CollationElementIterator i2 = rbc.getCollationElementIterator(s2); + final boolean found = collationContains(i1, i2, offsets, false); + if(found) + return offsets[0]; + else + return -1; + } + } + + private final static boolean collationStartsWith(CollationElementIterator s0, + CollationElementIterator s1) { + while (true) { + int e1 = s1.next(); + if (e1 == -1) { + return true; + } + int e0 = s0.next(); + if (e0 != e1) { + return false; + } + } + } + + private final static boolean collationContains(CollationElementIterator s0, CollationElementIterator s1, + int[] offsets, boolean endsWith ) { + int e1 = s1.next(); + if (e1 == -1) { + return true; + } + int e0 = -1; + while (true) { + // scan the first string to find a matching character + while (e0 != e1) { + e0 = s0.next(); + if (e0 == -1) { + // hit the end, no match + return false; + } + } + // matched first character, note the position of the possible match + int start = s0.getOffset(); + if (collationStartsWith(s0, s1)) { + if (endsWith) { + if (offsets != null) { + offsets[0] = start-1; + offsets[1] = s0.getOffset(); + } + return true; + } else { + // operation == ENDSWITH + if (s0.next() == -1) { + // the match is at the end + return true; + } + // else ignore this match and keep looking + } + } + // reset the position and try again + s0.setOffset(start); + + // workaround for a difference between JDK 1.4.0 and JDK 1.4.1 + if (s0.getOffset() != start) { + // JDK 1.4.0 takes this path + s0.next(); + } + s1.reset(); + e0 = -1; + e1 = s1.next(); + // loop round to try again + } + } + /** * @param lang |
From: Wolfgang M. M. <wol...@us...> - 2004-09-23 22:00:57
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25835/src/org/exist/xquery Modified Files: GeneralComparison.java Log Message: More string functions modified to support collations. Index: GeneralComparison.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/GeneralComparison.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GeneralComparison.java 22 Sep 2004 21:50:07 -0000 1.9 --- GeneralComparison.java 23 Sep 2004 22:00:14 -0000 1.10 *************** *** 289,293 **** } // now compare the input node set to the search expression ! return context.getBroker().getNodesEqualTo(nodes, docs, relation, cmp); } --- 289,293 ---- } // now compare the input node set to the search expression ! return context.getBroker().getNodesEqualTo(nodes, docs, relation, cmp, context.getDefaultCollator()); } *************** *** 333,341 **** switch(truncation) { case Constants.TRUNC_RIGHT: ! return lv.startsWith(rv); case Constants.TRUNC_LEFT: ! return lv.endsWith(rv); case Constants.TRUNC_BOTH: ! return lv.contains(rv); default: return lv.compareTo(context.getDefaultCollator(), relation, rv); --- 333,341 ---- switch(truncation) { case Constants.TRUNC_RIGHT: ! return lv.startsWith(context.getDefaultCollator(), rv); case Constants.TRUNC_LEFT: ! return lv.endsWith(context.getDefaultCollator(), rv); case Constants.TRUNC_BOTH: ! return lv.contains(context.getDefaultCollator(), rv); default: return lv.compareTo(context.getDefaultCollator(), relation, rv); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-23 22:00:57
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25835/src/org/exist/xquery/functions Modified Files: FunMax.java FunMin.java FunContains.java FunEndsWith.java FunStartsWith.java Log Message: More string functions modified to support collations. Index: FunMax.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunMax.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FunMax.java 12 Sep 2004 09:25:14 -0000 1.4 --- FunMax.java 23 Sep 2004 22:00:13 -0000 1.5 *************** *** 83,87 **** return DoubleValue.NaN; ! max = max.max(current); } return max; --- 83,87 ---- return DoubleValue.NaN; ! max = max.max(context.getDefaultCollator(), current); } return max; Index: FunEndsWith.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunEndsWith.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FunEndsWith.java 12 Sep 2004 09:25:14 -0000 1.2 --- FunEndsWith.java 23 Sep 2004 22:00:13 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- import org.exist.dom.QName; + import org.exist.util.Collations; import org.exist.xquery.Cardinality; import org.exist.xquery.Function; *************** *** 63,67 **** if (s1.getLength() == 0 || s2.getLength() == 0) return Sequence.EMPTY_SEQUENCE; ! if (s1.getStringValue().endsWith(s2.getStringValue())) return BooleanValue.TRUE; else --- 64,68 ---- if (s1.getLength() == 0 || s2.getLength() == 0) return Sequence.EMPTY_SEQUENCE; ! if (Collations.endsWith(context.getDefaultCollator(), s1.getStringValue(), s2.getStringValue())) return BooleanValue.TRUE; else Index: FunContains.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunContains.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FunContains.java 12 Sep 2004 09:25:14 -0000 1.2 --- FunContains.java 23 Sep 2004 22:00:13 -0000 1.3 *************** *** 7,10 **** --- 7,11 ---- import org.exist.dom.QName; + import org.exist.util.Collations; import org.exist.xquery.Cardinality; import org.exist.xquery.Function; *************** *** 52,56 **** .eval(contextSequence) .getStringValue(); ! if (s1.indexOf(s2) > -1) return BooleanValue.TRUE; else --- 53,57 ---- .eval(contextSequence) .getStringValue(); ! if (Collations.indexOf(context.getDefaultCollator(), s1, s2) > -1) return BooleanValue.TRUE; else Index: FunStartsWith.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunStartsWith.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FunStartsWith.java 12 Sep 2004 09:25:14 -0000 1.2 --- FunStartsWith.java 23 Sep 2004 22:00:13 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- import org.exist.dom.QName; + import org.exist.util.Collations; import org.exist.xquery.Cardinality; import org.exist.xquery.Function; *************** *** 57,61 **** if(s1.getLength() == 0 || s2.getLength() == 0) return Sequence.EMPTY_SEQUENCE; ! if(s1.getStringValue().startsWith(s2.getStringValue())) return BooleanValue.TRUE; else --- 58,62 ---- if(s1.getLength() == 0 || s2.getLength() == 0) return Sequence.EMPTY_SEQUENCE; ! if(Collations.startsWith(context.getDefaultCollator(), s1.getStringValue(), s2.getStringValue())) return BooleanValue.TRUE; else Index: FunMin.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunMin.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FunMin.java 12 Sep 2004 09:25:14 -0000 1.4 --- FunMin.java 23 Sep 2004 22:00:13 -0000 1.5 *************** *** 79,83 **** return DoubleValue.NaN; ! min = min.min(current); } return min; --- 79,83 ---- return DoubleValue.NaN; ! min = min.min(context.getDefaultCollator(), current); } return min; |
From: Wolfgang M. M. <wol...@us...> - 2004-09-23 22:00:31
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25835/src/org/exist/xquery/parser Modified Files: XQueryTreeParser.java XQueryParserTokenTypes.txt XQueryLexer.java XQueryParser.java XQueryParserTokenTypes.java Log Message: More string functions modified to support collations. Index: XQueryTreeParser.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryTreeParser.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** XQueryTreeParser.java 13 Sep 2004 14:06:36 -0000 1.21 --- XQueryTreeParser.java 23 Sep 2004 22:00:16 -0000 1.22 *************** *** 114,118 **** case XPOINTER: { ! AST __t278 = _t; org.exist.xquery.parser.XQueryAST tmp1_AST_in = (org.exist.xquery.parser.XQueryAST)_t; match(_t,XPOINTER); --- 114,118 ---- case XPOINTER: { ! AST __t279 = _t; org.exist.xquery.parser.XQueryAST tmp1_AST_in = (org.exist.xquery.parser.XQueryAST)_t; [...4435 lines suppressed...] private static final long[] mk_tokenSet_0() { ! long[] data = { 1442915454462623632L, -5765733423243055566L, 403177459L, 0L, 0L, 0L}; return data; } public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); private static final long[] mk_tokenSet_1() { ! long[] data = { 1152925765217026048L, 0L, 268435459L, 0L, 0L, 0L}; return data; } --- 5557,5566 ---- private static final long[] mk_tokenSet_0() { ! long[] data = { 5191673918136156048L, -4616189619262670648L, 1612709838L, 0L, 0L, 0L}; return data; } public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); private static final long[] mk_tokenSet_1() { ! long[] data = { 4611694539645124608L, 0L, 1073741836L, 0L, 0L, 0L}; return data; } Index: XQueryParser.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryParser.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** XQueryParser.java 12 Sep 2004 09:25:17 -0000 1.20 --- XQueryParser.java 23 Sep 2004 22:00:17 -0000 1.21 *************** *** 115,273 **** org.exist.xquery.parser.XQueryAST imaginaryTokenDefinitions_AST = null; - org.exist.xquery.parser.XQueryAST tmp84_AST = null; - tmp84_AST = (org.exist.xquery.parser.XQueryAST)astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp84_AST); - match(QNAME); - org.exist.xquery.parser.XQueryAST tmp85_AST = null; - tmp85_AST = (org.exist.xquery.parser.XQueryAST)astFactory.create(LT(1)); - astFactory.addASTChild(currentAST, tmp85_AST); - match(PREDICATE); [...5242 lines suppressed...] ! data[2]=562949953421311L; return data; } public static final BitSet _tokenSet_12 = new BitSet(mk_tokenSet_12()); private static final long[] mk_tokenSet_13() { ! long[] data = { 1152921504606846976L, 1073741824L, 8388611L, 0L, 0L, 0L}; return data; } --- 7200,7210 ---- long[] data = new long[8]; data[0]=-16L; ! data[1]=-72057602627862529L; ! data[2]=2251799813685247L; return data; } public static final BitSet _tokenSet_12 = new BitSet(mk_tokenSet_12()); private static final long[] mk_tokenSet_13() { ! long[] data = { 4611686018427387904L, 4294967296L, 33554444L, 0L, 0L, 0L}; return data; } Index: XQueryParserTokenTypes.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryParserTokenTypes.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** XQueryParserTokenTypes.java 12 Sep 2004 09:25:17 -0000 1.11 --- XQueryParserTokenTypes.java 23 Sep 2004 22:00:20 -0000 1.12 *************** *** 48,202 **** int NAMESPACE_DECL = 23; int DEF_NAMESPACE_DECL = 24; ! int DEF_FUNCTION_NS_DECL = 25; ! int GLOBAL_VAR = 26; ! int FUNCTION_DECL = 27; ! int PROLOG = 28; ! int ATOMIC_TYPE = 29; ! int MODULE = 30; ! int ORDER_BY = 31; ! int POSITIONAL_VAR = 32; ! int BEFORE = 33; ! int AFTER = 34; ! int MODULE_DECL = 35; ! int ATTRIBUTE_TEST = 36; ! int COMP_ELEM_CONSTRUCTOR = 37; ! int COMP_ATTR_CONSTRUCTOR = 38; ! int COMP_TEXT_CONSTRUCTOR = 39; ! int COMP_COMMENT_CONSTRUCTOR = 40; ! int COMP_PI_CONSTRUCTOR = 41; ! int COMP_NS_CONSTRUCTOR = 42; ! int LITERAL_xpointer = 43; ! int LPAREN = 44; ! int RPAREN = 45; ! int NCNAME = 46; ! int LITERAL_module = 47; ! int LITERAL_namespace = 48; ! int EQ = 49; ! int STRING_LITERAL = 50; ! int SEMICOLON = 51; ! int XQUERY = 52; ! int VERSION = 53; ! int LITERAL_declare = 54; ! int LITERAL_default = 55; ! int LITERAL_function = 56; ! int LITERAL_variable = 57; ! int LITERAL_element = 58; ! int DOLLAR = 59; ! int LCURLY = 60; ! int RCURLY = 61; ! int LITERAL_import = 62; ! int LITERAL_at = 63; ! int LITERAL_as = 64; ! int COMMA = 65; ! int LITERAL_empty = 66; ! int QUESTION = 67; ! int STAR = 68; ! int PLUS = 69; ! int LITERAL_item = 70; ! int LITERAL_for = 71; ! int LITERAL_let = 72; ! int LITERAL_some = 73; ! int LITERAL_every = 74; ! int LITERAL_if = 75; ! int LITERAL_where = 76; ! int LITERAL_return = 77; ! int LITERAL_in = 78; ! int COLON = 79; ! int LITERAL_order = 80; ! int LITERAL_by = 81; ! int LITERAL_ascending = 82; ! int LITERAL_descending = 83; ! int LITERAL_greatest = 84; ! int LITERAL_least = 85; ! int LITERAL_satisfies = 86; ! int LITERAL_then = 87; ! int LITERAL_else = 88; ! int LITERAL_or = 89; ! int LITERAL_and = 90; ! int LITERAL_instance = 91; ! int LITERAL_of = 92; ! int LITERAL_cast = 93; ! int LT = 94; ! int GT = 95; ! int LITERAL_eq = 96; ! int LITERAL_ne = 97; ! int LITERAL_lt = 98; ! int LITERAL_le = 99; ! int LITERAL_gt = 100; ! int LITERAL_ge = 101; ! int NEQ = 102; ! int GTEQ = 103; ! int LTEQ = 104; ! int LITERAL_is = 105; ! int LITERAL_isnot = 106; ! int ANDEQ = 107; ! int OREQ = 108; ! int LITERAL_to = 109; ! int MINUS = 110; ! int LITERAL_div = 111; ! int LITERAL_idiv = 112; ! int LITERAL_mod = 113; ! int LITERAL_union = 114; ! int UNION = 115; ! int LITERAL_intersect = 116; ! int LITERAL_except = 117; ! int SLASH = 118; ! int DSLASH = 119; ! int LITERAL_text = 120; ! int LITERAL_node = 121; ! int LITERAL_attribute = 122; ! int LITERAL_comment = 123; ! // "processing-instruction" = 124 ! // "document-node" = 125 ! int LITERAL_document = 126; ! int SELF = 127; ! int XML_COMMENT = 128; ! int XML_PI = 129; ! int LPPAREN = 130; ! int RPPAREN = 131; ! int AT = 132; ! int PARENT = 133; ! int LITERAL_child = 134; ! int LITERAL_self = 135; ! int LITERAL_descendant = 136; ! // "descendant-or-self" = 137 ! // "following-sibling" = 138 ! int LITERAL_following = 139; ! int LITERAL_parent = 140; ! int LITERAL_ancestor = 141; ! // "ancestor-or-self" = 142 ! // "preceding-sibling" = 143 ! int DOUBLE_LITERAL = 144; ! int DECIMAL_LITERAL = 145; ! int INTEGER_LITERAL = 146; ! int END_TAG_START = 147; ! int QUOT = 148; ! int APOS = 149; ! int ATTRIBUTE_CONTENT = 150; ! int ELEMENT_CONTENT = 151; ! int XML_COMMENT_END = 152; ! int XML_PI_END = 153; ! int LITERAL_collection = 154; ! int LITERAL_preceding = 155; ! int COMP_DOC_CONSTRUCTOR = 156; ! int XML_PI_START = 157; ! int LETTER = 158; ! int DIGITS = 159; ! int HEX_DIGITS = 160; ! int NMSTART = 161; ! int NMCHAR = 162; ! int WS = 163; ! int EXPR_COMMENT = 164; ! int PRAGMA = 165; ! int PRAGMA_CONTENT = 166; ! int PRAGMA_QNAME = 167; ! int PREDEFINED_ENTITY_REF = 168; ! int CHAR_REF = 169; ! int NEXT_TOKEN = 170; ! int CHAR = 171; ! int BASECHAR = 172; ! int IDEOGRAPHIC = 173; ! int COMBINING_CHAR = 174; ! int DIGIT = 175; ! int EXTENDER = 176; } --- 48,204 ---- int NAMESPACE_DECL = 23; int DEF_NAMESPACE_DECL = 24; ! int DEF_COLLATION_DECL = 25; ! int DEF_FUNCTION_NS_DECL = 26; ! int GLOBAL_VAR = 27; ! int FUNCTION_DECL = 28; ! int PROLOG = 29; ! int ATOMIC_TYPE = 30; ! int MODULE = 31; ! int ORDER_BY = 32; ! int POSITIONAL_VAR = 33; ! int BEFORE = 34; ! int AFTER = 35; ! int MODULE_DECL = 36; ! int ATTRIBUTE_TEST = 37; ! int COMP_ELEM_CONSTRUCTOR = 38; ! int COMP_ATTR_CONSTRUCTOR = 39; ! int COMP_TEXT_CONSTRUCTOR = 40; ! int COMP_COMMENT_CONSTRUCTOR = 41; ! int COMP_PI_CONSTRUCTOR = 42; ! int COMP_NS_CONSTRUCTOR = 43; ! int LITERAL_xpointer = 44; ! int LPAREN = 45; ! int RPAREN = 46; ! int NCNAME = 47; ! int LITERAL_module = 48; ! int LITERAL_namespace = 49; ! int EQ = 50; ! int STRING_LITERAL = 51; ! int SEMICOLON = 52; ! int XQUERY = 53; ! int VERSION = 54; ! int LITERAL_declare = 55; ! int LITERAL_default = 56; ! int LITERAL_function = 57; ! int LITERAL_variable = 58; ! int LITERAL_element = 59; ! int LITERAL_collation = 60; ! int DOLLAR = 61; ! int LCURLY = 62; ! int RCURLY = 63; ! int LITERAL_import = 64; ! int LITERAL_at = 65; ! int LITERAL_as = 66; ! int COMMA = 67; ! int LITERAL_empty = 68; ! int QUESTION = 69; ! int STAR = 70; ! int PLUS = 71; ! int LITERAL_item = 72; ! int LITERAL_for = 73; ! int LITERAL_let = 74; ! int LITERAL_some = 75; ! int LITERAL_every = 76; ! int LITERAL_if = 77; ! int LITERAL_where = 78; ! int LITERAL_return = 79; ! int LITERAL_in = 80; ! int COLON = 81; ! int LITERAL_order = 82; ! int LITERAL_by = 83; ! int LITERAL_ascending = 84; ! int LITERAL_descending = 85; ! int LITERAL_greatest = 86; ! int LITERAL_least = 87; ! int LITERAL_satisfies = 88; ! int LITERAL_then = 89; ! int LITERAL_else = 90; ! int LITERAL_or = 91; ! int LITERAL_and = 92; ! int LITERAL_instance = 93; ! int LITERAL_of = 94; ! int LITERAL_cast = 95; ! int LT = 96; ! int GT = 97; ! int LITERAL_eq = 98; ! int LITERAL_ne = 99; ! int LITERAL_lt = 100; ! int LITERAL_le = 101; ! int LITERAL_gt = 102; ! int LITERAL_ge = 103; ! int NEQ = 104; ! int GTEQ = 105; ! int LTEQ = 106; ! int LITERAL_is = 107; ! int LITERAL_isnot = 108; ! int ANDEQ = 109; ! int OREQ = 110; ! int LITERAL_to = 111; ! int MINUS = 112; ! int LITERAL_div = 113; ! int LITERAL_idiv = 114; ! int LITERAL_mod = 115; ! int LITERAL_union = 116; ! int UNION = 117; ! int LITERAL_intersect = 118; ! int LITERAL_except = 119; ! int SLASH = 120; ! int DSLASH = 121; ! int LITERAL_text = 122; ! int LITERAL_node = 123; ! int LITERAL_attribute = 124; ! int LITERAL_comment = 125; ! // "processing-instruction" = 126 ! // "document-node" = 127 ! int LITERAL_document = 128; ! int SELF = 129; ! int XML_COMMENT = 130; ! int XML_PI = 131; ! int LPPAREN = 132; ! int RPPAREN = 133; ! int AT = 134; ! int PARENT = 135; ! int LITERAL_child = 136; ! int LITERAL_self = 137; ! int LITERAL_descendant = 138; ! // "descendant-or-self" = 139 ! // "following-sibling" = 140 ! int LITERAL_following = 141; ! int LITERAL_parent = 142; ! int LITERAL_ancestor = 143; ! // "ancestor-or-self" = 144 ! // "preceding-sibling" = 145 ! int DOUBLE_LITERAL = 146; ! int DECIMAL_LITERAL = 147; ! int INTEGER_LITERAL = 148; ! int END_TAG_START = 149; ! int QUOT = 150; ! int APOS = 151; ! int ATTRIBUTE_CONTENT = 152; ! int ELEMENT_CONTENT = 153; ! int XML_COMMENT_END = 154; ! int XML_PI_END = 155; ! int LITERAL_collection = 156; ! int LITERAL_preceding = 157; ! int COMP_DOC_CONSTRUCTOR = 158; ! int XML_PI_START = 159; ! int LETTER = 160; ! int DIGITS = 161; ! int HEX_DIGITS = 162; ! int NMSTART = 163; ! int NMCHAR = 164; ! int WS = 165; ! int EXPR_COMMENT = 166; ! int PRAGMA = 167; ! int PRAGMA_CONTENT = 168; ! int PRAGMA_QNAME = 169; ! int PREDEFINED_ENTITY_REF = 170; ! int CHAR_REF = 171; ! int NEXT_TOKEN = 172; ! int CHAR = 173; ! int BASECHAR = 174; ! int IDEOGRAPHIC = 175; ! int COMBINING_CHAR = 176; ! int DIGIT = 177; ! int EXTENDER = 178; } Index: XQueryLexer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryLexer.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** XQueryLexer.java 12 Sep 2004 09:25:18 -0000 1.14 --- XQueryLexer.java 23 Sep 2004 22:00:17 -0000 1.15 *************** *** 80,154 **** setCaseSensitive(true); literals = new Hashtable(); ! literals.put(new ANTLRHashString("xpointer", this), new Integer(43)); ! literals.put(new ANTLRHashString("namespace", this), new Integer(48)); ! literals.put(new ANTLRHashString("comment", this), new Integer(123)); ! literals.put(new ANTLRHashString("ne", this), new Integer(97)); ! literals.put(new ANTLRHashString("le", this), new Integer(99)); ! literals.put(new ANTLRHashString("greatest", this), new Integer(84)); ! literals.put(new ANTLRHashString("ancestor-or-self", this), new Integer(142)); ! literals.put(new ANTLRHashString("descendant-or-self", this), new Integer(137)); [...1063 lines suppressed...] catch (RecognitionException pe) { ! synPredMatched609 = false; } ! rewind(_m609); inputState.guessing--; } ! if ( synPredMatched609 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { --- 4416,4425 ---- } catch (RecognitionException pe) { ! synPredMatched612 = false; } ! rewind(_m612); inputState.guessing--; } ! if ( synPredMatched612 ) { mDECIMAL_LITERAL(false); if ( inputState.guessing==0 ) { Index: XQueryParserTokenTypes.txt =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryParserTokenTypes.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** XQueryParserTokenTypes.txt 12 Sep 2004 09:25:17 -0000 1.13 --- XQueryParserTokenTypes.txt 23 Sep 2004 22:00:17 -0000 1.14 *************** *** 22,175 **** NAMESPACE_DECL=23 DEF_NAMESPACE_DECL=24 ! DEF_FUNCTION_NS_DECL=25 ! GLOBAL_VAR=26 ! FUNCTION_DECL=27 ! PROLOG=28 ! ATOMIC_TYPE=29 ! MODULE=30 ! ORDER_BY=31 ! POSITIONAL_VAR=32 ! BEFORE=33 ! AFTER=34 ! MODULE_DECL=35 ! ATTRIBUTE_TEST=36 ! COMP_ELEM_CONSTRUCTOR=37 ! COMP_ATTR_CONSTRUCTOR=38 ! COMP_TEXT_CONSTRUCTOR=39 ! COMP_COMMENT_CONSTRUCTOR=40 ! COMP_PI_CONSTRUCTOR=41 ! COMP_NS_CONSTRUCTOR=42 ! LITERAL_xpointer="xpointer"=43 ! LPAREN("'('")=44 ! RPAREN("')'")=45 ! NCNAME=46 ! LITERAL_module="module"=47 ! LITERAL_namespace="namespace"=48 ! EQ=49 ! STRING_LITERAL=50 ! SEMICOLON=51 ! XQUERY="xquery"=52 ! VERSION="version"=53 ! LITERAL_declare="declare"=54 ! LITERAL_default="default"=55 ! LITERAL_function="function"=56 ! LITERAL_variable="variable"=57 ! LITERAL_element="element"=58 ! DOLLAR=59 ! LCURLY=60 ! RCURLY=61 ! LITERAL_import="import"=62 ! LITERAL_at="at"=63 ! LITERAL_as="as"=64 ! COMMA=65 ! LITERAL_empty="empty"=66 ! QUESTION=67 ! STAR=68 ! PLUS=69 ! LITERAL_item="item"=70 ! LITERAL_for="for"=71 ! LITERAL_let="let"=72 ! LITERAL_some="some"=73 ! LITERAL_every="every"=74 ! LITERAL_if="if"=75 ! LITERAL_where="where"=76 ! LITERAL_return="return"=77 ! LITERAL_in="in"=78 ! COLON=79 ! LITERAL_order="order"=80 ! LITERAL_by="by"=81 ! LITERAL_ascending="ascending"=82 ! LITERAL_descending="descending"=83 ! LITERAL_greatest="greatest"=84 ! LITERAL_least="least"=85 ! LITERAL_satisfies="satisfies"=86 ! LITERAL_then="then"=87 ! LITERAL_else="else"=88 ! LITERAL_or="or"=89 ! LITERAL_and="and"=90 ! LITERAL_instance="instance"=91 ! LITERAL_of="of"=92 ! LITERAL_cast="cast"=93 ! LT=94 ! GT=95 ! LITERAL_eq="eq"=96 ! LITERAL_ne="ne"=97 ! LITERAL_lt="lt"=98 ! LITERAL_le="le"=99 ! LITERAL_gt="gt"=100 ! LITERAL_ge="ge"=101 ! NEQ=102 ! GTEQ=103 ! LTEQ=104 ! LITERAL_is="is"=105 ! LITERAL_isnot="isnot"=106 ! ANDEQ=107 ! OREQ=108 ! LITERAL_to="to"=109 ! MINUS=110 ! LITERAL_div="div"=111 ! LITERAL_idiv="idiv"=112 ! LITERAL_mod="mod"=113 ! LITERAL_union="union"=114 ! UNION=115 ! LITERAL_intersect="intersect"=116 ! LITERAL_except="except"=117 ! SLASH=118 ! DSLASH=119 ! LITERAL_text="text"=120 ! LITERAL_node="node"=121 ! LITERAL_attribute="attribute"=122 ! LITERAL_comment="comment"=123 ! "processing-instruction"=124 ! "document-node"=125 ! LITERAL_document="document"=126 ! SELF=127 ! XML_COMMENT=128 ! XML_PI=129 ! LPPAREN=130 ! RPPAREN=131 ! AT=132 ! PARENT=133 ! LITERAL_child="child"=134 ! LITERAL_self="self"=135 ! LITERAL_descendant="descendant"=136 ! "descendant-or-self"=137 ! "following-sibling"=138 ! LITERAL_following="following"=139 ! LITERAL_parent="parent"=140 ! LITERAL_ancestor="ancestor"=141 ! "ancestor-or-self"=142 ! "preceding-sibling"=143 ! DOUBLE_LITERAL=144 ! DECIMAL_LITERAL=145 ! INTEGER_LITERAL=146 ! END_TAG_START=147 ! QUOT=148 ! APOS=149 ! ATTRIBUTE_CONTENT=150 ! ELEMENT_CONTENT=151 ! XML_COMMENT_END=152 ! XML_PI_END=153 ! LITERAL_collection="collection"=154 ! LITERAL_preceding="preceding"=155 ! COMP_DOC_CONSTRUCTOR=156 ! XML_PI_START=157 ! LETTER=158 ! DIGITS=159 ! HEX_DIGITS=160 ! NMSTART=161 ! NMCHAR=162 ! WS=163 ! EXPR_COMMENT=164 ! PRAGMA=165 ! PRAGMA_CONTENT=166 ! PRAGMA_QNAME=167 ! PREDEFINED_ENTITY_REF=168 ! CHAR_REF=169 ! NEXT_TOKEN=170 ! CHAR=171 ! BASECHAR=172 ! IDEOGRAPHIC=173 ! COMBINING_CHAR=174 ! DIGIT=175 ! EXTENDER=176 --- 22,177 ---- NAMESPACE_DECL=23 DEF_NAMESPACE_DECL=24 ! DEF_COLLATION_DECL=25 ! DEF_FUNCTION_NS_DECL=26 ! GLOBAL_VAR=27 ! FUNCTION_DECL=28 ! PROLOG=29 ! ATOMIC_TYPE=30 ! MODULE=31 ! ORDER_BY=32 ! POSITIONAL_VAR=33 ! BEFORE=34 ! AFTER=35 ! MODULE_DECL=36 ! ATTRIBUTE_TEST=37 ! COMP_ELEM_CONSTRUCTOR=38 ! COMP_ATTR_CONSTRUCTOR=39 ! COMP_TEXT_CONSTRUCTOR=40 ! COMP_COMMENT_CONSTRUCTOR=41 ! COMP_PI_CONSTRUCTOR=42 ! COMP_NS_CONSTRUCTOR=43 ! LITERAL_xpointer="xpointer"=44 ! LPAREN("'('")=45 ! RPAREN("')'")=46 ! NCNAME=47 ! LITERAL_module="module"=48 ! LITERAL_namespace="namespace"=49 ! EQ=50 ! STRING_LITERAL=51 ! SEMICOLON=52 ! XQUERY="xquery"=53 ! VERSION="version"=54 ! LITERAL_declare="declare"=55 ! LITERAL_default="default"=56 ! LITERAL_function="function"=57 ! LITERAL_variable="variable"=58 ! LITERAL_element="element"=59 ! LITERAL_collation="collation"=60 ! DOLLAR=61 ! LCURLY=62 ! RCURLY=63 ! LITERAL_import="import"=64 ! LITERAL_at="at"=65 ! LITERAL_as="as"=66 ! COMMA=67 ! LITERAL_empty="empty"=68 ! QUESTION=69 ! STAR=70 ! PLUS=71 ! LITERAL_item="item"=72 ! LITERAL_for="for"=73 ! LITERAL_let="let"=74 ! LITERAL_some="some"=75 ! LITERAL_every="every"=76 ! LITERAL_if="if"=77 ! LITERAL_where="where"=78 ! LITERAL_return="return"=79 ! LITERAL_in="in"=80 ! COLON=81 ! LITERAL_order="order"=82 ! LITERAL_by="by"=83 ! LITERAL_ascending="ascending"=84 ! LITERAL_descending="descending"=85 ! LITERAL_greatest="greatest"=86 ! LITERAL_least="least"=87 ! LITERAL_satisfies="satisfies"=88 ! LITERAL_then="then"=89 ! LITERAL_else="else"=90 ! LITERAL_or="or"=91 ! LITERAL_and="and"=92 ! LITERAL_instance="instance"=93 ! LITERAL_of="of"=94 ! LITERAL_cast="cast"=95 ! LT=96 ! GT=97 ! LITERAL_eq="eq"=98 ! LITERAL_ne="ne"=99 ! LITERAL_lt="lt"=100 ! LITERAL_le="le"=101 ! LITERAL_gt="gt"=102 ! LITERAL_ge="ge"=103 ! NEQ=104 ! GTEQ=105 ! LTEQ=106 ! LITERAL_is="is"=107 ! LITERAL_isnot="isnot"=108 ! ANDEQ=109 ! OREQ=110 ! LITERAL_to="to"=111 ! MINUS=112 ! LITERAL_div="div"=113 ! LITERAL_idiv="idiv"=114 ! LITERAL_mod="mod"=115 ! LITERAL_union="union"=116 ! UNION=117 ! LITERAL_intersect="intersect"=118 ! LITERAL_except="except"=119 ! SLASH=120 ! DSLASH=121 ! LITERAL_text="text"=122 ! LITERAL_node="node"=123 ! LITERAL_attribute="attribute"=124 ! LITERAL_comment="comment"=125 ! "processing-instruction"=126 ! "document-node"=127 ! LITERAL_document="document"=128 ! SELF=129 ! XML_COMMENT=130 ! XML_PI=131 ! LPPAREN=132 ! RPPAREN=133 ! AT=134 ! PARENT=135 ! LITERAL_child="child"=136 ! LITERAL_self="self"=137 ! LITERAL_descendant="descendant"=138 ! "descendant-or-self"=139 ! "following-sibling"=140 ! LITERAL_following="following"=141 ! LITERAL_parent="parent"=142 ! LITERAL_ancestor="ancestor"=143 ! "ancestor-or-self"=144 ! "preceding-sibling"=145 ! DOUBLE_LITERAL=146 ! DECIMAL_LITERAL=147 ! INTEGER_LITERAL=148 ! END_TAG_START=149 ! QUOT=150 ! APOS=151 ! ATTRIBUTE_CONTENT=152 ! ELEMENT_CONTENT=153 ! XML_COMMENT_END=154 ! XML_PI_END=155 ! LITERAL_collection="collection"=156 ! LITERAL_preceding="preceding"=157 ! COMP_DOC_CONSTRUCTOR=158 ! XML_PI_START=159 ! LETTER=160 ! DIGITS=161 ! HEX_DIGITS=162 ! NMSTART=163 ! NMCHAR=164 ! WS=165 ! EXPR_COMMENT=166 ! PRAGMA=167 ! PRAGMA_CONTENT=168 ! PRAGMA_QNAME=169 ! PREDEFINED_ENTITY_REF=170 ! CHAR_REF=171 ! NEXT_TOKEN=172 ! CHAR=173 ! BASECHAR=174 ! IDEOGRAPHIC=175 ! COMBINING_CHAR=176 ! DIGIT=177 ! EXTENDER=178 |
From: Wolfgang M. M. <wol...@us...> - 2004-09-23 22:00:31
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25835/src/org/exist/dom Modified Files: ElementImpl.java Log Message: More string functions modified to support collations. Index: ElementImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ElementImpl.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** ElementImpl.java 21 Sep 2004 14:42:06 -0000 1.48 --- ElementImpl.java 23 Sep 2004 22:00:20 -0000 1.49 *************** *** 1204,1212 **** // reindex if required ownerDocument.broker.reindex(prevDoc, ownerDocument, null); - // try { - // ownerDocument.broker.saveCollection(ownerDocument.getCollection()); - // } catch (PermissionDeniedException e) { - // throw new DOMException(DOMException.INVALID_ACCESS_ERR, e.getMessage()); - // } } --- 1204,1207 ---- *************** *** 1345,1349 **** else previous = getLastNode(previous); ! ownerDocument.broker.removeNode(old, old.getPath()); ownerDocument.broker.endRemove(); appendChild(old.gid, previous, getPath(), newChild, true); --- 1340,1344 ---- else previous = getLastNode(previous); ! removeAll(old, old.getPath()); ownerDocument.broker.endRemove(); appendChild(old.gid, previous, getPath(), newChild, true); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-23 19:44:41
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28793/src/org/exist/xupdate Modified Files: XUpdateProcessor.java Rename.java Append.java Conditional.java Insert.java Modification.java Remove.java Update.java Added Files: Replace.java Log Message: 1) Added XUpdate extension: xupdate:replace. Replaces the selected nodes with a new node as specified in the content. 2) Declared variables are now passed to all select statements, including value-of and other xupdate:variable declarations. 3) Added test cases for xupdate:replace and xupdate:variable Index: XUpdateProcessor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/XUpdateProcessor.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** XUpdateProcessor.java 21 Sep 2004 21:04:53 -0000 1.27 --- XUpdateProcessor.java 23 Sep 2004 19:44:24 -0000 1.28 *************** *** 61,64 **** --- 61,86 ---- public class XUpdateProcessor implements ContentHandler, LexicalHandler { + public static final String MODIFICATIONS = "modifications"; + + // Modifications + public static final String INSERT_AFTER = "insert-after"; + public static final String INSERT_BEFORE = "insert-before"; + public static final String REPLACE = "replace"; + public static final String RENAME = "rename"; + public static final String REMOVE = "remove"; + public static final String APPEND = "append"; + public static final String UPDATE = "update"; + + // node constructors + public static final String COMMENT = "comment"; + public static final String PROCESSING_INSTRUCTION = "processing-instruction"; + public static final String TEXT = "text"; + public static final String ATTRIBUTE = "attribute"; + public static final String ELEMENT = "element"; + + public static final String VALUE_OF = "value-of"; + public static final String VARIABLE = "variable"; + public static final String IF = "if"; + public final static String XUPDATE_NS = "http://www.xmldb.org/xupdate"; *************** *** 198,226 **** } if (namespaceURI.equals(XUPDATE_NS)) { ! if (localName.equals("modifications")) { startModifications(atts); return; ! } ! ! // variable declaration ! if (localName.equals("variable")) { startVariableDecl(atts); return; ! } ! ! String select = null; ! if ("if".equals(localName)) { if (inModification) throw new SAXException("xupdate:if is not allowed inside a modification"); select = atts.getValue("test"); ! Conditional cond = new Conditional(broker, documentSet, select, namespaces); conditionals.push(cond); return; ! } else if ("append".equals(localName) ! || "insert-before".equals(localName) ! || "insert-after".equals(localName) ! || "remove".equals(localName) ! || "rename".equals(localName) ! || "update".equals(localName)) { if (inModification) throw new SAXException("nested modifications are not allowed"); --- 220,249 ---- } if (namespaceURI.equals(XUPDATE_NS)) { ! String select = null; ! if (localName.equals(MODIFICATIONS)) { startModifications(atts); return; ! } else if (localName.equals(VARIABLE)) { ! // variable declaration startVariableDecl(atts); return; ! } else if (IF.equals(localName)) { if (inModification) throw new SAXException("xupdate:if is not allowed inside a modification"); select = atts.getValue("test"); ! Conditional cond = new Conditional(broker, documentSet, select, namespaces, variables); conditionals.push(cond); return; ! } else if (VALUE_OF.equals(localName)) { ! if(!inModification) ! throw new SAXException("xupdate:value-of is not allowed outside a modification"); ! ! } else if (APPEND.equals(localName) ! || INSERT_BEFORE.equals(localName) ! || INSERT_AFTER.equals(localName) ! || REMOVE.equals(localName) ! || RENAME.equals(localName) ! || UPDATE.equals(localName) ! || REPLACE.equals(localName)) { if (inModification) throw new SAXException("nested modifications are not allowed"); *************** *** 233,265 **** inModification = true; } else if ( ! ("element".equals(localName) ! || "attribute".equals(localName) ! || "text".equals(localName) ! || "processing-instruction".equals(localName) ! || "comment".equals(localName)) ! && (!inModification)) ! throw new SAXException( ! "creation elements are only allowed inside " ! + "a modification"); // start a new modification section ! if ("append".equals(localName)) { String child = atts.getValue("child"); ! modification = new Append(broker, documentSet, select, child, namespaces); ! } else if ("update".equals(localName)) ! modification = new Update(broker, documentSet, select, namespaces); ! else if ("insert-before".equals(localName)) modification = ! new Insert(broker, documentSet, select, Insert.INSERT_BEFORE, namespaces); ! else if ("insert-after".equals(localName)) modification = ! new Insert(broker, documentSet, select, Insert.INSERT_AFTER, namespaces); ! else if ("remove".equals(localName)) ! modification = new Remove(broker, documentSet, select, namespaces); ! else if ("rename".equals(localName)) ! modification = new Rename(broker, documentSet, select, namespaces); // process commands for node creation ! else if ("element".equals(localName)) { String name = atts.getValue("name"); if (name == null) --- 256,292 ---- inModification = true; } else if ( ! (ELEMENT.equals(localName) ! || ATTRIBUTE.equals(localName) ! || TEXT.equals(localName) ! || PROCESSING_INSTRUCTION.equals(localName) ! || COMMENT.equals(localName))) { ! if(!inModification) ! throw new SAXException( ! "creation elements are only allowed inside " ! + "a modification"); ! } else ! throw new SAXException("Unknown XUpdate element: " + qName); // start a new modification section ! if (APPEND.equals(localName)) { String child = atts.getValue("child"); ! modification = new Append(broker, documentSet, select, child, namespaces, variables); ! } else if (UPDATE.equals(localName)) ! modification = new Update(broker, documentSet, select, namespaces, variables); ! else if (INSERT_BEFORE.equals(localName)) modification = ! new Insert(broker, documentSet, select, Insert.INSERT_BEFORE, namespaces, variables); ! else if (INSERT_AFTER.equals(localName)) modification = ! new Insert(broker, documentSet, select, Insert.INSERT_AFTER, namespaces, variables); ! else if (REMOVE.equals(localName)) ! modification = new Remove(broker, documentSet, select, namespaces, variables); ! else if (RENAME.equals(localName)) ! modification = new Rename(broker, documentSet, select, namespaces, variables); ! else if (REPLACE.equals(localName)) ! modification = new Replace(broker, documentSet, select, namespaces, variables); // process commands for node creation ! else if (ELEMENT.equals(localName)) { String name = atts.getValue("name"); if (name == null) *************** *** 289,293 **** } stack.push(elem); ! } else if ("attribute".equals(localName)) { String name = atts.getValue("name"); if (name == null) --- 316,320 ---- } stack.push(elem); ! } else if (ATTRIBUTE.equals(localName)) { String name = atts.getValue("name"); if (name == null) *************** *** 329,333 **** // process value-of ! } else if ("value-of".equals(localName)) { select = atts.getValue("select"); if (select == null) --- 356,360 ---- // process value-of ! } else if (VALUE_OF.equals(localName)) { select = atts.getValue("select"); if (select == null) *************** *** 418,434 **** } if (XUPDATE_NS.equals(namespaceURI)) { ! if ("if".equals(localName)) { Conditional cond = (Conditional) conditionals.pop(); modifications.add(cond); ! } else if (localName.equals("element")) { stack.pop(); ! } else if (localName.equals("attribute")) { inAttribute = false; ! } else if (localName.equals("append") ! || localName.equals("update") ! || localName.equals("remove") ! || localName.equals("rename") ! || localName.equals("insert-before") ! || localName.equals("insert-after")) { inModification = false; modification.setContent(contents); --- 445,462 ---- } if (XUPDATE_NS.equals(namespaceURI)) { ! if (IF.equals(localName)) { Conditional cond = (Conditional) conditionals.pop(); modifications.add(cond); ! } else if (localName.equals(ELEMENT)) { stack.pop(); ! } else if (localName.equals(ATTRIBUTE)) { inAttribute = false; ! } else if (localName.equals(APPEND) ! || localName.equals(UPDATE) ! || localName.equals(REMOVE) ! || localName.equals(RENAME) ! || localName.equals(REPLACE) ! || localName.equals(INSERT_BEFORE) ! || localName.equals(INSERT_AFTER)) { inModification = false; modification.setContent(contents); *************** *** 517,521 **** variables.put(name, result); } ! private Sequence processQuery(String select) throws SAXException { try { --- 545,549 ---- variables.put(name, result); } ! private Sequence processQuery(String select) throws SAXException { try { Index: Append.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Append.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Append.java 23 Jun 2004 12:43:05 -0000 1.18 --- Append.java 23 Sep 2004 19:44:24 -0000 1.19 *************** *** 51,56 **** */ public Append(DBBroker broker, DocumentSet docs, String selectStmt, ! String childAttr, Map namespaces) { ! super(broker, docs, selectStmt, namespaces); if(childAttr == null || childAttr.equals("last()")) child = -1; --- 51,56 ---- */ public Append(DBBroker broker, DocumentSet docs, String selectStmt, ! String childAttr, Map namespaces, Map variables) { ! super(broker, docs, selectStmt, namespaces, variables); if(childAttr == null || childAttr.equals("last()")) child = -1; Index: Update.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Update.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Update.java 23 Jun 2004 12:43:05 -0000 1.16 --- Update.java 23 Sep 2004 19:44:24 -0000 1.17 *************** *** 54,59 **** */ public Update(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces) { ! super(broker, docs, selectStmt, namespaces); } --- 54,59 ---- */ public Update(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces, Map variables) { ! super(broker, docs, selectStmt, namespaces, variables); } *************** *** 103,113 **** case Node.TEXT_NODE: parent = (ElementImpl) node.getParentNode(); ! if (children.getLength() != 0) { ! temp = children.item(0); ! text = new TextImpl(temp.getNodeValue()); ! } else { ! modifications = 1; ! text = new TextImpl(""); ! } text.setOwnerDocument(doc); parent.updateChild(node, text); --- 103,109 ---- case Node.TEXT_NODE: parent = (ElementImpl) node.getParentNode(); ! temp = children.item(0); ! text = new TextImpl(temp.getNodeValue()); ! modifications = 1; text.setOwnerDocument(doc); parent.updateChild(node, text); *************** *** 121,132 **** } AttrImpl attr = (AttrImpl) node; ! if (children.getLength() != 0) { ! temp = children.item(0); ! attribute = new AttrImpl(attr.getQName(), temp ! .getNodeValue()); ! } else { ! modifications = 1; ! attribute = new AttrImpl(attr.getQName(), ""); ! } attribute.setOwnerDocument(doc); parent.updateChild(node, attribute); --- 117,122 ---- } AttrImpl attr = (AttrImpl) node; ! temp = children.item(0); ! attribute = new AttrImpl(attr.getQName(), temp.getNodeValue()); attribute.setOwnerDocument(doc); parent.updateChild(node, attribute); *************** *** 152,156 **** */ public String getName() { ! return "update"; } --- 142,146 ---- */ public String getName() { ! return XUpdateProcessor.UPDATE; } Index: Insert.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Insert.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Insert.java 23 Jun 2004 12:43:05 -0000 1.16 --- Insert.java 23 Sep 2004 19:44:24 -0000 1.17 *************** *** 56,66 **** */ public Insert(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces) { ! super(broker, docs, selectStmt, namespaces); } public Insert(DBBroker broker, DocumentSet docs, String selectStmt, ! int mode, Map namespaces) { ! this(broker, docs, selectStmt, namespaces); this.mode = mode; } --- 56,66 ---- */ public Insert(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces, Map variables) { ! super(broker, docs, selectStmt, namespaces, variables); } public Insert(DBBroker broker, DocumentSet docs, String selectStmt, ! int mode, Map namespaces, Map variables) { ! this(broker, docs, selectStmt, namespaces, variables); this.mode = mode; } --- NEW FILE: Replace.java --- package org.exist.xupdate; import java.util.Map; import org.exist.EXistException; import org.exist.collections.Collection; import org.exist.dom.AttrImpl; import org.exist.dom.DocumentImpl; import org.exist.dom.DocumentSet; import org.exist.dom.ElementImpl; import org.exist.dom.NodeImpl; import org.exist.dom.TextImpl; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; import org.exist.storage.DBBroker; import org.exist.util.LockException; import org.exist.xquery.XPathException; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * Implements xupdate:replace, an extension to the XUpdate standard. * The modification replaces a node and its contents. It differs from xupdate:update * which only replaces the contents of the node, not the node itself. * * @author wolf */ public class Replace extends Modification { /** * @param broker * @param docs * @param selectStmt * @param namespaces * @param variables */ public Replace(DBBroker broker, DocumentSet docs, String selectStmt, Map namespaces, Map variables) { super(broker, docs, selectStmt, namespaces, variables); } /* (non-Javadoc) * @see org.exist.xupdate.Modification#process() */ public long process() throws PermissionDeniedException, LockException, EXistException, XPathException { NodeList children = content; if (children.getLength() == 0) return 0; if (children.getLength() > 1) throw new EXistException("xupdate:replace requires exactly one content node"); LOG.debug("processing replace ..."); int modifications = children.getLength(); try { NodeImpl ql[] = selectAndLock(); IndexListener listener = new IndexListener(ql); NodeImpl node; Node temp; TextImpl text; AttrImpl attribute; ElementImpl parent; DocumentImpl doc = null; Collection collection = null, prevCollection = null; DocumentSet modifiedDocs = new DocumentSet(); for (int i = 0; i < ql.length; i++) { node = ql[i]; if (node == null) { LOG.warn("select " + selectStmt + " returned empty node set"); continue; } doc = (DocumentImpl) node.getOwnerDocument(); doc.setIndexListener(listener); modifiedDocs.add(doc); collection = doc.getCollection(); if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE)) throw new PermissionDeniedException( "permission to update document denied"); if (prevCollection != null && collection != prevCollection) doc.getBroker().saveCollection(prevCollection); parent = (ElementImpl) node.getParentNode(); switch (node.getNodeType()) { case Node.ELEMENT_NODE: if (modifications == 0) modifications = 1; temp = children.item(0); parent.replaceChild(temp, node); break; case Node.TEXT_NODE: temp = children.item(0); text = new TextImpl(temp.getNodeValue()); modifications = 1; text.setOwnerDocument(doc); parent.updateChild(node, text); break; case Node.ATTRIBUTE_NODE: AttrImpl attr = (AttrImpl) node; temp = children.item(0); attribute = new AttrImpl(attr.getQName(), temp .getNodeValue()); attribute.setOwnerDocument(doc); parent.updateChild(node, attribute); break; default: throw new EXistException("unsupported node-type"); } doc.setLastModified(System.currentTimeMillis()); prevCollection = collection; } if (doc != null) doc.getBroker().saveCollection(collection); checkFragmentation(modifiedDocs); } finally { unlockDocuments(); } return modifications; } /* (non-Javadoc) * @see org.exist.xupdate.Modification#getName() */ public String getName() { return XUpdateProcessor.REPLACE; } } Index: Modification.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Modification.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Modification.java 22 Sep 2004 12:39:21 -0000 1.33 --- Modification.java 23 Sep 2004 19:44:24 -0000 1.34 *************** *** 28,31 **** --- 28,32 ---- import java.util.Iterator; import java.util.Map; + import java.util.TreeMap; import org.apache.log4j.Logger; *************** *** 66,69 **** --- 67,71 ---- protected DocumentSet docs; protected Map namespaces; + protected Map variables; protected DocumentSet lockedDocuments = null; *************** *** 72,80 **** */ public Modification(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces) { this.selectStmt = selectStmt; this.broker = broker; this.docs = docs; this.namespaces = new HashMap(namespaces); } --- 74,83 ---- */ public Modification(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces, Map variables) { this.selectStmt = selectStmt; this.broker = broker; this.docs = docs; this.namespaces = new HashMap(namespaces); + this.variables = new TreeMap(variables); } *************** *** 122,126 **** context.setStaticallyKnownDocuments(docs); declareNamespaces(context); ! if(compiled == null) try { --- 125,129 ---- context.setStaticallyKnownDocuments(docs); declareNamespaces(context); ! declareVariables(context); if(compiled == null) try { *************** *** 146,149 **** --- 149,163 ---- /** * @param context + * @throws XPathException + */ + protected void declareVariables(XQueryContext context) throws XPathException { + for (Iterator i = variables.entrySet().iterator(); i.hasNext(); ) { + Map.Entry entry = (Map.Entry) i.next(); + context.declareVariable(entry.getKey().toString(), entry.getValue()); + } + } + + /** + * @param context */ protected void declareNamespaces(XQueryContext context) { Index: Remove.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Remove.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Remove.java 23 Jun 2004 12:43:05 -0000 1.14 --- Remove.java 23 Sep 2004 19:44:24 -0000 1.15 *************** *** 50,55 **** */ public Remove(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces) { ! super(broker, docs, selectStmt, namespaces); } --- 50,55 ---- */ public Remove(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces, Map variables) { ! super(broker, docs, selectStmt, namespaces, variables); } Index: Conditional.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Conditional.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Conditional.java 22 Sep 2004 12:39:21 -0000 1.2 --- Conditional.java 23 Sep 2004 19:44:24 -0000 1.3 *************** *** 55,60 **** */ public Conditional(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces) { ! super(broker, docs, selectStmt, namespaces); } --- 55,60 ---- */ public Conditional(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces, Map variables) { ! super(broker, docs, selectStmt, namespaces, variables); } *************** *** 82,85 **** --- 82,86 ---- context.setStaticallyKnownDocuments(docs); declareNamespaces(context); + declareVariables(context); if(compiled == null) try { Index: Rename.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Rename.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Rename.java 23 Jun 2004 12:43:05 -0000 1.16 --- Rename.java 23 Sep 2004 19:44:24 -0000 1.17 *************** *** 52,57 **** */ public Rename(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces) { ! super(broker, docs, selectStmt, namespaces); } --- 52,57 ---- */ public Rename(DBBroker broker, DocumentSet docs, String selectStmt, ! Map namespaces, Map variables) { ! super(broker, docs, selectStmt, namespaces, variables); } |