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
(33) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 12:41:01
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31404/src/org/exist/xmlrpc Modified Files: RpcConnection.java Log Message: RemoteCollection.getResource should return null instead of throwing an exception if the resource does not exist. Index: RpcConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** RpcConnection.java 12 Sep 2004 09:25:19 -0000 1.69 --- RpcConnection.java 12 Sep 2004 12:40:51 -0000 1.70 *************** *** 355,375 **** } ! Hashtable describeResource(User user, String resourceName) throws EXistException, PermissionDeniedException { DBBroker broker = brokerPool.get(user); DocumentImpl doc = null; try { doc = (DocumentImpl) broker.openDocument(resourceName, Lock.READ_LOCK); if (doc == null) { LOG.debug("document " + resourceName + " not found!"); ! throw new EXistException("document not found"); } if (!doc.getCollection().getPermissions().validate(user, Permission.READ)) { throw new PermissionDeniedException("Not allowed to read collection"); } - Hashtable desc = new Hashtable(); - Vector collections = new Vector(); Permission perms = doc.getPermissions(); - Hashtable hash = new Hashtable(5); hash.put("name", resourceName); hash.put("owner", perms.getOwner()); --- 355,373 ---- } ! public Hashtable describeResource(User user, String resourceName) throws EXistException, PermissionDeniedException { DBBroker broker = brokerPool.get(user); DocumentImpl doc = null; + Hashtable hash = new Hashtable(5); try { doc = (DocumentImpl) broker.openDocument(resourceName, Lock.READ_LOCK); if (doc == null) { LOG.debug("document " + resourceName + " not found!"); ! return hash; } if (!doc.getCollection().getPermissions().validate(user, Permission.READ)) { throw new PermissionDeniedException("Not allowed to read collection"); } Permission perms = doc.getPermissions(); hash.put("name", resourceName); hash.put("owner", perms.getOwner()); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 12:41:00
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31404/src/org/exist/xmldb Modified Files: RemoteCollection.java Log Message: RemoteCollection.getResource should return null instead of throwing an exception if the resource does not exist. Index: RemoteCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteCollection.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** RemoteCollection.java 3 Sep 2004 09:05:32 -0000 1.18 --- RemoteCollection.java 12 Sep 2004 12:40:50 -0000 1.19 *************** *** 289,292 **** --- 289,294 ---- } String docName = (String) hash.get("name"); + if(docName == null) + return null; // resource does not exist! int p; if ((p = docName.lastIndexOf('/')) > -1) |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 10:40:26
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1248/src/org/exist/xquery/test Modified Files: XQueryTest.java Log Message: Applied patch by Christian Mayrhuber concerning large attribute string values. Index: XQueryTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XQueryTest.java 21 Aug 2004 15:34:00 -0000 1.4 --- XQueryTest.java 12 Sep 2004 10:40:14 -0000 1.5 *************** *** 17,20 **** --- 17,21 ---- import org.xmldb.api.modules.XMLResource; import org.xmldb.api.modules.XPathQueryService; + import org.exist.storage.NativeTextEngine; public class XQueryTest extends TestCase { *************** *** 204,207 **** --- 205,209 ---- xml += elem; xml += tail; + System.out.println("XML:\n" + xml); return large; } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 10:40:24
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1248/src/org/exist/storage Modified Files: NativeTextEngine.java Log Message: Applied patch by Christian Mayrhuber concerning large attribute string values. Index: NativeTextEngine.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeTextEngine.java,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** NativeTextEngine.java 12 Sep 2004 09:25:20 -0000 1.70 --- NativeTextEngine.java 12 Sep 2004 10:40:13 -0000 1.71 *************** *** 100,103 **** --- 100,109 ---- public final static byte ATTRIBUTE_SECTION = 1; public final static byte TEXT_SECTION = 0; + + /** + * Limit the length of the words to be indexed. + * Default is 512 characters for words in attributes and elements. + */ + public final static int MAX_WORD_LENGTH = Integer.MAX_VALUE; protected BFile dbWords; *************** *** 627,631 **** is = dbWords.getAsStream(ref); if (is == null) { - LOG.warn(word + " not found in the index. This should not happen!"); continue; } --- 633,636 ---- *************** *** 706,710 **** } word = token.getText().toLowerCase(); ! if (stoplist.contains(word) || word.length() > 512) { continue; } --- 711,715 ---- } word = token.getText().toLowerCase(); ! if (stoplist.contains(word) || word.length() > MAX_WORD_LENGTH) { continue; } *************** *** 735,751 **** invIdx.addText(sal, gid); } else { ! while (null != (token = tokenizer.nextToken())) { ! if (idx != null && idx.getIncludeAlphaNum() == false ! && token.isAlpha() == false) { ! continue; ! } ! word = token.getCharSequence(); ! // word = token.getText(); ! if (stoplist.contains(word) || word.length() > 1024) { ! continue; } - invIdx.setDocument(doc); - invIdx.addText(word, gid); - } } } --- 740,756 ---- invIdx.addText(sal, gid); } else { ! while (null != (token = tokenizer.nextToken())) { ! if (idx != null && idx.getIncludeAlphaNum() == false ! && token.isAlpha() == false) { ! continue; ! } ! word = token.getCharSequence(); ! // word = token.getText(); ! if (stoplist.contains(word) || word.length() > MAX_WORD_LENGTH) { ! continue; ! } ! invIdx.setDocument(doc); ! invIdx.addText(word, gid); } } } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 10:40:24
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1248/src/org/exist/xquery Modified Files: GeneralComparison.java Log Message: Applied patch by Christian Mayrhuber concerning large attribute string values. Index: GeneralComparison.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/GeneralComparison.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GeneralComparison.java 12 Sep 2004 09:25:14 -0000 1.6 --- GeneralComparison.java 12 Sep 2004 10:40:14 -0000 1.7 *************** *** 31,34 **** --- 31,35 ---- import org.exist.dom.NodeProxy; import org.exist.dom.NodeSet; + import org.exist.storage.NativeTextEngine; import org.exist.storage.IndexPaths; import org.exist.storage.analysis.SimpleTokenizer; *************** *** 237,245 **** return nodeSetCompare(nodes, contextSequence); Sequence rightSeq = getRight().eval(contextSequence); ! if (rightSeq.getLength() > 1) // fall back to nodeSetCompare return nodeSetCompare(nodes, contextSequence); DocumentSet docs = nodes.getDocumentSet(); - String cmp = rightSeq.getStringValue(); switch(truncation) { case Constants.TRUNC_RIGHT: --- 238,248 ---- return nodeSetCompare(nodes, contextSequence); Sequence rightSeq = getRight().eval(contextSequence); ! String cmp = rightSeq.getStringValue(); ! if (rightSeq.getLength() > 1 || ! cmp.length() > NativeTextEngine.MAX_WORD_LENGTH) // fall back to nodeSetCompare return nodeSetCompare(nodes, contextSequence); + LOG.debug("quick compare: " + cmp.length()); DocumentSet docs = nodes.getDocumentSet(); switch(truncation) { case Constants.TRUNC_RIGHT: |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:28:01
|
Update of /cvsroot/exist/eXist-1.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22000 Added Files: jfluid.opt Log Message: jfluid settings. --- NEW FILE: jfluid.opt --- (This appears to be a binary file; contents omitted.) |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/dom Modified Files: ArraySet.java SortedNodeSet.java SingleNodeSet.java NodeProxy.java EmptyNodeSet.java ExtArrayNodeSet.java AbstractNodeSet.java Match.java AVLTreeNodeSet.java XMLUtil.java VirtualNodeSet.java DocumentImpl.java DocumentOrderComparator.java Added Files: AbstractNodeSetBase.java Removed Files: TextSearchResult.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: AbstractNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AbstractNodeSet.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** AbstractNodeSet.java 5 Aug 2004 09:13:05 -0000 1.24 --- AbstractNodeSet.java 12 Sep 2004 09:25:20 -0000 1.25 *************** *** 23,27 **** import java.util.Iterator; - import org.apache.log4j.Logger; import org.exist.util.Range; import org.exist.xquery.XPathException; --- 23,26 ---- *************** *** 42,47 **** */ public abstract class AbstractNodeSet extends AbstractSequence implements NodeSet { - - protected final static Logger LOG = Logger.getLogger(AbstractNodeSet.class); protected AbstractNodeSet() { --- 41,44 ---- *************** *** 73,77 **** return Type.NODE; } ! /** * Check if this node set contains a node matching the given --- 70,74 ---- return Type.NODE; } ! /** * Check if this node set contains a node matching the given *************** *** 203,207 **** for(Iterator i = iterator(); i.hasNext(); ) { p = (NodeProxy)i.next(); ! ds.add(p.doc); } return ds; --- 200,204 ---- for(Iterator i = iterator(); i.hasNext(); ) { p = (NodeProxy)i.next(); ! ds.add(p.getDocument()); } return ds; *************** *** 223,228 **** int mode, boolean rememberContext) { ! Range range = XMLUtil.getChildRange(parent.doc, parent.gid); ! return getRange(parent.doc, range.getStart(), range.getEnd()); } --- 220,225 ---- int mode, boolean rememberContext) { ! Range range = XMLUtil.getChildRange(parent.getDocument(), parent.gid); ! return getRange(parent.getDocument(), range.getStart(), range.getEnd()); } *************** *** 275,280 **** for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = getSizeHint(lastDoc); } --- 272,277 ---- for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = getSizeHint(lastDoc); } *************** *** 292,297 **** for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = al.getSizeHint(lastDoc); } --- 289,294 ---- for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = al.getSizeHint(lastDoc); } *************** *** 386,394 **** n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = getSizeHint(lastDoc); } ! if ((p = al.parentWithChild(n.doc, n.gid, false, includeSelf, -1)) != null) { if (rememberContext) --- 383,391 ---- n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = getSizeHint(lastDoc); } ! if ((p = al.parentWithChild(n.getDocument(), n.gid, false, includeSelf, -1)) != null) { if (rememberContext) *************** *** 404,412 **** n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.doc != lastDoc) { ! lastDoc = n.doc; sizeHint = al.getSizeHint(lastDoc); } ! p = al.parentWithChild(n.doc, n.gid, false, includeSelf, -1); if (p != null) { if (rememberContext) --- 401,409 ---- n = (NodeProxy) i.next(); // get a size hint for every new document encountered ! if (lastDoc == null || n.getDocument() != lastDoc) { ! lastDoc = n.getDocument(); sizeHint = al.getSizeHint(lastDoc); } ! p = al.parentWithChild(n.getDocument(), n.gid, false, includeSelf, -1); if (p != null) { if (rememberContext) *************** *** 529,538 **** while (true) { // first, try to find nodes belonging to the same doc ! if (na.doc.getDocId() < nb.doc.getDocId()) { if (ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if (na.doc.getDocId() > nb.doc.getDocId()) { if (ib.hasNext()) nb = (NodeProxy) ib.next(); --- 526,535 ---- while (true) { // first, try to find nodes belonging to the same doc ! if (na.getDocument().getDocId() < nb.getDocument().getDocId()) { if (ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if (na.getDocument().getDocId() > nb.getDocument().getDocId()) { if (ib.hasNext()) nb = (NodeProxy) ib.next(); *************** *** 544,548 **** pb = nb.gid; // System.out.println(pa + " -> " + pb); ! pb = XMLUtil.getParentId(nb.doc, pb, nb.doc.getTreeLevel(pb)); // System.out.println("comparing " + pa + " -> " + pb); if(pa == pb) { --- 541,545 ---- pb = nb.gid; // System.out.println(pa + " -> " + pb); ! pb = XMLUtil.getParentId(nb.getDocument(), pb, nb.getDocument().getTreeLevel(pb)); // System.out.println("comparing " + pa + " -> " + pb); if(pa == pb) { *************** *** 601,605 **** for (Iterator i = dl.iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! ancestors = ancestorsForChild(n.doc, n.gid, false, includeSelf, -1); for(Iterator j = ancestors.iterator(); j.hasNext(); ) { p = (NodeProxy) j.next(); --- 598,602 ---- for (Iterator i = dl.iterator(); i.hasNext();) { n = (NodeProxy) i.next(); ! ancestors = ancestorsForChild(n.getDocument(), n.gid, false, includeSelf, -1); for(Iterator j = ancestors.iterator(); j.hasNext(); ) { p = (NodeProxy) j.next(); *************** *** 627,636 **** NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); while(true) { ! if(na.doc.getDocId() < nb.doc.getDocId()) { if(ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if(na.doc.getDocId() > nb.doc.getDocId()) { if(ib.hasNext()) nb = (NodeProxy) ib.next(); --- 624,633 ---- NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next(); while(true) { ! if(na.getDocument().getDocId() < nb.getDocument().getDocId()) { if(ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if(na.getDocument().getDocId() > nb.getDocument().getDocId()) { if(ib.hasNext()) nb = (NodeProxy) ib.next(); *************** *** 673,682 **** while (true) { // first, try to find nodes belonging to the same doc ! if (na.doc.getDocId() < nb.doc.getDocId()) { if (ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if (na.doc.getDocId() > nb.doc.getDocId()) { if (ib.hasNext()) nb = (NodeProxy) ib.next(); --- 670,679 ---- while (true) { // first, try to find nodes belonging to the same doc ! if (na.getDocument().getDocId() < nb.getDocument().getDocId()) { if (ia.hasNext()) na = (NodeProxy) ia.next(); else break; ! } else if (na.getDocument().getDocId() > nb.getDocument().getDocId()) { if (ib.hasNext()) nb = (NodeProxy) ib.next(); *************** *** 685,690 **** } else { // same document: check if the nodes have the same parent ! pa = XMLUtil.getParentId(na.doc, na.gid); ! pb = XMLUtil.getParentId(nb.doc, nb.gid); if (pa < pb) { // wrong parent: proceed --- 682,687 ---- } else { // same document: check if the nodes have the same parent ! pa = XMLUtil.getParentId(na.getDocument(), na.gid); ! pb = XMLUtil.getParentId(nb.getDocument(), nb.gid); if (pa < pb) { // wrong parent: proceed *************** *** 840,844 **** boolean includeSelf, int level) { ! return parentWithChild(proxy.doc, proxy.gid, directParent, includeSelf, level); } --- 837,841 ---- boolean includeSelf, int level) { ! return parentWithChild(proxy.getDocument(), proxy.gid, directParent, includeSelf, level); } *************** *** 882,888 **** p = (NodeProxy) i.next(); // calculate parent's gid ! pid = XMLUtil.getParentId(p.doc, p.gid); if (pid > -1) ! parents.add(new NodeProxy(p.doc, pid, Node.ELEMENT_NODE)); } return parents; --- 879,885 ---- p = (NodeProxy) i.next(); // calculate parent's gid ! pid = XMLUtil.getParentId(p.getDocument(), p.gid); if (pid > -1) ! parents.add(new NodeProxy(p.getDocument(), pid, Node.ELEMENT_NODE)); } return parents; *************** *** 890,907 **** /** - * Returns true if all nodes in this node set are included in - * the fulltext index. - * - * @return - */ - public boolean hasIndex() { - for (Iterator i = iterator(); i.hasNext();) { - if (!((NodeProxy) i.next()).hasIndex()) - return false; - } - return true; - } - - /** * Return a sub-range of this node set containing the range of nodes greater than or including * the lower node and smaller than or including the upper node. --- 887,890 ---- *************** *** 1065,1070 **** if (rememberContext) context.addContextNode(context); ! if(lastDoc != null && lastDoc.getDocId() != context.doc.getDocId()) { ! lastDoc = context.doc; result.add(context, getSizeHint(lastDoc)); } else --- 1048,1053 ---- if (rememberContext) context.addContextNode(context); ! if(lastDoc != null && lastDoc.getDocId() != context.getDocument().getDocId()) { ! lastDoc = context.getDocument(); result.add(context, getSizeHint(lastDoc)); } else Index: DocumentImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/DocumentImpl.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** DocumentImpl.java 28 Jul 2004 18:54:57 -0000 1.51 --- DocumentImpl.java 12 Sep 2004 09:25:21 -0000 1.52 *************** *** 260,264 **** if(treeLevelStartPoints[i + 1] > 0x6fffffffffffffffL || treeLevelStartPoints[i + 1] < 0) { ! throw new EXistException("The document is too complex/irregularily structured " + "to be mapped into eXist's numbering scheme. Number of children per level of the " + "tree: " + printTreeLevelOrder()); } --- 260,265 ---- if(treeLevelStartPoints[i + 1] > 0x6fffffffffffffffL || treeLevelStartPoints[i + 1] < 0) { ! throw new EXistException("The document is too complex/irregularily structured " + ! "to be mapped into eXist's numbering scheme. Number of children per level of the " + "tree: " + printTreeLevelOrder()); } Index: Match.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/Match.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Match.java 14 Jul 2004 19:03:24 -0000 1.6 --- Match.java 12 Sep 2004 09:25:20 -0000 1.7 *************** *** 1,9 **** /* ! * Match.java - Mar 20, 2003 * ! * @author wolf */ package org.exist.dom; public class Match implements Comparable { --- 1,44 ---- /* ! * eXist Open Source Native XML Database ! * Copyright (C) 2001-04, Wolfgang M. Meier (wol...@ex...) ! * and others (see http://exist-db.org) * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Library General Public License ! * as published by the Free Software Foundation; either version 2 ! * of the License, or (at your option) any later version. ! * ! * This library 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 Library General Public License for more details. ! * ! * You should have received a copy of the GNU Library General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! * $Id$ */ package org.exist.dom; + /** + * Used to track fulltext matches throughout the query. + * + * {@link org.exist.storage.TextSearchEngine} will add a + * match object to every {@link org.exist.dom.NodeProxy} + * that triggered a fulltext match for every term matched. The + * Match object contains the nodeId of the text node that triggered the + * match, the string value of the matching term and a frequency count, + * indicating the frequency of the matching term string within the corresponding + * single text node. + * + * All path operations copy existing match objects, i.e. the match objects + * are copied to the selected descendant or child nodes. This means that + * every NodeProxy being the direct or indirect result of a fulltext + * selection will have one or more match objects, indicating which text nodes + * among its descendant nodes contained a fulltext match. + * + * @author wolf + */ public class Match implements Comparable { *************** *** 62,65 **** return matchTerm.compareTo(other.matchTerm); } - } --- 97,99 ---- --- NEW FILE: AbstractNodeSetBase.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * 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: AbstractNodeSetBase.java,v 1.1 2004/09/12 09:25:20 wolfgang_m Exp $ */ package org.exist.dom; import java.util.Iterator; import org.apache.log4j.Logger; /** * @author wolf * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public abstract class AbstractNodeSetBase extends AbstractNodeSet { protected final static Logger LOG = Logger.getLogger(AbstractNodeSetBase.class); private final static int UNKNOWN = -1; private final static int NOT_INDEXED = 0; private final static int ALL_NODES_IN_INDEX = 1; // indicates if the nodes in this set and their descendant nodes // have been fulltext indexed private int hasIndex = UNKNOWN; private boolean isCached = false; protected AbstractNodeSetBase() { super(); } public void setIsCached(boolean cached) { isCached = cached; } public boolean isCached() { return isCached; } /** * Returns true if all nodes in this node set and their descendants * are included in the fulltext index. This information is required * to determine if comparison operators can use the * fulltext index to speed up equality comparisons. * * @see org.exist.xquery.GeneralComparison * @see org.exist.xquery.ValueComparison * @return */ public boolean hasIndex() { if(hasIndex == UNKNOWN) { hasIndex = ALL_NODES_IN_INDEX; for (Iterator i = iterator(); i.hasNext();) { if (!((NodeProxy) i.next()).hasIndex()) { hasIndex = NOT_INDEXED; break; } } } return hasIndex == ALL_NODES_IN_INDEX; } } Index: ArraySet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ArraySet.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** ArraySet.java 8 Jun 2004 08:16:08 -0000 1.32 --- ArraySet.java 12 Sep 2004 09:25:20 -0000 1.33 *************** *** 28,32 **** import org.w3c.dom.Node; ! public class ArraySet extends AbstractNodeSet { protected int counter = 0; --- 28,32 ---- import org.w3c.dom.Node; ! public class ArraySet extends AbstractNodeSetBase { protected int counter = 0; *************** *** 121,125 **** while (low <= high) { mid = (low + high) / 2; ! if (items[mid].doc.docId == cmpDoc.docId) { if (items[mid].gid == gid) return mid; --- 121,125 ---- while (low <= high) { mid = (low + high) / 2; ! if (items[mid].getDocument().docId == cmpDoc.docId) { if (items[mid].gid == gid) return mid; *************** *** 128,132 **** else low = mid + 1; ! } else if (items[mid].doc.docId > cmpDoc.docId) high = mid - 1; else --- 128,132 ---- else low = mid + 1; ! } else if (items[mid].getDocument().docId > cmpDoc.docId) high = mid - 1; else *************** *** 614,621 **** DocumentImpl lastDoc = null; for (int i = 0; i < counter; i++) { ! if(lastDoc == null || lastDoc.getDocId() != nodes[i].doc.getDocId()) { ! docs.add(nodes[i].doc, false); } ! lastDoc = nodes[i].doc; } return docs; --- 614,621 ---- DocumentImpl lastDoc = null; for (int i = 0; i < counter; i++) { ! if(lastDoc == null || lastDoc.getDocId() != nodes[i].getDocument().getDocId()) { ! docs.add(nodes[i].getDocument(), false); } ! lastDoc = nodes[i].getDocument(); } return docs; *************** *** 655,659 **** private final static NodeProxy[] copyNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].doc.docId, dd = dl.nodes[dx].doc.docId; final int alen = al.counter - 1, dlen = dl.counter - 1; final NodeProxy[] ol = new NodeProxy[dl.counter]; --- 655,659 ---- private final static NodeProxy[] copyNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].getDocument().docId, dd = dl.nodes[dx].getDocument().docId; final int alen = al.counter - 1, dlen = dl.counter - 1; final NodeProxy[] ol = new NodeProxy[dl.counter]; *************** *** 662,666 **** if (ax < alen) { ++ax; ! ad = al.nodes[ax].doc.docId; } else break; --- 662,666 ---- if (ax < alen) { ++ax; ! ad = al.nodes[ax].getDocument().docId; } else break; *************** *** 669,673 **** ol[dx] = null; ++dx; ! dd = dl.nodes[dx].doc.docId; } else break; --- 669,673 ---- ol[dx] = null; ++dx; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 676,680 **** if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].doc.docId; } else break; --- 676,680 ---- if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 686,690 **** private final static void trimNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].doc.docId, dd = dl.nodes[dx].doc.docId; int count = 0; final int alen = al.counter - 1, dlen = dl.counter - 1; --- 686,690 ---- private final static void trimNodeSet(ArraySet al, ArraySet dl) { int ax = 0, dx = 0; ! int ad = al.nodes[ax].getDocument().docId, dd = dl.nodes[dx].getDocument().docId; int count = 0; final int alen = al.counter - 1, dlen = dl.counter - 1; *************** *** 693,697 **** if (ax < alen) { ++ax; ! ad = al.nodes[ax].doc.docId; } else break; --- 693,697 ---- if (ax < alen) { ++ax; ! ad = al.nodes[ax].getDocument().docId; } else break; *************** *** 699,703 **** if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].doc.docId; } else break; --- 699,703 ---- if (dx < dlen) { ++dx; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 706,710 **** ++dx; count++; ! dd = dl.nodes[dx].doc.docId; } else break; --- 706,710 ---- ++dx; count++; ! dd = dl.nodes[dx].getDocument().docId; } else break; *************** *** 751,760 **** public int compare(int a, int b) { NodeProxy anode = nodes[a], bnode = nodes[b]; ! if (anode.doc.docId == bnode.doc.docId) { return anode.gid == bnode.gid ? 0 : (anode.gid < bnode.gid ? -1 : 1); } ! return anode.doc.docId < bnode.doc.docId ? -1 : 1; } --- 751,760 ---- public int compare(int a, int b) { NodeProxy anode = nodes[a], bnode = nodes[b]; ! if (anode.getDocument().docId == bnode.getDocument().docId) { return anode.gid == bnode.gid ? 0 : (anode.gid < bnode.gid ? -1 : 1); } ! return anode.getDocument().docId < bnode.getDocument().docId ? -1 : 1; } Index: VirtualNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/VirtualNodeSet.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** VirtualNodeSet.java 10 May 2004 11:22:39 -0000 1.34 --- VirtualNodeSet.java 12 Sep 2004 09:25:20 -0000 1.35 *************** *** 48,52 **** * @author Timo Boehme */ ! public class VirtualNodeSet extends AbstractNodeSet { protected int axis = -1; --- 48,52 ---- * @author Timo Boehme */ ! public class VirtualNodeSet extends AbstractNodeSetBase { protected int axis = -1; *************** *** 80,84 **** return ( (first != null) ! || (context.get(p.doc, XMLUtil.getParentId(p.doc, p.gid)) != null)); } --- 80,84 ---- return ( (first != null) ! || (context.get(p.getDocument(), XMLUtil.getParentId(p.getDocument(), p.gid)) != null)); } *************** *** 112,116 **** boolean directParent, int recursions) { ! long pid = XMLUtil.getParentId(node.doc, node.gid); NodeProxy parent; // check if the start-node should be included, e.g. to process an --- 112,116 ---- boolean directParent, int recursions) { ! long pid = XMLUtil.getParentId(node.getDocument(), node.gid); NodeProxy parent; // check if the start-node should be included, e.g. to process an *************** *** 120,124 **** // if we're on the child axis, test if // the node is a direct child of the context node ! if ((parent = context.get(new NodeProxy(node.doc, pid))) != null) { node.copyContext(parent); if (useSelfAsContext && inPredicate) { --- 120,124 ---- // if we're on the child axis, test if // the node is a direct child of the context node ! if ((parent = context.get(new NodeProxy(node.getDocument(), pid))) != null) { node.copyContext(parent); if (useSelfAsContext && inPredicate) { *************** *** 139,143 **** return null; } ! first = new NodeProxy(node.doc, pid, Node.ELEMENT_NODE); // Timo Boehme: we need a real parent (child from context) return getFirstParent(first, first, false, directParent, recursions + 1); --- 139,143 ---- return null; } ! first = new NodeProxy(node.getDocument(), pid, Node.ELEMENT_NODE); // Timo Boehme: we need a real parent (child from context) return getFirstParent(first, first, false, directParent, recursions + 1); *************** *** 145,149 **** // is pid member of the context set? ! parent = context.get(node.doc, pid); if (parent != null && test.matches(first)) { --- 145,149 ---- // is pid member of the context set? ! parent = context.get(node.getDocument(), pid); if (parent != null && test.matches(first)) { *************** *** 171,175 **** } else { // continue for expressions like //*/n or /*//n ! parent = new NodeProxy(node.doc, pid, Node.ELEMENT_NODE); return getFirstParent(parent, first, false, directParent, recursions + 1); } --- 171,175 ---- } else { // continue for expressions like //*/n or /*//n ! parent = new NodeProxy(node.getDocument(), pid, Node.ELEMENT_NODE); return getFirstParent(parent, first, false, directParent, recursions + 1); } *************** *** 251,259 **** || axis == Constants.DESCENDANT_SELF_AXIS || axis == Constants.DESCENDANT_ATTRIBUTE_AXIS) { ! domIter = docElemProxy.doc.getBroker().getNodeIterator(docElemProxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(docElemProxy.doc); node.setGID(docElemProxy.gid); ! docElemProxy.match = proxy.match; addChildren(docElemProxy, result, node, domIter, 0); } --- 251,259 ---- || axis == Constants.DESCENDANT_SELF_AXIS || axis == Constants.DESCENDANT_ATTRIBUTE_AXIS) { ! domIter = docElemProxy.getDocument().getBroker().getNodeIterator(docElemProxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(docElemProxy.getDocument()); node.setGID(docElemProxy.gid); ! docElemProxy.setMatches(proxy.getMatches()); addChildren(docElemProxy, result, node, domIter, 0); } *************** *** 261,267 **** // -- end of insertion -- } else { ! domIter = proxy.doc.getBroker().getNodeIterator(proxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(proxy.doc); node.setGID(proxy.gid); addChildren(proxy, result, node, domIter, 0); --- 261,267 ---- // -- end of insertion -- } else { ! domIter = proxy.getDocument().getBroker().getNodeIterator(proxy); NodeImpl node = (NodeImpl) domIter.next(); ! node.setOwnerDocument(proxy.getDocument()); node.setGID(proxy.gid); addChildren(proxy, result, node, domIter, 0); *************** *** 287,291 **** p = new NodeProxy(child.ownerDocument, child.gid, child.getNodeType()); p.setInternalAddress(child.internalAddress); ! p.match = contextNode.match; if (test.matches(child)) { if (((axis == Constants.CHILD_AXIS --- 287,291 ---- p = new NodeProxy(child.ownerDocument, child.gid, child.getNodeType()); p.setInternalAddress(child.internalAddress); ! p.setMatches(contextNode.getMatches()); if (test.matches(child)) { if (((axis == Constants.CHILD_AXIS *************** *** 311,315 **** NodeProxy p = new NodeProxy(node.ownerDocument, node.gid, node.getNodeType()); p.setInternalAddress(node.internalAddress); ! p.match = contextNode.match; result.add(p); p.copyContext(contextNode); --- 311,315 ---- NodeProxy p = new NodeProxy(node.ownerDocument, node.gid, node.getNodeType()); p.setInternalAddress(node.internalAddress); ! p.setMatches(contextNode.getMatches()); result.add(p); p.copyContext(contextNode); Index: ExtArrayNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ExtArrayNodeSet.java 5 Aug 2004 09:13:05 -0000 1.22 --- ExtArrayNodeSet.java 12 Sep 2004 09:25:20 -0000 1.23 *************** *** 52,56 **** * @since 0.9.3 */ ! public final class ExtArrayNodeSet extends AbstractNodeSet { private TreeMap map; --- 52,56 ---- * @since 0.9.3 */ ! public class ExtArrayNodeSet extends AbstractNodeSetBase { private TreeMap map; *************** *** 96,100 **** public void add(NodeProxy proxy) { ! getPart(proxy.doc, true, initalSize).add(proxy); ++size; isSorted = false; --- 96,100 ---- public void add(NodeProxy proxy) { ! getPart(proxy.getDocument(), true, initalSize).add(proxy); ++size; isSorted = false; *************** *** 111,115 **** */ public void add(NodeProxy proxy, int sizeHint) { ! getPart(proxy.doc, true, sizeHint > -1 ? sizeHint : initalSize).add( proxy); ++size; --- 111,115 ---- */ public void add(NodeProxy proxy, int sizeHint) { ! getPart(proxy.getDocument(), true, sizeHint > -1 ? sizeHint : initalSize).add( proxy); ++size; *************** *** 197,201 **** */ public boolean contains(NodeProxy proxy) { ! final Part part = getPart(proxy.doc, false, 0); return part == null ? false : part.contains(proxy.gid); } --- 197,201 ---- */ public boolean contains(NodeProxy proxy) { ! final Part part = getPart(proxy.getDocument(), false, 0); return part == null ? false : part.contains(proxy.gid); } *************** *** 256,260 **** */ public NodeProxy get(NodeProxy p) { ! final Part part = getPart(p.doc, false, 0); return part == null ? null : part.get(p.gid); } --- 256,260 ---- */ public NodeProxy get(NodeProxy p) { ! final Part part = getPart(p.getDocument(), false, 0); return part == null ? null : part.get(p.gid); } *************** *** 287,296 **** */ public void remove(NodeProxy node) { ! final Part part = getPart(node.doc, false, 0); if (part == null) return; part.remove(node); if (part.length == 0) ! map.remove(node.doc); setHasChanged(); } --- 287,296 ---- */ public void remove(NodeProxy node) { ! final Part part = getPart(node.getDocument(), false, 0); if (part == null) return; part.remove(node); if (part.length == 0) ! map.remove(node.getDocument()); setHasChanged(); } *************** *** 303,307 **** public NodeSet hasChildrenInSet(NodeProxy parent, int mode, boolean rememberContext) { ! final Part part = getPart(parent.doc, false, 0); if (part == null) return new ArraySet(1); --- 303,307 ---- public NodeSet hasChildrenInSet(NodeProxy parent, int mode, boolean rememberContext) { ! final Part part = getPart(parent.getDocument(), false, 0); if (part == null) return new ArraySet(1); *************** *** 487,491 **** if(length == 0) return null; ! return array[0].doc; } --- 487,491 ---- if(length == 0) return null; ! return array[0].getDocument(); } *************** *** 542,546 **** // get the range of node ids reserved for children of the parent // node ! Range range = XMLUtil.getChildRange(parent.doc, parent.gid); int low = 0; int high = length - 1; --- 542,546 ---- // get the range of node ids reserved for children of the parent // node ! Range range = XMLUtil.getChildRange(parent.getDocument(), parent.gid); int low = 0; int high = length - 1; Index: XMLUtil.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/XMLUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLUtil.java 1 Mar 2004 21:30:20 -0000 1.4 --- XMLUtil.java 12 Sep 2004 09:25:20 -0000 1.5 *************** *** 243,247 **** public final static long getParentId( NodeProxy node ) { ! return getParentId(node.doc, node.gid); } --- 243,247 ---- public final static long getParentId( NodeProxy node ) { ! return getParentId(node.getDocument(), node.gid); } *************** *** 322,332 **** return temp; if(level < 0) ! level = child.doc.getTreeLevel(child.gid); while (child.gid > 0) { // calculate parent's gid ! child.gid = (child.gid - child.doc.getLevelStartPoint(level)) ! / child.doc.getTreeLevelOrder(level) ! + child.doc.getLevelStartPoint(level - 1); ! if ((temp = contextSet.get(child.doc, child.gid)) != null) return temp; else --- 322,332 ---- return temp; if(level < 0) ! level = child.getDocument().getTreeLevel(child.gid); while (child.gid > 0) { // calculate parent's gid ! child.gid = (child.gid - child.getDocument().getLevelStartPoint(level)) ! / child.getDocument().getTreeLevelOrder(level) ! + child.getDocument().getLevelStartPoint(level - 1); ! if ((temp = contextSet.get(child.getDocument(), child.gid)) != null) return temp; else Index: DocumentOrderComparator.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/DocumentOrderComparator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DocumentOrderComparator.java 22 Dec 2003 18:48:45 -0000 1.1 --- DocumentOrderComparator.java 12 Sep 2004 09:25:21 -0000 1.2 *************** *** 40,47 **** final NodeProxy p1 = (NodeProxy) o1; final NodeProxy p2 = (NodeProxy) o2; ! final DocumentImpl doc = p1.doc; ! if (doc.docId > p2.doc.docId) return 1; ! else if (doc.docId < p2.doc.docId) return -1; else { --- 40,47 ---- final NodeProxy p1 = (NodeProxy) o1; final NodeProxy p2 = (NodeProxy) o2; ! final DocumentImpl doc = p1.getDocument(); ! if (doc.docId > p2.getDocument().docId) return 1; ! else if (doc.docId < p2.getDocument().docId) return -1; else { Index: SingleNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/SingleNodeSet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SingleNodeSet.java 29 Jan 2004 15:06:46 -0000 1.4 --- SingleNodeSet.java 12 Sep 2004 09:25:20 -0000 1.5 *************** *** 47,51 **** */ public boolean contains(DocumentImpl doc, long nodeId) { ! return nodes[0].doc.getDocId() == doc.getDocId() && nodes[0].gid == nodeId; } --- 47,51 ---- */ public boolean contains(DocumentImpl doc, long nodeId) { ! return nodes[0].getDocument().getDocId() == doc.getDocId() && nodes[0].gid == nodeId; } *************** *** 54,58 **** */ public boolean contains(NodeProxy proxy) { ! return nodes[0].doc.getDocId() == proxy.doc.getDocId() && nodes[0].gid == proxy.gid; } --- 54,58 ---- */ public boolean contains(NodeProxy proxy) { ! return nodes[0].getDocument().getDocId() == proxy.getDocument().getDocId() && nodes[0].gid == proxy.gid; } --- TextSearchResult.java DELETED --- Index: EmptyNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/EmptyNodeSet.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EmptyNodeSet.java 29 Jan 2004 15:06:46 -0000 1.9 --- EmptyNodeSet.java 12 Sep 2004 09:25:20 -0000 1.10 *************** *** 29,33 **** import org.w3c.dom.Node; ! public class EmptyNodeSet extends AbstractNodeSet { private final static EmptyNodeSetIterator EMPTY_ITERATOR = new EmptyNodeSetIterator(); --- 29,33 ---- import org.w3c.dom.Node; ! public class EmptyNodeSet extends AbstractNodeSetBase { private final static EmptyNodeSetIterator EMPTY_ITERATOR = new EmptyNodeSetIterator(); Index: NodeProxy.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/NodeProxy.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** NodeProxy.java 23 Jun 2004 12:44:17 -0000 1.33 --- NodeProxy.java 12 Sep 2004 09:25:20 -0000 1.34 *************** *** 24,28 **** import java.util.Iterator; ! import org.exist.memtree.Receiver; import org.exist.storage.DBBroker; import org.exist.storage.serializers.Serializer; --- 24,28 ---- import java.util.Iterator; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.storage.DBBroker; import org.exist.storage.serializers.Serializer; *************** *** 58,63 **** *@author Wolfgang Meier <wol...@ex...> */ ! public final class NodeProxy extends AbstractNodeSet implements NodeValue, Comparable { ! /** * The owner document of this node. --- 58,63 ---- *@author Wolfgang Meier <wol...@ex...> */ ! public class NodeProxy extends AbstractNodeSet implements NodeValue, Comparable { ! /** * The owner document of this node. *************** *** 87,91 **** private long internalAddress = -1; ! public NodeProxy() { } --- 87,91 ---- private long internalAddress = -1; ! public NodeProxy() { } *************** *** 265,268 **** --- 265,276 ---- } + public DocumentImpl getDocument() { + return doc; + } + + public void setDocument(DocumentImpl doc) { + this.doc = doc; + } + public long getGID() { return gid; *************** *** 334,338 **** this.nodeType = nodeType; } ! /** * Returns the storage address of this node in dom.dbx. --- 342,346 ---- this.nodeType = nodeType; } ! /** * Returns the storage address of this node in dom.dbx. *************** *** 361,364 **** --- 369,380 ---- } + public Match getMatches() { + return match; + } + + public void setMatches(Match match) { + this.match = match; + } + public boolean hasMatch(Match m) { if (m == null || match == null) *************** *** 407,411 **** if(p == this) return; ! Match m = p.match; while (m != null) { addMatch(new Match(m)); --- 423,427 ---- if(p == this) return; ! Match m = p.getMatches(); while (m != null) { addMatch(new Match(m)); *************** *** 448,452 **** if (context == null) { context = new ContextItem(node); - // Thread.dumpStack(); return; } --- 464,467 ---- *************** *** 461,474 **** next = next.getNextItem(); } - // Thread.dumpStack(); - } - - public void clearContext() { - context = null; } public void printContext() { ContextItem next = context; ! System.out.print(hashCode() + " " + gid + ": "); while (next != null) { System.out.print(next.getNode().gid); --- 476,484 ---- next = next.getNextItem(); } } public void printContext() { ContextItem next = context; ! System.out.print(gid + ": "); while (next != null) { System.out.print(next.getNode().gid); *************** *** 478,481 **** --- 488,492 ---- System.out.println(); } + public void copyContext(NodeProxy node) { context = node.getContext(); *************** *** 639,643 **** } ! public void copyTo(DBBroker broker, Receiver receiver) throws SAXException { if(nodeType == Node.ATTRIBUTE_NODE) { AttrImpl attr = (AttrImpl) getNode(); --- 650,654 ---- } ! public void copyTo(DBBroker broker, DocumentBuilderReceiver receiver) throws SAXException { if(nodeType == Node.ATTRIBUTE_NODE) { AttrImpl attr = (AttrImpl) getNode(); Index: AVLTreeNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AVLTreeNodeSet.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AVLTreeNodeSet.java 23 Jun 2004 14:05:49 -0000 1.8 --- AVLTreeNodeSet.java 12 Sep 2004 09:25:20 -0000 1.9 *************** *** 7,11 **** import org.exist.xquery.value.SequenceIterator; ! public class AVLTreeNodeSet extends AbstractNodeSet { private Node root; --- 7,11 ---- import org.exist.xquery.value.SequenceIterator; ! public class AVLTreeNodeSet extends AbstractNodeSetBase { private Node root; *************** *** 286,290 **** Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.doc.docId == doc.docId) { if (tempNode.data.gid == nodeId) return tempNode.data; --- 286,290 ---- Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.getDocument().docId == doc.docId) { if (tempNode.data.gid == nodeId) return tempNode.data; *************** *** 293,297 **** else tempNode = tempNode.leftChild; ! } else if (tempNode.data.doc.docId < doc.docId) tempNode = tempNode.rightChild; else --- 293,297 ---- else tempNode = tempNode.leftChild; ! } else if (tempNode.data.getDocument().docId < doc.docId) tempNode = tempNode.rightChild; else *************** *** 306,312 **** Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.doc.docId == doc.docId) { return true; ! } else if (tempNode.data.doc.docId < doc.docId) tempNode = tempNode.rightChild; else --- 306,312 ---- Node tempNode = root; while (tempNode != null) { ! if (tempNode.data.getDocument().docId == doc.docId) { return true; ! } else if (tempNode.data.getDocument().docId < doc.docId) tempNode = tempNode.rightChild; else Index: SortedNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/SortedNodeSet.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SortedNodeSet.java 15 Jul 2004 08:28:52 -0000 1.21 --- SortedNodeSet.java 12 Sep 2004 09:25:20 -0000 1.22 *************** *** 4,12 **** import java.util.Iterator; - import org.apache.log4j.Category; import org.exist.EXistException; - import org.exist.xquery.parser.XQueryLexer; - import org.exist.xquery.parser.XQueryParser; - import org.exist.xquery.parser.XQueryTreeParser; import org.exist.security.User; import org.exist.storage.BrokerPool; --- 4,8 ---- *************** *** 14,19 **** import org.exist.util.OrderedLinkedList; import org.exist.xquery.PathExpr; - import org.exist.xquery.XQueryContext; import org.exist.xquery.XPathException; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; --- 10,18 ---- import org.exist.util.OrderedLinkedList; import org.exist.xquery.PathExpr; import org.exist.xquery.XPathException; + import org.exist.xquery.XQueryContext; + import org.exist.xquery.parser.XQueryLexer; + import org.exist.xquery.parser.XQueryParser; + import org.exist.xquery.parser.XQueryTreeParser; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; *************** *** 24,30 **** import antlr.collections.AST; ! public class SortedNodeSet extends AbstractNodeSet { ! ! private static Category LOG = Category.getInstance(SortedNodeSet.class.getName()); private PathExpr expr; --- 23,27 ---- import antlr.collections.AST; ! public class SortedNodeSet extends AbstractNodeSetBase { private PathExpr expr; *************** *** 53,57 **** for (Iterator i = other.iterator(); i.hasNext();) { p = (NodeProxy)i.next(); ! docs.add(p.doc); } DBBroker broker = null; --- 50,54 ---- for (Iterator i = other.iterator(); i.hasNext();) { p = (NodeProxy)i.next(); ! docs.add(p.getDocument()); } DBBroker broker = null; *************** *** 59,63 **** broker = pool.get(user); XQueryContext context = new XQueryContext(broker); ! XQueryLexer lexer = new XQueryLexer(new StringReader(sortExpr)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 56,60 ---- broker = pool.get(user); XQueryContext context = new XQueryContext(broker); ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(sortExpr)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); *************** *** 149,153 **** public Node item(int pos) { NodeProxy p = ((IteratorItem) list.get(pos)).proxy; ! return p == null ? null : p.doc.getNode(p); } --- 146,150 ---- public Node item(int pos) { NodeProxy p = ((IteratorItem) list.get(pos)).proxy; ! return p == null ? null : p.getDocument().getNode(p); } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/transform In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery/functions/transform Modified Files: Transform.java Added Files: TransformModule.java Removed Files: ModuleImpl.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: Transform.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/transform/Transform.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Transform.java 2 Jul 2004 16:53:55 -0000 1.8 --- Transform.java 12 Sep 2004 09:25:22 -0000 1.9 *************** *** 51,55 **** import org.exist.dom.QName; import org.exist.memtree.MemTreeBuilder; ! import org.exist.memtree.Receiver; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; --- 51,55 ---- import org.exist.dom.QName; import org.exist.memtree.MemTreeBuilder; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; *************** *** 75,79 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("transform", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Applies an XSL stylesheet to the node tree passed as first argument. The stylesheet " + "is specified in the second argument. This should either be an URI or a node. " + --- 75,79 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("transform", TransformModule.NAMESPACE_URI, TransformModule.PREFIX), "Applies an XSL stylesheet to the node tree passed as first argument. The stylesheet " + "is specified in the second argument. This should either be an URI or a node. " + *************** *** 131,135 **** context.pushDocumentContext(); MemTreeBuilder builder = context.getDocumentBuilder(); ! Receiver receiver = new Receiver(builder); SAXResult result = new SAXResult(receiver); handler.setResult(result); --- 131,135 ---- context.pushDocumentContext(); MemTreeBuilder builder = context.getDocumentBuilder(); ! DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); SAXResult result = new SAXResult(receiver); handler.setResult(result); *************** *** 206,210 **** throws XPathException, TransformerConfigurationException { if(stylesheetRoot.getImplementationType() == NodeValue.PERSISTENT_NODE) { ! factory.setURIResolver(new DatabaseResolver(((NodeProxy)stylesheetRoot).doc)); } TemplatesHandler handler = factory.newTemplatesHandler(); --- 206,210 ---- throws XPathException, TransformerConfigurationException { if(stylesheetRoot.getImplementationType() == NodeValue.PERSISTENT_NODE) { ! factory.setURIResolver(new DatabaseResolver(((NodeProxy)stylesheetRoot).getDocument())); } TemplatesHandler handler = factory.newTemplatesHandler(); --- NEW FILE: TransformModule.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. * * $Id: TransformModule.java,v 1.1 2004/09/12 09:25:22 wolfgang_m Exp $ */ package org.exist.xquery.functions.transform; import org.exist.xquery.AbstractInternalModule; import org.exist.xquery.FunctionDef; /** * @author Wolfgang Meier (wol...@ex...) */ public class TransformModule extends AbstractInternalModule { public final static String NAMESPACE_URI = "http://exist-db.org/xquery/transform"; public final static String PREFIX = "transform"; private final static FunctionDef functions[] = { new FunctionDef(Transform.signature, Transform.class) }; public TransformModule() { super(functions); } /* (non-Javadoc) * @see org.exist.xquery.Module#getNamespaceURI() */ public String getNamespaceURI() { return NAMESPACE_URI; } /* (non-Javadoc) * @see org.exist.xquery.Module#getDefaultPrefix() */ public String getDefaultPrefix() { return PREFIX; } } --- ModuleImpl.java DELETED --- |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery/functions/xmldb Modified Files: XMLDBHasLock.java XMLDBGroup.java XMLDBRemove.java XMLDBOwner.java XMLDBCollection.java XMLDBRegisterDatabase.java XMLDBXUpdate.java XMLDBCreateCollection.java XMLDBLastModified.java XMLDBAuthenticate.java XMLDBGetChildCollections.java XMLDBStore.java XMLDBPermissions.java XMLDBCreated.java Added Files: XMLDBModule.java Removed Files: ModuleImpl.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: XMLDBGetChildCollections.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBGetChildCollections.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBGetChildCollections.java 5 May 2004 14:44:25 -0000 1.1 --- XMLDBGetChildCollections.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 46,50 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-child-collections", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the subcolls of collection", new SequenceType[] { --- 46,50 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-child-collections", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns the subcolls of collection", new SequenceType[] { Index: XMLDBXUpdate.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBXUpdate.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDBXUpdate.java 28 May 2004 10:54:17 -0000 1.4 --- XMLDBXUpdate.java 12 Sep 2004 09:25:16 -0000 1.5 *************** *** 55,59 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("update", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Process an XUpdate request on the current collection. The first " + "argument specifies the collection object as returned by the collection or " --- 55,59 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("update", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Process an XUpdate request on the current collection. The first " + "argument specifies the collection object as returned by the collection or " --- NEW FILE: XMLDBModule.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. * * $Id: XMLDBModule.java,v 1.1 2004/09/12 09:25:16 wolfgang_m Exp $ */ package org.exist.xquery.functions.xmldb; import org.exist.xquery.AbstractInternalModule; import org.exist.xquery.FunctionDef; /** * @author Wolfgang Meier (wol...@ex...) */ public class XMLDBModule extends AbstractInternalModule { public final static String NAMESPACE_URI = "http://exist-db.org/xquery/xmldb"; public final static String PREFIX = "xmldb"; public final static FunctionDef[] functions = { new FunctionDef(XMLDBCollection.signature, XMLDBCollection.class), new FunctionDef(XMLDBCreateCollection.signature, XMLDBCreateCollection.class), new FunctionDef(XMLDBRegisterDatabase.signature, XMLDBRegisterDatabase.class), new FunctionDef(XMLDBStore.signature, XMLDBStore.class), new FunctionDef(XMLDBAuthenticate.signature, XMLDBAuthenticate.class), new FunctionDef(XMLDBXUpdate.signature, XMLDBXUpdate.class), new FunctionDef(XMLDBRemove.signature, XMLDBRemove.class), new FunctionDef(XMLDBHasLock.signature, XMLDBHasLock.class), new FunctionDef(XMLDBCreated.signature, XMLDBCreated.class), new FunctionDef(XMLDBLastModified.signature, XMLDBLastModified.class), new FunctionDef(XMLDBPermissions.signature, XMLDBPermissions.class), new FunctionDef(XMLDBGroup.signature, XMLDBGroup.class), new FunctionDef(XMLDBOwner.signature, XMLDBOwner.class), new FunctionDef(XMLDBGetChildCollections.signature, XMLDBGetChildCollections.class) }; public XMLDBModule() { super(functions); } /* (non-Javadoc) * @see org.exist.xquery.Module#getNamespaceURI() */ public String getNamespaceURI() { return NAMESPACE_URI; } /* (non-Javadoc) * @see org.exist.xquery.Module#getDefaultPrefix() */ public String getDefaultPrefix() { return PREFIX; } } Index: XMLDBCreated.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBCreated.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLDBCreated.java 22 Jun 2004 11:05:20 -0000 1.2 --- XMLDBCreated.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 46,50 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("created", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the creation date", new SequenceType[] { --- 46,50 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("created", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns the creation date", new SequenceType[] { *************** *** 65,69 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new DateTimeValue(proxy.doc.getCreated()); } return Sequence.EMPTY_SEQUENCE; --- 65,69 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new DateTimeValue(proxy.getDocument().getCreated()); } return Sequence.EMPTY_SEQUENCE; --- ModuleImpl.java DELETED --- Index: XMLDBStore.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBStore.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDBStore.java 28 May 2004 10:54:17 -0000 1.4 --- XMLDBStore.java 12 Sep 2004 09:25:16 -0000 1.5 *************** *** 47,51 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("store", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Store a node as a new document into the database. The first " + "argument specifies the collection object as returned by the collection or " + --- 47,51 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("store", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Store a node as a new document into the database. The first " + "argument specifies the collection object as returned by the collection or " + Index: XMLDBHasLock.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBHasLock.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBHasLock.java 1 Mar 2004 13:44:37 -0000 1.1 --- XMLDBHasLock.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 46,50 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-has-lock", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the name of the user that holds a write lock on the document of the " + "specified node. If no lock is in place, the empty sequence is returned.", --- 46,50 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-has-lock", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns the name of the user that holds a write lock on the document of the " + "specified node. If no lock is in place, the empty sequence is returned.", *************** *** 66,70 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! User u = proxy.doc.getUserLock(); if(u == null) return Sequence.EMPTY_SEQUENCE; --- 66,70 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! User u = proxy.getDocument().getUserLock(); if(u == null) return Sequence.EMPTY_SEQUENCE; Index: XMLDBCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBCollection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDBCollection.java 28 May 2004 10:54:17 -0000 1.4 --- XMLDBCollection.java 12 Sep 2004 09:25:16 -0000 1.5 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("collection", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Get a reference to a collection identified by the XMLDB URI passed " + "as first argument. The second argument should specify the name of " + --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("collection", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Get a reference to a collection identified by the XMLDB URI passed " + "as first argument. The second argument should specify the name of " + Index: XMLDBPermissions.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBPermissions.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBPermissions.java 26 Apr 2004 14:08:10 -0000 1.1 --- XMLDBPermissions.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 48,52 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-resource-permissions", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns document permissions", new SequenceType[] { --- 48,52 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-resource-permissions", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns document permissions", new SequenceType[] { *************** *** 68,72 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! perm = proxy.doc.getPermissions(); if(perm == null) return Sequence.EMPTY_SEQUENCE; --- 68,72 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! perm = proxy.getDocument().getPermissions(); if(perm == null) return Sequence.EMPTY_SEQUENCE; Index: XMLDBOwner.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBOwner.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBOwner.java 26 Apr 2004 14:08:10 -0000 1.1 --- XMLDBOwner.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 47,51 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-resource-owner", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns document owner", new SequenceType[] { --- 47,51 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-resource-owner", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns document owner", new SequenceType[] { *************** *** 67,71 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! perm = proxy.doc.getPermissions(); if(perm == null) return Sequence.EMPTY_SEQUENCE; --- 67,71 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! perm = proxy.getDocument().getPermissions(); if(perm == null) return Sequence.EMPTY_SEQUENCE; Index: XMLDBGroup.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBGroup.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBGroup.java 26 Apr 2004 14:08:10 -0000 1.1 --- XMLDBGroup.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 47,51 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-resource-group", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns document group", new SequenceType[] { --- 47,51 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("get-resource-group", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns document group", new SequenceType[] { *************** *** 67,71 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! perm = proxy.doc.getPermissions(); if(perm == null) return Sequence.EMPTY_SEQUENCE; --- 67,71 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! perm = proxy.getDocument().getPermissions(); if(perm == null) return Sequence.EMPTY_SEQUENCE; Index: XMLDBRegisterDatabase.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBRegisterDatabase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLDBRegisterDatabase.java 28 May 2004 10:54:17 -0000 1.3 --- XMLDBRegisterDatabase.java 12 Sep 2004 09:25:16 -0000 1.4 *************** *** 44,49 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("register-database", ModuleImpl.NAMESPACE_URI, ! ModuleImpl.PREFIX), "Register an XMLDB driver class with the XMLDB Database Manager. " + "This is only required if you want to access a database instance different " --- 44,49 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("register-database", XMLDBModule.NAMESPACE_URI, ! XMLDBModule.PREFIX), "Register an XMLDB driver class with the XMLDB Database Manager. " + "This is only required if you want to access a database instance different " Index: XMLDBCreateCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDBCreateCollection.java 28 May 2004 10:54:17 -0000 1.4 --- XMLDBCreateCollection.java 12 Sep 2004 09:25:16 -0000 1.5 *************** *** 43,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("create-collection", ModuleImpl.NAMESPACE_URI, ! ModuleImpl.PREFIX), "Create a new collection as a child of the collection object passed as " + "first argument. The second argument specifies the name of the new " --- 43,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("create-collection", XMLDBModule.NAMESPACE_URI, ! XMLDBModule.PREFIX), "Create a new collection as a child of the collection object passed as " + "first argument. The second argument specifies the name of the new " Index: XMLDBLastModified.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBLastModified.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLDBLastModified.java 22 Jun 2004 11:05:20 -0000 1.3 --- XMLDBLastModified.java 12 Sep 2004 09:25:16 -0000 1.4 *************** *** 46,50 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("last-modified", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the modified date", new SequenceType[] { --- 46,50 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("last-modified", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Returns the modified date", new SequenceType[] { *************** *** 65,69 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new DateTimeValue(proxy.doc.getLastModified()); } return Sequence.EMPTY_SEQUENCE; --- 65,69 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new DateTimeValue(proxy.getDocument().getLastModified()); } return Sequence.EMPTY_SEQUENCE; Index: XMLDBRemove.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBRemove.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLDBRemove.java 21 Feb 2004 17:56:51 -0000 1.2 --- XMLDBRemove.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 45,49 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("remove-resource", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Remove a resource from the collection. The first " + "argument specifies the collection object as returned by the collection or " + --- 45,49 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("remove-resource", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Remove a resource from the collection. The first " + "argument specifies the collection object as returned by the collection or " + Index: XMLDBAuthenticate.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBAuthenticate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLDBAuthenticate.java 28 May 2004 10:54:17 -0000 1.2 --- XMLDBAuthenticate.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("authenticate", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Check if a user is registered as database user. The function simply tries to " + "read the database collection specified in the first parameter $a, using the " + --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("authenticate", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), "Check if a user is registered as database user. The function simply tries to " + "read the database collection specified in the first parameter $a, using the " + |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xmldb/test Modified Files: TestEXistXMLSerialize.java RemoteCollectionTest.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: RemoteCollectionTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/RemoteCollectionTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RemoteCollectionTest.java 3 Sep 2004 09:05:33 -0000 1.3 --- RemoteCollectionTest.java 12 Sep 2004 09:25:22 -0000 1.4 *************** *** 96,101 **** String[] actualContents = getCollection().listResources(); - System.out.println(actualContents); for (int i = 0; i < actualContents.length; i++) { xmlNames.remove(actualContents[i]); binaryNames.remove(actualContents[i]); --- 96,101 ---- String[] actualContents = getCollection().listResources(); for (int i = 0; i < actualContents.length; i++) { + System.out.println("---------------------->" + actualContents[i]); xmlNames.remove(actualContents[i]); binaryNames.remove(actualContents[i]); Index: TestEXistXMLSerialize.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/TestEXistXMLSerialize.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestEXistXMLSerialize.java 2 Feb 2004 15:30:34 -0000 1.1 --- TestEXistXMLSerialize.java 12 Sep 2004 09:25:22 -0000 1.2 *************** *** 6,23 **** package org.exist.xmldb.test; - import org.xml.sax.InputSource; - import org.xmldb.api.DatabaseManager; - import org.xmldb.api.modules.*; - import org.xmldb.api.base.*; - - import org.apache.xml.serialize.OutputFormat; - import org.apache.xml.serialize.XMLSerializer; - import org.exist.util.serializer.DOMSerializer; - import org.w3c.dom.*; - - import javax.xml.transform.*; - import javax.xml.transform.dom.DOMSource; - import javax.xml.transform.stream.StreamResult; - import java.io.ByteArrayOutputStream; import java.io.File; --- 6,9 ---- *************** *** 25,29 **** import java.util.Properties; ! import junit.framework.*; /** --- 11,32 ---- import java.util.Properties; ! import javax.xml.transform.Transformer; ! import javax.xml.transform.TransformerFactory; ! import javax.xml.transform.dom.DOMSource; ! import javax.xml.transform.stream.StreamResult; ! ! import junit.framework.TestCase; ! ! import org.apache.xml.serialize.OutputFormat; ! import org.apache.xml.serialize.XMLSerializer; ! import org.exist.util.serializer.DOMSerializer; ! import org.exist.util.serializer.SAXSerializer; ! import org.w3c.dom.Document; ! import org.w3c.dom.Element; ! import org.w3c.dom.Node; ! import org.xmldb.api.DatabaseManager; ! import org.xmldb.api.base.Collection; ! import org.xmldb.api.base.Database; ! import org.xmldb.api.modules.XMLResource; /** *************** *** 138,141 **** --- 141,167 ---- } + public void testSerialize4( ) throws Exception{ + System.out.println("Xerces version: "+org.apache.xerces.impl.Version.getVersion( )); + Document doc = javax.xml.parsers.DocumentBuilderFactory.newInstance( ).newDocumentBuilder().parse(testFile); + XMLResource resource = (XMLResource) c.createResource(null, "XMLResource"); + resource.setContentAsDOM(doc); + System.out.println("Storing resource: "+resource.getId( )); + c.storeResource(resource); + + resource = (XMLResource)c.getResource(resource.getId()); + Node node = resource.getContentAsDOM(); + System.out.println("Attempting serialization using eXist's SAX serializer"); + StringWriter writer = new StringWriter(); + Properties outputProperties = new Properties(); + outputProperties.setProperty("indent", "yes"); + SAXSerializer serializer = new SAXSerializer(writer, outputProperties); + resource.getContentAsSAX(serializer); + + System.out.println("Using org.exist.util.serializer.SAXSerializer"); + System.out.println("---------------------"); + System.out.println(writer.toString()); + System.out.println("---------------------"); + } + /** * @param args the command line arguments |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage/store In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/storage/store Modified Files: DOMFile.java NodeIterator.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: DOMFile.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/store/DOMFile.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** DOMFile.java 16 Aug 2004 19:47:11 -0000 1.51 --- DOMFile.java 12 Sep 2004 09:25:21 -0000 1.52 *************** *** 792,796 **** final long firstChildId = XMLUtil.getFirstChildId(doc, id); ! final Iterator iter = new NodeIterator(lock, this, node.doc, parentPointer); final NodeImpl n = (NodeImpl) iter.next(); --- 792,796 ---- final long firstChildId = XMLUtil.getFirstChildId(doc, id); ! final Iterator iter = new NodeIterator(lock, this, node.getDocument(), parentPointer); final NodeImpl n = (NodeImpl) iter.next(); *************** *** 1679,1683 **** byte flags; for (int pos = 0; pos < dlen;) { ! currentId = ByteConversion.byteToShort(data, pos); flags = ItemId.getFlags(currentId); if (ItemId.matches(currentId, targetId)) { --- 1679,1684 ---- byte flags; for (int pos = 0; pos < dlen;) { ! currentId = (short) ( ( data[pos] & 0xff ) + ( ( data[pos + 1] & 0xff ) << 8 ) ); ! // currentId = ByteConversion.byteToShort(data, pos); flags = ItemId.getFlags(currentId); if (ItemId.matches(currentId, targetId)) { *************** *** 1692,1696 **** pos += 10; } else { ! vlen = ByteConversion.byteToShort(data, pos + 2); if ((flags & ItemId.RELOCATED_FLAG) != 0) { pos += vlen + 12; --- 1693,1698 ---- pos += 10; } else { ! vlen = (short) ( ( data[pos + 2] & 0xff ) + ( ( data[pos + 3] & 0xff ) << 8 ) ); ! // vlen = ByteConversion.byteToShort(data, pos + 2); if ((flags & ItemId.RELOCATED_FLAG) != 0) { pos += vlen + 12; Index: NodeIterator.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/store/NodeIterator.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NodeIterator.java 28 Jul 2004 18:54:56 -0000 1.14 --- NodeIterator.java 12 Sep 2004 09:25:22 -0000 1.15 *************** *** 40,44 **** throws BTreeException, IOException { this.db = db; ! this.doc = node.doc; this.useNodePool = poolable; if (-1 < node.getInternalAddress()) --- 40,44 ---- throws BTreeException, IOException { this.db = db; ! this.doc = node.getDocument(); this.useNodePool = poolable; if (-1 < node.getInternalAddress()) |
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery Modified Files: FunctionFactory.java ValueComparison.java Module.java BindingExpression.java DescendantOrSelfSelector.java DocumentConstructor.java FunctionCall.java LocationStep.java EnclosedExpr.java XQueryContext.java Variable.java AbstractExpression.java RangeExpression.java JavaCall.java XQueryWatchDog.java Function.java XQuery.java GeneralComparison.java ForExpr.java LetExpr.java XPathUtil.java LiteralValue.java UserDefinedFunction.java Predicate.java VariableDeclaration.java QuantifiedExpression.java Added Files: LocalVariable.java Pragma.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: JavaCall.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/JavaCall.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JavaCall.java 13 Aug 2004 21:28:48 -0000 1.4 --- JavaCall.java 12 Sep 2004 09:25:14 -0000 1.5 *************** *** 173,177 **** } } ! LOG.debug("calling method " + bestMethod.toString()); Class paramTypes[] = null; boolean isStatic = true; --- 173,177 ---- } } ! // LOG.debug("calling method " + bestMethod.toString()); Class paramTypes[] = null; boolean isStatic = true; Index: QuantifiedExpression.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/QuantifiedExpression.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QuantifiedExpression.java 28 May 2004 10:54:13 -0000 1.2 --- QuantifiedExpression.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 52,57 **** public Sequence eval(Sequence contextSequence, Item contextItem, Sequence resultSequence) throws XPathException { ! context.pushLocalContext(false); ! Variable var = new Variable(QName.parse(context, varName)); context.declareVariable(var); Sequence inSeq = inputSequence.eval(null); --- 52,58 ---- public Sequence eval(Sequence contextSequence, Item contextItem, Sequence resultSequence) throws XPathException { ! // context.pushLocalContext(false); ! LocalVariable mark = context.markLocalVariables(); ! LocalVariable var = new LocalVariable(QName.parse(context, varName, null)); context.declareVariable(var); Sequence inSeq = inputSequence.eval(null); *************** *** 72,76 **** break; } ! context.popLocalContext(); return found ? BooleanValue.TRUE : BooleanValue.FALSE; } --- 73,78 ---- break; } ! // context.popLocalContext(); ! context.popLocalVariables(mark); return found ? BooleanValue.TRUE : BooleanValue.FALSE; } Index: XQueryContext.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XQueryContext.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** XQueryContext.java 4 Aug 2004 19:00:05 -0000 1.22 --- XQueryContext.java 12 Sep 2004 09:25:14 -0000 1.23 *************** *** 30,35 **** --- 30,37 ---- import java.net.URI; import java.net.URL; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; + import java.util.List; import java.util.Map; import java.util.Stack; *************** *** 43,48 **** import org.exist.security.User; import org.exist.storage.DBBroker; - import org.exist.xquery.functions.text.TextModule; - import org.exist.xquery.functions.transform.ModuleImpl; import org.exist.xquery.parser.XQueryLexer; import org.exist.xquery.parser.XQueryParser; --- 45,48 ---- *************** *** 72,76 **** public final static String XQUERY_LOCAL_NS = "http://www.w3.org/2003/08/xquery-local-functions"; ! private final static Logger LOG = Logger.getLogger(XQueryContext.class); --- 72,78 ---- public final static String XQUERY_LOCAL_NS = "http://www.w3.org/2003/08/xquery-local-functions"; ! public final static String EXIST_NS = ! "http://exist.sourceforge.net/NS/exist"; ! private final static Logger LOG = Logger.getLogger(XQueryContext.class); *************** *** 93,108 **** private TreeMap declaredFunctions = new TreeMap(); ! // Globally declare variables private TreeMap globalVariables = new TreeMap(); ! // Local in-scope variables in the current context ! private TreeMap variables = new TreeMap(); - // Local in-scope variable stack - private Stack variableStack = new Stack(); - // Unresolved references to user defined functions private Stack forwardReferences = new Stack(); private XQueryWatchDog watchdog; --- 95,112 ---- private TreeMap declaredFunctions = new TreeMap(); ! // Globally declared variables private TreeMap globalVariables = new TreeMap(); + + // The last element in the linked list of local in-scope variables + private LocalVariable lastVar = null; ! // The current size of the variable stack ! private int variableStackSize = 0; // Unresolved references to user defined functions private Stack forwardReferences = new Stack(); + private List pragmas = null; + private XQueryWatchDog watchdog; *************** *** 123,127 **** private String moduleLoadPath = "."; ! private String defaultFunctionNamespace = Function.BUILTIN_FUNCTION_NS; /** --- 127,131 ---- private String moduleLoadPath = "."; ! private String defaultFunctionNamespace = Module.BUILTIN_FUNCTION_NS; /** *************** *** 359,363 **** builder.startDocument(); staticDocuments = null; ! variableStack.clear(); fragmentStack = new Stack(); watchdog.reset(); --- 363,367 ---- builder.startDocument(); staticDocuments = null; ! lastVar = null; fragmentStack = new Stack(); watchdog.reset(); *************** *** 466,470 **** /** ! * Declare a variable. This is called by variable binding expressions like * "let" and "for". * --- 470,474 ---- /** ! * Declare a local variable. This is called by variable binding expressions like * "let" and "for". * *************** *** 473,479 **** * @throws XPathException */ ! public Variable declareVariable(Variable var) throws XPathException { ! variables.put(var.getQName(), var); ! var.setStackPosition(variableStack.size()); return var; } --- 477,490 ---- * @throws XPathException */ ! public LocalVariable declareVariable(LocalVariable var) throws XPathException { ! // variables.put(var.getQName(), var); ! if(lastVar == null) ! lastVar = var; ! else { ! lastVar.addAfter(var); ! lastVar = var; ! } ! // var.setStackPosition(variableStack.size()); ! var.setStackPosition(variableStackSize); return var; } *************** *** 489,493 **** public Variable declareGlobalVariable(Variable var) throws XPathException { globalVariables.put(var.getQName(), var); ! var.setStackPosition(variableStack.size()); return var; } --- 500,504 ---- public Variable declareGlobalVariable(Variable var) throws XPathException { globalVariables.put(var.getQName(), var); ! var.setStackPosition(variableStackSize); return var; } *************** *** 507,511 **** */ public Variable declareVariable(String qname, Object value) throws XPathException { ! QName qn = QName.parse(this, qname); Variable var; Module module = getModule(qn.getNamespaceURI()); --- 518,522 ---- */ public Variable declareVariable(String qname, Object value) throws XPathException { ! QName qn = QName.parse(this, qname, null); Variable var; Module module = getModule(qn.getNamespaceURI()); *************** *** 552,556 **** return var; } ! var = (Variable) variables.get(qname); if (var == null) { var = (Variable) globalVariables.get(qname); --- 563,568 ---- return var; } ! var = resolveLocalVariable(qname); ! // var = (Variable) variables.get(qname); if (var == null) { var = (Variable) globalVariables.get(qname); *************** *** 561,564 **** --- 573,584 ---- } + private Variable resolveLocalVariable(QName qname) throws XPathException { + for(LocalVariable var = lastVar; var != null; var = var.before) { + if(qname.equals(var.getQName())) + return var; + } + return null; + } + /** * Turn on/off XPath 1.0 backwards compatibility. *************** *** 730,752 **** /** ! * Save the current context on top of a stack. * ! * Use {@link popContext()} to restore the current state. ! * This method saves the current in-scope variable ! * definitions. */ ! public void pushLocalContext(boolean emptyContext) { ! variableStack.push(variables); ! if (emptyContext) ! variables = new TreeMap(); ! else ! variables = new TreeMap(variables); } ! /** ! * Restore previous state. */ ! public void popLocalContext() { ! variables = (TreeMap) variableStack.pop(); } --- 750,775 ---- /** ! * Returns the last variable on the local variable stack. ! * The current variable context can be restored by passing ! * the return value to {@link #popLocalVariables(LocalVariable)}. * ! * @return */ ! public LocalVariable markLocalVariables() { ! variableStackSize++; ! return lastVar; } ! /** ! * Restore the local variable stack to the position marked ! * by variable var. ! * ! * @param var */ ! public void popLocalVariables(LocalVariable var) { ! if(var != null) ! var.after = null; ! lastVar = var; ! variableStackSize--; } *************** *** 758,762 **** */ public int getCurrentStackSize() { ! return variableStack.size(); } --- 781,785 ---- */ public int getCurrentStackSize() { ! return variableStackSize; } *************** *** 810,814 **** } XQueryContext context = new ModuleContext(this); ! XQueryLexer lexer = new XQueryLexer(reader); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser astParser = new XQueryTreeParser(context); --- 833,837 ---- } XQueryContext context = new ModuleContext(this); ! XQueryLexer lexer = new XQueryLexer(context, reader); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser astParser = new XQueryTreeParser(context); *************** *** 881,884 **** --- 904,913 ---- } + /** + * Called by XUpdate to tell the query engine that it is running in + * exclusive mode, i.e. no other query is executed at the same time. + * + * @param exclusive + */ public void setExclusiveMode(boolean exclusive) { this.exclusive = exclusive; *************** *** 889,892 **** --- 918,954 ---- } + public void addPragma(String qnameString, String contents) throws XPathException { + QName qn; + try { + qn = QName.parse(this, qnameString, defaultFunctionNamespace); + } catch (XPathException e) { + // unknown pragma: just ignore it + LOG.debug("Ignoring unknown pragma: " + qnameString); + return; + } + Pragma pragma = new Pragma(qn, contents); + if(pragmas == null) + pragmas = new ArrayList(); + pragmas.add(pragma); + + // check predefined pragmas + if(Pragma.TIMEOUT_QNAME.compareTo(qn) == 0) + watchdog.setTimeoutFromPragma(pragma); + if(Pragma.OUTPUT_SIZE_QNAME.compareTo(qn) == 0) + watchdog.setMaxNodesFromPragma(pragma); + } + + public Pragma getPragma(QName qname) { + if(pragmas != null) { + Pragma pragma; + for(int i = 0; i < pragmas.size(); i++) { + pragma = (Pragma)pragmas.get(i); + if(qname.compareTo(pragma.getQName()) == 0) + return pragma; + } + } + return null; + } + /** * Load the default prefix/namespace mappings table and set up *************** *** 910,932 **** declareNamespace("xdt", XPATH_DATATYPES_NS); declareNamespace("local", XQUERY_LOCAL_NS); ! declareNamespace("fn", Function.BUILTIN_FUNCTION_NS); // load built-in modules loadBuiltInModule( ! Function.BUILTIN_FUNCTION_NS, "org.exist.xquery.functions.ModuleImpl"); loadBuiltInModule( ! Function.UTIL_FUNCTION_NS, ! "org.exist.xquery.functions.util.ModuleImpl"); ! loadBuiltInModule(ModuleImpl.NAMESPACE_URI, ! "org.exist.xquery.functions.transform.ModuleImpl"); loadBuiltInModule( ! Function.XMLDB_FUNCTION_NS, ! "org.exist.xquery.functions.xmldb.ModuleImpl"); loadBuiltInModule( ! Function.REQUEST_FUNCTION_NS, "org.exist.xquery.functions.request.RequestModule"); loadBuiltInModule( ! TextModule.NAMESPACE_URI, "org.exist.xquery.functions.text.TextModule"); } --- 972,998 ---- declareNamespace("xdt", XPATH_DATATYPES_NS); declareNamespace("local", XQUERY_LOCAL_NS); ! declareNamespace("fn", Module.BUILTIN_FUNCTION_NS); ! declareNamespace("exist", EXIST_NS); // load built-in modules + + // these modules are loaded dynamically. It is not an error if the + // specified module class cannot be found in the classpath. loadBuiltInModule( ! Module.BUILTIN_FUNCTION_NS, "org.exist.xquery.functions.ModuleImpl"); loadBuiltInModule( ! Module.UTIL_FUNCTION_NS, ! "org.exist.xquery.functions.util.UtilModule"); ! loadBuiltInModule(Module.TRANSFORM_FUNCTION_NS, ! "org.exist.xquery.functions.transform.TransformModule"); loadBuiltInModule( ! Module.XMLDB_FUNCTION_NS, ! "org.exist.xquery.functions.xmldb.XMLDBModule"); loadBuiltInModule( ! Module.REQUEST_FUNCTION_NS, "org.exist.xquery.functions.request.RequestModule"); loadBuiltInModule( ! Module.TEXT_FUNCTION_NS, "org.exist.xquery.functions.text.TextModule"); } Index: LetExpr.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/LetExpr.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LetExpr.java 28 May 2004 10:54:13 -0000 1.2 --- LetExpr.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 26,29 **** --- 26,30 ---- import org.exist.xquery.value.Item; import org.exist.xquery.value.OrderedValueSequence; + import org.exist.xquery.value.PreorderedValueSequence; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.Type; *************** *** 46,59 **** public Sequence eval(Sequence contextSequence, Item contextItem, Sequence resultSequence) throws XPathException { ! context.pushLocalContext(false); ! Variable var = new Variable(QName.parse(context, varName)); context.declareVariable(var); ! Sequence val = inputSequence.eval(null, null); if (sequenceType != null) { ! sequenceType.checkType(val.getItemType()); ! sequenceType.checkCardinality(val); } ! var.setValue(val); ! Sequence filtered = null; if (whereExpr != null) { --- 47,64 ---- public Sequence eval(Sequence contextSequence, Item contextItem, Sequence resultSequence) throws XPathException { ! // Save the local variable stack ! LocalVariable mark = context.markLocalVariables(); ! ! // Declare the iteration variable ! LocalVariable var = new LocalVariable(QName.parse(context, varName, null)); context.declareVariable(var); ! ! Sequence in = inputSequence.eval(null, null); if (sequenceType != null) { ! sequenceType.checkType(in.getItemType()); ! sequenceType.checkCardinality(in); } ! var.setValue(in); ! Sequence filtered = null; if (whereExpr != null) { *************** *** 66,72 **** return Sequence.EMPTY_SEQUENCE; } if(resultSequence == null) { ! if(orderSpecs != null) ! resultSequence = new OrderedValueSequence(orderSpecs, val.getLength()); else resultSequence = new ValueSequence(); --- 71,90 ---- return Sequence.EMPTY_SEQUENCE; } + + // Check if we can speed up the processing of the "order by" clause. + boolean fastOrderBy = checkOrderSpecs(in); + + // PreorderedValueSequence applies the order specs to all items + // in one single processing step + if(fastOrderBy) { + in = new PreorderedValueSequence(orderSpecs, in.toNodeSet()); + } + + // Otherwise, if there's an order by clause, wrap the result into + // an OrderedValueSequence. OrderedValueSequence will compute + // order expressions for every item when it is added to the result sequence. if(resultSequence == null) { ! if(orderSpecs != null && !fastOrderBy) ! resultSequence = new OrderedValueSequence(orderSpecs, in.getLength()); else resultSequence = new ValueSequence(); *************** *** 76,85 **** ((BindingExpression)returnExpr).eval(null, null, resultSequence); } else { ! val = returnExpr.eval(null); ! resultSequence.addAll(val); } ! if(orderSpecs != null) ((OrderedValueSequence)resultSequence).sort(); ! context.popLocalContext(); return resultSequence; } --- 94,105 ---- ((BindingExpression)returnExpr).eval(null, null, resultSequence); } else { ! in = returnExpr.eval(null); ! resultSequence.addAll(in); } ! if(orderSpecs != null && !fastOrderBy) ((OrderedValueSequence)resultSequence).sort(); ! ! // Restore the local variable stack ! context.popLocalVariables(mark); return resultSequence; } Index: UserDefinedFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/UserDefinedFunction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UserDefinedFunction.java 28 May 2004 10:54:13 -0000 1.3 --- UserDefinedFunction.java 12 Sep 2004 09:25:14 -0000 1.4 *************** *** 53,57 **** public void addVariable(String varName) throws XPathException { ! QName qname = QName.parse(context, varName); parameters.add(qname); } --- 53,57 ---- public void addVariable(String varName) throws XPathException { ! QName qname = QName.parse(context, varName, null); parameters.add(qname); } *************** *** 72,81 **** throws XPathException { QName varName; ! Variable var; Sequence argSeq; int j = 0; for(Iterator i = parameters.iterator(); i.hasNext(); j++) { varName = (QName)i.next(); ! var = new Variable(varName); var.setValue(currentArguments[j]); context.declareVariable(var); --- 72,81 ---- throws XPathException { QName varName; ! LocalVariable var; Sequence argSeq; int j = 0; for(Iterator i = parameters.iterator(); i.hasNext(); j++) { varName = (QName)i.next(); ! var = new LocalVariable(varName); var.setValue(currentArguments[j]); context.declareVariable(var); Index: GeneralComparison.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/GeneralComparison.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GeneralComparison.java 28 May 2004 10:54:12 -0000 1.5 --- GeneralComparison.java 12 Sep 2004 09:25:14 -0000 1.6 *************** *** 78,89 **** this.truncation = truncation; // simplify arguments ! if (left instanceof PathExpr && ((PathExpr) left).getLength() == 1) ! add(((PathExpr) left).getExpression(0)); ! else ! add(left); ! if (right instanceof PathExpr && ((PathExpr) right).getLength() == 1) ! add(((PathExpr) right).getExpression(0)); ! else ! add(right); } --- 78,89 ---- this.truncation = truncation; // simplify arguments ! if (left instanceof PathExpr && ((PathExpr) left).getLength() == 1) { ! left = ((PathExpr) left).getExpression(0); ! } ! add(left); ! if (right instanceof PathExpr && ((PathExpr) right).getLength() == 1) { ! right = ((PathExpr) right).getExpression(0); ! } ! add(right); } *************** *** 168,172 **** lv = ls.itemAt(0).atomize(); rv = rs.itemAt(0).atomize(); ! return new BooleanValue(compareValues(lv, rv)); } else { for (SequenceIterator i1 = ls.iterate(); i1.hasNext();) { --- 168,172 ---- lv = ls.itemAt(0).atomize(); rv = rs.itemAt(0).atomize(); ! return BooleanValue.valueOf(compareValues(lv, rv)); } else { for (SequenceIterator i1 = ls.iterate(); i1.hasNext();) { Index: LiteralValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/LiteralValue.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LiteralValue.java 28 May 2004 10:54:13 -0000 1.2 --- LiteralValue.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 23,27 **** package org.exist.xquery; - import org.exist.dom.DocumentSet; import org.exist.xquery.value.AtomicValue; import org.exist.xquery.value.Item; --- 23,26 ---- *************** *** 63,74 **** /* (non-Javadoc) - * @see org.exist.xquery.Expression#preselect(org.exist.dom.DocumentSet, org.exist.xquery.StaticContext) - */ - public DocumentSet preselect(DocumentSet in_docs) - throws XPathException { - return in_docs; - } - - /* (non-Javadoc) * @see org.exist.xquery.Expression#pprint() */ --- 62,65 ---- Index: ValueComparison.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/ValueComparison.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ValueComparison.java 29 Jan 2004 15:06:41 -0000 1.1 --- ValueComparison.java 12 Sep 2004 09:25:14 -0000 1.2 *************** *** 26,30 **** import org.exist.dom.ContextItem; - import org.exist.dom.DocumentSet; import org.exist.dom.ExtArrayNodeSet; import org.exist.dom.NodeProxy; --- 26,29 ---- *************** *** 72,76 **** lv = ls.itemAt(0).atomize(); rv = rs.itemAt(0).atomize(); ! return new BooleanValue(compareValues(lv, rv)); } else throw new XPathException("Type error: sequence with less or more than one item is not allowed here"); --- 71,75 ---- lv = ls.itemAt(0).atomize(); rv = rs.itemAt(0).atomize(); ! return BooleanValue.valueOf(compareValues(lv, rv)); } else throw new XPathException("Type error: sequence with less or more than one item is not allowed here"); Index: Function.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/Function.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Function.java 19 Jul 2004 13:06:24 -0000 1.5 --- Function.java 12 Sep 2004 09:25:14 -0000 1.6 *************** *** 48,73 **** */ public abstract class Function extends PathExpr { ! ! /** ! * XQuery/XPath 2.0 function namespace. ! */ public final static String BUILTIN_FUNCTION_NS = "http://www.w3.org/2003/05/xpath-functions"; - /** - * Namespace for the built-in xmldb functions. - */ - public final static String XMLDB_FUNCTION_NS = - "http://exist-db.org/xquery/xmldb"; - - /** - * Namespace for the built-in utility functions. - */ - public final static String UTIL_FUNCTION_NS = - "http://exist-db.org/xquery/util"; - - public final static String REQUEST_FUNCTION_NS = - "http://exist-db.org/xquery/request"; - // The signature of the function. protected FunctionSignature mySignature; --- 48,55 ---- */ public abstract class Function extends PathExpr { ! public final static String BUILTIN_FUNCTION_NS = "http://www.w3.org/2003/05/xpath-functions"; // The signature of the function. protected FunctionSignature mySignature; Index: Module.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/Module.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Module.java 28 May 2004 10:54:12 -0000 1.2 --- Module.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 43,46 **** --- 43,76 ---- public interface Module { + /** + * XQuery/XPath 2.0 function namespace. + */ + public final static String BUILTIN_FUNCTION_NS = + "http://www.w3.org/2003/05/xpath-functions"; + + /** + * Namespace for the built-in xmldb module. + */ + public final static String XMLDB_FUNCTION_NS = + "http://exist-db.org/xquery/xmldb"; + + /** + * Namespace for the built-in utility module. + */ + public final static String UTIL_FUNCTION_NS = + "http://exist-db.org/xquery/util"; + + /** + * Namespace for the built-in request module. + */ + public final static String REQUEST_FUNCTION_NS = + "http://exist-db.org/xquery/request"; + + public final static String TRANSFORM_FUNCTION_NS = + "http://exist-db.org/xquery/transform"; + + public final static String TEXT_FUNCTION_NS = + "http://exist-db.org/xquery/text"; + /** * Returns the namespace URI that uniquely identifies this module. Index: RangeExpression.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/RangeExpression.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RangeExpression.java 28 May 2004 10:54:12 -0000 1.2 --- RangeExpression.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 40,44 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("to", BUILTIN_FUNCTION_NS), new SequenceType[] { new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), --- 40,44 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("to", Module.BUILTIN_FUNCTION_NS), new SequenceType[] { new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), Index: XQueryWatchDog.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XQueryWatchDog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XQueryWatchDog.java 22 Jun 2004 08:14:16 -0000 1.2 --- XQueryWatchDog.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 50,58 **** public XQueryWatchDog(XQueryContext context) { this.context = context; ! configure(); startTime = System.currentTimeMillis(); } ! private void configure() { try { Configuration conf = BrokerPool.getInstance().getConfiguration(); --- 50,58 ---- public XQueryWatchDog(XQueryContext context) { this.context = context; ! configureDefaults(); startTime = System.currentTimeMillis(); } ! private void configureDefaults() { try { Configuration conf = BrokerPool.getInstance().getConfiguration(); *************** *** 70,73 **** --- 70,97 ---- } + public void setTimeoutFromPragma(Pragma pragma) throws XPathException { + String[] contents = pragma.tokenizeContents(); + if(contents.length != 1) + throw new XPathException("Pragma 'timeout' should have exactly one parameter: the timeout value."); + try { + timeout = Long.parseLong(contents[0]); + } catch (NumberFormatException e) { + throw new XPathException("Error parsing timeout value in pragma " + pragma.getQName().toString()); + } + LOG.debug("timeout set from pragma: " + timeout + "ms."); + } + + public void setMaxNodesFromPragma(Pragma pragma) throws XPathException { + String[] contents = pragma.tokenizeContents(); + if(contents.length != 1) + throw new XPathException("Pragma 'output-size-limit' should have exactly one parameter: the timeout value."); + try { + maxNodesLimit = Integer.parseInt(contents[0]); + } catch (NumberFormatException e) { + throw new XPathException("Error parsing size-limit value in pragma " + pragma.getQName().toString()); + } + LOG.debug("output-size-limit set from pragma: " + maxNodesLimit); + } + public void proceed(Expression expr) throws TerminatedException { final long elapsed = System.currentTimeMillis() - startTime; Index: Variable.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/Variable.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Variable.java 5 May 2004 18:05:41 -0000 1.2 --- Variable.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 34,42 **** --- 34,54 ---- public class Variable { + // the name of the variable private QName qname; + + // the current value assigned to the variable private Sequence value = null; + + // the context position of this variable in the local variable stack + // this can be used to determine if a variable has been declared + // before another private int positionInStack = 0; + + // the cardinality of this variable private int cardinality = Cardinality.ZERO_OR_MORE; + + // the context document set private DocumentSet contextDocs = null; + /** * --- NEW FILE: Pragma.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * 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: Pragma.java,v 1.1 2004/09/12 09:25:14 wolfgang_m Exp $ */ package org.exist.xquery; import java.util.StringTokenizer; import org.apache.oro.text.perl.Perl5Util; import org.apache.oro.text.regex.MalformedPatternException; import org.apache.oro.text.regex.MatchResult; import org.apache.oro.text.regex.Pattern; import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Perl5Matcher; import org.exist.dom.QName; /** * Represents an XQuery pragma. Pragmas are used to pass * vendor-specific information to the XQuery engine. They may * occur anywhere inside the query. The specified pragmas can * be accessed through method * {@link org.exist.xquery.XQueryContext#getPragma(QName)}. * * @author wolf */ public class Pragma { public final static QName TIMEOUT_QNAME = new QName("timeout", XQueryContext.EXIST_NS); public final static QName OUTPUT_SIZE_QNAME = new QName("output-size-limit", XQueryContext.EXIST_NS); public final static QName SERIALIZE_QNAME = new QName("serialize", XQueryContext.EXIST_NS); private final static String paramPattern = "\\s*([\\w\\.-]+)\\s*=\\s*('[^']*'|\"[^\"]*\"|[^\\s]+)"; private static Perl5Matcher matcher = new Perl5Matcher(); private static Pattern pattern; static { Perl5Compiler compiler = new Perl5Compiler(); try { pattern = compiler.compile(paramPattern); } catch (MalformedPatternException e) { throw new RuntimeException(e); } } private QName qname; private String contents; public Pragma(QName qname, String contents) { this.qname = qname; this.contents = contents; } public QName getQName() { return qname; } public String getContents() { return contents; } public String[] tokenizeContents() { if(contents == null) return new String[0]; StringTokenizer tok = new StringTokenizer(contents, " \r\t\n"); String[] items = new String[tok.countTokens()]; for(int i = 0; tok.hasMoreTokens(); i++) { items[i] = tok.nextToken(); } return items; } public static synchronized String[] parseKeyValuePair(String s) { if(matcher.matches(s, pattern)) { MatchResult result = matcher.getMatch(); String value = result.group(2); if(value.charAt(0) == '\'' || value.charAt(0) == '"') value = value.substring(1, value.length() - 1); return new String[] { result.group(1), value }; } return null; } } Index: Predicate.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/Predicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Predicate.java 3 Jun 2004 10:31:36 -0000 1.3 --- Predicate.java 12 Sep 2004 09:25:14 -0000 1.4 *************** *** 94,99 **** for (Iterator i = nodes.iterator(); i.hasNext(); count++) { current = (NodeProxy) i.next(); ! if(lastDoc == null || current.doc != lastDoc) { ! lastDoc = current.doc; sizeHint = nodes.getSizeHint(lastDoc); } --- 94,99 ---- for (Iterator i = nodes.iterator(); i.hasNext(); count++) { current = (NodeProxy) i.next(); ! if(lastDoc == null || current.getDocument() != lastDoc) { ! lastDoc = current.getDocument(); sizeHint = nodes.getSizeHint(lastDoc); } Index: BindingExpression.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/BindingExpression.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BindingExpression.java 15 Jul 2004 19:41:04 -0000 1.5 --- BindingExpression.java 12 Sep 2004 09:25:14 -0000 1.6 *************** *** 129,134 **** for (Iterator i = nodes.iterator(); i.hasNext(); count++) { current = (NodeProxy) i.next(); ! if(lastDoc == null || current.doc != lastDoc) { ! lastDoc = current.doc; sizeHint = nodes.getSizeHint(lastDoc); } --- 129,134 ---- for (Iterator i = nodes.iterator(); i.hasNext(); count++) { current = (NodeProxy) i.next(); ! if(lastDoc == null || current.getDocument() != lastDoc) { ! lastDoc = current.getDocument(); sizeHint = nodes.getSizeHint(lastDoc); } *************** *** 170,173 **** --- 170,194 ---- } + /** + * Check all order specs to see if we can process them in + * one single step. In general, this is possible if all order + * expressions return nodes. + * + * @return + */ + protected boolean checkOrderSpecs(Sequence in) { + if(orderSpecs == null) + return false; + if(!Type.subTypeOf(in.getItemType(), Type.NODE)) + return false; + for(int i = 0; i < orderSpecs.length; i++) { + Expression expr = orderSpecs[i].getSortExpression(); + if(!Type.subTypeOf(expr.returnsType(), Type.NODE) || + (expr.getDependencies() & Dependency.CONTEXT_ITEM ) != 0) + return false; + } + return true; + } + /* (non-Javadoc) * @see org.exist.xquery.Expression#preselect(org.exist.dom.DocumentSet, org.exist.xquery.StaticContext) Index: FunctionFactory.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/FunctionFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FunctionFactory.java 4 Aug 2004 19:00:05 -0000 1.5 --- FunctionFactory.java 12 Sep 2004 09:25:14 -0000 1.6 *************** *** 59,63 **** String uri = qname.getNamespaceURI(); Expression step = null; ! if(uri.equals(Function.BUILTIN_FUNCTION_NS)) { // near(node-set, string) if (local.equals("near")) { --- 59,63 ---- String uri = qname.getNamespaceURI(); Expression step = null; ! if(uri.equals(Module.BUILTIN_FUNCTION_NS)) { // near(node-set, string) if (local.equals("near")) { Index: DocumentConstructor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/DocumentConstructor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DocumentConstructor.java 27 Jun 2004 21:10:06 -0000 1.1 --- DocumentConstructor.java 12 Sep 2004 09:25:14 -0000 1.2 *************** *** 25,29 **** import org.exist.memtree.MemTreeBuilder; import org.exist.memtree.NodeImpl; ! import org.exist.memtree.Receiver; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; --- 25,29 ---- import org.exist.memtree.MemTreeBuilder; import org.exist.memtree.NodeImpl; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; *************** *** 60,64 **** context.pushDocumentContext(); MemTreeBuilder builder = context.getDocumentBuilder(); ! Receiver receiver = new Receiver(builder); if(contentSeq.getLength() == 0) --- 60,64 ---- context.pushDocumentContext(); MemTreeBuilder builder = context.getDocumentBuilder(); ! DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); if(contentSeq.getLength() == 0) Index: DescendantOrSelfSelector.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/DescendantOrSelfSelector.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DescendantOrSelfSelector.java 25 Mar 2004 12:50:50 -0000 1.1 --- DescendantOrSelfSelector.java 12 Sep 2004 09:25:14 -0000 1.2 *************** *** 41,45 **** public boolean match(NodeProxy node) { NodeProxy p; ! if((p = context.parentWithChild(node.doc, node.gid, false, true, -1)) != null) { if (rememberContext) node.addContextNode(p); --- 41,45 ---- public boolean match(NodeProxy node) { NodeProxy p; ! if((p = context.parentWithChild(node.getDocument(), node.gid, false, true, -1)) != null) { if (rememberContext) node.addContextNode(p); Index: EnclosedExpr.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/EnclosedExpr.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EnclosedExpr.java 28 May 2004 10:54:13 -0000 1.6 --- EnclosedExpr.java 12 Sep 2004 09:25:14 -0000 1.7 *************** *** 24,28 **** import org.exist.memtree.MemTreeBuilder; ! import org.exist.memtree.Receiver; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; --- 24,28 ---- import org.exist.memtree.MemTreeBuilder; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; *************** *** 59,63 **** // create the output MemTreeBuilder builder = context.getDocumentBuilder(); ! Receiver receiver = new Receiver(builder); start = System.currentTimeMillis(); try { --- 59,63 ---- // create the output MemTreeBuilder builder = context.getDocumentBuilder(); ! DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); start = System.currentTimeMillis(); try { Index: XQuery.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XQuery.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XQuery.java 8 Aug 2004 19:03:26 -0000 1.4 --- XQuery.java 12 Sep 2004 09:25:14 -0000 1.5 *************** *** 72,76 **** public CompiledXQuery compile(XQueryContext context, Reader reader) throws XPathException { long start = System.currentTimeMillis(); ! XQueryLexer lexer = new XQueryLexer(reader); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 72,76 ---- public CompiledXQuery compile(XQueryContext context, Reader reader) throws XPathException { long start = System.currentTimeMillis(); ! XQueryLexer lexer = new XQueryLexer(context, reader); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); Index: LocationStep.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/LocationStep.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** LocationStep.java 3 Aug 2004 15:25:59 -0000 1.15 --- LocationStep.java 12 Sep 2004 09:25:14 -0000 1.16 *************** *** 64,77 **** super(context, axis, test); } - - /* (non-Javadoc) - * @see org.exist.xquery.Step#returnsType() - */ - // public int returnsType() { - // if(axis == Constants.SELF_AXIS) - // return Type.ITEM; - // else - // return Type.NODE; - // } /* (non-Javadoc) --- 64,67 ---- *************** *** 114,117 **** --- 104,108 ---- if(!((NodeSet)contextSequence).hasChanged(timestamp)) { // LOG.debug("returning cached result"); + cachedResult.setIsCached(true); return (predicates.size() == 0) *************** *** 380,388 **** if (axis == Constants.ANCESTOR_SELF_AXIS && test.matches(p)) result.add( ! new NodeProxy(p.doc, p.gid, p.getInternalAddress())); ! while ((p.gid = XMLUtil.getParentId(p.doc, p.gid)) > 0) { p.nodeType = Node.ELEMENT_NODE; if (test.matches(p)) ! result.add(new NodeProxy(p.doc, p.gid)); } } --- 371,379 ---- if (axis == Constants.ANCESTOR_SELF_AXIS && test.matches(p)) result.add( ! new NodeProxy(p.getDocument(), p.gid, p.getInternalAddress())); ! while ((p.gid = XMLUtil.getParentId(p.getDocument(), p.gid)) > 0) { p.nodeType = Node.ELEMENT_NODE; if (test.matches(p)) ! result.add(new NodeProxy(p.getDocument(), p.gid)); } } --- NEW FILE: LocalVariable.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * 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: LocalVariable.java,v 1.1 2004/09/12 09:25:14 wolfgang_m Exp $ */ package org.exist.xquery; import org.exist.dom.QName; /** * Represents a local variable as declared by for and let. * * Local variables are stored as a linked list. * * @author wolf */ public class LocalVariable extends Variable { protected LocalVariable before = null; protected LocalVariable after = null; public LocalVariable(QName qname) { super(qname); } public void addAfter(LocalVariable var) { this.after = var; var.before = this; } } Index: AbstractExpression.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/AbstractExpression.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractExpression.java 5 May 2004 18:05:41 -0000 1.3 --- AbstractExpression.java 12 Sep 2004 09:25:14 -0000 1.4 *************** *** 23,31 **** import org.exist.dom.DocumentSet; - import org.exist.dom.NodeProxy; import org.exist.xquery.parser.XQueryAST; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; - import org.exist.xquery.value.SequenceIterator; public abstract class AbstractExpression implements Expression { --- 23,29 ---- *************** *** 82,94 **** } - public final static void setContext(Sequence seq) { - Item next; - for (SequenceIterator i = seq.unorderedIterator(); i.hasNext();) { - next = i.nextItem(); - if (next instanceof NodeProxy) - ((NodeProxy) next).addContextNode((NodeProxy) next); - } - } - /* (non-Javadoc) --- 80,83 ---- Index: ForExpr.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/ForExpr.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ForExpr.java 10 Aug 2004 20:27:18 -0000 1.7 --- ForExpr.java 12 Sep 2004 09:25:14 -0000 1.8 *************** *** 30,33 **** --- 30,34 ---- import org.exist.xquery.value.Item; import org.exist.xquery.value.OrderedValueSequence; + import org.exist.xquery.value.PreorderedValueSequence; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.SequenceIterator; *************** *** 60,100 **** Sequence resultSequence) throws XPathException { ! context.pushLocalContext(false); ! // declare the variable ! Variable var = new Variable(QName.parse(context, varName)); context.declareVariable(var); ! // declare positional variable ! Variable at = null; if(positionalVariable != null) { ! at = new Variable(QName.parse(context, positionalVariable)); context.declareVariable(at); } ! // evaluate the "in" expression Sequence in = inputSequence.eval(null, null); ! // assign to the bound variable var.setValue(in); if(in instanceof NodeSet) { DocumentSet contextDocs = ((NodeSet)in).getDocumentSet(); var.setContextDocs(contextDocs); } if(whereExpr != null) { whereExpr.setInPredicate(true); ! setContext(in); } boolean fastExec = whereExpr != null && ( whereExpr.getDependencies() & Dependency.CONTEXT_ITEM ) == 0 && at == null && in.getItemType() == Type.NODE; ! if(fastExec) { ! LOG.debug("fast evaluation mode"); in = applyWhereExpression(in); } ! // if there's an order by clause, wrap the result into ! // an OrderedValueSequence if(resultSequence == null) { ! if(orderSpecs != null) resultSequence = new OrderedValueSequence(orderSpecs, in.getLength()); --- 61,128 ---- Sequence resultSequence) throws XPathException { ! // Save the local variable stack ! LocalVariable mark = context.markLocalVariables(); ! ! // Declare the iteration variable ! LocalVariable var = new LocalVariable(QName.parse(context, varName, null)); context.declareVariable(var); ! // Declare positional variable ! LocalVariable at = null; if(positionalVariable != null) { ! at = new LocalVariable(QName.parse(context, positionalVariable, null)); context.declareVariable(at); } ! // Evaluate the "in" expression Sequence in = inputSequence.eval(null, null); ! ! // Assign the whole input sequence to the bound variable. ! // This is required if we process the "where" or "order by" clause ! // in one step. var.setValue(in); + + // Save the current context document set to the variable as a hint + // for path expressions occurring in the "return" clause. if(in instanceof NodeSet) { DocumentSet contextDocs = ((NodeSet)in).getDocumentSet(); var.setContextDocs(contextDocs); } + + // Check if we can speed up the processing of the "order by" clause. + boolean fastOrderBy = false; // checkOrderSpecs(in); + if(whereExpr != null) { whereExpr.setInPredicate(true); ! if(!(in.isCached() || fastOrderBy)) ! setContext(in); } + + // See if we can process the "where" clause in a single step (instead of + // calling the where expression for each item in the input sequence) + // This is possible if the input sequence is a node set and has no + // dependencies on the current context item. boolean fastExec = whereExpr != null && ( whereExpr.getDependencies() & Dependency.CONTEXT_ITEM ) == 0 && at == null && in.getItemType() == Type.NODE; ! ! // If possible, apply the where expression ahead of the iteration if(fastExec) { ! // LOG.debug("fast evaluation mode"); in = applyWhereExpression(in); } ! ! // PreorderedValueSequence applies the order specs to all items ! // in one single processing step ! if(fastOrderBy) { ! in = new PreorderedValueSequence(orderSpecs, in); ! } ! ! // Otherwise, if there's an order by clause, wrap the result into ! // an OrderedValueSequence. OrderedValueSequence will compute ! // order expressions for every item when it is added to the result sequence. if(resultSequence == null) { ! if(orderSpecs != null && !fastOrderBy) resultSequence = new OrderedValueSequence(orderSpecs, in.getLength()); *************** *** 108,112 **** if(positionalVariable != null) at.setValue(atVal); ! // loop through each variable binding for (SequenceIterator i = in.iterate(); i.hasNext(); p++) { context.proceed(this); --- 136,141 ---- if(positionalVariable != null) at.setValue(atVal); ! ! // Loop through each variable binding for (SequenceIterator i = in.iterate(); i.hasNext(); p++) { context.proceed(this); *************** *** 122,128 **** --- 151,159 ---- // check sequence type sequenceType.checkType(contextItem.getType()); + // set variable value to current item var.setValue(contextSequence); val = contextSequence; + // check optional where clause if (whereExpr != null && (!fastExec)) { *************** *** 148,157 **** } } ! if(orderSpecs != null) ((OrderedValueSequence)resultSequence).sort(); ! context.popLocalContext(); return resultSequence; } ! /* (non-Javadoc) * @see org.exist.xquery.Expression#pprint() --- 179,190 ---- } } ! if(orderSpecs != null && !fastOrderBy) ((OrderedValueSequence)resultSequence).sort(); ! ! // restore the local variable stack ! context.popLocalVariables(mark); return resultSequence; } ! /* (non-Javadoc) * @see org.exist.xquery.Expression#pprint() *************** *** 187,189 **** --- 220,231 ---- return Type.ITEM; } + + public final static void setContext(Sequence seq) { + Item next; + for (SequenceIterator i = seq.unorderedIterator(); i.hasNext();) { + next = i.nextItem(); + if (next instanceof NodeProxy) + ((NodeProxy) next).addContextNode((NodeProxy) next); + } + } } Index: FunctionCall.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/FunctionCall.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FunctionCall.java 28 May 2004 10:54:12 -0000 1.4 --- FunctionCall.java 12 Sep 2004 09:25:14 -0000 1.5 *************** *** 106,110 **** functionDef.setArguments(seq); ! context.pushLocalContext(true); try { Sequence returnSeq = expression.eval(contextSequence, contextItem); --- 106,111 ---- functionDef.setArguments(seq); ! // context.pushLocalContext(true); ! LocalVariable mark = context.markLocalVariables(); try { Sequence returnSeq = expression.eval(contextSequence, contextItem); *************** *** 115,119 **** throw e; } finally { ! context.popLocalContext(); } } --- 116,121 ---- throw e; } finally { ! // context.popLocalContext(); ! context.popLocalVariables(mark); } } Index: VariableDeclaration.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/VariableDeclaration.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VariableDeclaration.java 28 May 2004 10:54:13 -0000 1.2 --- VariableDeclaration.java 12 Sep 2004 09:25:14 -0000 1.3 *************** *** 66,70 **** Item contextItem) throws XPathException { ! QName qn = QName.parse(context, qname); Module myModule = context.getModule(qn.getNamespaceURI()); --- 66,70 ---- Item contextItem) throws XPathException { ! QName qn = QName.parse(context, qname, null); Module myModule = context.getModule(qn.getNamespaceURI()); Index: XPathUtil.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XPathUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XPathUtil.java 17 May 2004 09:59:42 -0000 1.3 --- XPathUtil.java 12 Sep 2004 09:25:14 -0000 1.4 *************** *** 30,34 **** import org.exist.memtree.MemTreeBuilder; import org.exist.memtree.NodeImpl; ! import org.exist.memtree.Receiver; import org.exist.util.serializer.DOMStreamer; import org.exist.util.serializer.DOMStreamerPool; --- 30,34 ---- import org.exist.memtree.MemTreeBuilder; import org.exist.memtree.NodeImpl; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.util.serializer.DOMStreamer; import org.exist.util.serializer.DOMStreamerPool; *************** *** 66,70 **** return new StringValue((String) obj); else if (obj instanceof Boolean) ! return new BooleanValue(((Boolean) obj).booleanValue()); else if (obj instanceof Float) return new FloatValue(((Float) obj).floatValue()); --- 66,70 ---- return new StringValue((String) obj); else if (obj instanceof Boolean) ! return BooleanValue.valueOf(((Boolean) obj).booleanValue()); else if (obj instanceof Float) return new FloatValue(((Float) obj).floatValue()); *************** *** 99,103 **** MemTreeBuilder builder = new MemTreeBuilder(); builder.startDocument(); ! Receiver receiver = new Receiver(builder); streamer.setContentHandler(receiver); ValueSequence seq = new ValueSequence(); --- 99,103 ---- MemTreeBuilder builder = new MemTreeBuilder(); builder.startDocument(); ! DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); streamer.setContentHandler(receiver); ValueSequence seq = new ValueSequence(); *************** *** 122,126 **** MemTreeBuilder builder = new MemTreeBuilder(); builder.startDocument(); ! Receiver receiver = new Receiver(builder); streamer.setContentHandler(receiver); streamer.serialize((Node)obj, false); --- 122,126 ---- MemTreeBuilder builder = new MemTreeBuilder(); builder.startDocument(); ! DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); streamer.setContentHandler(receiver); streamer.serialize((Node)obj, false); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:04
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xupdate Modified Files: XUpdateProcessor.java Modification.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: XUpdateProcessor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/XUpdateProcessor.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** XUpdateProcessor.java 16 Jun 2004 13:36:53 -0000 1.24 --- XUpdateProcessor.java 12 Sep 2004 09:25:22 -0000 1.25 *************** *** 21,32 **** import org.exist.dom.NodeListImpl; import org.exist.dom.XMLUtil; - import org.exist.xquery.parser.XQueryLexer; - import org.exist.xquery.parser.XQueryParser; - import org.exist.xquery.parser.XQueryTreeParser; import org.exist.storage.DBBroker; import org.exist.util.FastStringBuffer; import org.exist.xquery.PathExpr; - import org.exist.xquery.XQueryContext; import org.exist.xquery.XPathException; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.Type; --- 21,32 ---- import org.exist.dom.NodeListImpl; import org.exist.dom.XMLUtil; import org.exist.storage.DBBroker; import org.exist.util.FastStringBuffer; import org.exist.xquery.PathExpr; import org.exist.xquery.XPathException; + import org.exist.xquery.XQueryContext; + import org.exist.xquery.parser.XQueryLexer; + import org.exist.xquery.parser.XQueryParser; + import org.exist.xquery.parser.XQueryTreeParser; import org.exist.xquery.value.Sequence; import org.exist.xquery.value.Type; *************** *** 34,38 **** import org.w3c.dom.Comment; import org.w3c.dom.Document; - import org.w3c.dom.DocumentFragment; import org.w3c.dom.Element; import org.w3c.dom.Node; --- 34,37 ---- *************** *** 122,129 **** SAXParser sax = saxFactory.newSAXParser(); XMLReader reader = sax.getXMLReader(); - reader.setContentHandler(this); reader.setProperty( ! "http://xml.org/sax/properties/lexical-handler", ! this); reader.parse(is); Modification mods[] = new Modification[modifications.size()]; --- 121,129 ---- SAXParser sax = saxFactory.newSAXParser(); XMLReader reader = sax.getXMLReader(); reader.setProperty( ! "http://xml.org/sax/properties/lexical-handler", ! this); ! reader.setContentHandler(this); ! reader.parse(is); Modification mods[] = new Modification[modifications.size()]; *************** *** 483,487 **** (String) entry.getValue()); } ! XQueryLexer lexer = new XQueryLexer(new StringReader(select)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 483,487 ---- (String) entry.getValue()); } ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(select)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); Index: Modification.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Modification.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Modification.java 19 Jul 2004 13:06:25 -0000 1.30 --- Modification.java 12 Sep 2004 09:25:23 -0000 1.31 *************** *** 123,127 **** (String) entry.getValue()); } ! XQueryLexer lexer = new XQueryLexer(new StringReader(selectStmt)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 123,127 ---- (String) entry.getValue()); } ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(selectStmt)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:03
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery/functions/util Modified Files: CatchFunction.java DocumentId.java EvalFunction.java LogFunction.java BuiltinFunctions.java ExclusiveLockFunction.java CollectionName.java DescribeFunction.java DocumentName.java SharedLockFunction.java MD5.java Added Files: UtilModule.java Removed Files: ModuleImpl.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: ExclusiveLockFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/ExclusiveLockFunction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExclusiveLockFunction.java 2 Jun 2004 11:33:30 -0000 1.1 --- ExclusiveLockFunction.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 34,38 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("exclusive-lock", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Puts an exclusive lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + --- 34,38 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("exclusive-lock", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Puts an exclusive lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + Index: DocumentName.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/DocumentName.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DocumentName.java 8 Jun 2004 08:16:12 -0000 1.3 --- DocumentName.java 12 Sep 2004 09:25:16 -0000 1.4 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-name", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the name of the document to which the passed node belongs.", new SequenceType[] { --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-name", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns the name of the document to which the passed node belongs.", new SequenceType[] { *************** *** 63,67 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.doc.getFileName()); } return Sequence.EMPTY_SEQUENCE; --- 63,67 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.getDocument().getFileName()); } return Sequence.EMPTY_SEQUENCE; --- ModuleImpl.java DELETED --- Index: BuiltinFunctions.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/BuiltinFunctions.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BuiltinFunctions.java 28 May 2004 10:54:21 -0000 1.2 --- BuiltinFunctions.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 49,53 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("builtin-functions", UTIL_FUNCTION_NS, "util"), "Returns a sequence containing the QNames of all built-in functions " + "currently known to the system.", --- 49,53 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("builtin-functions", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns a sequence containing the QNames of all built-in functions " + "currently known to the system.", --- NEW FILE: UtilModule.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. * * $Id: UtilModule.java,v 1.1 2004/09/12 09:25:16 wolfgang_m Exp $ */ package org.exist.xquery.functions.util; import org.exist.xquery.AbstractInternalModule; import org.exist.xquery.FunctionDef; /** * @author Wolfgang Meier (wol...@ex...) */ public class UtilModule extends AbstractInternalModule { public final static String NAMESPACE_URI = "http://exist-db.org/xquery/util"; public final static String PREFIX = "util"; public final static FunctionDef[] functions = { new FunctionDef(BuiltinFunctions.signature, BuiltinFunctions.class), new FunctionDef(DescribeFunction.signature, DescribeFunction.class), new FunctionDef(EvalFunction.signature, EvalFunction.class), new FunctionDef(MD5.signature, MD5.class), new FunctionDef(DocumentName.signature, DocumentName.class), new FunctionDef(DocumentId.signature, DocumentId.class), new FunctionDef(CollectionName.signature, CollectionName.class), new FunctionDef(LogFunction.signature, LogFunction.class), new FunctionDef(CatchFunction.signature, CatchFunction.class), new FunctionDef(ExclusiveLockFunction.signature, ExclusiveLockFunction.class), new FunctionDef(SharedLockFunction.signature, SharedLockFunction.class) }; public UtilModule() { super(functions); } /* (non-Javadoc) * @see org.exist.xquery.Module#getNamespaceURI() */ public String getNamespaceURI() { return NAMESPACE_URI; } /* (non-Javadoc) * @see org.exist.xquery.Module#getDefaultPrefix() */ public String getDefaultPrefix() { return PREFIX; } } Index: DescribeFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/DescribeFunction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DescribeFunction.java 4 Aug 2004 19:00:08 -0000 1.4 --- DescribeFunction.java 12 Sep 2004 09:25:16 -0000 1.5 *************** *** 48,52 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("describe-function", UTIL_FUNCTION_NS, "util"), "Describes a built-in function. Returns an element describing the " + "function signature.", --- 48,52 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("describe-function", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Describes a built-in function. Returns an element describing the " + "function signature.", Index: EvalFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/EvalFunction.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EvalFunction.java 28 Aug 2004 16:20:23 -0000 1.7 --- EvalFunction.java 12 Sep 2004 09:25:16 -0000 1.8 *************** *** 59,63 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("eval", UTIL_FUNCTION_NS, "util"), "Dynamically evaluates its string argument as an XPath/XQuery expression. " + "The argument expression will inherit the current execution context, i.e. all " + --- 59,63 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("eval", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Dynamically evaluates its string argument as an XPath/XQuery expression. " + "The argument expression will inherit the current execution context, i.e. all " + *************** *** 88,92 **** throws XPathException { // get the query expression ! String expr = getArgument(0).eval(contextSequence, contextItem).getStringValue(); if ("".equals(expr.trim())) return new EmptySequence(); --- 88,92 ---- throws XPathException { // get the query expression ! String expr = StringValue.expand(getArgument(0).eval(contextSequence, contextItem).getStringValue()); if ("".equals(expr.trim())) return new EmptySequence(); *************** *** 100,104 **** } LOG.debug("eval: " + expr); ! XQueryLexer lexer = new XQueryLexer(new StringReader(expr)); XQueryParser parser = new XQueryParser(lexer); // shares the context of the outer expression --- 100,104 ---- } LOG.debug("eval: " + expr); ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(expr)); XQueryParser parser = new XQueryParser(lexer); // shares the context of the outer expression Index: CollectionName.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/CollectionName.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CollectionName.java 16 Feb 2004 15:59:37 -0000 1.2 --- CollectionName.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("collection-name", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the name of the collection to which the passed node belongs.", new SequenceType[] { --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("collection-name", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns the name of the collection to which the passed node belongs.", new SequenceType[] { *************** *** 63,67 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.doc.getCollection().getName()); } return Sequence.EMPTY_SEQUENCE; --- 63,67 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.getDocument().getCollection().getName()); } return Sequence.EMPTY_SEQUENCE; Index: CatchFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/CatchFunction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CatchFunction.java 17 May 2004 11:28:47 -0000 1.2 --- CatchFunction.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("catch", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "This function corresponds to a try-catch statement in Java. The code block " + "in $b will be put inside a try-catch statement. If an exception is thrown while executing " + --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("catch", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "This function corresponds to a try-catch statement in Java. The code block " + "in $b will be put inside a try-catch statement. If an exception is thrown while executing " + *************** *** 86,92 **** if(exClass.getName().equals(e.getClass().getName()) || exClass.isInstance(e)) { LOG.debug("Calling exception handler to process " + e.getClass().getName()); ! ModuleImpl myModule = ! (ModuleImpl) context.getModule(ModuleImpl.NAMESPACE_URI); ! QName exQname = new QName("exception", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX); myModule.declareVariable(exQname, new StringValue(e.getClass().getName())); return getArgument(2).eval(contextSequence, contextItem); --- 86,92 ---- if(exClass.getName().equals(e.getClass().getName()) || exClass.isInstance(e)) { LOG.debug("Calling exception handler to process " + e.getClass().getName()); ! UtilModule myModule = ! (UtilModule) context.getModule(UtilModule.NAMESPACE_URI); ! QName exQname = new QName("exception", UtilModule.NAMESPACE_URI, UtilModule.PREFIX); myModule.declareVariable(exQname, new StringValue(e.getClass().getName())); return getArgument(2).eval(contextSequence, contextItem); Index: DocumentId.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/DocumentId.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DocumentId.java 17 Feb 2004 15:04:58 -0000 1.1 --- DocumentId.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 31,35 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-id", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the internal id of the document to which the passed node belongs.", new SequenceType[] { --- 31,35 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-id", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns the internal id of the document to which the passed node belongs.", new SequenceType[] { *************** *** 50,55 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! String path = proxy.doc.getFileName(); ! return new IntegerValue(proxy.doc.getDocId(), Type.INT); } return Sequence.EMPTY_SEQUENCE; --- 50,55 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! String path = proxy.getDocument().getFileName(); ! return new IntegerValue(proxy.getDocument().getDocId(), Type.INT); } return Sequence.EMPTY_SEQUENCE; Index: SharedLockFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/SharedLockFunction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SharedLockFunction.java 2 Jun 2004 11:33:30 -0000 1.1 --- SharedLockFunction.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 35,39 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("shared-lock", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Puts a shared lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + --- 35,39 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("shared-lock", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Puts a shared lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + Index: LogFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/LogFunction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LogFunction.java 18 Feb 2004 11:14:34 -0000 1.1 --- LogFunction.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 42,46 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("log", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Logs the message specified in $b to the current logger. $a indicates " + "the log priority, e.g. 'debug' or 'warn'.", --- 42,46 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("log", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Logs the message specified in $b to the current logger. $a indicates " + "the log priority, e.g. 'debug' or 'warn'.", Index: MD5.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/MD5.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MD5.java 28 May 2004 10:54:21 -0000 1.2 --- MD5.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("md5", UTIL_FUNCTION_NS, "util"), "Generates an MD5 key from a string.", new SequenceType[] { --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("md5", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Generates an MD5 key from a string.", new SequenceType[] { |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:03
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/memtree In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/memtree Modified Files: NodeImpl.java DocumentImpl.java Added Files: DocumentBuilderReceiver.java Removed Files: Receiver.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: NodeImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/NodeImpl.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** NodeImpl.java 1 Sep 2004 17:41:30 -0000 1.19 --- NodeImpl.java 12 Sep 2004 09:25:19 -0000 1.20 *************** *** 31,34 **** --- 31,35 ---- import org.exist.util.serializer.DOMStreamer; import org.exist.util.serializer.DOMStreamerPool; + import org.exist.util.serializer.Receiver; import org.exist.xquery.Cardinality; import org.exist.xquery.XPathException; *************** *** 541,549 **** } ! public void copyTo(DBBroker broker, Receiver receiver) throws SAXException { ! // toSAX(broker, receiver); document.copyTo(this, receiver); } /* (non-Javadoc) * @see org.exist.xquery.value.Item#conversionPreference(java.lang.Class) --- 542,553 ---- } ! public void copyTo(DBBroker broker, DocumentBuilderReceiver receiver) throws SAXException { document.copyTo(this, receiver); } + public void streamTo(Serializer serializer, Receiver receiver) throws SAXException { + document.streamTo(serializer, this, receiver); + } + /* (non-Javadoc) * @see org.exist.xquery.value.Item#conversionPreference(java.lang.Class) *************** *** 599,601 **** --- 603,620 ---- public void setSelfAsContext() { } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#isCached() + */ + public boolean isCached() { + // always return false + return false; + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#setIsCached(boolean) + */ + public void setIsCached(boolean cached) { + // ignore + } } --- NEW FILE: DocumentBuilderReceiver.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. * * $Id: DocumentBuilderReceiver.java,v 1.1 2004/09/12 09:25:19 wolfgang_m Exp $ */ package org.exist.memtree; import org.exist.dom.NodeProxy; import org.exist.dom.QName; import org.exist.util.serializer.AttrList; import org.exist.util.serializer.Receiver; import org.exist.xquery.XQueryContext; import org.w3c.dom.Document; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; /** * Builds an in-memory DOM tree from SAX {@link org.exist.util.serializer.Receiver} * events. * * @author Wolfgang <wol...@ex...> */ public class DocumentBuilderReceiver implements ContentHandler, LexicalHandler, Receiver { private MemTreeBuilder builder = null; public DocumentBuilderReceiver() { super(); } public DocumentBuilderReceiver(MemTreeBuilder builder) { super(); this.builder = builder; } public Document getDocument() { return builder.getDocument(); } public XQueryContext getContext() { return builder.getContext(); } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator) */ public void setDocumentLocator(Locator arg0) { } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#startDocument() */ public void startDocument() throws SAXException { if(builder == null) { builder = new MemTreeBuilder(); builder.startDocument(); } } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#endDocument() */ public void endDocument() throws SAXException { builder.endDocument(); } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String) */ public void startPrefixMapping(String arg0, String arg1) throws SAXException { } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String) */ public void endPrefixMapping(String arg0) throws SAXException { } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ public void startElement( String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException { builder.startElement(namespaceURI, localName, qName, attrs); } public void startElement(QName qname, AttrList attribs) { builder.startElement(qname, null); if(attribs != null) { for(int i = 0; i < attribs.getLength(); i++) { builder.addAttribute(attribs.getQName(i), attribs.getValue(i)); } } } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ public void endElement(String arg0, String arg1, String arg2) throws SAXException { builder.endElement(); } public void endElement(QName qname) throws SAXException { builder.endElement(); } public void addReferenceNode(NodeProxy proxy) throws SAXException { builder.addReferenceNode(proxy); } public void addNamespaceNode(QName qname) throws SAXException { builder.namespaceNode(qname); } public void characters(CharSequence seq) throws SAXException { builder.characters(seq); } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ public void characters(char[] ch, int start, int len) throws SAXException { builder.characters(ch, start, len); } public void attribute(QName qname, String value) throws SAXException { builder.addAttribute(qname, value); } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int) */ public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException { } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String) */ public void processingInstruction(String target, String data) throws SAXException { builder.processingInstruction(target, data); } /* (non-Javadoc) * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String) */ public void skippedEntity(String arg0) throws SAXException { } /* (non-Javadoc) * @see org.xml.sax.ext.LexicalHandler#endCDATA() */ public void endCDATA() throws SAXException { // TODO ignored } /* (non-Javadoc) * @see org.xml.sax.ext.LexicalHandler#endDTD() */ public void endDTD() throws SAXException { } /* (non-Javadoc) * @see org.xml.sax.ext.LexicalHandler#startCDATA() */ public void startCDATA() throws SAXException { // TODO Ignored } /* (non-Javadoc) * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int) */ public void comment(char[] ch, int start, int length) throws SAXException { builder.comment(ch, start, length); } /* (non-Javadoc) * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String) */ public void endEntity(String name) throws SAXException { } /* (non-Javadoc) * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String) */ public void startEntity(String name) throws SAXException { } /* (non-Javadoc) * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String) */ public void startDTD(String name, String publicId, String systemId) throws SAXException { } } Index: DocumentImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/DocumentImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DocumentImpl.java 7 Aug 2004 16:28:02 -0000 1.12 --- DocumentImpl.java 12 Sep 2004 09:25:19 -0000 1.13 *************** *** 25,29 **** --- 25,32 ---- import org.exist.dom.NodeProxy; import org.exist.dom.QName; + import org.exist.storage.serializers.Serializer; import org.exist.util.hashtable.NamePool; + import org.exist.util.serializer.AttrList; + import org.exist.util.serializer.Receiver; import org.exist.xquery.XQueryContext; import org.w3c.dom.Attr; *************** *** 103,107 **** protected int nextRef = 0; ! private final static int NODE_SIZE = 128; private final static int ATTR_SIZE = 64; --- 106,110 ---- protected int nextRef = 0; ! private final static int NODE_SIZE = 128; private final static int ATTR_SIZE = 64; *************** *** 547,557 **** * @param receiver */ ! public void copyTo(NodeImpl node, Receiver receiver) throws SAXException { NodeImpl top = node; while (node != null) { ! startNode(node, receiver); NodeImpl nextNode = (NodeImpl) node.getFirstChild(); while (nextNode == null) { ! endNode(node, receiver); if (top != null && top.nodeNumber == node.nodeNumber) break; nextNode = (NodeImpl) node.getNextSibling(); --- 550,560 ---- * @param receiver */ ! public void copyTo(NodeImpl node, DocumentBuilderReceiver receiver) throws SAXException { NodeImpl top = node; while (node != null) { ! copyStartNode(node, receiver); NodeImpl nextNode = (NodeImpl) node.getFirstChild(); while (nextNode == null) { ! copyEndNode(node, receiver); if (top != null && top.nodeNumber == node.nodeNumber) break; nextNode = (NodeImpl) node.getNextSibling(); *************** *** 559,563 **** node = (NodeImpl) node.getParentNode(); if (node == null || (top != null && top.nodeNumber == node.nodeNumber)) { ! endNode(node, receiver); nextNode = null; break; --- 562,566 ---- node = (NodeImpl) node.getParentNode(); if (node == null || (top != null && top.nodeNumber == node.nodeNumber)) { ! copyEndNode(node, receiver); nextNode = null; break; *************** *** 569,573 **** } ! private void startNode(NodeImpl node, Receiver receiver) throws SAXException { int nr = node.nodeNumber; --- 572,576 ---- } ! private void copyStartNode(NodeImpl node, DocumentBuilderReceiver receiver) throws SAXException { int nr = node.nodeNumber; *************** *** 576,580 **** QName nodeName = (QName) document.namePool .get(document.nodeName[nr]); ! receiver.startElement(nodeName); int attr = document.alpha[nr]; if (-1 < attr) { --- 579,583 ---- QName nodeName = (QName) document.namePool .get(document.nodeName[nr]); ! receiver.startElement(nodeName, null); int attr = document.alpha[nr]; if (-1 < attr) { *************** *** 626,632 **** } ! private void endNode(NodeImpl node, Receiver receiver) throws SAXException { if(node.getNodeType() == Node.ELEMENT_NODE) receiver.endElement(node.getQName()); } } \ No newline at end of file --- 629,707 ---- } ! private void copyEndNode(NodeImpl node, DocumentBuilderReceiver receiver) throws SAXException { if(node.getNodeType() == Node.ELEMENT_NODE) receiver.endElement(node.getQName()); } + + public void streamTo(Serializer serializer, NodeImpl node, Receiver receiver) throws SAXException { + NodeImpl top = node; + while (node != null) { + startNode(serializer, node, receiver); + NodeImpl nextNode = (NodeImpl) node.getFirstChild(); + while (nextNode == null) { + endNode(node, receiver); + if (top != null && top.nodeNumber == node.nodeNumber) break; + nextNode = (NodeImpl) node.getNextSibling(); + if (nextNode == null) { + node = (NodeImpl) node.getParentNode(); + if (node == null || (top != null && top.nodeNumber == node.nodeNumber)) { + endNode(node, receiver); + nextNode = null; + break; + } + } + } + node = nextNode; + } + } + + private void startNode(Serializer serializer, NodeImpl node, Receiver receiver) + throws SAXException { + int nr = node.nodeNumber; + switch (node.getNodeType()) { + case Node.ELEMENT_NODE: + QName nodeName = (QName) document.namePool + .get(document.nodeName[nr]); + AttrList attribs = null; + int attr = document.alpha[nr]; + if (-1 < attr) { + attribs = new AttrList(); + while (attr < document.nextAttr + && document.attrParent[attr] == nr) { + QName attrQName = (QName) document.namePool + .get(document.attrName[attr]); + attribs.addAttribute(attrQName, attrValue[attr]); + ++attr; + } + } + receiver.startElement(nodeName, attribs); + break; + case Node.TEXT_NODE: + receiver.characters(new String(document.characters, document.alpha[nr], + document.alphaLen[nr])); + break; + case Node.ATTRIBUTE_NODE: + QName attrQName = (QName) document.namePool.get(document.attrName[nr]); + receiver.attribute(attrQName, attrValue[nr]); + break; + case Node.COMMENT_NODE: + receiver.comment(document.characters, document.alpha[nr], + document.alphaLen[nr]); + break; + case Node.PROCESSING_INSTRUCTION_NODE: + QName qn = (QName) document.namePool.get(document.nodeName[nr]); + String data = new String(document.characters, + document.alpha[nr], document.alphaLen[nr]); + receiver.processingInstruction(qn.getLocalName(), data); + break; + case NodeImpl.REFERENCE_NODE: + serializer.toReceiver(document.references[document.alpha[nr]]); + break; + } + } + + private void endNode(NodeImpl node, Receiver receiver) throws SAXException { + if(node.getNodeType() == Node.ELEMENT_NODE) + receiver.endElement(node.getQName()); + } } \ No newline at end of file --- Receiver.java DELETED --- |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:02
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/util/serializer Modified Files: SAXSerializer.java XMLIndenter.java DOMSerializer.java XMLWriter.java Added Files: AttrList.java Receiver.java ReceiverToSAX.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. --- NEW FILE: ReceiverToSAX.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * 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: ReceiverToSAX.java,v 1.1 2004/09/12 09:25:16 wolfgang_m Exp $ */ package org.exist.util.serializer; import org.exist.dom.QName; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.AttributesImpl; /** * A wrapper class that forwards the method calls defined in the * {@link org.exist.util.serializer.Receiver} interface to a * SAX content handler and lexical handler. * * @author wolf */ public class ReceiverToSAX implements Receiver { private ContentHandler contentHandler; private LexicalHandler lexicalHandler = null; /** * */ public ReceiverToSAX(ContentHandler handler) { super(); this.contentHandler = handler; } public void setLexicalHandler(LexicalHandler handler) { this.lexicalHandler = handler; } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#startDocument() */ public void startDocument() throws SAXException { contentHandler.startDocument(); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#endDocument() */ public void endDocument() throws SAXException { contentHandler.endDocument(); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#startPrefixMapping(java.lang.String, java.lang.String) */ public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException { contentHandler.startPrefixMapping(prefix, namespaceURI); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#endPrefixMapping(java.lang.String) */ public void endPrefixMapping(String prefix) throws SAXException { contentHandler.endPrefixMapping(prefix); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#startElement(org.exist.dom.QName, org.exist.util.serializer.AttrList) */ public void startElement(QName qname, AttrList attribs) throws SAXException { AttributesImpl a = new AttributesImpl(); if(attribs != null) { QName attrQName; for(int i = 0; i < attribs.getLength(); i++) { attrQName = attribs.getQName(i); a.addAttribute(attrQName.getNamespaceURI(), attrQName.getLocalName(), attrQName.toString(), "CDATA", attribs.getValue(i)); } } contentHandler.startElement(qname.getNamespaceURI(), qname.getLocalName(), qname.toString(), a); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#endElement(org.exist.dom.QName) */ public void endElement(QName qname) throws SAXException { contentHandler.endElement(qname.getNamespaceURI(), qname.getLocalName(), qname.toString()); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#characters(java.lang.CharSequence) */ public void characters(CharSequence seq) throws SAXException { contentHandler.characters(seq.toString().toCharArray(), 0, seq.length()); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#attribute(org.exist.dom.QName, java.lang.String) */ public void attribute(QName qname, String value) throws SAXException { } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#comment(char[], int, int) */ public void comment(char[] ch, int start, int length) throws SAXException { if(lexicalHandler != null) lexicalHandler.comment(ch, start, length); } /* (non-Javadoc) * @see org.exist.util.serializer.Receiver#processingInstruction(java.lang.String, java.lang.String) */ public void processingInstruction(String target, String data) throws SAXException { contentHandler.processingInstruction(target, data); } } --- NEW FILE: AttrList.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * 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: AttrList.java,v 1.1 2004/09/12 09:25:16 wolfgang_m Exp $ */ package org.exist.util.serializer; import org.exist.dom.QName; /** * Represents a list of attributes. Each attribute is defined by * a {@link org.exist.dom.QName} and a value. Instances * of this class can be passed to * {@link org.exist.util.serializer.Receiver#startElement(QName, AttrList)}. * * @author wolf */ public class AttrList { protected QName names[] = new QName[4]; protected String values[] = new String[4]; protected int size = 0; /** * */ public AttrList() { super(); } public void addAttribute(QName name, String value) { ensureCapacity(); names[size] = name; values[size] = value; size++; } public int getLength() { return size; } public QName getQName(int pos) { return names[pos]; } public String getValue(int pos) { return values[pos]; } public String getValue(QName name) { for(int i = 0; i < size; i++) { if(names[i].equals(name)) return values[i]; } return null; } private void ensureCapacity() { if(size == names.length) { // resize final int newSize = names.length * 3 / 2; QName tnames[] = new QName[newSize]; System.arraycopy(names, 0, tnames, 0, names.length); String tvalues[] = new String[newSize]; System.arraycopy(values, 0, tvalues, 0, values.length); names = tnames; values = tvalues; } } } Index: XMLWriter.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer/XMLWriter.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** XMLWriter.java 12 Aug 2004 15:48:42 -0000 1.9 --- XMLWriter.java 12 Sep 2004 09:25:16 -0000 1.10 *************** *** 24,32 **** import java.util.Arrays; import java.util.Properties; - import java.util.Stack; import javax.xml.transform.OutputKeys; import javax.xml.transform.TransformerException; import org.exist.util.XMLString; import org.exist.util.serializer.encodings.CharacterSet; --- 24,32 ---- import java.util.Arrays; import java.util.Properties; import javax.xml.transform.OutputKeys; import javax.xml.transform.TransformerException; + import org.exist.dom.QName; import org.exist.util.XMLString; import org.exist.util.serializer.encodings.CharacterSet; *************** *** 47,51 **** protected Writer writer = null; protected CharacterSet charSet = null; - protected Stack elementStack = new Stack(); protected boolean tagIsOpen = false; protected boolean tagIsEmpty = true; --- 47,50 ---- *************** *** 112,116 **** tagIsEmpty = true; declarationWritten = false; - elementStack.clear(); } --- 111,114 ---- *************** *** 119,123 **** tagIsEmpty = true; declarationWritten = false; - elementStack.clear(); } --- 117,120 ---- *************** *** 134,138 **** writer.write(qname); tagIsOpen = true; - elementStack.push(qname); } catch (IOException e) { throw new TransformerException(e.getMessage(), e); --- 131,134 ---- *************** *** 140,146 **** } ! public void endElement() throws TransformerException { try { - String qname = (String) elementStack.pop(); if (tagIsOpen) closeStartTag(true); --- 136,159 ---- } ! public void startElement(QName qname) throws TransformerException { ! if (!declarationWritten) ! writeDeclaration(); ! try { ! if (tagIsOpen) ! closeStartTag(false); ! writer.write('<'); ! if(qname.getPrefix() != null && qname.getPrefix().length() > 0) { ! writer.write(qname.getPrefix()); ! writer.write(':'); ! } ! writer.write(qname.getLocalName()); ! tagIsOpen = true; ! } catch (IOException e) { ! throw new TransformerException(e.getMessage(), e); ! } ! } ! ! public void endElement(String qname) throws TransformerException { try { if (tagIsOpen) closeStartTag(true); *************** *** 155,158 **** --- 168,189 ---- } + public void endElement(QName qname) throws TransformerException { + try { + if (tagIsOpen) + closeStartTag(true); + else { + writer.write("</"); + if(qname.getPrefix() != null && qname.getPrefix().length() > 0) { + writer.write(qname.getPrefix()); + writer.write(':'); + } + writer.write(qname.getLocalName()); + writer.write('>'); + } + } catch (IOException e) { + throw new TransformerException(e.getMessage(), e); + } + } + public void namespace(String prefix, String nsURI) throws TransformerException { *************** *** 180,185 **** throws TransformerException { try { ! if (!tagIsOpen) ! throw new TransformerException("Found an attribute outside an element"); writer.write(' '); writer.write(qname); --- 211,219 ---- throws TransformerException { try { ! if (!tagIsOpen) { ! characters(value); ! return; ! // throw new TransformerException("Found an attribute outside an element"); ! } writer.write(' '); writer.write(qname); *************** *** 192,195 **** --- 226,250 ---- } + public void attribute(QName qname, String value) throws TransformerException { + try { + if (!tagIsOpen) { + characters(value); + return; + // throw new TransformerException("Found an attribute outside an element"); + } + writer.write(' '); + if(qname.getPrefix() != null && qname.getPrefix().length() > 0) { + writer.write(qname.getPrefix()); + writer.write(':'); + } + writer.write(qname.getLocalName()); + writer.write("=\""); + writeChars(value, true); + writer.write('"'); + } catch (IOException e) { + throw new TransformerException(e.getMessage(), e); + } + } + public void characters(CharSequence chars) throws TransformerException { if (!declarationWritten) *************** *** 311,315 **** i++; } ! writer.write(s.subSequence(pos, i).toString()); if(i >= len) return; --- 366,371 ---- i++; } ! writeCharSeq(s, pos, i); ! // writer.write(s.subSequence(pos, i).toString()); if(i >= len) return; *************** *** 343,346 **** --- 399,408 ---- } + private void writeCharSeq(CharSequence ch, int start, int end) throws IOException { + for(int i = start; i < end; i++) { + writer.write(ch.charAt(i)); + } + } + protected void writeCharacterReference(char charval) throws IOException { int o = 0; --- NEW FILE: Receiver.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * 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: Receiver.java,v 1.1 2004/09/12 09:25:16 wolfgang_m Exp $ */ package org.exist.util.serializer; import org.exist.dom.QName; import org.xml.sax.SAXException; /** * A receiver is similar to the SAX content handler and lexical handler interfaces, but * uses some higher level types as arguments. For example, element names are internally * stored as QName objects, so startElement and endElement expect a QName. This way, * we avoid copying objects. * * @author wolf */ public interface Receiver { public abstract void startDocument() throws SAXException; public abstract void endDocument() throws SAXException; public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException; public void endPrefixMapping(String prefix) throws SAXException; public abstract void startElement(QName qname, AttrList attribs) throws SAXException; public abstract void endElement(QName qname) throws SAXException; public abstract void characters(CharSequence seq) throws SAXException; public abstract void attribute(QName qname, String value) throws SAXException; public abstract void comment(char[] ch, int start, int length) throws SAXException; public void processingInstruction(String target, String data) throws SAXException; } Index: SAXSerializer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer/SAXSerializer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SAXSerializer.java 3 May 2004 13:08:45 -0000 1.7 --- SAXSerializer.java 12 Sep 2004 09:25:15 -0000 1.8 *************** *** 29,32 **** --- 29,33 ---- import javax.xml.transform.TransformerException; + import org.exist.dom.QName; import org.exist.util.XMLString; import org.xml.sax.Attributes; *************** *** 37,41 **** import org.xml.sax.helpers.NamespaceSupport; ! public class SAXSerializer implements ContentHandler, LexicalHandler { private final static Properties defaultProperties = new Properties(); --- 38,42 ---- import org.xml.sax.helpers.NamespaceSupport; ! public class SAXSerializer implements ContentHandler, LexicalHandler, Receiver { private final static Properties defaultProperties = new Properties(); *************** *** 215,218 **** --- 216,304 ---- /* (non-Javadoc) + * @see org.exist.util.serializer.Receiver#startElement(org.exist.dom.QName) + */ + public void startElement(QName qname, AttrList attribs) throws SAXException { + try { + namespaceDecls.clear(); + nsSupport.pushContext(); + receiver.startElement(qname); + String prefix = qname.getPrefix(); + String namespaceURI = qname.getNamespaceURI(); + if(prefix == null) + prefix = ""; + if (namespaceURI == null) + namespaceURI = ""; + if (nsSupport.getURI(prefix) == null) { + namespaceDecls.put(prefix, namespaceURI); + nsSupport.declarePrefix(prefix, namespaceURI); + } + // check attributes for required namespace declarations + QName attrQName; + String uri; + if(attribs != null) { + for (int i = 0; i < attribs.getLength(); i++) { + attrQName = attribs.getQName(i); + if (attrQName.getLocalName().equals("xmlns")) { + if (nsSupport.getURI("") == null) { + uri = attribs.getValue(i); + namespaceDecls.put("", uri); + nsSupport.declarePrefix("", uri); + } + } else if (attrQName.getPrefix() != null && attrQName.getPrefix().length() > 0) { + prefix = attrQName.getPrefix(); + if(prefix.equals("xmlns:")) { + if (nsSupport.getURI(prefix) == null) { + uri = attribs.getValue(i); + prefix = attrQName.getLocalName(); + namespaceDecls.put(prefix, uri); + nsSupport.declarePrefix(prefix, uri); + } + } else { + if (nsSupport.getURI(prefix) == null) { + uri = attrQName.getNamespaceURI(); + namespaceDecls.put(prefix, uri); + nsSupport.declarePrefix(prefix, uri); + } + } + } + } + } + Map.Entry nsEntry; + for (Iterator i = optionalNamespaceDecls.entrySet().iterator(); + i.hasNext(); + ) { + nsEntry = (Map.Entry) i.next(); + prefix = (String) nsEntry.getKey(); + uri = (String) nsEntry.getValue(); + receiver.namespace(prefix, uri); + nsSupport.declarePrefix(prefix, uri); + } + // output all namespace declarations + for (Iterator i = namespaceDecls.entrySet().iterator(); + i.hasNext(); + ) { + nsEntry = (Map.Entry) i.next(); + prefix = (String) nsEntry.getKey(); + uri = (String) nsEntry.getValue(); + if(!optionalNamespaceDecls.containsKey(prefix)) { + receiver.namespace(prefix, uri); + } + } + optionalNamespaceDecls.clear(); + if(attribs != null) { + // output attributes + for (int i = 0; i < attribs.getLength(); i++) { + if (!attribs.getQName(i).getLocalName().startsWith("xmlns")) + receiver.attribute( + attribs.getQName(i), + attribs.getValue(i)); + } + } + } catch (TransformerException e) { + throw new SAXException(e.getMessage(), e); + } + } + + /* (non-Javadoc) * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ *************** *** 221,225 **** try { nsSupport.popContext(); ! receiver.endElement(); } catch (TransformerException e) { throw new SAXException(e.getMessage(), e); --- 307,311 ---- try { nsSupport.popContext(); ! receiver.endElement(qname); } catch (TransformerException e) { throw new SAXException(e.getMessage(), e); *************** *** 228,231 **** --- 314,344 ---- /* (non-Javadoc) + * @see org.exist.util.serializer.Receiver#endElement(org.exist.dom.QName) + */ + public void endElement(QName qname) throws SAXException { + try { + nsSupport.popContext(); + receiver.endElement(qname); + } catch (TransformerException e) { + throw new SAXException(e.getMessage(), e); + } + } + + /* (non-Javadoc) + * @see org.exist.util.serializer.Receiver#attribute(org.exist.dom.QName, java.lang.String) + */ + public void attribute(QName qname, String value) throws SAXException { + // ignore namespace declaration attributes + if((qname.getPrefix() != null && qname.getPrefix().equals("xmlns")) || + qname.getLocalName().equals("xmlns")) + return; + try { + receiver.attribute(qname, value); + } catch (TransformerException e) { + throw new SAXException(e.getMessage(), e); + } + } + + /* (non-Javadoc) * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ Index: XMLIndenter.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer/XMLIndenter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** XMLIndenter.java 6 Feb 2004 10:00:58 -0000 1.5 --- XMLIndenter.java 12 Sep 2004 09:25:16 -0000 1.6 *************** *** 26,29 **** --- 26,30 ---- import javax.xml.transform.TransformerException; + import org.exist.dom.QName; import org.exist.storage.serializers.EXistOutputKeys; *************** *** 71,80 **** /* (non-Javadoc) * @see org.exist.util.serializer.XMLWriter#endElement() */ ! public void endElement() throws TransformerException { level--; if (afterTag && !sameline) indent(); ! super.endElement(); sameline = false; afterTag = true; --- 72,104 ---- /* (non-Javadoc) + * @see org.exist.util.serializer.XMLWriter#startElement(org.exist.dom.QName) + */ + public void startElement(QName qname) throws TransformerException { + if(afterTag) + indent(); + super.startElement(qname); + level++; + afterTag = true; + sameline = true; + } + + /* (non-Javadoc) * @see org.exist.util.serializer.XMLWriter#endElement() */ ! public void endElement(String qname) throws TransformerException { level--; if (afterTag && !sameline) indent(); ! super.endElement(qname); ! sameline = false; ! afterTag = true; ! } ! ! /* (non-Javadoc) ! * @see org.exist.util.serializer.XMLWriter#endElement(org.exist.dom.QName) ! */ ! public void endElement(QName qname) throws TransformerException { ! level--; ! if (afterTag && !sameline) indent(); ! super.endElement(qname); sameline = false; afterTag = true; Index: DOMSerializer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/serializer/DOMSerializer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DOMSerializer.java 21 Feb 2004 18:24:57 -0000 1.6 --- DOMSerializer.java 12 Sep 2004 09:25:16 -0000 1.7 *************** *** 187,191 **** if (node.getNodeType() == Node.ELEMENT_NODE) { nsSupport.popContext(); ! receiver.endElement(); } } --- 187,191 ---- if (node.getNodeType() == Node.ELEMENT_NODE) { nsSupport.popContext(); ! receiver.endElement(node.getNodeName()); } } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:02
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/storage Modified Files: NativeBroker.java NativeTextEngine.java NativeElementIndex.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** NativeBroker.java 16 Aug 2004 19:47:11 -0000 1.100 --- NativeBroker.java 12 Sep 2004 09:25:20 -0000 1.101 *************** *** 1647,1661 **** public Node objectWith(final NodeProxy p) { if (p.getInternalAddress() < 0) ! return objectWith(p.doc, p.gid); return (Node) new DOMTransaction(this, domDb) { public Object start() { Value val = domDb.get(p.getInternalAddress()); if (val == null) { ! LOG.debug("Node " + p.gid + " not found in document " + p.doc.getName() + ! "; docId = " + p.doc.getDocId()); // LOG.debug(domDb.debugPages(p.doc)); Thread.dumpStack(); // return null; ! return objectWith(p.doc, p.gid); // retry? } NodeImpl node = --- 1647,1661 ---- public Node objectWith(final NodeProxy p) { if (p.getInternalAddress() < 0) ! return objectWith(p.getDocument(), p.gid); return (Node) new DOMTransaction(this, domDb) { public Object start() { Value val = domDb.get(p.getInternalAddress()); if (val == null) { ! LOG.debug("Node " + p.gid + " not found in document " + p.getDocument().getName() + ! "; docId = " + p.getDocument().getDocId()); // LOG.debug(domDb.debugPages(p.doc)); Thread.dumpStack(); // return null; ! return objectWith(p.getDocument(), p.gid); // retry? } NodeImpl node = *************** *** 1664,1670 **** 0, val.getLength(), ! (DocumentImpl) p.doc); node.setGID(p.gid); ! node.setOwnerDocument(p.doc); node.setInternalAddress(p.getInternalAddress()); return node; --- 1664,1670 ---- 0, val.getLength(), ! (DocumentImpl) p.getDocument()); node.setGID(p.gid); ! node.setOwnerDocument(p.getDocument()); node.setInternalAddress(p.getInternalAddress()); return node; Index: NativeElementIndex.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeElementIndex.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** NativeElementIndex.java 3 Sep 2004 09:18:04 -0000 1.36 --- NativeElementIndex.java 12 Sep 2004 09:25:20 -0000 1.37 *************** *** 160,163 **** --- 160,165 ---- gid = 0; for (int k = 0; k < len; k++) { + // if(result.getLength() > 1000) + // continue; gid = gid + is.readLong(); if(selector == null) Index: NativeTextEngine.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeTextEngine.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** NativeTextEngine.java 15 Aug 2004 20:29:09 -0000 1.69 --- NativeTextEngine.java 12 Sep 2004 09:25:20 -0000 1.70 *************** *** 59,63 **** import org.exist.dom.NodeSet; import org.exist.dom.TextImpl; - import org.exist.dom.TextSearchResult; import org.exist.dom.XMLUtil; import org.exist.security.Permission; --- 59,62 ---- *************** *** 427,435 **** TermMatcher matcher, CharSequence startTerm) throws TerminatedException { // long start = System.currentTimeMillis(); ! NodeSet result; ! if (contextSet == null) ! result = new TextSearchResult(trackMatches != Serializer.TAG_NONE); ! else ! result = new ExtArrayNodeSet(); Value ref; Collection collection; --- 426,430 ---- TermMatcher matcher, CharSequence startTerm) throws TerminatedException { // long start = System.currentTimeMillis(); ! NodeSet result = new ExtArrayNodeSet(); Value ref; Collection collection; *************** *** 1224,1233 **** freq = is.readInt(); last = gid; if (contextSet != null) { - proxy = (section == TEXT_SECTION - ? new NodeProxy(doc, gid, - Node.TEXT_NODE) - : new NodeProxy(doc, gid, - Node.ATTRIBUTE_NODE)); parent = contextSet.parentWithChild(proxy, false, true, -1); --- 1219,1228 ---- freq = is.readInt(); last = gid; + proxy = (section == TEXT_SECTION + ? new NodeProxy(doc, gid, + Node.TEXT_NODE) + : new NodeProxy(doc, gid, + Node.ATTRIBUTE_NODE)); if (contextSet != null) { parent = contextSet.parentWithChild(proxy, false, true, -1); *************** *** 1240,1244 **** } } else ! ((TextSearchResult) result).add(doc, gid, word); } } --- 1235,1239 ---- } } else ! result.add(proxy, sizeHint); } } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:02
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery/value Modified Files: OrderedValueSequence.java NodeValue.java Sequence.java AbstractSequence.java BooleanValue.java AtomicValue.java Item.java Added Files: PreorderedValueSequence.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: Item.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/Item.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Item.java 28 May 2004 10:54:10 -0000 1.2 --- Item.java 12 Sep 2004 09:25:15 -0000 1.3 *************** *** 21,25 **** package org.exist.xquery.value; ! import org.exist.memtree.Receiver; import org.exist.storage.DBBroker; import org.exist.xquery.XPathException; --- 21,25 ---- package org.exist.xquery.value; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.storage.DBBroker; import org.exist.xquery.XPathException; *************** *** 74,78 **** public void toSAX(DBBroker broker, ContentHandler handler) throws SAXException; ! public void copyTo(DBBroker broker, Receiver receiver) throws SAXException; public int conversionPreference(Class javaClass); --- 74,78 ---- public void toSAX(DBBroker broker, ContentHandler handler) throws SAXException; ! public void copyTo(DBBroker broker, DocumentBuilderReceiver receiver) throws SAXException; public int conversionPreference(Class javaClass); Index: OrderedValueSequence.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/OrderedValueSequence.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OrderedValueSequence.java 28 May 2004 10:54:10 -0000 1.2 --- OrderedValueSequence.java 12 Sep 2004 09:25:15 -0000 1.3 *************** *** 29,32 **** --- 29,39 ---- /** + * A sequence that sorts its entries in the order specified by the order specs of + * an "order by" clause. Used by {@link org.exist.xquery.ForExpr}. + * + * Contrary to class {@link org.exist.xquery.value.PreorderedValueSequence}, + * all order expressions are evaluated once for each item in the sequence + * <b>while</b> items are added. + * * @author wolf */ *************** *** 37,40 **** --- 44,49 ---- private int count = 0; + private long execTime = 0; + public OrderedValueSequence(OrderSpec orderSpecs[], int size) { this.orderSpecs = orderSpecs; *************** *** 99,102 **** --- 108,112 ---- public void sort() { FastQSort.sort(items, 0, count - 1); + System.out.println("order by took " + execTime); } *************** *** 124,127 **** --- 134,138 ---- public Entry(Item item) throws XPathException { + long start = System.currentTimeMillis(); this.item = item; values = new AtomicValue[orderSpecs.length]; *************** *** 135,138 **** --- 146,150 ---- orderSpecs[i].getSortExpression().pprint() + " ; found: " + seq.getLength()); } + execTime = execTime + (System.currentTimeMillis() - start); } Index: BooleanValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/BooleanValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BooleanValue.java 28 May 2004 10:54:10 -0000 1.3 --- BooleanValue.java 12 Sep 2004 09:25:15 -0000 1.4 *************** *** 31,34 **** --- 31,45 ---- private boolean value; + /** + * Returns one of the static fields TRUE or FALSE depending on + * the value of the parameter. + * + * @param bool + * @return + */ + public final static BooleanValue valueOf(boolean bool) { + return bool ? TRUE : FALSE; + } + public BooleanValue(boolean bool) { value = bool; Index: AbstractSequence.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/AbstractSequence.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AbstractSequence.java 14 Aug 2004 09:45:46 -0000 1.7 --- AbstractSequence.java 12 Sep 2004 09:25:15 -0000 1.8 *************** *** 184,186 **** --- 184,201 ---- } } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#isCached() + */ + public boolean isCached() { + // always return false by default + return false; + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#setIsCached(boolean) + */ + public void setIsCached(boolean cached) { + // ignore by default + } } Index: Sequence.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/Sequence.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Sequence.java 2 Jun 2004 11:34:34 -0000 1.4 --- Sequence.java 12 Sep 2004 09:25:15 -0000 1.5 *************** *** 164,167 **** --- 164,183 ---- public Object toJavaObject(Class target) throws XPathException; + /** + * Returns true if the sequence is the result of a previous operation + * and has been cached. + * + * @return + */ + public boolean isCached(); + + /** + * Indicates that the sequence is the result of a previous operation + * and has not been recomputed. + * + * @param cached + */ + public void setIsCached(boolean cached); + public void setSelfAsContext(); } --- NEW FILE: PreorderedValueSequence.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) * and others (see http://exist-db.org) * * 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: PreorderedValueSequence.java,v 1.1 2004/09/12 09:25:15 wolfgang_m Exp $ */ package org.exist.xquery.value; import java.util.Arrays; import java.util.Comparator; import java.util.Iterator; import org.exist.dom.ContextItem; import org.exist.dom.NodeProxy; import org.exist.dom.NodeSet; import org.exist.xquery.Expression; import org.exist.xquery.OrderSpec; import org.exist.xquery.XPathException; /** * A sequence that sorts its items in the order specified by the order specs * of an "order by" clause. Used by {@link org.exist.xquery.ForExpr}. * * For better performance, the whole input sequence is sorted in one single step. * However, this only works if every order expression returns a result of type * node. * * @author wolf */ public class PreorderedValueSequence extends AbstractSequence { private OrderSpec orderSpecs[]; private OrderedNodeProxy[] nodes; public PreorderedValueSequence(OrderSpec specs[], Sequence input) throws XPathException { this.orderSpecs = specs; nodes = new OrderedNodeProxy[input.getLength()]; int j = 0; for(SequenceIterator i = input.unorderedIterator(); i.hasNext(); j++) { NodeProxy p = (NodeProxy)i.nextItem(); nodes[j] = new OrderedNodeProxy(p); p.addContextNode(nodes[j]); } processAll(); } private void processAll() throws XPathException { long start = System.currentTimeMillis(); for(int i = 0; i < orderSpecs.length; i++) { Expression expr = orderSpecs[i].getSortExpression(); expr.setInPredicate(true); NodeSet result = expr.eval(null).toNodeSet(); for(Iterator j = result.iterator(); j.hasNext(); ) { NodeProxy p = (NodeProxy)j.next(); ContextItem context = p.getContext(); while(context != null) { if(context.getNode() instanceof OrderedNodeProxy) { OrderedNodeProxy cp = (OrderedNodeProxy)context.getNode(); cp.values[i] = p.atomize(); System.out.println(cp.values[i]); } context = context.getNextItem(); } } } System.out.println("Sorting took " + (System.currentTimeMillis() - start)); } /* (non-Javadoc) * @see org.exist.xquery.value.AbstractSequence#getItemType() */ public int getItemType() { return Type.NODE; } /* (non-Javadoc) * @see org.exist.xquery.value.AbstractSequence#iterate() */ public SequenceIterator iterate() { sort(); return new PreorderedValueSequenceIterator(); } /* (non-Javadoc) * @see org.exist.xquery.value.AbstractSequence#unorderedIterator() */ public SequenceIterator unorderedIterator() { return new PreorderedValueSequenceIterator(); } /* (non-Javadoc) * @see org.exist.xquery.value.AbstractSequence#getLength() */ public int getLength() { return nodes.length; } /* (non-Javadoc) * @see org.exist.xquery.value.AbstractSequence#add(org.exist.xquery.value.Item) */ public void add(Item item) throws XPathException { } /* (non-Javadoc) * @see org.exist.xquery.value.AbstractSequence#itemAt(int) */ public Item itemAt(int pos) { return nodes[pos]; } /* (non-Javadoc) * @see org.exist.xquery.value.Sequence#toNodeSet() */ public NodeSet toNodeSet() throws XPathException { return null; } private void sort() { Arrays.sort(nodes, new OrderedComparator()); } private class OrderedComparator implements Comparator { /* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { final OrderedNodeProxy p1 = (OrderedNodeProxy)o1; final OrderedNodeProxy p2 = (OrderedNodeProxy)o2; int cmp = 0; AtomicValue a, b; for(int i = 0; i < p1.values.length; i++) { try { a = p1.values[i]; b = p2.values[i]; if(a == AtomicValue.EMPTY_VALUE && b != AtomicValue.EMPTY_VALUE) { if((orderSpecs[i].getModifiers() & OrderSpec.EMPTY_LEAST) != 0) cmp = -1; else cmp = 1; } else if(b == AtomicValue.EMPTY_VALUE && a != AtomicValue.EMPTY_VALUE) { if((orderSpecs[i].getModifiers() & OrderSpec.EMPTY_LEAST) != 0) cmp = 1; else cmp = -1; } else cmp = a.compareTo(b); if((orderSpecs[i].getModifiers() & OrderSpec.DESCENDING_ORDER) != 0) cmp = cmp * -1; if(cmp != 0) break; } catch (XPathException e) { } } return cmp; } } private class OrderedNodeProxy extends NodeProxy { AtomicValue[] values; public OrderedNodeProxy(NodeProxy p) { super(p); values = new AtomicValue[orderSpecs.length]; for(int i = 0; i < values.length; i++) values[i] = AtomicValue.EMPTY_VALUE; } } private class PreorderedValueSequenceIterator implements SequenceIterator { int pos = 0; /* (non-Javadoc) * @see org.exist.xquery.value.SequenceIterator#hasNext() */ public boolean hasNext() { return pos < nodes.length; } /* (non-Javadoc) * @see org.exist.xquery.value.SequenceIterator#nextItem() */ public Item nextItem() { if(pos < nodes.length) return nodes[pos++]; return null; } } } Index: NodeValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/NodeValue.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NodeValue.java 29 Jan 2004 15:06:42 -0000 1.1 --- NodeValue.java 12 Sep 2004 09:25:15 -0000 1.2 *************** *** 23,30 **** package org.exist.xquery.value; - import org.exist.storage.serializers.Serializer; import org.exist.xquery.XPathException; import org.w3c.dom.Node; - import org.xml.sax.SAXException; /** --- 23,28 ---- Index: AtomicValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/AtomicValue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AtomicValue.java 2 Jun 2004 11:34:34 -0000 1.4 --- AtomicValue.java 12 Sep 2004 09:25:15 -0000 1.5 *************** *** 23,27 **** import org.exist.dom.DocumentSet; import org.exist.dom.NodeSet; ! import org.exist.memtree.Receiver; import org.exist.storage.DBBroker; import org.exist.xquery.Cardinality; --- 23,27 ---- import org.exist.dom.DocumentSet; import org.exist.dom.NodeSet; ! import org.exist.memtree.DocumentBuilderReceiver; import org.exist.storage.DBBroker; import org.exist.xquery.Cardinality; *************** *** 127,131 **** } ! public void copyTo(DBBroker broker, Receiver receiver) throws SAXException { try { final String s = getStringValue(); --- 127,131 ---- } ! public void copyTo(DBBroker broker, DocumentBuilderReceiver receiver) throws SAXException { try { final String s = getStringValue(); *************** *** 212,215 **** --- 212,230 ---- /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#isCached() + */ + public boolean isCached() { + // always returns false by default + return false; + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#setIsCached(boolean) + */ + public void setIsCached(boolean cached) { + // ignore + } + + /* (non-Javadoc) * @see org.exist.xquery.value.Sequence#setSelfAsContext() */ |
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery/parser Modified Files: XQueryParserTokenTypes.txt XQueryParserTokenTypes.java XQueryParser.java XQueryTreeParser.java XQueryLexer.java XQuery.g Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: XQueryTreeParser.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryTreeParser.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** XQueryTreeParser.java 10 Aug 2004 20:27:17 -0000 1.19 --- XQueryTreeParser.java 12 Sep 2004 09:25:18 -0000 1.20 *************** *** 5001,5005 **** _t = _t.getNextSibling(); ! step= new LiteralValue(context, new StringValue(c.getText())); step.setASTNode(c); --- 5001,5007 ---- _t = _t.getNextSibling(); ! StringValue val = new StringValue(c.getText()); ! val.expand(); ! step= new LiteralValue(context, val); step.setASTNode(c); *************** *** 5402,5405 **** --- 5404,5410 ---- "WS", "EXPR_COMMENT", + "PRAGMA", + "PRAGMA_CONTENT", + "PRAGMA_QNAME", "PREDEFINED_ENTITY_REF", "CHAR_REF", Index: XQueryParser.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryParser.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** XQueryParser.java 10 Aug 2004 20:27:16 -0000 1.19 --- XQueryParser.java 12 Sep 2004 09:25:17 -0000 1.20 *************** *** 7036,7039 **** --- 7036,7042 ---- "WS", "EXPR_COMMENT", + "PRAGMA", + "PRAGMA_CONTENT", + "PRAGMA_QNAME", "PREDEFINED_ENTITY_REF", "CHAR_REF", *************** *** 7115,7119 **** data[0]=-16L; data[1]=-18014400656965633L; ! data[2]=70368744177663L; return data; } --- 7118,7122 ---- data[0]=-16L; data[1]=-18014400656965633L; ! data[2]=562949953421311L; return data; } Index: XQueryLexer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryLexer.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** XQueryLexer.java 10 Aug 2004 20:27:16 -0000 1.13 --- XQueryLexer.java 12 Sep 2004 09:25:18 -0000 1.14 *************** *** 59,62 **** --- 59,69 ---- protected boolean inAttributeContent= false; protected boolean inComment= false; + + protected XQueryContext context; + + public XQueryLexer(XQueryContext context, Reader in) { + this(in); + this.context = context; + } [...1416 lines suppressed...] --- 5005,5010 ---- return data; } ! public static final BitSet _tokenSet_21 = new BitSet(mk_tokenSet_21()); ! private static final long[] mk_tokenSet_22() { long[] data = new long[2756]; data[1]=576460745995190270L; *************** *** 4880,4884 **** return data; } ! public static final BitSet _tokenSet_20 = new BitSet(mk_tokenSet_20()); } --- 5080,5084 ---- return data; } ! public static final BitSet _tokenSet_22 = new BitSet(mk_tokenSet_22()); } Index: XQuery.g =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQuery.g,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** XQuery.g 18 Aug 2004 20:08:57 -0000 1.24 --- XQuery.g 12 Sep 2004 09:25:18 -0000 1.25 *************** *** 2598,2602 **** options { ! k = 3; testLiterals = false; charVocabulary = '\u0003'..'\uffff'; --- 2598,2602 ---- options { ! k = 4; testLiterals = false; charVocabulary = '\u0003'..'\uffff'; *************** *** 2615,2618 **** --- 2615,2625 ---- protected boolean inAttributeContent= false; protected boolean inComment= false; + + protected XQueryContext context; + + public XQueryLexer(XQueryContext context, Reader in) { + this(in); + this.context = context; + } } *************** *** 2709,2712 **** --- 2716,2747 ---- ; + protected PRAGMA + options { + testLiterals=false; + } + { String content = null; }: + "(::" "pragma" + WS qn:PRAGMA_QNAME WS + ( c:PRAGMA_CONTENT { content = c.getText(); } )? ':' ':' ')' + { + try { + context.addPragma(qn.getText(), content); + } catch(XPathException e) { + throw new RecognitionException(e.getMessage()); + } + } + ; + + protected PRAGMA_CONTENT + : + ( ~( ' ' | '\t' | '\n' | '\r' ) ) + ( CHAR | (':' ~( ':' )) => ':' | (':' ':' ~(')') ) => ':' ':' )+ + ; + + protected PRAGMA_QNAME + : + NCNAME ( ':' NCNAME )? + ; + protected INTEGER_LITERAL : { !(inElementContent || inAttributeContent) }? DIGITS ; *************** *** 2850,2853 **** --- 2885,2891 ---- } | + ( "(::" ) => PRAGMA + { $setType(Token.SKIP); } + | EXPR_COMMENT { $setType(Token.SKIP); } Index: XQueryParserTokenTypes.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryParserTokenTypes.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** XQueryParserTokenTypes.java 10 Aug 2004 20:27:17 -0000 1.10 --- XQueryParserTokenTypes.java 12 Sep 2004 09:25:17 -0000 1.11 *************** *** 188,199 **** int WS = 163; int EXPR_COMMENT = 164; ! int PREDEFINED_ENTITY_REF = 165; ! int CHAR_REF = 166; ! int NEXT_TOKEN = 167; ! int CHAR = 168; ! int BASECHAR = 169; ! int IDEOGRAPHIC = 170; ! int COMBINING_CHAR = 171; ! int DIGIT = 172; ! int EXTENDER = 173; } --- 188,202 ---- 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; } Index: XQueryParserTokenTypes.txt =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/parser/XQueryParserTokenTypes.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** XQueryParserTokenTypes.txt 10 Aug 2004 20:27:16 -0000 1.12 --- XQueryParserTokenTypes.txt 12 Sep 2004 09:25:17 -0000 1.13 *************** *** 162,172 **** WS=163 EXPR_COMMENT=164 ! PREDEFINED_ENTITY_REF=165 ! CHAR_REF=166 ! NEXT_TOKEN=167 ! CHAR=168 ! BASECHAR=169 ! IDEOGRAPHIC=170 ! COMBINING_CHAR=171 ! DIGIT=172 ! EXTENDER=173 --- 162,175 ---- 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 |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:00
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xmlrpc Modified Files: RpcConnection.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: RpcConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** RpcConnection.java 16 Aug 2004 19:53:47 -0000 1.68 --- RpcConnection.java 12 Sep 2004 09:25:19 -0000 1.69 *************** *** 197,201 **** } LOG.debug("compiling " + xquery); ! XQueryLexer lexer = new XQueryLexer(new StringReader(xquery)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 197,201 ---- } LOG.debug("compiling " + xquery); ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(xquery)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); *************** *** 1220,1224 **** nodes.add(node); docs = new DocumentSet(); ! docs.add(node.doc); } resultSeq = doQuery(user, broker, xpath, docs, nodes, parameters); --- 1220,1224 ---- nodes.add(node); docs = new DocumentSet(); ! docs.add(node.getDocument()); } resultSeq = doQuery(user, broker, xpath, docs, nodes, parameters); *************** *** 1245,1249 **** if (((NodeValue) next).getImplementationType() == NodeValue.PERSISTENT_NODE) { p = (NodeProxy) next; ! entry.addElement(p.doc.getCollection().getName() + '/' + p.doc.getFileName()); entry.addElement(Long.toString(p.getGID())); } else { --- 1245,1249 ---- if (((NodeValue) next).getImplementationType() == NodeValue.PERSISTENT_NODE) { p = (NodeProxy) next; ! entry.addElement(p.getDocument().getCollection().getName() + '/' + p.getDocument().getFileName()); entry.addElement(Long.toString(p.getGID())); } else { *************** *** 1710,1720 **** for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); ! docName = p.doc.getCollection().getName() + '/' + p.doc.getFileName(); ! doctype = p.doc.getDoctype(); if (map.containsKey(docName)) { counter = (NodeCount) map.get(docName); counter.inc(); } else { ! counter = new NodeCount(p.doc); map.put(docName, counter); } --- 1710,1720 ---- for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); ! docName = p.getDocument().getCollection().getName() + '/' + p.getDocument().getFileName(); ! doctype = p.getDocument().getDoctype(); if (map.containsKey(docName)) { counter = (NodeCount) map.get(docName); counter.inc(); } else { ! counter = new NodeCount(p.getDocument()); map.put(docName, counter); } *************** *** 1786,1796 **** for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); ! docName = p.doc.getCollection().getName() + '/' + p.doc.getFileName(); ! doctype = p.doc.getDoctype(); if (map.containsKey(docName)) { counter = (NodeCount) map.get(docName); counter.inc(); } else { ! counter = new NodeCount(p.doc); map.put(docName, counter); } --- 1786,1796 ---- for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); ! docName = p.getDocument().getCollection().getName() + '/' + p.getDocument().getFileName(); ! doctype = p.getDocument().getDoctype(); if (map.containsKey(docName)) { counter = (NodeCount) map.get(docName); counter.inc(); } else { ! counter = new NodeCount(p.getDocument()); map.put(docName, counter); } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:00
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/text In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery/functions/text Modified Files: MatchCount.java TextRank.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: MatchCount.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/text/MatchCount.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchCount.java 16 Jul 2004 17:39:40 -0000 1.2 --- MatchCount.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 76,80 **** throw new XPathException(getName() + " cannot be applied to XQuery-constructed nodes."); NodeProxy np = (NodeProxy)nv; ! for(Match nextMatch = np.match; nextMatch != null; ) { count += nextMatch.getFrequency(); nextMatch = nextMatch.getNextMatch(); --- 76,80 ---- throw new XPathException(getName() + " cannot be applied to XQuery-constructed nodes."); NodeProxy np = (NodeProxy)nv; ! for(Match nextMatch = np.getMatches(); nextMatch != null; ) { count += nextMatch.getFrequency(); nextMatch = nextMatch.getNextMatch(); Index: TextRank.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/text/TextRank.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TextRank.java 14 Jul 2004 19:03:25 -0000 1.2 --- TextRank.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 68,72 **** int freq = 0; ! Match nextMatch = proxy.match; // we just count the number of distinct terms matched while(nextMatch != null) { --- 68,72 ---- int freq = 0; ! Match nextMatch = proxy.getMatches(); // we just count the number of distinct terms matched while(nextMatch != null) { |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:25:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage/serializers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/storage/serializers Modified Files: NativeSerializer.java XIncludeFilter.java Serializer.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: XIncludeFilter.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/serializers/XIncludeFilter.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** XIncludeFilter.java 23 Jul 2004 14:19:53 -0000 1.19 --- XIncludeFilter.java 12 Sep 2004 09:25:17 -0000 1.20 *************** *** 1,2 **** --- 1,23 ---- + /* + * eXist Open Source Native XML Database + * Copyright (C) 2001-04 Wolfgang M. Meier (wol...@ex...) + * and others (see http://exist-db.org) + * + * 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$ + */ package org.exist.storage.serializers; *************** *** 11,17 **** --- 32,41 ---- import org.exist.dom.NodeProxy; import org.exist.dom.NodeSet; + import org.exist.dom.QName; import org.exist.dom.XMLUtil; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; + import org.exist.util.serializer.AttrList; + import org.exist.util.serializer.Receiver; import org.exist.xquery.PathExpr; import org.exist.xquery.XPathException; *************** *** 22,28 **** import org.exist.xquery.value.Sequence; import org.exist.xquery.value.Type; - import org.xml.sax.Attributes; - import org.xml.sax.ContentHandler; - import org.xml.sax.Locator; import org.xml.sax.SAXException; --- 46,49 ---- *************** *** 32,51 **** /** ! * Used to filter the SAX stream generated by the ! * serializer for XInclude statements. */ ! public class XIncludeFilter implements ContentHandler { private final static Logger LOG = Logger.getLogger(XIncludeFilter.class); public final static String XINCLUDE_NS = "http://www.w3.org/2001/XInclude"; ! ! private ContentHandler contentHandler; private Serializer serializer; private DocumentImpl document = null; private HashMap namespaces = new HashMap(10); ! public XIncludeFilter(Serializer serializer, ContentHandler contentHandler) { ! this.contentHandler = contentHandler; this.serializer = serializer; } --- 53,76 ---- /** ! * A filter that listens for XInclude elements in the stream ! * of events generated by the {@link org.exist.storage.serializers.Serializer}. ! * ! * XInclude elements are expanded at the position where they were found. */ ! public class XIncludeFilter implements Receiver { private final static Logger LOG = Logger.getLogger(XIncludeFilter.class); public final static String XINCLUDE_NS = "http://www.w3.org/2001/XInclude"; ! ! private final static QName HREF_ATTRIB = new QName("href", ""); ! ! private Receiver receiver; private Serializer serializer; private DocumentImpl document = null; private HashMap namespaces = new HashMap(10); ! public XIncludeFilter(Serializer serializer, Receiver receiver) { ! this.receiver = receiver; this.serializer = serializer; } *************** *** 55,64 **** } ! public void setContentHandler(ContentHandler handler) { ! this.contentHandler = handler; } ! public ContentHandler getContentHandler() { ! return contentHandler; } --- 80,89 ---- } ! public void setReceiver(Receiver handler) { ! this.receiver = handler; } ! public Receiver getReceiver() { ! return receiver; } *************** *** 67,106 **** } ! /** ! * @see org.xml.sax.ContentHandler#characters(char, int, int) */ ! public void characters(char[] ch, int start, int length) throws SAXException { ! contentHandler.characters(ch, start, length); } ! /** * @see org.xml.sax.ContentHandler#endDocument() */ public void endDocument() throws SAXException { ! contentHandler.endDocument(); } ! /** ! * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ ! public void endElement(String namespaceURI, String localName, String qName) ! throws SAXException { ! if (namespaceURI == null || (!namespaceURI.equals(XINCLUDE_NS))) ! contentHandler.endElement(namespaceURI, localName, qName); } ! ! /** ! * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String) ! */ public void endPrefixMapping(String prefix) throws SAXException { namespaces.remove(prefix); ! contentHandler.endPrefixMapping(prefix); ! } ! ! /** ! * @see org.xml.sax.ContentHandler#ignorableWhitespace(char, int, int) ! */ ! public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { ! contentHandler.ignorableWhitespace(ch, start, length); } --- 92,127 ---- } ! /* (non-Javadoc) ! * @see org.exist.util.serializer.Receiver#characters(java.lang.CharSequence) */ ! public void characters(CharSequence seq) throws SAXException { ! receiver.characters(seq); } ! ! /* (non-Javadoc) ! * @see org.exist.util.serializer.Receiver#comment(char[], int, int) ! */ ! public void comment(char[] ch, int start, int length) throws SAXException { ! receiver.comment(ch, start, length); ! } ! /** * @see org.xml.sax.ContentHandler#endDocument() */ public void endDocument() throws SAXException { ! receiver.endDocument(); } ! /* (non-Javadoc) ! * @see org.exist.util.serializer.Receiver#endElement(org.exist.dom.QName) */ ! public void endElement(QName qname) throws SAXException { ! if(!qname.getNamespaceURI().equals(XINCLUDE_NS)) ! receiver.endElement(qname); } ! public void endPrefixMapping(String prefix) throws SAXException { namespaces.remove(prefix); ! receiver.endPrefixMapping(prefix); } *************** *** 109,127 **** */ public void processingInstruction(String target, String data) throws SAXException { ! contentHandler.processingInstruction(target, data); ! } ! ! /** ! * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator) ! */ ! public void setDocumentLocator(Locator locator) { ! contentHandler.setDocumentLocator(locator); ! } ! ! /** ! * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String) ! */ ! public void skippedEntity(String name) throws SAXException { ! contentHandler.skippedEntity(name); } --- 130,134 ---- */ public void processingInstruction(String target, String data) throws SAXException { ! receiver.processingInstruction(target, data); } *************** *** 130,153 **** */ public void startDocument() throws SAXException { ! contentHandler.startDocument(); } ! /** ! * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ ! public void startElement(String namespaceURI, String localName, String qName, Attributes atts) ! throws SAXException { ! if (namespaceURI != null && namespaceURI.equals(XINCLUDE_NS)) { ! if (localName.equals("include")) { LOG.debug("processing include ..."); ! processXInclude(atts); } } else { //LOG.debug("start: " + qName); ! contentHandler.startElement(namespaceURI, localName, qName, atts); } } ! ! protected void processXInclude(Attributes atts) throws SAXException { // save some settings DocumentImpl prevDoc = document; --- 137,168 ---- */ public void startDocument() throws SAXException { ! receiver.startDocument(); } ! /* (non-Javadoc) ! * @see org.exist.util.serializer.Receiver#attribute(org.exist.dom.QName, java.lang.String) */ ! public void attribute(QName qname, String value) throws SAXException { ! receiver.attribute(qname, value); ! } ! ! /* (non-Javadoc) ! * @see org.exist.util.serializer.Receiver#startElement(org.exist.dom.QName, org.exist.util.serializer.AttrList) ! */ ! public void startElement(QName qname, AttrList attribs) throws SAXException { ! if (qname.getNamespaceURI() != null && qname.getNamespaceURI().equals(XINCLUDE_NS)) { ! if (qname.getLocalName().equals("include")) { LOG.debug("processing include ..."); ! processXInclude(attribs.getValue(HREF_ATTRIB)); } } else { //LOG.debug("start: " + qName); ! receiver.startElement(qname, attribs); } } ! ! protected void processXInclude(String href) throws SAXException { ! if(href == null) ! throw new SAXException("No href attribute found in XInclude include element"); // save some settings DocumentImpl prevDoc = document; *************** *** 156,160 **** // parse the href attribute - String href = atts.getValue("href"); if (href != null) { LOG.debug("found href=\"" + href + "\""); --- 171,174 ---- *************** *** 193,197 **** if (xpointer == null) // no xpointer found - just serialize the doc ! serializer.serializeToSAX(doc, false); else { // process the xpointer --- 207,211 ---- if (xpointer == null) // no xpointer found - just serialize the doc ! serializer.serializeToReceiver(doc, false); else { // process the xpointer *************** *** 215,219 **** context.declareNamespaces(namespaces); ! XQueryLexer lexer = new XQueryLexer(new StringReader(xpointer)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 229,233 ---- context.declareNamespaces(namespaces); ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(xpointer)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); *************** *** 241,245 **** for (Iterator i = set.iterator(); i.hasNext();) { proxy = (NodeProxy) i.next(); ! serializer.serializeToSAX(proxy, false); } break; --- 255,259 ---- for (Iterator i = set.iterator(); i.hasNext();) { proxy = (NodeProxy) i.next(); ! serializer.serializeToReceiver(proxy, false); } break; *************** *** 248,252 **** for (int i = 0; i < seq.getLength(); i++) { val = seq.itemAt(i).getStringValue(); ! characters(val.toCharArray(), 0, val.length()); } break; --- 262,266 ---- for (int i = 0; i < seq.getLength(); i++) { val = seq.itemAt(i).getStringValue(); ! characters(val); } break; *************** *** 277,281 **** public void startPrefixMapping(String prefix, String uri) throws SAXException { namespaces.put(prefix, uri); ! contentHandler.startPrefixMapping(prefix, uri); } --- 291,295 ---- public void startPrefixMapping(String prefix, String uri) throws SAXException { namespaces.put(prefix, uri); ! receiver.startPrefixMapping(prefix, uri); } Index: NativeSerializer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/serializers/NativeSerializer.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** NativeSerializer.java 23 Jun 2004 12:45:12 -0000 1.25 --- NativeSerializer.java 12 Sep 2004 09:25:17 -0000 1.26 *************** *** 1,21 **** /* ! * eXist Open Source Native XML Database Copyright (C) 2001-03 Wolfgang M. Meier ! * me...@if... 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: */ package org.exist.storage.serializers; --- 1,23 ---- /* ! * eXist Open Source Native XML Database ! * Copyright (C) 2001-04 Wolfgang M. Meier ! * wol...@ex... ! * http://exist-db.org ! * ! * 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$ */ package org.exist.storage.serializers; *************** *** 24,27 **** --- 26,30 ---- import java.util.Set; import java.util.TreeSet; + import org.apache.oro.text.perl.Perl5Util; import org.exist.dom.AttrImpl; *************** *** 32,43 **** import org.exist.dom.NodeImpl; import org.exist.dom.NodeProxy; - import org.exist.dom.NodeSet; import org.exist.dom.ProcessingInstructionImpl; import org.exist.dom.QName; import org.exist.dom.TextImpl; import org.exist.dom.XMLUtil; - import org.exist.memtree.Receiver; import org.exist.storage.DBBroker; import org.exist.util.Configuration; import org.w3c.dom.Node; import org.w3c.dom.NodeList; --- 35,46 ---- import org.exist.dom.NodeImpl; import org.exist.dom.NodeProxy; import org.exist.dom.ProcessingInstructionImpl; import org.exist.dom.QName; import org.exist.dom.TextImpl; import org.exist.dom.XMLUtil; import org.exist.storage.DBBroker; import org.exist.util.Configuration; + import org.exist.util.serializer.AttrList; + import org.exist.util.serializer.Receiver; import org.w3c.dom.Node; import org.w3c.dom.NodeList; *************** *** 45,48 **** --- 48,56 ---- import org.xml.sax.helpers.AttributesImpl; + /** + * Serializer implementation for the native database backend. + * + * @author wolf + */ public class NativeSerializer extends Serializer { *************** *** 56,59 **** --- 64,71 ---- private final static QName MATCH_ELEMENT = new QName("match", EXIST_NS, "exist"); + private final static QName TEXT_ELEMENT = new QName("text", EXIST_NS, "exist"); + private final static QName ATTRIB_ELEMENT = new QName("attribute", EXIST_NS, "exist"); + private final static QName SOURCE_ATTRIB = new QName("source", EXIST_NS, "exist"); + private final static QName ID_ATTRIB = new QName("id", EXIST_NS, "exist"); private int showId = EXIST_ID_ELEMENT; *************** *** 75,169 **** } ! protected void serializeToSAX(NodeSet set, int start, int howmany, ! long queryTime) throws SAXException { ! boolean generateDocEvents = getProperty(Serializer.GENERATE_DOC_EVENTS, ! "false").equals("true"); ! Iterator iter = set.iterator(); ! for (int i = 0; i < start - 1; i++) ! iter.next(); ! if (!iter.hasNext()) return; ! if (generateDocEvents) contentHandler.startDocument(); ! contentHandler.startPrefixMapping("exist", EXIST_NS); ! AttributesImpl attribs = new AttributesImpl(); ! attribs.addAttribute("", "hitCount", "hitCount", "CDATA", Integer ! .toString(set.getLength())); ! if (queryTime >= 0) ! attribs.addAttribute("", "queryTime", "queryTime", "CDATA", ! Long.toString(queryTime)); ! contentHandler ! .startElement(EXIST_NS, "result", "exist:result", attribs); ! NodeProxy p; ! long startTime = System.currentTimeMillis(); ! Iterator domIter; ! for (int i = 0; i < howmany && iter.hasNext(); i++) { ! p = (NodeProxy) iter.next(); ! if (p == null) continue; ! domIter = broker.getNodeIterator(p); ! if (domIter == null) continue; ! serializeToSAX(null, domIter, p.doc, p.gid, true, p.match); ! } ! contentHandler.endElement(EXIST_NS, "result", "exist:result"); ! if (generateDocEvents) contentHandler.endDocument(); ! } ! ! protected void serializeToSAX(DocumentImpl doc, boolean generateDocEvent) ! throws SAXException { ! long start = System.currentTimeMillis(); ! setDocument(doc); ! NodeList children = doc.getChildNodes(); ! if (generateDocEvent) contentHandler.startDocument(); ! //contentHandler.startPrefixMapping("exist", EXIST_NS); ! // iterate through children ! for (int i = 0; i < children.getLength(); i++) { ! final NodeImpl n = (NodeImpl) children.item(i); ! final NodeProxy p = new NodeProxy((DocumentImpl) n ! .getOwnerDocument(), n.getGID(), n.getInternalAddress()); ! Iterator domIter = broker.getNodeIterator(p); ! domIter.next(); ! serializeToSAX(n, domIter, (DocumentImpl) n.getOwnerDocument(), n ! .getGID(), false, null); ! } ! LOG.debug("serializing document " + ((DocumentImpl) doc).getDocId() ! + "to SAX took " + (System.currentTimeMillis() - start)); ! //contentHandler.endPrefixMapping("exist"); ! if (generateDocEvent) contentHandler.endDocument(); ! } ! ! protected void serializeToSAX(NodeImpl n) throws SAXException { ! if (!(n instanceof NodeImpl)) ! throw new RuntimeException("wrong implementation"); ! serializeToSAX(new NodeProxy((DocumentImpl) n.getOwnerDocument(), ! ((NodeImpl) n).getGID())); ! } ! ! protected void serializeToSAX(NodeProxy p) throws SAXException { ! serializeToSAX(p, true); ! } ! ! protected void serializeToSAX(NodeProxy p, boolean generateDocEvents) ! throws SAXException { ! if (generateDocEvents) contentHandler.startDocument(); ! //contentHandler.startPrefixMapping("exist", EXIST_NS); Iterator domIter = broker.getNodeIterator(p); ! serializeToSAX(null, domIter, p.doc, p.gid, true, p.match); ! //contentHandler.endPrefixMapping("exist"); ! if (generateDocEvents) contentHandler.endDocument(); ! } ! ! protected void serializeToSAX(Iterator iter, DocumentImpl doc, long gid) ! throws SAXException { ! serializeToSAX(null, iter, doc, gid, true, null); } ! ! protected void serializeToSAX(NodeImpl node, Iterator iter, ! DocumentImpl doc, long gid, boolean first, Match match) ! throws SAXException { ! serializeToSAX(node, iter, doc, gid, first, new TreeSet(), match); } ! ! protected void serializeToSAX(NodeImpl node, Iterator iter, ! DocumentImpl doc, long gid, boolean first, Set namespaces, ! Match match) throws SAXException { ! setDocument(doc); if (node == null) node = (NodeImpl) iter.next(); if (node == null) return; --- 87,122 ---- } ! protected void serializeToReceiver(NodeProxy p, boolean generateDocEvent) ! throws SAXException { ! if (generateDocEvent) receiver.startDocument(); Iterator domIter = broker.getNodeIterator(p); ! serializeToReceiver(null, domIter, p.getDocument(), p.gid, true, p.getMatches(), new TreeSet()); ! if (generateDocEvent) receiver.endDocument(); } ! ! protected void serializeToReceiver(DocumentImpl doc, boolean generateDocEvent) ! throws SAXException { ! long start = System.currentTimeMillis(); ! setDocument(doc); ! NodeList children = doc.getChildNodes(); ! if (generateDocEvent) receiver.startDocument(); ! // iterate through children ! for (int i = 0; i < children.getLength(); i++) { ! final NodeImpl n = (NodeImpl) children.item(i); ! final NodeProxy p = new NodeProxy((DocumentImpl) n ! .getOwnerDocument(), n.getGID(), n.getInternalAddress()); ! Iterator domIter = broker.getNodeIterator(p); ! domIter.next(); ! serializeToReceiver(n, domIter, (DocumentImpl) n.getOwnerDocument(), n ! .getGID(), true, p.getMatches(), new TreeSet()); ! } ! LOG.debug("serializing document " + ((DocumentImpl) doc).getDocId() ! + "to SAX took " + (System.currentTimeMillis() - start)); ! if (generateDocEvent) receiver.endDocument(); } ! ! protected void serializeToReceiver(NodeImpl node, Iterator iter, ! DocumentImpl doc, long gid, boolean first, Match match, Set namespaces) ! throws SAXException { if (node == null) node = (NodeImpl) iter.next(); if (node == null) return; *************** *** 172,189 **** switch (node.getNodeType()) { case Node.ELEMENT_NODE: ! int children = node.getChildCount(); ! int count = 0; ! int childLen; ! NodeImpl child = null; ! AttributesImpl attributes = new AttributesImpl(); ! if ((first && showId == EXIST_ID_ELEMENT) || showId == EXIST_ID_ALL) { ! attributes.addAttribute(EXIST_NS, "id", "exist:id", "CDATA", ! Long.toString(gid)); } if (first && showId > 0) { String src = doc.getCollection().getName() + '/' + doc.getFileName(); ! attributes.addAttribute(EXIST_NS, "source", "exist:source", ! "CDATA", doc.getFileName()); } if (children > 0) gid = XMLUtil.getFirstChildId(doc, gid); while (count < children) { --- 125,164 ---- switch (node.getNodeType()) { case Node.ELEMENT_NODE: ! String defaultNS = null; ! if (((ElementImpl) node).declaresNamespacePrefixes()) { ! // declare namespaces used by this element ! String prefix, uri; ! for (Iterator i = ((ElementImpl) node).getPrefixes(); i ! .hasNext();) { ! prefix = (String) i.next(); ! if (prefix.length() == 0) { ! defaultNS = ((ElementImpl) node) ! .getNamespaceForPrefix(prefix); ! receiver.startPrefixMapping("", defaultNS); ! namespaces.add(defaultNS); ! } else { ! uri = ((ElementImpl) node) ! .getNamespaceForPrefix(prefix); ! if (uri.equals(EXIST_NS)) continue; ! receiver.startPrefixMapping(prefix, uri); ! namespaces.add(uri); ! } ! } ! } ! String ns = defaultNS == null ? node.getNamespaceURI() : defaultNS; ! if (ns.length() > 0 && (!namespaces.contains(ns))) ! receiver.startPrefixMapping(node.getPrefix(), ns); ! AttrList attribs = new AttrList(); ! if ((first && showId == EXIST_ID_ELEMENT) || showId == EXIST_ID_ALL) { ! attribs.addAttribute(ID_ATTRIB, Long.toString(gid)); } if (first && showId > 0) { String src = doc.getCollection().getName() + '/' + doc.getFileName(); ! attribs.addAttribute(SOURCE_ATTRIB, doc.getFileName()); } + int children = node.getChildCount(); + int count = 0; + int childLen; + NodeImpl child = null; if (children > 0) gid = XMLUtil.getFirstChildId(doc, gid); while (count < children) { *************** *** 195,201 **** else cdata = ((AttrImpl) child).getValue(); ! attributes.addAttribute(child.getNamespaceURI(), child ! .getLocalName(), child.getNodeName(), "CDATA", ! cdata); count++; gid++; --- 170,174 ---- else cdata = ((AttrImpl) child).getValue(); ! attribs.addAttribute(child.getQName(), cdata); count++; gid++; *************** *** 204,236 **** break; } ! String defaultNS = null; ! if (((ElementImpl) node).declaresNamespacePrefixes()) { ! // declare namespaces used by this element ! String prefix, uri; ! for (Iterator i = ((ElementImpl) node).getPrefixes(); i ! .hasNext();) { ! prefix = (String) i.next(); ! if (prefix.length() == 0) { ! defaultNS = ((ElementImpl) node) ! .getNamespaceForPrefix(prefix); ! contentHandler.startPrefixMapping("", defaultNS); ! namespaces.add(defaultNS); ! } else { ! uri = ((ElementImpl) node) ! .getNamespaceForPrefix(prefix); ! if (uri.equals(EXIST_NS)) continue; ! contentHandler.startPrefixMapping(prefix, uri); ! namespaces.add(uri); ! } ! } ! } ! String ns = defaultNS == null ? node.getNamespaceURI() : defaultNS; ! if (ns.length() > 0 && (!namespaces.contains(ns))) ! contentHandler.startPrefixMapping(node.getPrefix(), ns); ! contentHandler.startElement(ns, node.getLocalName(), node ! .getNodeName(), attributes); while (count < children) { ! serializeToSAX(child, iter, doc, gid++, false, namespaces, ! match); if (++count < children) { child = (NodeImpl) iter.next(); --- 177,183 ---- break; } ! receiver.startElement(node.getQName(), attribs); while (count < children) { ! serializeToReceiver(child, iter, doc, gid++, false, match, namespaces); if (++count < children) { child = (NodeImpl) iter.next(); *************** *** 238,243 **** break; } ! contentHandler.endElement(ns, node.getLocalName(), node ! .getNodeName()); if (((ElementImpl) node).declaresNamespacePrefixes()) { String prefix; --- 185,189 ---- break; } ! receiver.endElement(node.getQName()); if (((ElementImpl) node).declaresNamespacePrefixes()) { String prefix; *************** *** 245,374 **** .hasNext();) { prefix = (String) i.next(); ! contentHandler.endPrefixMapping(prefix); } } if (ns.length() > 0 && (!namespaces.contains(ns))) ! contentHandler.endPrefixMapping(node.getPrefix()); ! break; ! case Node.TEXT_NODE: ! if (first && createContainerElements) { ! AttributesImpl attribs = new AttributesImpl(); ! if (showId > 0) { ! attribs.addAttribute(EXIST_NS, "id", "exist:id", "CDATA", ! Long.toString(gid)); ! attribs.addAttribute(EXIST_NS, "source", "exist:source", ! "CDATA", doc.getFileName()); ! } ! contentHandler.startElement(EXIST_NS, "text", "exist:text", ! attribs); ! } ! if ((getHighlightingMode() & TAG_ELEMENT_MATCHES) == TAG_ELEMENT_MATCHES ! && (cdata = processText((TextImpl) node, gid, match)) != null) ! scanText(cdata); ! else { ! ((TextImpl) node).getXMLString().toSAX(contentHandler); ! } ! if (first && createContainerElements) ! contentHandler.endElement(EXIST_NS, "text", "exist:text"); node.release(); break; ! case Node.ATTRIBUTE_NODE: ! if (first && createContainerElements) { ! AttributesImpl attribs = new AttributesImpl(); if (showId > 0) { ! attribs.addAttribute(EXIST_NS, "id", "exist:id", "CDATA", ! Long.toString(gid)); ! attribs.addAttribute(EXIST_NS, "source", "exist:source", ! "CDATA", doc.getFileName()); } ! if ((getHighlightingMode() & TAG_ATTRIBUTE_MATCHES) > 0) ! cdata = processAttribute(((AttrImpl) node).getValue(), gid, ! match); ! else ! cdata = ((AttrImpl) node).getValue(); ! attribs.addAttribute(node.getNamespaceURI(), node ! .getLocalName(), node.getNodeName(), "CDATA", cdata); ! contentHandler.startElement(EXIST_NS, "attribute", ! "exist:attribute", attribs); ! contentHandler.endElement(EXIST_NS, "attribute", ! "exist:attribute"); ! } else { ! if ((getHighlightingMode() & TAG_ATTRIBUTE_MATCHES) == TAG_ATTRIBUTE_MATCHES) ! cdata = processAttribute(((AttrImpl) node).getValue(), gid, ! match); ! else ! cdata = ((AttrImpl) node).getValue(); ! ch = new char[cdata.length()]; ! cdata.getChars(0, ch.length, ch, 0); ! contentHandler.characters(ch, 0, ch.length); ! } ! node.release(); ! break; ! case Node.PROCESSING_INSTRUCTION_NODE: ! contentHandler.processingInstruction( ! ((ProcessingInstructionImpl) node).getTarget(), ! ((ProcessingInstructionImpl) node).getData()); ! node.release(); ! break; ! case Node.COMMENT_NODE: ! if (lexicalHandler != null) { ! String comment = ((CommentImpl) node).getData(); ! char data[] = new char[comment.length()]; ! comment.getChars(0, data.length - 1, data, 0); ! lexicalHandler.comment(data, 0, data.length - 1); ! } ! node.release(); ! break; ! } ! } ! ! protected void serializeToReceiver(NodeProxy p, Receiver receiver) ! throws SAXException { ! Iterator domIter = broker.getNodeIterator(p); ! serializeToReceiver(null, domIter, p.doc, p.gid, p.match, receiver); ! } ! ! protected void serializeToReceiver(NodeImpl node, Iterator iter, ! DocumentImpl doc, long gid, Match match, Receiver receiver) ! throws SAXException { ! if (node == null) node = (NodeImpl) iter.next(); ! if (node == null) return; ! char ch[]; ! String cdata; ! switch (node.getNodeType()) { ! case Node.ELEMENT_NODE: ! receiver.startElement(node.getQName()); ! ! int children = node.getChildCount(); ! int count = 0; ! int childLen; ! NodeImpl child = null; ! if (children > 0) gid = XMLUtil.getFirstChildId(doc, gid); ! while (count < children) { ! child = (NodeImpl) iter.next(); ! if (child.getNodeType() == Node.ATTRIBUTE_NODE) { ! if ((getHighlightingMode() & TAG_ATTRIBUTE_MATCHES) > 0) ! cdata = processAttribute(((AttrImpl) child).getValue(), ! gid, match); ! else ! cdata = ((AttrImpl) child).getValue(); ! receiver.attribute(child.getQName(), cdata); ! count++; ! gid++; ! child.release(); ! } else ! break; ! } ! while (count < children) { ! serializeToReceiver(child, iter, doc, gid++, match, receiver); ! if (++count < children) { ! child = (NodeImpl) iter.next(); ! } else ! break; } - receiver.endElement(node.getQName()); - node.release(); - break; - case Node.TEXT_NODE: if ((getHighlightingMode() & TAG_ELEMENT_MATCHES) == TAG_ELEMENT_MATCHES && (cdata = processText((TextImpl) node, gid, match)) != null) --- 191,210 ---- .hasNext();) { prefix = (String) i.next(); ! receiver.endPrefixMapping(prefix); } } if (ns.length() > 0 && (!namespaces.contains(ns))) ! receiver.endPrefixMapping(node.getPrefix()); node.release(); break; ! case Node.TEXT_NODE: ! if (first && createContainerElements) { ! AttrList tattribs = new AttrList(); if (showId > 0) { ! tattribs.addAttribute(ID_ATTRIB, Long.toString(gid)); ! tattribs.addAttribute(SOURCE_ATTRIB, doc.getFileName()); } ! receiver.startElement(TEXT_ELEMENT, tattribs); } if ((getHighlightingMode() & TAG_ELEMENT_MATCHES) == TAG_ELEMENT_MATCHES && (cdata = processText((TextImpl) node, gid, match)) != null) *************** *** 377,380 **** --- 213,218 ---- receiver.characters(((TextImpl) node).getXMLString()); } + if (first && createContainerElements) + receiver.endElement(TEXT_ELEMENT); node.release(); break; *************** *** 385,393 **** else cdata = ((AttrImpl) node).getValue(); ! receiver.attribute(node.getQName(), cdata); node.release(); break; case Node.PROCESSING_INSTRUCTION_NODE: ! contentHandler.processingInstruction( ((ProcessingInstructionImpl) node).getTarget(), ((ProcessingInstructionImpl) node).getData()); --- 223,241 ---- else cdata = ((AttrImpl) node).getValue(); ! if(first && createContainerElements) { ! AttrList tattribs = new AttrList(); ! if (showId > 0) { ! tattribs.addAttribute(ID_ATTRIB, Long.toString(gid)); ! tattribs.addAttribute(SOURCE_ATTRIB, doc.getFileName()); ! } ! tattribs.addAttribute(((AttrImpl)node).getQName(), cdata); ! receiver.startElement(ATTRIB_ELEMENT, tattribs); ! receiver.endElement(ATTRIB_ELEMENT); ! } else ! receiver.attribute(node.getQName(), cdata); node.release(); break; case Node.PROCESSING_INSTRUCTION_NODE: ! receiver.processingInstruction( ((ProcessingInstructionImpl) node).getTarget(), ((ProcessingInstructionImpl) node).getData()); *************** *** 399,403 **** char data[] = new char[comment.length()]; comment.getChars(0, data.length - 1, data, 0); ! lexicalHandler.comment(data, 0, data.length - 1); } node.release(); --- 247,251 ---- char data[] = new char[comment.length()]; comment.getChars(0, data.length - 1, data, 0); ! receiver.comment(data, 0, data.length - 1); } node.release(); *************** *** 463,467 **** } if (inTerm) { ! receiver.startElement(MATCH_ELEMENT); receiver.characters(data.substring(p0, p1)); receiver.endElement(MATCH_ELEMENT); --- 311,315 ---- } if (inTerm) { ! receiver.startElement(MATCH_ELEMENT, null); receiver.characters(data.substring(p0, p1)); receiver.endElement(MATCH_ELEMENT); *************** *** 474,505 **** } } - - private final void scanText(String data) throws SAXException { - int p0 = 0, p1; - boolean inTerm = false; - while (p0 < data.length()) { - p1 = data.indexOf("||", p0); - if (p1 < 0) { - outputText(data.substring(p0)); - break; - } - if (inTerm) { - contentHandler.startElement(EXIST_NS, "match", "exist:match", - EMPTY_ATTRIBUTES); - outputText(data.substring(p0, p1)); - contentHandler.endElement(EXIST_NS, "match", "exist:match"); - inTerm = false; - } else { - inTerm = true; - outputText(data.substring(p0, p1)); - } - p0 = p1 + 2; - } - } - - private final void outputText(String data) throws SAXException { - final char ch[] = new char[data.length()]; - data.getChars(0, ch.length, ch, 0); - contentHandler.characters(ch, 0, ch.length); - } } \ No newline at end of file --- 322,324 ---- Index: Serializer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/serializers/Serializer.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Serializer.java 28 Jul 2004 08:28:04 -0000 1.27 --- Serializer.java 12 Sep 2004 09:25:17 -0000 1.28 *************** *** 1,5 **** /* * eXist Open Source Native XML Database ! * Copyright (C) 2001 Wolfgang M. Meier * wol...@ex... * http://exist-db.org --- 1,5 ---- /* * eXist Open Source Native XML Database ! * Copyright (C) 2001-04 Wolfgang M. Meier * wol...@ex... * http://exist-db.org *************** *** 48,56 **** import org.apache.log4j.Logger; import org.exist.dom.DocumentImpl; - import org.exist.dom.NodeImpl; import org.exist.dom.NodeProxy; - import org.exist.dom.NodeSet; import org.exist.dom.XMLUtil; - import org.exist.memtree.Receiver; import org.exist.security.Permission; import org.exist.security.PermissionDeniedException; --- 48,53 ---- *************** *** 58,63 **** import org.exist.storage.DBBroker; import org.exist.util.Configuration; ! import org.exist.util.serializer.DOMStreamer; ! import org.exist.util.serializer.DOMStreamerPool; import org.exist.util.serializer.SAXSerializer; import org.exist.util.serializer.SAXSerializerPool; --- 55,60 ---- import org.exist.storage.DBBroker; import org.exist.util.Configuration; ! import org.exist.util.serializer.Receiver; ! import org.exist.util.serializer.ReceiverToSAX; import org.exist.util.serializer.SAXSerializer; import org.exist.util.serializer.SAXSerializerPool; *************** *** 77,85 **** import org.xml.sax.XMLReader; import org.xml.sax.ext.LexicalHandler; - import org.xml.sax.helpers.AttributesImpl; /** ! * Serializer base class, used to serialize a document or document fragment back to XML. ! * A serializer may be obtained by calling DBBroker.getSerializer(). * * The class basically offers two overloaded methods: serialize() --- 74,81 ---- import org.xml.sax.XMLReader; import org.xml.sax.ext.LexicalHandler; /** ! * Serializer base class, used to serialize a document or document fragment ! * back to XML. A serializer may be obtained by calling DBBroker.getSerializer(). * * The class basically offers two overloaded methods: serialize() *************** *** 87,91 **** * toSAX() generates a stream of SAX events. The stream of SAX * events is passed to the ContentHandler set by setContentHandler(). ! * serialize() internally calls toSAX(). * * Output can be configured through properties. Property keys are defined in classes --- 83,89 ---- * toSAX() generates a stream of SAX events. The stream of SAX * events is passed to the ContentHandler set by setContentHandler(). ! * ! * Internally, both types of methods pass events to a {@link org.exist.util.serializer.Receiver}. ! * Subclasses thus have to implement the various serializeToReceiver() methods. * * Output can be configured through properties. Property keys are defined in classes *************** *** 123,129 **** protected TransformerHandler xslHandler = null; protected XIncludeFilter xinclude; protected SAXSerializer xmlout = null; - protected ContentHandler contentHandler; - protected DTDHandler dtdHandler = null; protected LexicalHandler lexicalHandler = null; protected User user = null; --- 121,126 ---- protected TransformerHandler xslHandler = null; protected XIncludeFilter xinclude; + protected Receiver receiver = null; protected SAXSerializer xmlout = null; protected LexicalHandler lexicalHandler = null; protected User user = null; *************** *** 133,137 **** factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); xinclude = new XIncludeFilter(this); ! contentHandler = xinclude; String option = (String) config.getProperty("serialization.enable-xsl"); if (option != null) --- 130,134 ---- factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); xinclude = new XIncludeFilter(this); ! receiver = xinclude; String option = (String) config.getProperty("serialization.enable-xsl"); if (option != null) *************** *** 140,145 **** defaultProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no"); option = (String) config.getProperty("serialization.enable-xinclude"); ! if (option != null) defaultProperties.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, option); option = (String) config.getProperty("serialization.indent"); if (option != null) --- 137,143 ---- defaultProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no"); option = (String) config.getProperty("serialization.enable-xinclude"); ! if (option != null) { defaultProperties.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, option); + } option = (String) config.getProperty("serialization.indent"); if (option != null) *************** *** 235,253 **** if (getProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes") .equals("yes")) { ! xinclude.setContentHandler(xslHandler); } else ! contentHandler = xslHandler; ! lexicalHandler = null; return sout; } - public ContentHandler getContentHandler() { - return contentHandler; - } - - public DTDHandler getDTDHandler() { - return dtdHandler; - } - /** * Return my internal EntityResolver --- 233,243 ---- if (getProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes") .equals("yes")) { ! xinclude.setReceiver(new ReceiverToSAX(xslHandler)); ! receiver = xinclude; } else ! receiver = new ReceiverToSAX(xslHandler); return sout; } /** * Return my internal EntityResolver *************** *** 306,311 **** public void parse(String systemId) throws IOException, SAXException { - if (contentHandler == null) - throw new SAXException("no content handler"); try { // try to load document from eXist --- 296,299 ---- *************** *** 317,321 **** if(!doc.getPermissions().validate(broker.getUser(), Permission.READ)) throw new PermissionDeniedException("Not allowed to read resource"); ! serializeToSAX(doc, true); } catch (PermissionDeniedException e) { throw new SAXException("permission denied"); --- 305,309 ---- if(!doc.getPermissions().validate(broker.getUser(), Permission.READ)) throw new PermissionDeniedException("Not allowed to read resource"); ! toSAX(doc); } catch (PermissionDeniedException e) { throw new SAXException("permission denied"); *************** *** 327,332 **** */ public void reset() { ! contentHandler = xinclude; ! xinclude.setContentHandler(null); xslHandler = null; templates = null; --- 315,320 ---- */ public void reset() { ! receiver = xinclude; ! xinclude.setReceiver(null); xslHandler = null; templates = null; *************** *** 335,374 **** /** - * Serialize a set of nodes - * - *@param set Description of the Parameter - *@param start Description of the Parameter - *@param howmany Description of the Parameter - *@return Description of the Return Value - *@exception SAXException Description of the Exception - */ - public String serialize(NodeSet set, int start, int howmany) throws SAXException { - return serialize(set, start, howmany, 0); - } - - /** - * Serialize a set of nodes - * - *@param set Description of the Parameter - *@param start Description of the Parameter - *@param howmany Description of the Parameter - *@param queryTime Description of the Parameter - *@return Description of the Return Value - *@exception SAXException Description of the Exception - */ - public String serialize(NodeSet set, int start, int howmany, long queryTime) - throws SAXException { - StringWriter out; - if (templates != null) - out = applyXSLHandler(); - else - out = setPrettyPrinter(false); - - serializeToSAX(set, start, howmany, queryTime); - releasePrettyPrinter(); - return out.toString(); - } - - /** * Serialize a document * --- 323,326 ---- *************** *** 388,412 **** else out = setPrettyPrinter(true); ! ! serializeToSAX(doc, true); ! releasePrettyPrinter(); ! return out.toString(); ! } ! ! /** ! * Serialize a single node. ! * ! *@param n Description of the Parameter ! *@return Description of the Return Value ! *@exception SAXException Description of the Exception ! */ ! public String serialize(NodeImpl n) throws SAXException { ! StringWriter out; ! if (templates != null) ! out = applyXSLHandler(); ! else ! out = setPrettyPrinter(false); ! ! serializeToSAX(n, true); releasePrettyPrinter(); return out.toString(); --- 340,345 ---- else out = setPrettyPrinter(true); ! ! serializeToReceiver(doc, true); releasePrettyPrinter(); return out.toString(); *************** *** 420,424 **** else out = setPrettyPrinter(false); ! serializeToSAX(n, true); releasePrettyPrinter(); return out.toString(); --- 353,357 ---- else out = setPrettyPrinter(false); ! serializeToReceiver(n, true); releasePrettyPrinter(); return out.toString(); *************** *** 438,442 **** else out = setPrettyPrinter(false); ! serializeToSAX(p, true); releasePrettyPrinter(); return out.toString(); --- 371,375 ---- else out = setPrettyPrinter(false); ! serializeToReceiver(p, false); releasePrettyPrinter(); return out.toString(); *************** *** 444,588 **** /** - * Serialize a document to a SAX stream - * - *@param doc Description of the Parameter - *@param generateDocEvent Description of the Parameter - *@exception SAXException Description of the Exception - */ - protected void serializeToSAX(DocumentImpl doc, boolean generateDocEvent) - throws SAXException { - long startTime = System.currentTimeMillis(); - setDocument((DocumentImpl) doc); - NodeList children = doc.getChildNodes(); - if (generateDocEvent) - contentHandler.startDocument(); - - contentHandler.startPrefixMapping("exist", EXIST_NS); - for (int i = 0; i < children.getLength(); i++) - ((NodeImpl) children.item(i)).toSAX(contentHandler, lexicalHandler, false); - - contentHandler.endPrefixMapping("exist"); - if (generateDocEvent) - contentHandler.endDocument(); - - LOG.debug( - "serializing document took " + (System.currentTimeMillis() - startTime)); - } - - /** - * Serialize a NodeSet to the SAX stream - * - *@param set Description of the Parameter - *@param start Description of the Parameter - *@param howmany Description of the Parameter - *@param queryTime Description of the Parameter - *@exception SAXException Description of the Exception - */ - protected void serializeToSAX(NodeSet set, int start, int howmany, long queryTime) - throws SAXException { - NodeImpl n; - long startTime = System.currentTimeMillis(); - contentHandler.startDocument(); - contentHandler.startPrefixMapping("exist", EXIST_NS); - AttributesImpl attribs = new AttributesImpl(); - attribs.addAttribute( - "", - "hitCount", - "hitCount", - "CDATA", - Integer.toString(set.getLength())); - if (queryTime >= 0) - attribs.addAttribute( - "", - "queryTime", - "queryTime", - "CDATA", - Long.toString(queryTime)); - - contentHandler.startElement(EXIST_NS, "result", "exist:result", attribs); - for (int i = start - 1; i < start + howmany - 1 && i < set.getLength(); i++) { - n = (NodeImpl) set.item(i); - setDocument((DocumentImpl) n.getOwnerDocument()); - if (n != null) - n.toSAX(contentHandler, lexicalHandler, true); - - } - contentHandler.endElement(EXIST_NS, "result", "exist:result"); - contentHandler.endPrefixMapping("exist"); - contentHandler.endDocument(); - } - - protected void serializeToSAX(NodeValue v, boolean generateDocEvents) - throws SAXException { - if(v.getImplementationType() == NodeValue.PERSISTENT_NODE) - serializeToSAX((NodeProxy)v, generateDocEvents); - else - serializeToSAX((org.exist.memtree.NodeImpl)v, generateDocEvents); - } - - /** - * Serialize a single Node to the SAX stream - * - *@param n Description of the Parameter - *@param generateDocEvents Description of the Parameter - *@exception SAXException Description of the Exception - */ - protected void serializeToSAX(NodeImpl n, boolean generateDocEvents) - throws SAXException { - if (generateDocEvents) - contentHandler.startDocument(); - - contentHandler.startPrefixMapping("exist", EXIST_NS); - setDocument((DocumentImpl) n.getOwnerDocument()); - n.toSAX(contentHandler, lexicalHandler, true); - contentHandler.endPrefixMapping("exist"); - if (generateDocEvents) - contentHandler.endDocument(); - } - - protected void serializeToSAX(org.exist.memtree.NodeImpl n, boolean generateDocEvents) - throws SAXException { - if (generateDocEvents) - contentHandler.startDocument(); - - //contentHandler.startPrefixMapping("exist", EXIST_NS); - - DOMStreamer streamer = null; - try { - streamer = DOMStreamerPool.getInstance().borrowDOMStreamer(this); - streamer.setContentHandler(contentHandler); - streamer.setLexicalHandler(lexicalHandler); - streamer.serialize(n, generateDocEvents); - //contentHandler.endPrefixMapping("exist"); - } catch(Exception e) { - e.printStackTrace(); - throw new SAXException(e.getMessage(), e); - } finally { - DOMStreamerPool.getInstance().returnDOMStreamer(streamer); - } - - if (generateDocEvents) - contentHandler.endDocument(); - } - - /** - * Serialize a single NodeProxy to the SAX stream - * - *@param p Description of the Parameter - *@param generateDocEvents Description of the Parameter - *@exception SAXException Description of the Exception - */ - protected void serializeToSAX(NodeProxy p, boolean generateDocEvents) - throws SAXException { - NodeImpl n; - if(p.gid < 0) - n = (NodeImpl)p.doc.getDocumentElement(); - else - n = (NodeImpl)p.getNode(); - if (n != null) - serializeToSAX(n, generateDocEvents); - } - - /** * Set the ContentHandler to be used during serialization. * --- 377,380 ---- *************** *** 590,610 **** */ public void setContentHandler(ContentHandler handler) { if (getProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes") .equals("yes")) { ! xinclude.setContentHandler(handler); ! contentHandler = xinclude; } else ! contentHandler = handler; } /** ! * Set the DTDHandler to be used during serialization. ! * ! *@param handler The new dTDHandler value */ ! public void setDTDHandler(DTDHandler handler) { ! dtdHandler = handler; } ! /** * Sets the entityResolver attribute of the Serializer object --- 382,404 ---- */ public void setContentHandler(ContentHandler handler) { + ReceiverToSAX toSAX = new ReceiverToSAX(handler); + toSAX.setLexicalHandler(lexicalHandler); if (getProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes") .equals("yes")) { ! xinclude.setReceiver(toSAX); ! receiver = xinclude; } else ! receiver = toSAX; } /** ! * Required by interface XMLReader. Always returns null. ! * ! * @see org.xml.sax.XMLReader#getContentHandler() */ ! public ContentHandler getContentHandler() { ! return null; } ! /** * Sets the entityResolver attribute of the Serializer object *************** *** 658,663 **** xmlout.setWriter(sout); xmlout.setOutputProperties(outputProperties); ! setContentHandler(xmlout); ! setLexicalHandler(xmlout); return sout; } --- 452,461 ---- xmlout.setWriter(sout); xmlout.setOutputProperties(outputProperties); ! if (getProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes") ! .equals("yes")) { ! xinclude.setReceiver(xmlout); ! receiver = xinclude; ! } else ! receiver = xmlout; return sout; } *************** *** 726,735 **** // save handlers ! ContentHandler oldHandler = contentHandler; ! LexicalHandler oldLexical = lexicalHandler; // compile stylesheet TemplatesHandler handler = factory.newTemplatesHandler(); ! contentHandler = handler; try { this.toSAX(xsl); --- 524,532 ---- // save handlers ! Receiver oldReceiver = receiver; // compile stylesheet TemplatesHandler handler = factory.newTemplatesHandler(); ! receiver = new ReceiverToSAX(handler); try { this.toSAX(xsl); *************** *** 740,745 **** // restore handlers ! contentHandler = oldHandler; ! lexicalHandler = oldLexical; factory.setURIResolver(null); } --- 537,541 ---- // restore handlers ! receiver = oldReceiver; factory.setURIResolver(null); } *************** *** 762,766 **** } - /** Sets the xSLHandler attribute of the Serializer object */ protected void setXSLHandler() { if (templates == null) --- 558,561 ---- *************** *** 768,772 **** if (xslHandler != null) { SAXResult result = new SAXResult(); - result.setLexicalHandler(lexicalHandler); boolean processXInclude = getProperty( --- 563,566 ---- *************** *** 775,800 **** "yes"); if (processXInclude) ! result.setHandler(xinclude.getContentHandler()); else ! result.setHandler(contentHandler); xslHandler.setResult(result); if (processXInclude) { ! xinclude.setContentHandler(xslHandler); ! contentHandler = xinclude; } else ! contentHandler = xslHandler; } } - public void toSAX(NodeSet set, int start, int howmany) throws SAXException { - toSAX(set, start, howmany, 0); - } - - public void toSAX(NodeSet set, int start, int howmany, long queryTime) - throws SAXException { - setXSLHandler(); - serializeToSAX(set, start, howmany, queryTime); - } - public void toSAX(DocumentImpl doc) throws SAXException { if (outputProperties.getProperty(EXistOutputKeys.PROCESS_XSL_PI, "no").equals("yes")) { --- 569,584 ---- "yes"); if (processXInclude) ! result.setHandler((ContentHandler)xinclude.getReceiver()); else ! result.setHandler((ContentHandler)receiver); xslHandler.setResult(result); if (processXInclude) { ! xinclude.setReceiver(new ReceiverToSAX(xslHandler)); ! receiver = xinclude; } else ! receiver = new ReceiverToSAX(xslHandler); } } public void toSAX(DocumentImpl doc) throws SAXException { if (outputProperties.getProperty(EXistOutputKeys.PROCESS_XSL_PI, "no").equals("yes")) { *************** *** 804,822 **** } setXSLHandler(); ! serializeToSAX( doc, getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); } - public void toSAX(NodeImpl n) throws SAXException { - setXSLHandler(); - serializeToSAX( - n, - getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); - } - public void toSAX(NodeValue n) throws SAXException { setXSLHandler(); ! serializeToSAX( n, getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); --- 588,599 ---- } setXSLHandler(); ! serializeToReceiver( doc, getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); } public void toSAX(NodeValue n) throws SAXException { setXSLHandler(); ! serializeToReceiver( n, getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); *************** *** 826,839 **** setXSLHandler(); if(p.gid < 0) ! serializeToSAX(p.doc, getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); else ! serializeToSAX(p, getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); } ! public void toReceiver(NodeProxy p, Receiver receiver) throws SAXException { ! serializeToReceiver(p, receiver); } ! protected abstract void serializeToReceiver(NodeProxy p, Receiver receiver) throws SAXException; private String hasXSLPi(Document doc) { --- 603,654 ---- setXSLHandler(); if(p.gid < 0) ! serializeToReceiver(p.getDocument(), getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); else ! serializeToReceiver(p, getProperty(GENERATE_DOC_EVENTS, "false").equals("true")); } ! public void toReceiver(NodeProxy p) throws SAXException { ! serializeToReceiver(p, false); } ! ! protected abstract void serializeToReceiver(NodeProxy p, boolean generateDocEvent) throws SAXException; ! ! protected abstract void serializeToReceiver(DocumentImpl doc, boolean generateDocEvent) ! throws SAXException; ! ! protected void serializeToReceiver(NodeValue v, boolean generateDocEvents) !... [truncated message content] |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:25:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/http Modified Files: RESTServer.java HttpServerConnection.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: RESTServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/RESTServer.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** RESTServer.java 3 Aug 2004 15:26:00 -0000 1.15 --- RESTServer.java 12 Sep 2004 09:25:19 -0000 1.16 *************** *** 581,586 **** sax.setOutputProperties(outputProperties); serializer.setProperties(outputProperties); - serializer.setContentHandler(sax); serializer.setLexicalHandler(sax); AttributesImpl attrs = new AttributesImpl(); --- 581,586 ---- sax.setOutputProperties(outputProperties); serializer.setProperties(outputProperties); serializer.setLexicalHandler(sax); + serializer.setContentHandler(sax); AttributesImpl attrs = new AttributesImpl(); Index: HttpServerConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/HttpServerConnection.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** HttpServerConnection.java 23 Apr 2004 13:07:47 -0000 1.18 --- HttpServerConnection.java 12 Sep 2004 09:25:19 -0000 1.19 *************** *** 247,257 **** for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); ! docName = p.doc.getFileName(); ! doctype = p.doc.getDoctype(); if (map.containsKey(docName)) { counter = (NodeCount) map.get(docName); counter.inc(); } else { ! counter = new NodeCount(p.doc); map.put(docName, counter); } --- 247,257 ---- for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); ! docName = p.getDocument().getFileName(); ! doctype = p.getDocument().getDoctype(); if (map.containsKey(docName)) { counter = (NodeCount) map.get(docName); counter.inc(); } else { ! counter = new NodeCount(p.getDocument()); map.put(docName, counter); } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:25:54
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xmldb Modified Files: LocalXMLResource.java LocalCollection.java LocalResourceSet.java LocalXPathQueryService.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: LocalXPathQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalXPathQueryService.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** LocalXPathQueryService.java 2 Jul 2004 16:53:53 -0000 1.43 --- LocalXPathQueryService.java 12 Sep 2004 09:25:15 -0000 1.44 *************** *** 42,45 **** --- 42,46 ---- import org.exist.storage.XQueryPool; import org.exist.xquery.CompiledXQuery; + import org.exist.xquery.Pragma; import org.exist.xquery.XPathException; import org.exist.xquery.XQuery; *************** *** 259,262 **** --- 260,285 ---- } context.setBackwardsCompatibility(xpathCompatible); + checkPragmas(context); + } + + /** + * Check if the XQuery contains pragmas that define serialization settings. + * If yes, copy the corresponding settings to the current set of output properties. + * + * @param context + */ + protected void checkPragmas(XQueryContext context) throws XPathException { + Pragma pragma = context.getPragma(Pragma.SERIALIZE_QNAME); + if(pragma == null) + return; + String[] contents = pragma.tokenizeContents(); + for(int i = 0; i < contents.length; i++) { + String[] pair = Pragma.parseKeyValuePair(contents[i]); + if(pair == null) + throw new XPathException("Unknown parameter found in " + pragma.getQName().toString() + + ": '" + contents[i] + "'"); + LOG.debug("Setting serialization property from pragma: " + pair[0] + " = " + pair[1]); + properties.setProperty(pair[0], pair[1]); + } } Index: LocalCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollection.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** LocalCollection.java 16 Aug 2004 19:53:47 -0000 1.42 --- LocalCollection.java 12 Sep 2004 09:25:15 -0000 1.43 *************** *** 78,82 **** defaultProperties.setProperty(OutputKeys.ENCODING, "UTF-8"); defaultProperties.setProperty(OutputKeys.INDENT, "yes"); ! defaultProperties.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes"); defaultProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no"); } --- 78,82 ---- defaultProperties.setProperty(OutputKeys.ENCODING, "UTF-8"); defaultProperties.setProperty(OutputKeys.INDENT, "yes"); ! defaultProperties.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, "no"); defaultProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no"); } Index: LocalResourceSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalResourceSet.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** LocalResourceSet.java 10 May 2004 11:22:51 -0000 1.19 --- LocalResourceSet.java 12 Sep 2004 09:25:15 -0000 1.20 *************** *** 156,162 **** LocalCollection coll = collection; if (coll == null ! || p.doc.getCollection() == null ! || coll.getCollection().getId() != p.doc.getCollection().getId()) { ! coll = new LocalCollection(user, brokerPool, null, p.doc.getCollection().getName()); coll.properties = outputProperties; } --- 156,162 ---- LocalCollection coll = collection; if (coll == null ! || p.getDocument().getCollection() == null ! || coll.getCollection().getId() != p.getDocument().getCollection().getId()) { ! coll = new LocalCollection(user, brokerPool, null, p.getDocument().getCollection().getName()); coll.properties = outputProperties; } Index: LocalXMLResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalXMLResource.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** LocalXMLResource.java 12 Aug 2004 16:07:17 -0000 1.40 --- LocalXMLResource.java 12 Sep 2004 09:25:15 -0000 1.41 *************** *** 64,68 **** public LocalXMLResource(User user, BrokerPool pool, LocalCollection parent, NodeProxy p) throws XMLDBException { ! this(user, pool, parent, p.doc.getFileName(), p.gid); this.proxy = p; } --- 64,68 ---- public LocalXMLResource(User user, BrokerPool pool, LocalCollection parent, NodeProxy p) throws XMLDBException { ! this(user, pool, parent, p.getDocument().getFileName(), p.gid); this.proxy = p; } |
From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:25:40
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/soap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/soap Modified Files: QuerySoapBindingImpl.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: QuerySoapBindingImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/soap/QuerySoapBindingImpl.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** QuerySoapBindingImpl.java 2 Jul 2004 16:53:55 -0000 1.22 --- QuerySoapBindingImpl.java 12 Sep 2004 09:25:24 -0000 1.23 *************** *** 261,265 **** context.setStaticallyKnownDocuments(docs); ! XQueryLexer lexer = new XQueryLexer(new StringReader(query)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); --- 261,265 ---- context.setStaticallyKnownDocuments(docs); ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(query)); XQueryParser parser = new XQueryParser(lexer); XQueryTreeParser treeParser = new XQueryTreeParser(context); *************** *** 394,398 **** for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext();) { p = (NodeProxy) i.next(); ! path = p.doc.getCollection().getName() + '/' + p.doc.getFileName(); if (path.equals(docPath)) hitsByDoc.add(p); --- 394,398 ---- for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext();) { p = (NodeProxy) i.next(); ! path = p.getDocument().getCollection().getName() + '/' + p.getDocument().getFileName(); if (path.equals(docPath)) hitsByDoc.add(p); *************** *** 441,452 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy p = (NodeProxy)node; ! if ((documents = (TreeMap) collections.get(p.doc.getCollection().getName())) == null) { documents = new TreeMap(); ! collections.put(p.doc.getCollection().getName(), documents); } ! if ((hits = (Integer) documents.get(p.doc.getFileName())) == null) ! documents.put(p.doc.getFileName(), new Integer(1)); else ! documents.put(p.doc.getFileName(), new Integer(hits.intValue() + 1)); } } --- 441,452 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy p = (NodeProxy)node; ! if ((documents = (TreeMap) collections.get(p.getDocument().getCollection().getName())) == null) { documents = new TreeMap(); ! collections.put(p.getDocument().getCollection().getName(), documents); } ! if ((hits = (Integer) documents.get(p.getDocument().getFileName())) == null) ! documents.put(p.getDocument().getFileName(), new Integer(1)); else ! documents.put(p.getDocument().getFileName(), new Integer(hits.intValue() + 1)); } } |