zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #03189
[Merge] lp:~fcavalieri/zorba/pul-xdm into lp:zorba
Federico Cavalieri has proposed merging lp:~fcavalieri/zorba/pul-xdm into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~fcavalieri/zorba/pul-xdm/+merge/87233
Introduced a module for representing PUL as XDM instances and for restoring a PUL from its XDM representation.
--
The attached diff has been truncated due to its size.
https://code.launchpad.net/~fcavalieri/zorba/pul-xdm/+merge/87233
Your team Zorba Coders is subscribed to branch lp:zorba.
=== added file 'NOTICE.txt'
--- NOTICE.txt 1970-01-01 00:00:00 +0000
+++ NOTICE.txt 2012-01-02 09:53:25 +0000
@@ -0,0 +1,740 @@
+-----------
+Zorba 2.1.0
+-----------
+
+(Note: This file is generated automatically from NOTICE.xml.
+Please do not modify this file directly.)
+
+
+
+
+Apache 2
+
+ Copyright 2006-2011 The FLWOR Foundation
+
+ See LICENSE.txt for license information.
+
+ ------------------------
+ This product includes software developed at
+ The FLWOR Foundation (http://www.flworfound.org/).
+
+ ------------------------
+ Portions of this software were developed at the Systems
+ Group of the ETH Zurich, Switzerland.
+
+
+Other files used by this project:
+----------------------------------------------------
+
+src/zorbatypes/m_apm.h
+src/zorbatypes/mapm/
+
+Copyright: 1999-2007 Michael C. Ring
+Website: http://www.tc.umn.edu/~ringx004/mapm-main.html
+
+ This software is Freeware.
+
+ Permission to use, copy, and distribute this software and its
+ documentation for any purpose with or without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and
+ that both that copyright notice and this permission notice appear
+ in supporting documentation.
+
+ Permission to modify the software is granted. Permission to distribute
+ the modified code is granted. Modifications are to be distributed by
+ using the file 'license.txt' as a template to modify the file header.
+ 'license.txt' is available in the official MAPM distribution.
+
+ To distribute modified source code, insert the file 'license.txt'
+ at the top of all modified source code files and edit accordingly.
+
+ This software is provided "as is" without express or implied warranty.
+
+----------------------------------------------------
+
+src/zorbamisc/config/stdint.h
+
+Copyright: 2006 Alexander Chemeris
+
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The name of the author may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------
+
+src/zorbautils/stemmer/
+
+Copyright: 2001 Dr. Martin Porter
+
+
+ All the software given out on this Snowball site is covered by the BSD
+ License (see http://www.opensource.org/licenses/bsd-license.html), with
+ Copyright (c) 2001, Dr Martin Porter, and (for the Java developments)
+ Copyright (c) 2002, Richard Boulton.
+
+ Essentially, all this means is that you can do what you like with the code,
+ except claim another Copyright for it, or claim that it is issued under a
+ different license. The software is also issued without warranties, which
+ means that if anyone suffers through its use, they cannot come back and sue
+ you. You also have to alert anyone to whom you give the Snowball software to
+ the fact that it is covered by the BSD license.
+
+ We have not bothered to insert the licensing arrangement into the text of
+ the Snowball software.
+
+----------------------------------------------------
+
+src/util/less.h
+
+Copyright: 1998 Paul J. Lucas
+
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ o Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ o Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ o The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------
+
+src/util/auto_vector.h (has been modified)
+
+Copyright: 2003 Reliable Software
+
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ o Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ o Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ o The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------
+
+cmake_modules/FindBoost.cmake
+
+Copyright:
+ 2006-2008 Andreas Schneider <mail@xxxxxxxxxxxx>
+ 2007 Wengo
+ 2007 Mike Jackson
+ 2008 Andreas Pakulat <apaku@xxxxxx>
+
+
+
+ Redistribution AND use is allowed according to the terms of the New BSD license.
+ For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+----------------------------------------------------
+
+cmake_modules/FindJNI.cmake
+cmake_modules/FindPythonLibs.cmake
+cmake_modules/FindSWIG.cmake
+
+Copyright: 2001-2009 Kitware, Inc.
+
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the names of Kitware, Inc., the Insight Software Consortium,
+ nor the names of their contributors may be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ ------------------------------------------------------------------------------
+
+ The above copyright and license notice applies to distributions of
+ CMake in source and binary form. Some source files contain additional
+ notices of original copyright by their contributors; see each source
+ for details. Third-party software packages supplied with CMake under
+ compatible licenses provide their own copyright notices documented in
+ corresponding subdirectories.
+
+ ------------------------------------------------------------------------------
+
+ CMake was initially developed by Kitware with the following sponsorship:
+
+ * National Library of Medicine at the National Institutes of Health
+ as part of the Insight Segmentation and Registration Toolkit (ITK).
+
+ * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
+ Visualization Initiative.
+
+ * National Alliance for Medical Image Computing (NAMIC) is funded by the
+ National Institutes of Health through the NIH Roadmap for Medical Research,
+ Grant U54 EB005149.
+
+ * Kitware, Inc.
+
+----------------------------------------------------
+
+/xml.xsd
+
+Copyright: 2001 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
+
+
+ All Rights Reserved. This work is distributed under the W3C Software License [1] 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.
+
+ W3C Software Notice and License
+
+ This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
+
+ License
+
+ By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
+
+ Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
+ •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+ •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
+ •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
+
+ Disclaimers
+
+ THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
+
+----------------------------------------------------
+
+schemas/xslt-xquery-serialization.xsd
+
+Copyright: 2010 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
+
+
+ All Rights Reserved. This work is distributed under the W3C Software License [1] 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.
+
+ W3C Software Notice and License
+
+ This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
+
+ License
+
+ By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
+
+ Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
+ •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+ •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
+ •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
+
+ Disclaimers
+
+ THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
+
+----------------------------------------------------
+
+modules/w3c/xpath-functions.xsd
+
+Copyright: 2005 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
+
+
+ All Rights Reserved. This work is distributed under the W3C Software License [1] 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.
+
+ W3C Software Notice and License
+
+ This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
+
+ License
+
+ By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
+
+ Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
+ •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+ •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
+ •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
+
+ Disclaimers
+
+ THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
+
+----------------------------------------------------
+
+include/xqc.h
+
+Copyright: 2008, Matthias Brantner, John Snelson
+
+
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the developers nor the names of contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------
+
+modules/functx/functx.xq
+
+Copyright: 2007 Datypic
+
+
+ : This library 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.1 of the License.
+
+ : 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
+ : Lesser General Public License for more details.
+
+ : You should have received a copy of the GNU Lesser General Public
+ : License along with this library; if not, write to the Free Software
+ : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+----------------------------------------------------
+
+src/compiler/parser/FlexLexer.h
+
+Copyright: 1993 The Regents of the University of California
+
+
+ // All rights reserved.
+ //
+ // This code is derived from software contributed to Berkeley by
+ // Kent Williams and Tom Epperly.
+ //
+ // Redistribution and use in source and binary forms, with or without
+ // modification, are permitted provided that the following conditions
+ // are met:
+
+ // 1. Redistributions of source code must retain the above copyright
+ // notice, this list of conditions and the following disclaimer.
+ // 2. Redistributions in binary form must reproduce the above copyright
+ // notice, this list of conditions and the following disclaimer in the
+ // documentation and/or other materials provided with the distribution.
+
+ // Neither the name of the University nor the names of its contributors
+ // may be used to endorse or promote products derived from this software
+ // without specific prior written permission.
+
+ // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ // PURPOSE.
+
+----------------------------------------------------
+
+src/diagnostics/StackWalker.cpp
+src/diagnostics/StackWalker.h
+
+Copyright: 2005 Jochen Kalmbach
+
+
+ Under BSD License: http://www.opensource.org/licenses/bsd-license.php
+
+----------------------------------------------------
+
+src/util/singleton.h
+src/util/threads.h
+
+Copyright: 2001 Andrei Alexandrescu
+
+
+ This code accompanies the book:
+ Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+ Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+ Permission to use, copy, modify, distribute and sell this software for any
+ purpose is hereby granted without fee, provided that the above copyright
+ notice appear in all copies and that both that copyright notice and this
+ permission notice appear in supporting documentation.
+ The author or Addison-Wesley Longman make no representations about the
+ suitability of this software for any purpose. It is provided "as is"
+ without express or implied warranty.
+
+
+External libraries used by this project:
+----------------------------------------------------
+
+Name: LIBXML2
+Preferred version: 2.2.16 or higher
+Is mandatory: true
+Website: http://xmlsoft.org/
+License: MIT
+Copyright: 1998-2002 Daniel Veillard. All Rights Reserved.
+External notice:
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name of Daniel Veillard shall not
+ be used in advertising or otherwise to promote the sale, use or other deal-
+ ings in this Software without prior written authorization from him.
+
+----------------------------------------------------
+
+Name: LIBXSLT
+Preferred version: 1.1.26
+Is mandatory: false
+Website: http://xmlsoft.org/XSLT/
+License: MIT
+Copyright: 2001-2002 Daniel Veillard. All Rights Reserved.
+External notice:
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+ Except as contained in this notice, the name of Daniel Veillard shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from him.
+
+
+----------------------------------------------------
+
+Name: ICU4C
+Preferred version: 3.6 or higher
+Is mandatory: true
+Website: http://www.icu-project.org/
+License: ICU License
+Copyright: 1995-2011 International Business Machines Corporation and others
+External notice:
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
+
+----------------------------------------------------
+
+Name: CURL
+Preferred version: above 7.12
+Is mandatory: false
+Website: http://curl.haxx.se/
+License: MIT/X derivate license
+Copyright: 1996 - 2011, Daniel Stenberg, <daniel@xxxxxxx>.
+External notice:
+
+ All rights reserved.
+
+ Permission to use, copy, modify, and distribute this software for any purpose
+ with or without fee is hereby granted, provided that the above copyright
+ notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name of a copyright holder shall not
+ be used in advertising or otherwise to promote the sale, use or other dealings
+ in this Software without prior written authorization of the copyright holder.
+
+----------------------------------------------------
+
+Name: ICONV
+Preferred version: above 1.12
+Is mandatory: true
+Website: http://www.gnu.org/software/libiconv/
+License: LGPL
+Copyright: 1998, 2010 Free Software Foundation, Inc.
+External notice:
+
+----------------------------------------------------
+
+Name: ZLIB
+Preferred version: 1.2.5
+Is mandatory: true
+Website: http://www.zlib.net/
+Copyright: 1995-2004 Jean-loup Gailly and Mark Adler
+External notice:
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly jloup@xxxxxxxx
+ Mark Adler madler@xxxxxxxxxxxxxxxxxx
+
+----------------------------------------------------
+
+Name: XERCES
+Preferred version: 2.8.0 or higher
+Is mandatory: true
+Website: http://xerces.apache.org/xerces-c/
+License: Apache 2
+Copyright: Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.
+External notice:
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+----------------------------------------------------
+
+Name: BOOST (boost_filesystem)
+Preferred version: 1.32 or higher
+Is mandatory: false
+Website: http://www.boost.org/
+License: Boost Software License v1.0
+Copyright:
+ Beman Dawes, David Abrahams, 1998-2005.
+ Rene Rivera 2004-2007
+
+External notice:
+
+ Permission is hereby granted, free of charge, to any person or organization
+ obtaining a copy of the software and accompanying documentation covered by
+ this license (the "Software") to use, reproduce, display, distribute,
+ execute, and transmit the Software, and to prepare derivative works of the
+ Software, and to permit third-parties to whom the Software is furnished to
+ do so, all subject to the following:
+
+ The copyright notices in the Software and this entire statement, including
+ the above license grant, this restriction and the following disclaimer,
+ must be included in all copies of the Software, in whole or in part, and
+ all derivative works of the Software, unless such copies or derivative
+ works are solely in the form of machine-executable object code generated by
+ a source language processor.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+
+External applications used by this project:
+----------------------------------------------------
+
+Name: FLEX
+Preferred version: 2.5.33
+Is mandatory: false
+Website: http://flex.sourceforge.net/
+Copyright:
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The Flex Project.
+ 1990, 1997 The Regents of the University of California. All rights reserved.
+
+External notice:
+
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+ Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+----------------------------------------------------
+
+Name: BISON
+Preferred version: 2.4 or higher
+Is mandatory: false
+Website: http://www.gnu.org/software/bison/
+License: GPL
+Copyright: 1998, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+External notice:
+
+----------------------------------------------------
+
+Name: DOXYGEN
+Preferred version: v1.7.4
+Is mandatory: false
+Website: www.doxygen.org
+License: GPL
+Copyright: 1997-2011 by Dimitri van Heesch
+External notice:
+
+ Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted.
+ No representations are made about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+ See the GNU General Public License for more details.
+
+ Documents produced by doxygen are derivative works derived from the input used in their production; they are not affected by this license.
+
+----------------------------------------------------
+
+Name: CMAKE
+Preferred version: 2.8.4
+Is mandatory: true
+Website: http://www.cmake.org/
+License: Creative Commons Attribution-NoDerivs 3.0 Unported License
+Copyright: 2000-2009 Kitware, Inc., Insight Software Consortium. All rights reserved.
+External notice:
+
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+ Neither the names of Kitware, Inc., the Insight Software Consortium, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------
+
+Name: SWIG
+Preferred version: 2.0.4 or above
+Is mandatory: false
+Website: http://www.swig.org/
+License: GPL
+Copyright:
+ 1995-2011 The SWIG Developers
+ 2005-2006 Arizona Board of Regents (University of Arizona).
+ 1998-2005 University of Chicago.
+ 1995-1998 The University of Utah and the Regents of the University of California
+
+External notice:
+
+ SWIG is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version. See the LICENSE-GPL file for
+ the full terms of the GNU General Public license version 3.
+
+ Portions of SWIG are also licensed under the terms of the licenses
+ in the file LICENSE-UNIVERSITIES. You must observe the terms of
+ these licenses, as well as the terms of the GNU General Public License,
+ when you distribute SWIG.
+
+ The SWIG library and examples, under the Lib and Examples top level
+ directories, are distributed under the following terms:
+
+ You may copy, modify, distribute, and make derivative works based on
+ this software, in source code or object code form, without
+ restriction. If you distribute the software to others, you may do
+ so according to the terms of your choice. This software is offered as
+ is, without warranty of any kind.
+
+ See the COPYRIGHT file for a list of contributors to SWIG and their
+ copyright notices.
+
\ No newline at end of file
=== removed file 'NOTICE.txt'
--- NOTICE.txt 2011-10-21 08:09:17 +0000
+++ NOTICE.txt 1970-01-01 00:00:00 +0000
@@ -1,740 +0,0 @@
------------
-Zorba 2.1.0
------------
-
-(Note: This file is generated automatically from NOTICE.xml.
-Please do not modify this file directly.)
-
-
-
-
-Apache 2
-
- Copyright 2006-2011 The FLWOR Foundation
-
- See LICENSE.txt for license information.
-
- ------------------------
- This product includes software developed at
- The FLWOR Foundation (http://www.flworfound.org/).
-
- ------------------------
- Portions of this software were developed at the Systems
- Group of the ETH Zurich, Switzerland.
-
-
-Other files used by this project:
-----------------------------------------------------
-
-src/zorbatypes/m_apm.h
-src/zorbatypes/mapm/
-
-Copyright: 1999-2007 Michael C. Ring
-Website: http://www.tc.umn.edu/~ringx004/mapm-main.html
-
- This software is Freeware.
-
- Permission to use, copy, and distribute this software and its
- documentation for any purpose with or without fee is hereby granted,
- provided that the above copyright notice appear in all copies and
- that both that copyright notice and this permission notice appear
- in supporting documentation.
-
- Permission to modify the software is granted. Permission to distribute
- the modified code is granted. Modifications are to be distributed by
- using the file 'license.txt' as a template to modify the file header.
- 'license.txt' is available in the official MAPM distribution.
-
- To distribute modified source code, insert the file 'license.txt'
- at the top of all modified source code files and edit accordingly.
-
- This software is provided "as is" without express or implied warranty.
-
-----------------------------------------------------
-
-src/zorbamisc/config/stdint.h
-
-Copyright: 2006 Alexander Chemeris
-
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. The name of the author may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-src/zorbautils/stemmer/
-
-Copyright: 2001 Dr. Martin Porter
-
-
- All the software given out on this Snowball site is covered by the BSD
- License (see http://www.opensource.org/licenses/bsd-license.html), with
- Copyright (c) 2001, Dr Martin Porter, and (for the Java developments)
- Copyright (c) 2002, Richard Boulton.
-
- Essentially, all this means is that you can do what you like with the code,
- except claim another Copyright for it, or claim that it is issued under a
- different license. The software is also issued without warranties, which
- means that if anyone suffers through its use, they cannot come back and sue
- you. You also have to alert anyone to whom you give the Snowball software to
- the fact that it is covered by the BSD license.
-
- We have not bothered to insert the licensing arrangement into the text of
- the Snowball software.
-
-----------------------------------------------------
-
-src/util/less.h
-
-Copyright: 1998 Paul J. Lucas
-
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- o Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- o Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- o The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-src/util/auto_vector.h (has been modified)
-
-Copyright: 2003 Reliable Software
-
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- o Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- o Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- o The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-cmake_modules/FindBoost.cmake
-
-Copyright:
- 2006-2008 Andreas Schneider <mail@xxxxxxxxxxxx>
- 2007 Wengo
- 2007 Mike Jackson
- 2008 Andreas Pakulat <apaku@xxxxxx>
-
-
-
- Redistribution AND use is allowed according to the terms of the New BSD license.
- For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-----------------------------------------------------
-
-cmake_modules/FindJNI.cmake
-cmake_modules/FindPythonLibs.cmake
-cmake_modules/FindSWIG.cmake
-
-Copyright: 2001-2009 Kitware, Inc.
-
-
- Distributed under the OSI-approved BSD License (the "License");
- see accompanying file Copyright.txt for details.
-
- This software is distributed WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the License for more information.
-
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the names of Kitware, Inc., the Insight Software Consortium,
- nor the names of their contributors may be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- ------------------------------------------------------------------------------
-
- The above copyright and license notice applies to distributions of
- CMake in source and binary form. Some source files contain additional
- notices of original copyright by their contributors; see each source
- for details. Third-party software packages supplied with CMake under
- compatible licenses provide their own copyright notices documented in
- corresponding subdirectories.
-
- ------------------------------------------------------------------------------
-
- CMake was initially developed by Kitware with the following sponsorship:
-
- * National Library of Medicine at the National Institutes of Health
- as part of the Insight Segmentation and Registration Toolkit (ITK).
-
- * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
- Visualization Initiative.
-
- * National Alliance for Medical Image Computing (NAMIC) is funded by the
- National Institutes of Health through the NIH Roadmap for Medical Research,
- Grant U54 EB005149.
-
- * Kitware, Inc.
-
-----------------------------------------------------
-
-/xml.xsd
-
-Copyright: 2001 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
-
-
- All Rights Reserved. This work is distributed under the W3C Software License [1] 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.
-
- W3C Software Notice and License
-
- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
-
- License
-
- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
-
- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
-
- Disclaimers
-
- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
-
- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
-
- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
-
-----------------------------------------------------
-
-schemas/xslt-xquery-serialization.xsd
-
-Copyright: 2010 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
-
-
- All Rights Reserved. This work is distributed under the W3C Software License [1] 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.
-
- W3C Software Notice and License
-
- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
-
- License
-
- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
-
- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
-
- Disclaimers
-
- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
-
- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
-
- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
-
-----------------------------------------------------
-
-modules/w3c/xpath-functions.xsd
-
-Copyright: 2005 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
-
-
- All Rights Reserved. This work is distributed under the W3C Software License [1] 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.
-
- W3C Software Notice and License
-
- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
-
- License
-
- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
-
- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
-
- Disclaimers
-
- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
-
- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
-
- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
-
-----------------------------------------------------
-
-include/xqc.h
-
-Copyright: 2008, Matthias Brantner, John Snelson
-
-
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the developers nor the names of contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-modules/functx/functx.xq
-
-Copyright: 2007 Datypic
-
-
- : This library 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.1 of the License.
-
- : 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
- : Lesser General Public License for more details.
-
- : You should have received a copy of the GNU Lesser General Public
- : License along with this library; if not, write to the Free Software
- : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-----------------------------------------------------
-
-src/compiler/parser/FlexLexer.h
-
-Copyright: 1993 The Regents of the University of California
-
-
- // All rights reserved.
- //
- // This code is derived from software contributed to Berkeley by
- // Kent Williams and Tom Epperly.
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions
- // are met:
-
- // 1. Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- // 2. Redistributions in binary form must reproduce the above copyright
- // notice, this list of conditions and the following disclaimer in the
- // documentation and/or other materials provided with the distribution.
-
- // Neither the name of the University nor the names of its contributors
- // may be used to endorse or promote products derived from this software
- // without specific prior written permission.
-
- // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- // PURPOSE.
-
-----------------------------------------------------
-
-src/diagnostics/StackWalker.cpp
-src/diagnostics/StackWalker.h
-
-Copyright: 2005 Jochen Kalmbach
-
-
- Under BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-----------------------------------------------------
-
-src/util/singleton.h
-src/util/threads.h
-
-Copyright: 2001 Andrei Alexandrescu
-
-
- This code accompanies the book:
- Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
- Patterns Applied". Copyright (c) 2001. Addison-Wesley.
- Permission to use, copy, modify, distribute and sell this software for any
- purpose is hereby granted without fee, provided that the above copyright
- notice appear in all copies and that both that copyright notice and this
- permission notice appear in supporting documentation.
- The author or Addison-Wesley Longman make no representations about the
- suitability of this software for any purpose. It is provided "as is"
- without express or implied warranty.
-
-
-External libraries used by this project:
-----------------------------------------------------
-
-Name: LIBXML2
-Preferred version: 2.2.16 or higher
-Is mandatory: true
-Website: http://xmlsoft.org/
-License: MIT
-Copyright: 1998-2002 Daniel Veillard. All Rights Reserved.
-External notice:
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name of Daniel Veillard shall not
- be used in advertising or otherwise to promote the sale, use or other deal-
- ings in this Software without prior written authorization from him.
-
-----------------------------------------------------
-
-Name: LIBXSLT
-Preferred version: 1.1.26
-Is mandatory: false
-Website: http://xmlsoft.org/XSLT/
-License: MIT
-Copyright: 2001-2002 Daniel Veillard. All Rights Reserved.
-External notice:
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
- Except as contained in this notice, the name of Daniel Veillard shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from him.
-
-
-----------------------------------------------------
-
-Name: ICU4C
-Preferred version: 3.6 or higher
-Is mandatory: true
-Website: http://www.icu-project.org/
-License: ICU License
-Copyright: 1995-2011 International Business Machines Corporation and others
-External notice:
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
- Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
-
-----------------------------------------------------
-
-Name: CURL
-Preferred version: above 7.12
-Is mandatory: false
-Website: http://curl.haxx.se/
-License: MIT/X derivate license
-Copyright: 1996 - 2011, Daniel Stenberg, <daniel@xxxxxxx>.
-External notice:
-
- All rights reserved.
-
- Permission to use, copy, modify, and distribute this software for any purpose
- with or without fee is hereby granted, provided that the above copyright
- notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
- NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
- OR OTHER DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name of a copyright holder shall not
- be used in advertising or otherwise to promote the sale, use or other dealings
- in this Software without prior written authorization of the copyright holder.
-
-----------------------------------------------------
-
-Name: ICONV
-Preferred version: above 1.12
-Is mandatory: true
-Website: http://www.gnu.org/software/libiconv/
-License: LGPL
-Copyright: 1998, 2010 Free Software Foundation, Inc.
-External notice:
-
-----------------------------------------------------
-
-Name: ZLIB
-Preferred version: 1.2.5
-Is mandatory: true
-Website: http://www.zlib.net/
-Copyright: 1995-2004 Jean-loup Gailly and Mark Adler
-External notice:
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly jloup@xxxxxxxx
- Mark Adler madler@xxxxxxxxxxxxxxxxxx
-
-----------------------------------------------------
-
-Name: XERCES
-Preferred version: 2.8.0 or higher
-Is mandatory: true
-Website: http://xerces.apache.org/xerces-c/
-License: Apache 2
-Copyright: Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.
-External notice:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-----------------------------------------------------
-
-Name: BOOST (boost_filesystem)
-Preferred version: 1.32 or higher
-Is mandatory: false
-Website: http://www.boost.org/
-License: Boost Software License v1.0
-Copyright:
- Beman Dawes, David Abrahams, 1998-2005.
- Rene Rivera 2004-2007
-
-External notice:
-
- Permission is hereby granted, free of charge, to any person or organization
- obtaining a copy of the software and accompanying documentation covered by
- this license (the "Software") to use, reproduce, display, distribute,
- execute, and transmit the Software, and to prepare derivative works of the
- Software, and to permit third-parties to whom the Software is furnished to
- do so, all subject to the following:
-
- The copyright notices in the Software and this entire statement, including
- the above license grant, this restriction and the following disclaimer,
- must be included in all copies of the Software, in whole or in part, and
- all derivative works of the Software, unless such copies or derivative
- works are solely in the form of machine-executable object code generated by
- a source language processor.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
-
-External applications used by this project:
-----------------------------------------------------
-
-Name: FLEX
-Preferred version: 2.5.33
-Is mandatory: false
-Website: http://flex.sourceforge.net/
-Copyright:
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The Flex Project.
- 1990, 1997 The Regents of the University of California. All rights reserved.
-
-External notice:
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
- Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-----------------------------------------------------
-
-Name: BISON
-Preferred version: 2.4 or higher
-Is mandatory: false
-Website: http://www.gnu.org/software/bison/
-License: GPL
-Copyright: 1998, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-External notice:
-
-----------------------------------------------------
-
-Name: DOXYGEN
-Preferred version: v1.7.4
-Is mandatory: false
-Website: www.doxygen.org
-License: GPL
-Copyright: 1997-2011 by Dimitri van Heesch
-External notice:
-
- Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted.
- No representations are made about the suitability of this software for any purpose.
- It is provided "as is" without express or implied warranty.
- See the GNU General Public License for more details.
-
- Documents produced by doxygen are derivative works derived from the input used in their production; they are not affected by this license.
-
-----------------------------------------------------
-
-Name: CMAKE
-Preferred version: 2.8.4
-Is mandatory: true
-Website: http://www.cmake.org/
-License: Creative Commons Attribution-NoDerivs 3.0 Unported License
-Copyright: 2000-2009 Kitware, Inc., Insight Software Consortium. All rights reserved.
-External notice:
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
- Neither the names of Kitware, Inc., the Insight Software Consortium, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-Name: SWIG
-Preferred version: 2.0.4 or above
-Is mandatory: false
-Website: http://www.swig.org/
-License: GPL
-Copyright:
- 1995-2011 The SWIG Developers
- 2005-2006 Arizona Board of Regents (University of Arizona).
- 1998-2005 University of Chicago.
- 1995-1998 The University of Utah and the Regents of the University of California
-
-External notice:
-
- SWIG is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version. See the LICENSE-GPL file for
- the full terms of the GNU General Public license version 3.
-
- Portions of SWIG are also licensed under the terms of the licenses
- in the file LICENSE-UNIVERSITIES. You must observe the terms of
- these licenses, as well as the terms of the GNU General Public License,
- when you distribute SWIG.
-
- The SWIG library and examples, under the Lib and Examples top level
- directories, are distributed under the following terms:
-
- You may copy, modify, distribute, and make derivative works based on
- this software, in source code or object code form, without
- restriction. If you distribute the software to others, you may do
- so according to the terms of your choice. This software is offered as
- is, without warranty of any kind.
-
- See the COPYRIGHT file for a list of contributors to SWIG and their
- copyright notices.
-
\ No newline at end of file
=== added file 'bin/path_util.cpp'
--- bin/path_util.cpp 1970-01-01 00:00:00 +0000
+++ bin/path_util.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "path_util.h"
+
+#include <stdlib.h>
+//#include "zorba/zorba_string.h"
+#include "zorba/util/path.h"
+
+#include "util.h"
+#include "zorbacmdproperties.h"
+#include <zorba/static_context.h>
+
+namespace zorba {
+
+namespace PathUtil {
+
+static std::string
+getPathFromEnvironment(std::string const& aEnvVar)
+{
+#ifdef WIN32
+ char* lBuffer;
+ size_t lLen=0;
+ errno_t lErr = getenv_s(&lLen, NULL, 0, aEnvVar.c_str());
+ if (lErr || !lLen) return "";
+ lBuffer = (char*)malloc(lLen * sizeof(char));
+ if (!lBuffer) return "";
+ getenv_s(&lLen, lBuffer, lLen, aEnvVar.c_str());
+ std::string lRes(lBuffer);
+ free(lBuffer);
+ return lRes;
+#else
+ const char* lEnvValue = getenv(aEnvVar.c_str());
+ return lEnvValue != 0 ? lEnvValue : "";
+#endif
+}
+
+
+static void
+tokenizePath(
+ const std::string& aPathStr,
+ std::vector<String>& aResult)
+{
+ std::vector<std::string> lPath;
+#ifdef WIN32
+ Util::tokenize(aPathStr, ";", lPath);
+#else
+ Util::tokenize(aPathStr, ":", lPath);
+#endif
+ for (std::vector<std::string>::iterator lIter = lPath.begin();
+ lIter != lPath.end(); ++lIter) {
+ aResult.push_back(*lIter);
+ }
+}
+
+void
+setPathsOnContext(
+ const ZorbaCMDProperties& aProperties,
+ StaticContext_t& aStaticCtx)
+{
+ std::vector<String> lPath;
+ std::string lPathStr, lEnvStr;
+
+ // Compute the current working directory to append to all paths.
+ filesystem_path lCWD;
+
+ // setModulePaths() *overwrites* the URI path and lib path, so there's no
+ // sense in calling both. So if either --module-path or ZORBA_MODULE_PATH
+ // exists, just use those.
+ aProperties.getModulePath(lPathStr);
+ lEnvStr = getPathFromEnvironment("ZORBA_MODULE_PATH");
+ if (lPathStr.length() > 0 || lEnvStr.length() > 0) {
+ tokenizePath(lPathStr, lPath);
+ tokenizePath(lEnvStr, lPath);
+ lPath.push_back(lCWD.get_path());
+ aStaticCtx->setModulePaths(lPath);
+ }
+ else {
+ // Compute and set URI path
+ aProperties.getURIPath(lPathStr);
+ tokenizePath(lPathStr, lPath);
+ lEnvStr = getPathFromEnvironment("ZORBA_URI_PATH");
+ tokenizePath(lEnvStr, lPath);
+ lPath.push_back(lCWD.get_path());
+ aStaticCtx->setURIPath(lPath);
+ lPath.clear();
+
+ // Compute and set lib path
+ aProperties.getLibPath(lPathStr);
+ tokenizePath(lPathStr, lPath);
+ lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");
+ lPath.push_back(lCWD.get_path());
+ tokenizePath(lEnvStr, lPath);
+ aStaticCtx->setLibPath(lPath);
+ }
+}
+
+} /* namespace ModulePath */
+
+} /* namespace zorba */
=== removed file 'bin/path_util.cpp'
--- bin/path_util.cpp 2011-10-21 08:07:43 +0000
+++ bin/path_util.cpp 1970-01-01 00:00:00 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "path_util.h"
-
-#include <stdlib.h>
-//#include "zorba/zorba_string.h"
-#include "zorba/util/path.h"
-
-#include "util.h"
-#include "zorbacmdproperties.h"
-#include <zorba/static_context.h>
-
-namespace zorba {
-
-namespace PathUtil {
-
-static std::string
-getPathFromEnvironment(std::string const& aEnvVar)
-{
-#ifdef WIN32
- char* lBuffer;
- size_t lLen=0;
- errno_t lErr = getenv_s(&lLen, NULL, 0, aEnvVar.c_str());
- if (lErr || !lLen) return "";
- lBuffer = (char*)malloc(lLen * sizeof(char));
- if (!lBuffer) return "";
- getenv_s(&lLen, lBuffer, lLen, aEnvVar.c_str());
- std::string lRes(lBuffer);
- free(lBuffer);
- return lRes;
-#else
- const char* lEnvValue = getenv(aEnvVar.c_str());
- return lEnvValue != 0 ? lEnvValue : "";
-#endif
-}
-
-
-static void
-tokenizePath(
- const std::string& aPathStr,
- std::vector<String>& aResult)
-{
- std::vector<std::string> lPath;
-#ifdef WIN32
- Util::tokenize(aPathStr, ";", lPath);
-#else
- Util::tokenize(aPathStr, ":", lPath);
-#endif
- for (std::vector<std::string>::iterator lIter = lPath.begin();
- lIter != lPath.end(); ++lIter) {
- aResult.push_back(*lIter);
- }
-}
-
-void
-setPathsOnContext(
- const ZorbaCMDProperties& aProperties,
- StaticContext_t& aStaticCtx)
-{
- std::vector<String> lPath;
- std::string lPathStr, lEnvStr;
-
- // Compute the current working directory to append to all paths.
- filesystem_path lCWD;
-
- // setModulePaths() *overwrites* the URI path and lib path, so there's no
- // sense in calling both. So if either --module-path or ZORBA_MODULE_PATH
- // exists, just use those.
- aProperties.getModulePath(lPathStr);
- lEnvStr = getPathFromEnvironment("ZORBA_MODULE_PATH");
- if (lPathStr.length() > 0 || lEnvStr.length() > 0) {
- tokenizePath(lPathStr, lPath);
- tokenizePath(lEnvStr, lPath);
- lPath.push_back(lCWD.get_path());
- aStaticCtx->setModulePaths(lPath);
- }
- else {
- // Compute and set URI path
- aProperties.getURIPath(lPathStr);
- tokenizePath(lPathStr, lPath);
- lEnvStr = getPathFromEnvironment("ZORBA_URI_PATH");
- tokenizePath(lEnvStr, lPath);
- lPath.push_back(lCWD.get_path());
- aStaticCtx->setURIPath(lPath);
- lPath.clear();
-
- // Compute and set lib path
- aProperties.getLibPath(lPathStr);
- tokenizePath(lPathStr, lPath);
- lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");
- lPath.push_back(lCWD.get_path());
- tokenizePath(lEnvStr, lPath);
- aStaticCtx->setLibPath(lPath);
- }
-}
-
-} /* namespace ModulePath */
-
-} /* namespace zorba */
=== added file 'bin/path_util.h'
--- bin/path_util.h 1970-01-01 00:00:00 +0000
+++ bin/path_util.h 2012-01-02 09:53:25 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_MODULE_PATH_H
+#define ZORBA_MODULE_PATH_H
+
+#include <vector>
+#include <string>
+#include <zorba/api_shared_types.h>
+
+class ZorbaCMDProperties;
+
+namespace zorba {
+
+ class String;
+
+ namespace PathUtil {
+
+ void
+ setPathsOnContext(const ZorbaCMDProperties& aProperties,
+ zorba::StaticContext_t& aStaticCtx);
+
+
+ }
+} /* namespace zorba */
+
+#endif
=== removed file 'bin/path_util.h'
--- bin/path_util.h 2011-10-21 08:07:43 +0000
+++ bin/path_util.h 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ZORBA_MODULE_PATH_H
-#define ZORBA_MODULE_PATH_H
-
-#include <vector>
-#include <string>
-#include <zorba/api_shared_types.h>
-
-class ZorbaCMDProperties;
-
-namespace zorba {
-
- class String;
-
- namespace PathUtil {
-
- void
- setPathsOnContext(const ZorbaCMDProperties& aProperties,
- zorba::StaticContext_t& aStaticCtx);
-
-
- }
-} /* namespace zorba */
-
-#endif
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2011-12-21 14:40:33 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2012-01-02 09:53:25 +0000
@@ -494,8 +494,6 @@
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0029_REFERENCE_ALREADY_PRESENT;
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0030_NO_CURRENT_REFERENCE;
-
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0039_XQUERY_HAS_ITERATOR_ALREADY;
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0040_ITERATOR_NOT_OPEN;
=== modified file 'modules/com/zorba-xquery/www/modules/CMakeLists.txt'
--- modules/com/zorba-xquery/www/modules/CMakeLists.txt 2011-12-21 14:40:33 +0000
+++ modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-01-02 09:53:25 +0000
@@ -75,6 +75,15 @@
DECLARE_ZORBA_MODULE(FILE xqdoc2xhtml/index.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/xqdoc2xhtml/")
+#Pul
+DECLARE_ZORBA_MODULE(FILE store/pul/representation.xq VERSION 2.0
+ URI "http://www.zorba-xquery.com/modules/store/pul/representation")
+DECLARE_ZORBA_MODULE(FILE store/pul/errors.xq VERSION 2.0
+ URI "http://www.zorba-xquery.com/modules/store/pul/errors")
+DECLARE_ZORBA_SCHEMA(FILE store/pul/representation.xsd
+ URI "http://www.zorba-xquery.com/modules/store/pul/representation")
+
+
DECLARE_ZORBA_MODULE(FILE store/data-structures/unordered-map.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map")
DECLARE_ZORBA_MODULE(FILE store/documents/dynamic.xq VERSION 2.0
=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2011-12-21 14:40:33 +0000
+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2012-01-02 09:53:25 +0000
@@ -289,10 +289,6 @@
(:~
:)
-declare variable $zerr:ZAPI0030 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0030");
-
-(:~
-:)
declare variable $zerr:ZAPI0039 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0039");
(:~
=== added directory 'modules/com/zorba-xquery/www/modules/store/pul'
=== added file 'modules/com/zorba-xquery/www/modules/store/pul/errors.xq'
--- modules/com/zorba-xquery/www/modules/store/pul/errors.xq 1970-01-01 00:00:00 +0000
+++ modules/com/zorba-xquery/www/modules/store/pul/errors.xq 2012-01-02 09:53:25 +0000
@@ -0,0 +1,69 @@
+(:
+ : Copyright 2006-2011 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+:)
+
+(:~
+ : This module defines all errors for the PUL module.
+ :)
+module namespace err = "http://www.zorba-xquery.com/modules/store/pul/errors";
+
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
+declare option ver:module-version "2.0";
+
+
+(:~
+ : Error namespace URI.
+ :)
+declare variable $err:errNS as xs:string := "http://www.zorba-xquery.com/modules/store/pul/errors";
+
+(:~
+ : The first argument of pul:pul-to-xdm or pulr:pul-to-complete-xdm must be a PUL.
+ :)
+declare variable $err:PUL001 as xs:QName := fn:QName($err:errNS, "err:PUL001");
+
+(:~
+ : The provided PUL contains unsupported operations.
+ :)
+declare variable $err:PUL002 as xs:QName := fn:QName($err:errNS, "err:PUL002");
+
+(:~
+ : The validation of the provided XDM PUL failed.
+ :)
+declare variable $err:PUL010 as xs:QName := fn:QName($err:errNS, "err:PUL010");
+
+(:~
+ : The provided PUL cannot be parsed.
+ :)
+declare variable $err:PUL011 as xs:QName := fn:QName($err:errNS, "err:PUL011");
+
+(:~
+ : The typing information in the provided XDM PUL cannot be restored.
+ :)
+declare variable $err:PUL012 as xs:QName := fn:QName($err:errNS, "err:PUL012");
+
+(:~
+ : A node identifier cannot be resolved.
+ :)
+declare variable $err:PUL020 as xs:QName := fn:QName($err:errNS, "err:PUL020");
+
+(:~
+ : A node identifier cannot be resolved through the specified uuid to node map.
+ :)
+declare variable $err:PUL021 as xs:QName := fn:QName($err:errNS, "err:PUL021");
+
+(:~
+ : The specified node to uuid map is not valid.
+ :)
+declare variable $err:PUL022 as xs:QName := fn:QName($err:errNS, "err:PUL022");
\ No newline at end of file
=== added file 'modules/com/zorba-xquery/www/modules/store/pul/representation.xq'
--- modules/com/zorba-xquery/www/modules/store/pul/representation.xq 1970-01-01 00:00:00 +0000
+++ modules/com/zorba-xquery/www/modules/store/pul/representation.xq 2012-01-02 09:53:25 +0000
@@ -0,0 +1,544 @@
+(:
+ : Copyright 2006-2011 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+:)
+
+module namespace pulr = "http://www.zorba-xquery.com/modules/store/pul/representation";
+
+declare namespace ann = "http://www.zorba-xquery.com/annotations";
+declare namespace err = "http://www.w3.org/2005/xqt-errors";
+declare namespace zerr = 'http://www.zorba-xquery.com/errors';
+
+import module namespace schema="http://www.zorba-xquery.com/modules/schema";
+import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference";
+import module namespace perr = "http://www.zorba-xquery.com/modules/store/pul/errors";
+
+import schema namespace pul = "http://www.zorba-xquery.com/modules/store/pul/representation";
+
+declare revalidation skip;
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
+declare option ver:module-version "2.0";
+
+(:~
+ : Generates a representation of a PUL as an XDM instance.
+ : The PUL operations argument nodes can be encoded.
+ : If so, the size of the produced XDM instance increases, but the argument
+ : nodes types and identifiers are preserved even if the PUL is serialized.
+ : Otherwise, argument nodes identifiers are not saved in the XDM instance,
+ : while argument nodes types are lost in case the PUL is serialized.
+ :
+ : @param $pul A PUL
+ : @param $encode whether to encode the PUL operation arguments or not
+ : @return the representation of the given PUL as an XDM instance
+ :
+ : @error perr:PUL001 if the provided argument is not a PUL
+ : @error perr:PUL002 if the provided PUL contains unsupported operations
+ :)
+declare function pulr:pul-to-xdm($pul as item()*, $encode as xs:boolean) as element() external;
+
+(:~
+ : Generates a representation of a PUL as an XDM instance.
+ : The PUL is applied and undo information is stored in the XDM
+ : representation of the PUL. The argument nodes types and identifiers
+ : are preserved even if the PUL is serialized.
+ :
+ : @param $pul PUL as identified by an updating expression
+ : @param $encode whether to encode the PUL operation arguments or not
+ : @return the representation of the given PUL as an XDM instance
+ :
+ : @return PUL as an XDM instance
+ :
+ : @error perr:PUL001 if the provided argument is not a PUL
+ : @error perr:PUL002 if the provided PUL contains unsupported operations
+ :)
+declare %ann:sequential function pulr:pul-to-complete-xdm($pul as item()*) as element() external;
+
+(:~
+ : Returns the PUL represented in the given XDM instance. Argument nodes types
+ : and identifiers are restored if present in the XDM instance.
+ :
+ : @param $xdm-pul XDM representation of a PUL
+ : @return the represented PUL
+ :
+ : @error perr:PUL010 if the provided XDM PUL is not valid
+ : @error perr:PUL011 if an error is raised during the parsing of the XDM PUL
+ : @error perr:PUL012 if the typing information in the XDM PUL cannot be restored
+ : @error perr:PUL029 if a node reference cannot be restored because it is assigned
+ : to another node
+ :
+ : Also, the following update primitive errors can be raised:
+ :
+ : @error err:XPTY0004
+ : @error err:XQDY0026
+ : @error err:XQDY0072
+ : @error err:XQDY0074
+ : @error err:XUDY0009
+ : @error err:XUDY0015
+ : @error err:XUDY0016
+ : @error err:XUDY0017
+ : @error err:XUDY0029
+ : @error err:XUTY0005
+ : @error err:XUTY0006
+ : @error err:XUTY0008
+ : @error err:XUTY0010
+ : @error err:XUTY0011
+ : @error err:XUTY0012
+ : @error err:XUTY0022
+ : @error zerr:ZAPI0020
+ : @error zerr:ZDDY0001
+ : @error zerr:ZDDY0002
+ : @error zerr:ZDDY0003
+ : @error zerr:ZDDY0004
+ : @error zerr:ZDDY0005
+ : @error zerr:ZDDY0006
+ : @error zerr:ZDDY0007
+ : @error zerr:ZDDY0009
+ : @error zerr:ZDDY0010
+ : @error zerr:ZDDY0011
+ : @error zerr:ZDDY0012
+ : @error zerr:ZDDY0016
+ : @error zerr:ZDDY0018
+ : @error zerr:ZDDY0027
+ : @error zerr:ZDDY0032
+ : @error zerr:ZXQD0002
+ :)
+declare updating function pulr:xdm-to-pul($xdm-pul as element())
+{
+ pulr:xdm-to-pul($xdm-pul,fn:true())
+};
+
+(:~
+ : Returns the PUL represented in the given XDM instance. Argument nodes identifiers
+ : are restored if present in the XDM instance. It is possible to restore argument
+ : nodes types if desired.
+ :
+ : @param $xdm-pul XDM representation of a PUL
+ : @return the represented PUL
+ :
+ : @error perr:PUL010 if the provided XDM PUL is not valid
+ : @error perr:PUL011 if an error is raised during the parsing of the XDM PUL
+ : @error perr:PUL012 if the typing information in the XDM PUL cannot be restored
+ : @error perr:PUL020 if a node reference cannot be dereferenced
+ : @error perr:PUL029 if a node reference cannot be restored because it is assigned
+ : to another node
+ :
+ : Also, the following update primitive errors can be raised:
+ :
+ : @error err:XPTY0004
+ : @error err:XQDY0026
+ : @error err:XQDY0072
+ : @error err:XQDY0074
+ : @error err:XUDY0009
+ : @error err:XUDY0015
+ : @error err:XUDY0016
+ : @error err:XUDY0017
+ : @error err:XUDY0029
+ : @error err:XUTY0005
+ : @error err:XUTY0006
+ : @error err:XUTY0008
+ : @error err:XUTY0010
+ : @error err:XUTY0011
+ : @error err:XUTY0012
+ : @error err:XUTY0022
+ : @error zerr:ZAPI0020
+ : @error zerr:ZDDY0001
+ : @error zerr:ZDDY0002
+ : @error zerr:ZDDY0003
+ : @error zerr:ZDDY0004
+ : @error zerr:ZDDY0005
+ : @error zerr:ZDDY0006
+ : @error zerr:ZDDY0007
+ : @error zerr:ZDDY0009
+ : @error zerr:ZDDY0010
+ : @error zerr:ZDDY0011
+ : @error zerr:ZDDY0012
+ : @error zerr:ZDDY0016
+ : @error zerr:ZDDY0018
+ : @error zerr:ZDDY0027
+ : @error zerr:ZDDY0032
+ : @error zerr:ZXQD0002
+ :)
+declare updating function pulr:xdm-to-pul($xdm-pul as element(), $restore-types as xs:boolean)
+{
+ try
+ {
+ let $validated:=
+ if (not(schema:is-validated($xdm-pul)))
+ then validate {$xdm-pul}
+ else $xdm-pul
+ return switch (node-name($xdm-pul))
+ case xs:QName("pul:pending-update-list")
+ return pulr:xdm-to-pul-impl($xdm-pul,fn:false(),$restore-types)
+ case xs:QName("pul:complete-pending-update-list")
+ return pulr:xdm-to-pul-impl($validated,fn:true(),$restore-types)
+ case xs:QName("pul:encoded-pending-update-list")
+ return pulr:xdm-to-pul-impl($validated,fn:true(),$restore-types)
+ default
+ return fn:error($perr:PUL010,"The provided argument is not a valid XDM PUL.")
+ }
+ catch XQDY0027
+ {
+ fn:error($perr:PUL010,fn:concat("The validation of the provided XDM PUL failed: ", $err:description))
+ }
+};
+
+(:~
+ : Given a complete XDM PUL it returns an XDM PUL without the additional undo
+ : information.
+ :
+ : @param $complete-xdm-pul complete XDM PUL representation
+ : @return XDM PUL representation
+ :
+ : @error perr:PUL010 if the provided XDM PUL is not valid
+ :)
+declare function pulr:complete-xdm-to-xdm($complete-xdm-pul as element(pul:complete-pending-update-list)) as element(pul:encoded-pending-update-list)
+{
+ try
+ {
+ copy $pul:=
+ if (fn:not(schema:is-validated($complete-xdm-pul)))
+ then validate {$complete-xdm-pul}
+ else ($complete-xdm-pul)
+ modify
+ (
+ delete node $pul/*/(
+ pul:parent | pul:left-sibling | pul:deleted-node | pul:replaced-node |
+ pul:old-string-value | pul:replaced-nodes | pul:oldName | pul:deleted-nodes |
+ pul:old-annotations | pul:deleted-nodes | pul:deleted-document | pul:deleted-document-reference |
+ pul:old-type-name | pul:old-value | pul:old-have-value | pul:old-have-empty-value |
+ pul:old-have-typed-value | pul:old-have-list-value | pul:old-is-in-substitution-group | pul:type-undo-list),
+ delete node $pul/pul:deactivateIC/(pul:from-collection-name | pul:to-collection-name | pul:collection-name),
+ rename node $pul as "pul:encoded-pending-update-list"
+ )
+ return $pul
+ }
+ catch XQDY0027
+ {
+ fn:error($perr:PUL010,fn:concat("The validation of the provided XDM PUL failed: ", $err:description))
+ }
+};
+
+(:~
+ : Returns the prefixes of all the namespaces bound in a given element.
+ :
+ : @param $elem an element node
+ : @return the sequence of all namespaces bound in $elem
+ :)
+declare %private function pulr:local-namespace-prefixes($elem as element()) as xs:string* external;
+
+(:~
+ : Encodes a non encoded, non complete XDM representation of a PUL.
+ :
+ : @param $xdm-pul non encoded, non complete XDM PUL
+ : @return encoded XDM PUL
+ :)
+declare function pulr:encode-xdm-pul-impl($xdm-pul as element()) as element()
+{
+ copy $enc-pul:=$xdm-pul
+ modify
+ (
+ rename node $enc-pul as ("pul:encoded-pending-update-list"),
+ for $argumentroot in ($enc-pul/*/(pul:content | pul:replacement | pul:text | pul:replaced-nodes))
+ return pulr:encode-xdm-parameter($argumentroot),
+ for $argumentroot in ($enc-pul/*/(pul:nodes | pul:document | pul:node))
+ return pulr:encode-partially-encoded-xdm-parameter($argumentroot)
+ )
+ return $enc-pul
+};
+
+(:~
+ : Encodes a complete XDM representation of a PUL.
+ :
+ : @param $xdm-pul internal complete XDM PUL representation
+ : @return complete XDM PUL representation
+ :)
+declare updating function pulr:encode-complete-xdm-pul-impl($xdm-pul as element())
+{
+ for $argumentroot in ($xdm-pul/*/(pul:content | pul:deleted-node | pul:replacement | pul:replaced-node | pul:text | pul:replaced-nodes))
+ return pulr:encode-xdm-parameter($argumentroot),
+ for $argumentroot in ($xdm-pul/*/(pul:nodes | pul:deleted-nodes/pul:deleted-node | pul:deleted-collection | pul:document | pul:deleted-document | pul:node))
+ return pulr:encode-partially-encoded-xdm-parameter($argumentroot)
+};
+
+
+(:~
+ : Encodes all attributes and children of the given node.
+ : The given node content must not be partially encoded.
+ :
+ : @param $parameter Node to encode
+ : @return empty-sequence()
+ :)
+declare %private updating function pulr:encode-xdm-parameter($parameter as element())
+{
+ for $node in ($parameter/node())
+ return replace node $node with pulr:encode-node($node),
+ for $node in ($parameter/@*)
+ return
+ (
+ delete node $node,
+ insert node pulr:encode-attribute($node) into $parameter
+ )
+};
+
+(:~
+ : Encodes all attributes and children of the given node.
+ : The given node content must be partially encoded.
+ :
+ : @param $parameter Node to encode
+ : @return empty-sequence()
+ :)
+declare %private updating function pulr:encode-partially-encoded-xdm-parameter($parameter as element())
+{
+ for $node in ($parameter/pul:document/pul:children/node())
+ return replace node $node with pulr:encode-node($node),
+ for $node in ($parameter/pul:non-document)
+ return
+ if ($node/node())
+ then replace node $node with pulr:encode-node($node/node())
+ else (
+ if ($node/@*)
+ then replace node $node with pulr:encode-attribute($node/@*)
+ else ()
+ )
+};
+
+(:~
+ : Encodes a single (element, attribute, text, document-node, comment
+ : or processing-instruction) node.
+ : The subtree rooted at the specified node is translated as well.
+ :
+ : @param $node the node to encode
+ : @return encoded node
+ :)
+declare %private function pulr:encode-node($node as node()) as element()*
+{
+ if ($node instance of element()) then pulr:encode-element($node)
+ else if ($node instance of attribute()) then pulr:encode-attribute($node)
+ else if ($node instance of text()) then pulr:encode-text($node)
+ else if ($node instance of document-node()) then pulr:encode-document-node($node)
+ else if ($node instance of comment()) then pulr:encode-comment($node)
+ else if ($node instance of processing-instruction()) then pulr:encode-processing-instruction($node)
+ else ()
+};
+
+(:~
+ : Returns an attribute describing the type of the given node, if any.
+ : If the node is untyped no attribute is returned.
+ :
+ : @param $node a node
+ : @param $prefix the prefix to use in the type QName
+ : @return an attribute describing the given node type
+ :)
+declare %private function pulr:encode-node-type($node as node(),$prefix as xs:string) as attribute()?
+{
+ let $type-name:=schema:schema-type($node)
+ let $uri:=fn:namespace-uri-from-QName($type-name)
+ let $local:=fn:local-name-from-QName($type-name)
+ return
+ if ($uri eq "http://www.w3.org/2001/XMLSchema" and $local eq "untyped")
+ then ()
+ else
+ (
+ attribute {"type-name"}{QName($uri,concat($prefix,":", $local))}
+ )
+};
+
+
+(:~
+ : Encodes a single document node.
+ : The subtree rooted at the specified node is translated as well.
+ :
+ : @param $doc the node to encode
+ : @return encoded node
+ :)
+declare %private function pulr:encode-document-node($document as document-node()) as element()
+{
+ element {"pul:document"}
+ {
+ let $base-uri:=fn:base-uri($document)
+ return if ($base-uri) then (attribute base-uri {$base-uri}) else (),
+ let $document-uri:=fn:document-uri($document)
+ return if ($document-uri) then (attribute document-uri {$document-uri}) else (),
+ attribute reference {ref:node-reference($document)},
+ pulr:encode-attributes-children-namespaces($document)
+ }
+};
+
+
+(:~
+ : Encodes a single element node.
+ : The subtree rooted at the specified node is translated as well.
+ :
+ : @param $element the node to encode
+ : @return encoded node
+ :)
+declare %private function pulr:encode-element($element as element()) as element()
+{
+ let $type-prefix:=if (fn:prefix-from-QName(fn:node-name($element)) eq "type") then "typex" else "type"
+ return
+ element {fn:node-name($element)} (:Ensures namespace binding for node name.:)
+ {
+ element {QName(fn:namespace-uri-from-QName(schema:schema-type($element)), (:Ensures namespace binding for type name.:)
+ concat($type-prefix,":type"))}
+ {
+ element {
+ if (fn:prefix-from-QName(fn:node-name($element)) eq "pul")
+ then QName("http://www.zorba-xquery.com/modules/store/pul/representation","pulx:element")
+ else "pul:element"}
+ {
+ attribute node-name {fn:node-name($element)},
+ pulr:encode-node-type($element,$type-prefix),
+ if ($element instance of xs:ID) then attribute is-id {fn:true()} else (),
+ if ($element instance of xs:IDREF) then attribute is-idrefs {fn:true()} else (),
+ if (fn:nilled($element)) then (attribute nilled {fn:true()}) else (),
+ attribute reference {ref:node-reference($element)},
+ pulr:encode-attributes-children-namespaces($element)
+ }
+ }}/*/*
+};
+
+
+(:~
+ : Encodes a single attribute node.
+ :
+ : @param $attribute the node to encode
+ : @return encoded node
+ :)
+declare %private function pulr:encode-attribute($attribute as attribute()) as element()
+{
+ let $type-prefix:=if (fn:prefix-from-QName(fn:node-name($attribute)) eq "type") then "typex" else "type"
+ return
+ element {fn:node-name($attribute)} (:Ensures namespace binding for node name.:)
+ {
+ element {QName(fn:namespace-uri-from-QName(schema:schema-type($attribute)), (:Ensures namespace binding for type name.:)
+ fn:concat($type-prefix,":type"))}
+ {
+
+ element {
+ if (fn:prefix-from-QName(fn:node-name($attribute)) eq "pul")
+ then QName("http://www.zorba-xquery.com/modules/store/pul/representation","pulx:attribute")
+ else "pul:attribute"}
+ {
+ attribute node-name {fn:node-name($attribute)},
+ pulr:encode-node-type($attribute,$type-prefix),
+ if ($attribute instance of xs:ID) then attribute is-id {fn:true()} else (),
+ if ($attribute instance of xs:IDREF) then attribute is-idrefs {fn:true()} else (),
+ attribute reference {ref:node-reference($attribute)},
+ fn:data($attribute)
+ }
+ }}/*/*
+};
+
+(:~
+ : Encodes a single text node.
+ :
+ : @param $doc the node to encode
+ : @return encoded node
+ :)
+declare %private function pulr:encode-text($text as text()) as element()
+{
+ element {"pul:text"}
+ {
+ attribute reference {ref:node-reference($text)},
+ fn:data($text)
+ }
+};
+
+(:~
+ : Encodes a single comment node.
+ :
+ : @param $doc the node to encode
+ : @return encoded node
+ :)
+declare %private function pulr:encode-comment($comment as comment()) as element()
+{
+ element {"pul:comment"}
+ {
+ attribute reference {ref:node-reference($comment)},
+ fn:data($comment)
+ }
+};
+
+
+(:~
+ : Encodes a single processing-instruction node.
+ :
+ : @param $doc the node to encode
+ : @return encoded node
+ :)
+declare %private function pulr:encode-processing-instruction($processing-instruction as processing-instruction()) as element()
+{
+ element {"pul:processing-instruction"}
+ {
+ attribute node-name {fn:node-name($processing-instruction)},
+ attribute reference {ref:node-reference($processing-instruction)},
+ fn:data($processing-instruction)
+ }
+};
+
+
+(:~
+ : Encodes the entire subtree of a given node, except the node itself.
+ :
+ : @param $node the root of the subtree to encode
+ : @return the encoded subtree
+ :)
+declare %private function pulr:encode-attributes-children-namespaces($node as node()) as element()*
+{
+ let $children:=$node/node()
+ let $attributes:=$node/@*
+ let $prefixes:=pulr:local-namespace-prefixes($node)
+ return (
+ if ($attributes)
+ then (element {"pul:attributes"}
+ {
+ for $attribute in ($attributes)
+ return pulr:encode-attribute($attribute)
+ })
+ else (),
+ if ($children)
+ then (element {"pul:children"}
+ {
+ for $child in ($children)
+ return pulr:encode-node($child)
+ })
+ else (),
+ if (fn:count($prefixes))
+ then (element {"pul:namespace-nodes"}
+ {
+ for $prefix in ($prefixes)
+ return pulr:encode-namespace($prefix,$node)
+ })
+ else()
+ )
+};
+
+(:~
+ : Encodes a single namespace binding. The namespace URI is resolved
+ : with respect to the element passed as second argument.
+ :
+ : @param $namespace-prefix the prefix of the namespace to encode
+ : @param $element the element respect to which the namespace declaration will be resolved
+ : @return the encoded namespace
+ :)
+declare %private function pulr:encode-namespace($namespace-prefix as xs:string, $element as element()) as element()
+{
+ element {"pul:namespace"}
+ {
+ attribute node-name { $namespace-prefix },
+ fn:namespace-uri-for-prefix($namespace-prefix,$element)
+ }
+};
+
+declare %private updating function pulr:xdm-to-pul-impl($pul as element(), $encoded as xs:boolean, $restore-types as xs:boolean) external;
\ No newline at end of file
=== added file 'modules/com/zorba-xquery/www/modules/store/pul/representation.xsd'
--- modules/com/zorba-xquery/www/modules/store/pul/representation.xsd 1970-01-01 00:00:00 +0000
+++ modules/com/zorba-xquery/www/modules/store/pul/representation.xsd 2012-01-02 09:53:25 +0000
@@ -0,0 +1,1029 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:pul="http://www.zorba-xquery.com/modules/store/pul/representation"
+ targetNamespace="http://www.zorba-xquery.com/modules/store/pul/representation"
+ elementFormDefault="qualified">
+
+ <!--
+ ****************************************************
+ *** PULs Formats ***
+ ****************************************************
+ -->
+
+ <xs:element name="pending-update-list" type="pul:xdm-pul-type"/>
+ <xs:element name="encoded-pending-update-list" type="pul:exdm-pul-type"/>
+ <xs:element name="complete-pending-update-list" type="pul:cxdm-pul-type"/>
+
+
+ <!--
+ *** XDM PUL ***
+ -->
+
+ <xs:complexType name="xdm-pul-type">
+ <xs:choice maxOccurs="unbounded" minOccurs="0">
+ <xs:element name="insertBefore" type="pul:insert"/>
+ <xs:element name="insertAfter" type="pul:insert"/>
+ <xs:element name="insertInto" type="pul:insert"/>
+ <xs:element name="insertIntoAsFirst" type="pul:insert"/>
+ <xs:element name="insertIntoAsLast" type="pul:insert"/>
+ <xs:element name="insertAttributes" type="pul:insertAttributes"/>
+ <xs:element name="delete" type="pul:delete"/>
+ <xs:element name="replaceNode" type="pul:replaceNode"/>
+ <xs:element name="replaceValue" type="pul:replaceValue"/>
+ <xs:element name="replaceElementContent" type="pul:replaceElementContent"/>
+ <xs:element name="rename" type="pul:rename"/>
+ <xs:element name="put" type="pul:put"/>
+ <xs:element name="createCollection" type="pul:createCollection"/>
+ <xs:element name="insertAfterIntoCollection" type="pul:insertRelativeIntoCollection"/>
+ <xs:element name="insertBeforeIntoCollection" type="pul:insertRelativeIntoCollection"/>
+ <xs:element name="insertFirstIntoCollection" type="pul:insertAbsoluteIntoCollection"/>
+ <xs:element name="insertIntoCollection" type="pul:insertAbsoluteIntoCollection"/>
+ <xs:element name="insertLastIntoCollection" type="pul:insertAbsoluteIntoCollection"/>
+ <xs:element name="removeFromCollection" type="pul:removeFromCollection"/>
+ <xs:element name="deleteCollection" type="pul:deleteCollection"/>
+ <xs:element name="activateForeignKeyIC" type="pul:activateForeignKeyIC"/>
+ <xs:element name="activateIC" type="pul:activateIC"/>
+ <xs:element name="deactivateIC" type="pul:deactivateIC"/>
+ <!--
+ <xs:element name="setAttributeType" type="pul:setAttributeType"/>
+ <xs:element name="setElementType" type="pul:setElementType"/>
+ -->
+ <xs:element name="revalidate" type="pul:revalidateType"/>
+ <xs:element name="createDocument" type="pul:createDocument"/>
+ <xs:element name="deleteDocument" type="pul:deleteDocument"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <!--
+ *** ENCODED XDM PUL ***
+ -->
+
+ <xs:complexType name="exdm-pul-type">
+ <xs:choice maxOccurs="unbounded" minOccurs="0">
+ <xs:element name="insertBefore" type="pul:e-insert"/>
+ <xs:element name="insertAfter" type="pul:e-insert"/>
+ <xs:element name="insertInto" type="pul:e-insert"/>
+ <xs:element name="insertIntoAsFirst" type="pul:e-insert"/>
+ <xs:element name="insertIntoAsLast" type="pul:e-insert"/>
+ <xs:element name="insertAttributes" type="pul:e-insertAttributes"/>
+ <xs:element name="delete" type="pul:delete"/>
+ <xs:element name="replaceNode" type="pul:e-replaceNode"/>
+ <xs:element name="replaceValue" type="pul:replaceValue"/>
+ <xs:element name="replaceElementContent" type="pul:e-replaceElementContent"/>
+ <xs:element name="rename" type="pul:rename"/>
+ <xs:element name="put" type="pul:e-put"/>
+ <xs:element name="createCollection" type="pul:e-createCollection"/>
+ <xs:element name="insertAfterIntoCollection" type="pul:e-insertRelativeIntoCollection"/>
+ <xs:element name="insertBeforeIntoCollection" type="pul:e-insertRelativeIntoCollection"/>
+ <xs:element name="insertFirstIntoCollection" type="pul:e-insertAbsoluteIntoCollection"/>
+ <xs:element name="insertIntoCollection" type="pul:e-insertAbsoluteIntoCollection"/>
+ <xs:element name="insertLastIntoCollection" type="pul:e-insertAbsoluteIntoCollection"/>
+ <xs:element name="removeFromCollection" type="pul:removeFromCollection"/>
+ <xs:element name="deleteCollection" type="pul:deleteCollection"/>
+ <xs:element name="activateForeignKeyIC" type="pul:activateForeignKeyIC"/>
+ <xs:element name="activateIC" type="pul:activateIC"/>
+ <xs:element name="deactivateIC" type="pul:deactivateIC"/>
+ <!--
+ <xs:element name="setAttributeType" type="pul:setAttributeType"/>
+ <xs:element name="setElementType" type="pul:setElementType"/>
+ -->
+ <xs:element name="revalidate" type="pul:revalidateType"/>
+ <xs:element name="createDocument" type="pul:e-createDocument"/>
+ <xs:element name="deleteDocument" type="pul:deleteDocument"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <!--
+ *** Complete XML PUL ***
+ -->
+
+ <xs:complexType name="cxdm-pul-type">
+ <xs:choice maxOccurs="unbounded" minOccurs="0">
+ <xs:element name="insertBefore" type="pul:e-insert"/> <!--e-c-insert-->
+ <xs:element name="insertAfter" type="pul:e-insert"/> <!--e-c-insert-->
+ <xs:element name="insertInto" type="pul:e-insert"/> <!--e-c-insert-->
+ <xs:element name="insertIntoAsFirst" type="pul:e-insert"/> <!--e-c-insert-->
+ <xs:element name="insertIntoAsLast" type="pul:e-insert"/> <!--e-c-insert-->
+ <xs:element name="insertAttributes" type="pul:e-insertAttributes"/> <!--e-c-insertAttributes-->
+ <xs:element name="delete" type="pul:e-c-delete"/>
+ <xs:element name="replaceNode" type="pul:e-c-replaceNode"/>
+ <xs:element name="replaceValue" type="pul:e-c-replaceValue"/>
+ <xs:element name="replaceElementContent" type="pul:e-c-replaceElementContent"/>
+ <xs:element name="rename" type="pul:e-c-rename"/>
+ <xs:element name="put" type="pul:e-put"/>
+ <xs:element name="createCollection" type="pul:e-createCollection"/>
+ <xs:element name="insertAfterIntoCollection" type="pul:e-insertRelativeIntoCollection"/>
+ <xs:element name="insertBeforeIntoCollection" type="pul:e-insertRelativeIntoCollection"/>
+ <xs:element name="insertFirstIntoCollection" type="pul:e-insertAbsoluteIntoCollection"/>
+ <xs:element name="insertIntoCollection" type="pul:e-insertAbsoluteIntoCollection"/>
+ <xs:element name="insertLastIntoCollection" type="pul:e-insertAbsoluteIntoCollection"/>
+ <xs:element name="removeFromCollection" type="pul:e-c-removeFromCollection"/>
+ <xs:element name="deleteCollection" type="pul:e-c-deleteCollection"/>
+ <xs:element name="activateForeignKeyIC" type="pul:activateForeignKeyIC"/>
+ <xs:element name="activateIC" type="pul:activateIC"/>
+ <xs:element name="deactivateIC" type="pul:e-c-deactivateIC"/>
+ <!--
+ <xs:element name="setAttributeType" type="pul:e-c-setAttributeType"/>
+ <xs:element name="setElementType" type="pul:e-c-setElementType"/>
+ -->
+ <xs:element name="revalidate" type="pul:revalidateType"/> <!--e-c-revalidateType-->
+ <xs:element name="createDocument" type="pul:e-createDocument"/>
+ <xs:element name="deleteDocument" type="pul:e-c-deleteDocument"/>
+ </xs:choice>
+ </xs:complexType>
+
+
+ <!--
+ ****************************************************
+ *** Content Nodes ***
+ ****************************************************
+ -->
+
+ <!--
+ *** Complete XML PUL ***
+ -->
+
+ <xs:complexType name="node-sequence" mixed="true">
+ <xs:sequence>
+ <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute processContents="skip"/>
+ </xs:complexType>
+
+ <xs:complexType name="enc-document">
+ <xs:sequence>
+ <xs:element name="children" minOccurs="0">
+ <xs:complexType mixed="true">
+ <xs:sequence>
+ <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="base-uri" type="xs:string" use="required"/>
+ <xs:attribute name="document-uri" type="xs:string" use="required"/>
+ <xs:attribute name="reference" type="xs:anyURI" use="optional"/>
+ </xs:complexType>
+
+ <xs:complexType name="enc-non-document" mixed="true">
+ <xs:sequence>
+ <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute processContents="skip"/>
+ </xs:complexType>
+
+ <xs:complexType name="partially-encoded-node-sequence">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="document" type="pul:enc-document"/>
+ <xs:element name="non-document" type="pul:enc-non-document"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="partially-encoded-single-node-sequence">
+ <xs:choice>
+ <xs:element name="document" type="pul:enc-document"/>
+ <xs:element name="non-document" type="pul:enc-non-document"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="partially-encoded-single-document-sequence">
+ <xs:sequence>
+ <xs:element name="document" type="pul:enc-document"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ ****************************************************
+ *** Content Nodes Serialization: Sequences ***
+ ****************************************************
+ -->
+
+ <xs:complexType name="ser-seq-children-nodes">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="element" type="pul:ser-element"/>
+ <xs:element name="comment" type="pul:ser-comment"/>
+ <xs:element name="text" type="pul:ser-text"/>
+ <xs:element name="processing-instruction" type="pul:ser-processing-instruction"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-non-empty-children-nodes">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="element" type="pul:ser-element"/>
+ <xs:element name="comment" type="pul:ser-comment"/>
+ <xs:element name="text" type="pul:ser-text"/>
+ <xs:element name="processing-instruction" type="pul:ser-processing-instruction"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-namespaces">
+ <xs:sequence maxOccurs="unbounded">
+ <xs:element name="namespace" type="pul:ser-namespace"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-attributes">
+ <xs:sequence maxOccurs="unbounded">
+ <xs:element name="attribute" type="pul:ser-attribute"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-any-node">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="document" type="pul:ser-document"/>
+ <xs:element name="element" type="pul:ser-element"/>
+ <xs:element name="comment" type="pul:ser-comment"/>
+ <xs:element name="text" type="pul:ser-text"/>
+ <xs:element name="processing-instruction" type="pul:ser-processing-instruction"/>
+ <xs:element name="attribute" type="pul:ser-attribute"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-single-any-node">
+ <xs:choice>
+ <xs:element name="document" type="pul:ser-document"/>
+ <xs:element name="element" type="pul:ser-element"/>
+ <xs:element name="comment" type="pul:ser-comment"/>
+ <xs:element name="text" type="pul:ser-text"/>
+ <xs:element name="processing-instruction" type="pul:ser-processing-instruction"/>
+ <xs:element name="attribute" type="pul:ser-attribute"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-single-document">
+ <xs:sequence>
+ <xs:element name="document" type="pul:ser-document"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-opt-text-node">
+ <xs:sequence minOccurs="0">
+ <xs:element name="text" type="pul:ser-text"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-single-child-or-attribute">
+ <xs:choice>
+ <xs:element name="element" type="pul:ser-element"/>
+ <xs:element name="comment" type="pul:ser-comment"/>
+ <xs:element name="text" type="pul:ser-text"/>
+ <xs:element name="processing-instruction" type="pul:ser-processing-instruction"/>
+ <xs:element name="attribute" type="pul:ser-attribute"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="ser-seq-children-or-attributes">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="element" type="pul:ser-element"/>
+ <xs:element name="comment" type="pul:ser-comment"/>
+ <xs:element name="text" type="pul:ser-text"/>
+ <xs:element name="processing-instruction" type="pul:ser-processing-instruction"/>
+ <xs:element name="attribute" type="pul:ser-attribute" maxOccurs="unbounded"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <!--
+ ****************************************************
+ *** Content Nodes Serialization: Nodes ***
+ ****************************************************
+ -->
+
+ <xs:complexType name="ser-document">
+ <xs:sequence>
+ <xs:element name="children" type="pul:ser-seq-children-nodes" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="base-uri" type="xs:anyURI" use="optional"/>
+ <xs:attribute name="document-uri" type="xs:anyURI" use="optional"/>
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+
+ <xs:complexType name="ser-element">
+ <xs:sequence>
+ <xs:element name="attributes" type="pul:ser-seq-attributes" minOccurs="0"/>
+ <xs:element name="children" type="pul:ser-seq-children-nodes" minOccurs="0"/>
+ <xs:element name="namespace-nodes" type="pul:ser-seq-namespaces" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="node-name" type="xs:QName" use="required"/>
+ <xs:attribute name="type-name" type="xs:QName" default="xs:untyped"/>
+ <xs:attribute name="is-id" type="xs:boolean" default="false"/>
+ <xs:attribute name="is-idrefs" type="xs:boolean" default="false"/>
+ <xs:attribute name="nilled" type="xs:boolean" default="false"/>
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+
+ <xs:complexType name="ser-attribute">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="node-name" type="xs:QName" use="required"/>
+ <xs:attribute name="type-name" type="xs:QName" default="xs:untypedAtomic"/>
+ <xs:attribute name="is-id" type="xs:boolean" default="false"/>
+ <xs:attribute name="is-idrefs" type="xs:boolean" default="false"/>
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:complexType name="ser-namespace">
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:attribute name="node-name" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:complexType name="ser-processing-instruction">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="node-name" type="xs:QName" use="required"/>
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:complexType name="ser-comment">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:complexType name="ser-text">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ <xs:attribute name="type" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <!--
+ ****************************************************
+ *** Target Nodes ***
+ ****************************************************
+ -->
+ <xs:complexType name="target-type">
+ <xs:sequence>
+ <xs:element name="reference" type="xs:anyURI"/>
+ <xs:element name="position" type="xs:anyURI"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="targets-type">
+ <xs:sequence maxOccurs="unbounded">
+ <xs:element name="target" type="pul:target-type"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ ****************************************************
+ *** Annotations ***
+ ****************************************************
+ -->
+ <xs:complexType name="annotations">
+ <xs:sequence>
+ <xs:element name="annotation" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="literals" type="pul:literals" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="literals">
+ <xs:sequence maxOccurs="unbounded">
+ <xs:element name="literal">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="type" type="xs:QName" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ ****************************************************
+ *** Deleted Nodes ***
+ ****************************************************
+ -->
+ <xs:complexType name="deleted-nodes">
+ <xs:sequence>
+ <xs:element name="deleted-node" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice>
+ <xs:element name="document" type="pul:enc-document"/>
+ <xs:element name="non-document" type="pul:enc-non-document"/>
+ </xs:choice>
+ <xs:element name="left-sibling" minOccurs="0" type="pul:target-type"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="ser-deleted-nodes">
+ <xs:sequence>
+ <xs:element name="deleted-node" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice>
+ <xs:element name="document" type="pul:ser-document"/>
+ <xs:element name="element" type="pul:ser-element"/>
+ <xs:element name="comment" type="pul:ser-comment"/>
+ <xs:element name="text" type="pul:ser-text"/>
+ <xs:element name="processing-instruction" type="pul:ser-processing-instruction"/>
+ <xs:element name="attribute" type="pul:ser-attribute"/>
+ </xs:choice>
+ <xs:element name="left-sibling" minOccurs="0" type="pul:target-type"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ ****************************************************
+ *** Types ***
+ ****************************************************
+ -->
+
+ <xs:complexType name="atomic-value">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="have-list-value" type="xs:anyURI" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <!--
+ <xs:complexType name="type-undo-list">
+ <xs:choice maxOccurs="unbounded">
+ <xs:element name="element-type" type="pul:type-undo-element"/>
+ <xs:element name="attribute-type" type="pul:type-undo-attribute"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="type-undo-element">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="type-name" type="xs:QName"/>
+ <xs:element name="value" type="pul:atomic-value" minOccurs="0"/>
+ <xs:element name="have-value" type="xs:boolean"/>
+ <xs:element name="have-empty-value" type="xs:boolean"/>
+ <xs:element name="is-in-substitution-group" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="type-undo-attribute">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="type-name" type="xs:QName"/>
+ <xs:element name="value" type="pul:atomic-value"/>
+ </xs:sequence>
+ </xs:complexType>
+ -->
+
+ <!--
+ ****************************************************
+ *** XQueryUpdate Operations ***
+ ****************************************************
+ -->
+
+ <!--
+ *** Insertions ***
+ -->
+ <xs:complexType name="insert">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="content" type="pul:node-sequence"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-insert">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="content" type="pul:ser-seq-non-empty-children-nodes"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ <xs:complexType name="e-c-insert">
+ <xs:complexContent>
+ <xs:extension base="pul:e-insert">
+ <xs:sequence>
+ <xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ -->
+
+ <xs:complexType name="insertAttributes">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="content" type="pul:node-sequence"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-insertAttributes">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="content" type="pul:ser-seq-attributes"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ <xs:complexType name="e-c-insertAttributes">
+ <xs:complexContent>
+ <xs:extension base="pul:e-insertAttributes">
+ <xs:sequence>
+ <xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ -->
+
+ <!--
+ *** Deletion ***
+ -->
+
+ <xs:complexType name="delete">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-delete">
+ <xs:complexContent>
+ <xs:extension base="pul:delete">
+ <xs:sequence>
+ <xs:element name="parent" type="pul:target-type"/>
+ <xs:element name="left-sibling" type="pul:target-type" minOccurs="0"/>
+ <xs:element name="deleted-node" type="pul:ser-seq-single-child-or-attribute"/>
+ <!--<xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>-->
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** Node Replacement ***
+ -->
+
+
+ <xs:complexType name="replaceNode">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="replacement" type="pul:node-sequence"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-replaceNode">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="replacement" type="pul:ser-seq-children-or-attributes"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-replaceNode">
+ <xs:complexContent>
+ <xs:extension base="pul:replaceNode">
+ <xs:sequence>
+ <xs:element name="parent" type="pul:target-type"/>
+ <xs:element name="left-sibling" type="pul:target-type" minOccurs="0"/>
+ <xs:element name="replaced-node" type="pul:ser-seq-single-child-or-attribute"/>
+ <!--<xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>-->
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** Value Replacement ***
+ -->
+
+ <xs:complexType name="replaceValue">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="string-value" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-replaceValue">
+ <xs:complexContent>
+ <xs:extension base="pul:replaceValue">
+ <xs:sequence>
+ <xs:element name="old-string-value" type="xs:string"/>
+ <!--<xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>-->
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** Element Content Replacement ***
+ -->
+
+ <xs:complexType name="replaceElementContent">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="text" type="pul:node-sequence"/>
+ <!-- text -->
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-replaceElementContent">
+
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="text" type="pul:ser-seq-opt-text-node"/>
+ <!-- (text)? -->
+ </xs:sequence>
+ </xs:complexType>
+
+
+ <xs:complexType name="e-c-replaceElementContent">
+ <xs:complexContent>
+ <xs:extension base="pul:replaceElementContent">
+ <xs:sequence>
+ <xs:element name="replaced-nodes" type="pul:ser-seq-children-nodes"/>
+ <!--<xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>-->
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** Rename ***
+ -->
+
+ <xs:complexType name="rename">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="newName" type="xs:QName"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-rename">
+ <xs:complexContent>
+ <xs:extension base="pul:rename">
+ <xs:sequence>
+ <xs:element name="oldName" type="xs:QName"/>
+ <!--<xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>-->
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** Put ***
+ -->
+
+ <xs:complexType name="put">
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI"/>
+ <xs:element name="node" type="pul:partially-encoded-single-document-sequence"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-put">
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI"/>
+ <xs:element name="node" type="pul:ser-seq-single-document"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ *** Create Collection ***
+ -->
+
+ <xs:complexType name="createCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="annotations" type="pul:annotations"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ <xs:element name="node-type" type="xs:QName" minOccurs="0"/>
+ <xs:element name="nodes" type="pul:partially-encoded-node-sequence" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-createCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="annotations" type="pul:annotations"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ <xs:element name="node-type" type="xs:QName" minOccurs="0"/>
+ <xs:element name="nodes" type="pul:ser-seq-any-node" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ *** Collection Insertions ***
+ -->
+
+ <xs:complexType name="insertRelativeIntoCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="nodes" type="pul:partially-encoded-node-sequence"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-insertRelativeIntoCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="nodes" type="pul:ser-seq-any-node"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="insertAbsoluteIntoCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="nodes" type="pul:partially-encoded-node-sequence"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-insertAbsoluteIntoCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="nodes" type="pul:ser-seq-any-node"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ *** Collection Node Deletions ***
+ -->
+
+ <xs:complexType name="removeFromCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="targets" type="pul:targets-type"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-removeFromCollection">
+ <xs:complexContent>
+ <xs:extension base="pul:removeFromCollection">
+ <xs:sequence>
+ <xs:element name="deleted-nodes" type="pul:ser-deleted-nodes"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** Collection Deletion ***
+ -->
+
+ <xs:complexType name="deleteCollection">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="dynamic-collection" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-deleteCollection">
+ <xs:complexContent>
+ <xs:extension base="pul:deleteCollection">
+ <xs:sequence>
+ <xs:element name="old-annotations" type="pul:annotations"/>
+ <xs:element name="old-node-type" type="xs:QName" minOccurs="0"/>
+ <xs:element name="deleted-nodes" type="pul:ser-seq-any-node"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** IC Activations ***
+ -->
+
+ <xs:complexType name="activateForeignKeyIC">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="from-collection-name" type="xs:QName"/>
+ <xs:element name="to-collection-name" type="xs:QName"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="activateIC">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ <xs:element name="collection-name" type="xs:QName"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ *** IC Deactivation ***
+ -->
+
+ <xs:complexType name="deactivateIC">
+ <xs:sequence>
+ <xs:element name="name" type="xs:QName"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-deactivateIC">
+ <xs:complexContent>
+ <xs:extension base="pul:deactivateIC">
+ <xs:sequence>
+ <xs:choice>
+ <xs:sequence>
+ <xs:element name="from-collection-name" type="xs:QName"/>
+ <xs:element name="to-collection-name" type="xs:QName" minOccurs="0"/>
+ </xs:sequence>
+ <xs:element name="collection-name" type="xs:QName"/>
+ </xs:choice>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!--
+ *** Set Types ***
+ -->
+ <!--
+ <xs:complexType name="setAttributeType">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="type-name" type="xs:QName"/>
+ <xs:element name="value" type="pul:atomic-value"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-setAttributeType">
+ <xs:complexContent>
+ <xs:extension base="pul:setAttributeType">
+ <xs:sequence>
+ <xs:element name="old-type-name" type="xs:QName"/>
+ <xs:element name="old-value" type="pul:atomic-value"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:complexType name="setElementType">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ <xs:element name="type-name" type="xs:QName"/>
+ <xs:element name="value" type="pul:atomic-value" minOccurs="0"/>
+ <xs:element name="have-value" type="xs:boolean"/>
+ <xs:element name="have-empty-value" type="xs:boolean"/>
+ <xs:element name="is-in-substitution-group" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-setElementType">
+ <xs:complexContent>
+ <xs:extension base="pul:setElementType">
+ <xs:sequence>
+ <xs:element name="old-type-name" type="xs:QName"/>
+ <xs:element name="old-value" type="pul:atomic-value" minOccurs="0"/>
+ <xs:element name="old-have-value" type="xs:boolean"/>
+ <xs:element name="old-have-empty-value" type="xs:boolean"/>
+ <xs:element name="old-is-in-substitution-group" type="xs:boolean"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ -->
+
+ <xs:complexType name="revalidateType">
+ <xs:sequence>
+ <xs:element name="target" type="pul:target-type"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ <xs:complexType name="e-c-revalidateType">
+ <xs:complexContent>
+ <xs:extension base="pul:revalidateType">
+ <xs:sequence>
+ <xs:element name="type-undo-list" type="pul:type-undo-list" minOccurs="0"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ -->
+
+ <!--
+ *** Create Document ***
+ -->
+
+ <xs:complexType name="createDocument">
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI"/>
+ <xs:element name="document-reference" type="pul:target-type"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-createDocument">
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI"/>
+ <xs:element name="document-reference" type="pul:target-type"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!--
+ *** Delete Document ***
+ -->
+
+ <xs:complexType name="deleteDocument">
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="e-c-deleteDocument">
+ <xs:complexContent>
+ <xs:extension base="pul:deleteDocument">
+ <xs:sequence>
+ <xs:element name="deleted-document" type="pul:ser-seq-single-document"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!-- The following operations are not supported since the indexes definition
+ are in the static context of the query and not in that of the PUL manipulation modules
+ <xs:element name="createIndex">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="qname" type="xs:QName"/>
+ <xs:element name="the-num-key-columns" type="xs:nonNegativeInteger"/>
+ <xs:element name="key-types">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="key-type" type="xs:QName" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="collations">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="collation" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="timezone" type="xs:nonNegativeInteger"/>
+ <xs:element name="is-general" type="xs:boolean"/>
+ <xs:element name="is-unique" type="xs:boolean"/>
+ <xs:element name="is-sorted" type="xs:boolean"/>
+ <xs:element name="is-temp" type="xs:boolean"/>
+ <xs:element name="is-thread-safe" type="xs:boolean"/>
+ <xs:element name="is-automatic" type="xs:boolean"/>
+ <xs:element name="e-sources">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="source" type="xs:QName" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="o-sources">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="source" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="rebuildIndex">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="qname" type="xs:QName"/>
+ <xs:element name="sources">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="source" type="xs:QName" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="dropIndex">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="qname" type="xs:QName"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ -->
+
+</xs:schema>
=== modified file 'src/compiler/expression/fo_expr.cpp'
--- src/compiler/expression/fo_expr.cpp 2011-11-23 15:16:51 +0000
+++ src/compiler/expression/fo_expr.cpp 2012-01-02 09:53:25 +0000
@@ -215,7 +215,12 @@
expr* arg = theArgs[i].getp();
- if (arg->is_updating())
+ if (arg->is_updating() &&
+ !(
+ func->getKind() == FunctionConsts::ZORBA_STORE_PUL_REPRESENTATION_PUL_TO_XDM_2 ||
+ func->getKind() == FunctionConsts::ZORBA_STORE_PUL_REPRESENTATION_PUL_TO_COMPLETE_XDM_1
+ )
+ )
{
throw XQUERY_EXCEPTION(err::XUST0001,
ERROR_PARAMS(ZED(XUST0001_Generic)),
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2011-12-22 14:14:53 +0000
+++ src/context/static_context.cpp 2012-01-02 09:53:25 +0000
@@ -325,6 +325,11 @@
= static_context::ZORBA_NS_PREFIX + "modules/store/data-structures/unordered-map";
const zstring
+static_context::ZORBA_STORE_PUL_REPRESENTATION_FN_NS
+ = static_context::ZORBA_NS_PREFIX + "modules/store/pul/representation";
+
+
+const zstring
static_context::ZORBA_SCHEMA_FN_NS = static_context::ZORBA_NS_PREFIX + "modules/schema";
const zstring
@@ -407,6 +412,7 @@
ns == ZORBA_STORE_STATIC_INDEXES_DML_FN_NS ||
ns == ZORBA_STORE_STATIC_INTEGRITY_CONSTRAINTS_DDL_FN_NS ||
ns == ZORBA_STORE_STATIC_INTEGRITY_CONSTRAINTS_DML_FN_NS ||
+ ns == ZORBA_STORE_PUL_REPRESENTATION_FN_NS ||
ns == ZORBA_SCHEMA_FN_NS ||
ns == ZORBA_XQDOC_FN_NS ||
ns == ZORBA_RANDOM_FN_NS ||
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2011-12-22 14:14:53 +0000
+++ src/context/static_context.h 2012-01-02 09:53:25 +0000
@@ -458,6 +458,7 @@
static const zstring ZORBA_STORE_STATIC_INTEGRITY_CONSTRAINTS_DML_FN_NS;
static const zstring ZORBA_STORE_DYNAMIC_DOCUMENTS_FN_NS;
static const zstring ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS;
+ static const zstring ZORBA_STORE_PUL_REPRESENTATION_FN_NS;
static const zstring ZORBA_SCHEMA_FN_NS;
static const zstring ZORBA_XQDOC_FN_NS;
static const zstring ZORBA_RANDOM_FN_NS;
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2011-12-21 14:40:33 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-01-02 09:53:25 +0000
@@ -1796,10 +1796,6 @@
<value>"$1": reference already present in the store</value>
</diagnostic>
- <diagnostic code="ZAPI0030" name="NO_CURRENT_REFERENCE">
- <value>node has no current reference</value>
- </diagnostic>
-
<diagnostic code="ZAPI0039" name="XQUERY_HAS_ITERATOR_ALREADY">
<value>XQuery has iterator already</value>
</diagnostic>
=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp 2011-12-21 14:40:33 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-01-02 09:53:25 +0000
@@ -720,9 +720,6 @@
ZorbaErrorCode ZAPI0029_REFERENCE_ALREADY_PRESENT( "ZAPI0029" );
-ZorbaErrorCode ZAPI0030_NO_CURRENT_REFERENCE( "ZAPI0030" );
-
-
ZorbaErrorCode ZAPI0039_XQUERY_HAS_ITERATOR_ALREADY( "ZAPI0039" );
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2011-12-21 14:40:33 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-01-02 09:53:25 +0000
@@ -241,7 +241,6 @@
{ "ZAPI0027", "cannot update dynamic context with iterators" },
{ "ZAPI0028", "\"$1\": invalid node URI" },
{ "ZAPI0029", "\"$1\": reference already present in the store" },
- { "ZAPI0030", "node has no current reference" },
{ "ZAPI0039", "XQuery has iterator already" },
{ "ZAPI0040", "iterator is not open" },
{ "ZAPI0041", "iterator is already open" },
=== modified file 'src/functions/library.cpp'
--- src/functions/library.cpp 2011-10-14 07:35:51 +0000
+++ src/functions/library.cpp 2012-01-02 09:53:25 +0000
@@ -60,6 +60,7 @@
#include "functions/func_var_decl.h"
#include "functions/func_xqdoc.h"
#include "functions/func_documents.h"
+#include "functions/func_pul.h"
#include "functions/func_maps.h"
#include "functions/func_eval.h"
#include "functions/func_reflection.h"
@@ -124,6 +125,7 @@
populate_context_xqdoc(sctx);
populate_context_function_item_iter(sctx);
populate_context_documents(sctx);
+ populate_context_pul(sctx);
populate_context_maps(sctx);
populateContext_Arithmetics(sctx);
=== added file 'src/functions/pregenerated/func_pul.cpp'
--- src/functions/pregenerated/func_pul.cpp 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_pul.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#include "stdafx.h"
+#include "runtime/store/pul.h"
+#include "functions/func_pul.h"
+
+
+namespace zorba{
+
+
+
+PlanIter_t zorba_store_pul_representation_pul_to_xdm::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new PulToXdmImplIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_store_pul_representation_pul_to_complete_xdm::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new PulToCompleteXdmImplIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_store_pul_representation_xdm_to_pul_impl::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new XdmToPulImplIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_store_pul_representation_local_namespace_prefixes::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new LocalNamespacePrefixesIterator(sctx, loc, argv);
+}
+
+void populate_context_pul(static_context* sctx)
+{
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_store_pul_representation_pul_to_xdm,
+ (createQName("http://www.zorba-xquery.com/modules/store/pul/representation","","pul-to-xdm"),
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
+ GENV_TYPESYSTEM.ELEMENT_TYPE_ONE),
+ FunctionConsts::ZORBA_STORE_PUL_REPRESENTATION_PUL_TO_XDM_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_store_pul_representation_pul_to_complete_xdm,
+ (createQName("http://www.zorba-xquery.com/modules/store/pul/representation","","pul-to-complete-xdm"),
+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.ELEMENT_TYPE_ONE),
+ FunctionConsts::ZORBA_STORE_PUL_REPRESENTATION_PUL_TO_COMPLETE_XDM_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_store_pul_representation_xdm_to_pul_impl,
+ (createQName("http://www.zorba-xquery.com/modules/store/pul/representation","","xdm-to-pul-impl"),
+ GENV_TYPESYSTEM.ELEMENT_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
+ GENV_TYPESYSTEM.EMPTY_TYPE),
+ FunctionConsts::ZORBA_STORE_PUL_REPRESENTATION_XDM_TO_PUL_IMPL_3);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_store_pul_representation_xdm_to_pul_impl,
+ (createQName("http://www.zorba-xquery.com/modules/store/pul/representation","","xdm-to-pul-impl"),
+ GENV_TYPESYSTEM.ELEMENT_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
+ GENV_TYPESYSTEM.QNAME_TYPE_ONE,
+ GENV_TYPESYSTEM.EMPTY_TYPE),
+ FunctionConsts::ZORBA_STORE_PUL_REPRESENTATION_XDM_TO_PUL_IMPL_4);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_store_pul_representation_local_namespace_prefixes,
+ (createQName("http://www.zorba-xquery.com/modules/store/pul/representation","","local-namespace-prefixes"),
+ GENV_TYPESYSTEM.ELEMENT_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_STAR),
+ FunctionConsts::ZORBA_STORE_PUL_REPRESENTATION_LOCAL_NAMESPACE_PREFIXES_1);
+
+ }
+
+}
+
+
+}
+
+
+
=== added file 'src/functions/pregenerated/func_pul.h'
--- src/functions/pregenerated/func_pul.h 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_pul.h 2012-01-02 09:53:25 +0000
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#ifndef ZORBA_FUNCTIONS_PUL_H
+#define ZORBA_FUNCTIONS_PUL_H
+
+
+#include "common/shared_types.h"
+#include "functions/function_impl.h"
+
+
+namespace zorba {
+
+
+void populate_context_pul(static_context* sctx);
+
+
+
+
+//zorba-store-pul-representation:pul-to-xdm
+class zorba_store_pul_representation_pul_to_xdm : public function
+{
+public:
+ zorba_store_pul_representation_pul_to_xdm(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ bool accessesDynCtx() const { return true; }
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-store-pul-representation:pul-to-complete-xdm
+class zorba_store_pul_representation_pul_to_complete_xdm : public function
+{
+public:
+ zorba_store_pul_representation_pul_to_complete_xdm(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
+
+ bool accessesDynCtx() const { return true; }
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-store-pul-representation:xdm-to-pul-impl
+class zorba_store_pul_representation_xdm_to_pul_impl : public function
+{
+public:
+ zorba_store_pul_representation_xdm_to_pul_impl(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ short getScriptingKind() const { return UPDATING_EXPR; }
+
+ bool accessesDynCtx() const { return true; }
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-store-pul-representation:local-namespace-prefixes
+class zorba_store_pul_representation_local_namespace_prefixes : public function
+{
+public:
+ zorba_store_pul_representation_local_namespace_prefixes(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ CODEGEN_DECL();
+};
+
+
+} //namespace zorba
+
+
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2011-12-21 14:40:33 +0000
+++ src/functions/pregenerated/function_enum.h 2012-01-02 09:53:25 +0000
@@ -327,6 +327,11 @@
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_KEYS_1,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_SIZE_1,
ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_AVAILABLE_MAPS_0,
+ ZORBA_STORE_PUL_REPRESENTATION_PUL_TO_XDM_2,
+ ZORBA_STORE_PUL_REPRESENTATION_PUL_TO_COMPLETE_XDM_1,
+ ZORBA_STORE_PUL_REPRESENTATION_XDM_TO_PUL_IMPL_3,
+ ZORBA_STORE_PUL_REPRESENTATION_XDM_TO_PUL_IMPL_4,
+ ZORBA_STORE_PUL_REPRESENTATION_LOCAL_NAMESPACE_PREFIXES_1,
FN_CODEPOINTS_TO_STRING_1,
FN_STRING_TO_CODEPOINTS_1,
FN_COMPARE_2,
=== modified file 'src/runtime/spec/mappings.xml'
--- src/runtime/spec/mappings.xml 2011-10-14 07:35:51 +0000
+++ src/runtime/spec/mappings.xml 2012-01-02 09:53:25 +0000
@@ -78,6 +78,11 @@
prefix="zorba-store-documents"/>
<zorba:namespace
+ uri="http://www.zorba-xquery.com/modules/store/pul/representation"
+ define="ZORBA_STORE_PUL_REPRESENTATION_FN_NS"
+ prefix="zorba-store-pul-representation"/>
+
+ <zorba:namespace
uri="http://www.zorba-xquery.com/modules/store/data-structures/unordered-map"
define="ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS"
prefix="zorba-store-data-structure-unordered-map"/>
=== added file 'src/runtime/spec/store/pul.xml'
--- src/runtime/spec/store/pul.xml 1970-01-01 00:00:00 +0000
+++ src/runtime/spec/store/pul.xml 2012-01-02 09:53:25 +0000
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+-->
+<zorba:iterators xmlns:zorba="http://www.zorba-xquery.com"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
+
+ <zorba:source>
+ <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
+ </zorba:source>
+
+
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
+<zorba:iterator name="PulToXdmImplIterator">
+ <zorba:description author="Federico Cavalieri">
+ Creates an XDM representation of a PUL
+ </zorba:description>
+ <zorba:function>
+
+ <zorba:signature localname="pul-to-xdm"
+ prefix="zorba-store-pul-representation">
+ <zorba:param>item()*</zorba:param>
+ <zorba:param>xs:boolean</zorba:param>
+ <zorba:output>element()</zorba:output>
+ </zorba:signature>
+
+ <zorba:methods>
+ <zorba:accessesDynCtx returnValue="true" />
+ </zorba:methods>
+
+ </zorba:function>
+
+</zorba:iterator>
+
+ <zorba:iterator name="PulToCompleteXdmImplIterator">
+
+ <zorba:description author="Federico Cavalieri">
+ Creates an XDM representation of a PUL with undo information.
+ </zorba:description>
+
+ <zorba:function>
+
+ <zorba:signature localname="pul-to-complete-xdm"
+ prefix="zorba-store-pul-representation">
+ <zorba:param>item()*</zorba:param>
+ <zorba:output>element()</zorba:output>
+ </zorba:signature>
+
+ <zorba:methods>
+ <zorba:getScriptingKind returnValue="SEQUENTIAL_FUNC_EXPR" />
+ <zorba:accessesDynCtx returnValue="true" />
+ </zorba:methods>
+
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <zorba:iterator name="XdmToPulImplIterator">
+
+ <zorba:description author="Federico Cavalieri">
+ Restores a PUL from an XDM representation.
+ </zorba:description>
+
+ <zorba:function>
+
+ <zorba:signature localname="xdm-to-pul-impl"
+ prefix="zorba-store-pul-representation">
+ <zorba:param>element()</zorba:param>
+ <zorba:param>xs:boolean</zorba:param>
+ <zorba:param>xs:boolean</zorba:param>
+ <zorba:output>empty-sequence()</zorba:output>
+ </zorba:signature>
+
+ <zorba:signature localname="xdm-to-pul-impl"
+ prefix="zorba-store-pul-representation">
+ <zorba:param>element()</zorba:param>
+ <zorba:param>xs:boolean</zorba:param>
+ <zorba:param>xs:boolean</zorba:param>
+ <zorba:param>xs:QName</zorba:param>
+ <zorba:output>empty-sequence()</zorba:output>
+ </zorba:signature>
+
+ <zorba:methods>
+ <zorba:getScriptingKind returnValue="UPDATING_EXPR" />
+ <zorba:accessesDynCtx returnValue="true" />
+ </zorba:methods>
+
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <zorba:iterator name="LocalNamespacePrefixesIterator">
+
+ <zorba:description author="Federico Cavalieri">
+ Used for retrieving the local namespace bindings of an element
+ </zorba:description>
+
+ <zorba:function>
+
+ <zorba:signature localname="local-namespace-prefixes"
+ prefix="zorba-store-pul-representation">
+ <zorba:param>element()</zorba:param>
+ <zorba:output>xs:string*</zorba:output>
+ </zorba:signature>
+
+ </zorba:function>
+
+ <zorba:state generateReset="false" generateDestructor="false">
+ <zorba:member type="store::NsBindings" name="theBindings"
+ brief="vector of local namespace bindings" />
+ <zorba:member type="ulong" name="thePosition" brief="current position" />
+ </zorba:state>
+
+ </zorba:iterator>
+
+</zorba:iterators>
=== added file 'src/runtime/store/pregenerated/pul.cpp'
--- src/runtime/store/pregenerated/pul.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/store/pregenerated/pul.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+#include "stdafx.h"
+#include "zorbatypes/rchandle.h"
+#include "zorbatypes/zstring.h"
+#include "runtime/visitors/planiter_visitor.h"
+#include "runtime/store/pul.h"
+#include "system/globalenv.h"
+
+
+#include "store/api/iterator.h"
+
+namespace zorba {
+
+// <PulToXdmImplIterator>
+const char* PulToXdmImplIterator::class_name_str = "PulToXdmImplIterator";
+PulToXdmImplIterator::class_factory<PulToXdmImplIterator>
+PulToXdmImplIterator::g_class_factory;
+
+const serialization::ClassVersion
+PulToXdmImplIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int PulToXdmImplIterator::class_versions_count =
+sizeof(PulToXdmImplIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void PulToXdmImplIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+PulToXdmImplIterator::~PulToXdmImplIterator() {}
+
+// </PulToXdmImplIterator>
+
+
+// <PulToCompleteXdmImplIterator>
+const char* PulToCompleteXdmImplIterator::class_name_str = "PulToCompleteXdmImplIterator";
+PulToCompleteXdmImplIterator::class_factory<PulToCompleteXdmImplIterator>
+PulToCompleteXdmImplIterator::g_class_factory;
+
+const serialization::ClassVersion
+PulToCompleteXdmImplIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int PulToCompleteXdmImplIterator::class_versions_count =
+sizeof(PulToCompleteXdmImplIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void PulToCompleteXdmImplIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+PulToCompleteXdmImplIterator::~PulToCompleteXdmImplIterator() {}
+
+// </PulToCompleteXdmImplIterator>
+
+
+// <XdmToPulImplIterator>
+const char* XdmToPulImplIterator::class_name_str = "XdmToPulImplIterator";
+XdmToPulImplIterator::class_factory<XdmToPulImplIterator>
+XdmToPulImplIterator::g_class_factory;
+
+const serialization::ClassVersion
+XdmToPulImplIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int XdmToPulImplIterator::class_versions_count =
+sizeof(XdmToPulImplIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void XdmToPulImplIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+XdmToPulImplIterator::~XdmToPulImplIterator() {}
+
+// </XdmToPulImplIterator>
+
+
+// <LocalNamespacePrefixesIterator>
+const char* LocalNamespacePrefixesIterator::class_name_str = "LocalNamespacePrefixesIterator";
+LocalNamespacePrefixesIterator::class_factory<LocalNamespacePrefixesIterator>
+LocalNamespacePrefixesIterator::g_class_factory;
+
+const serialization::ClassVersion
+LocalNamespacePrefixesIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int LocalNamespacePrefixesIterator::class_versions_count =
+sizeof(LocalNamespacePrefixesIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void LocalNamespacePrefixesIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+LocalNamespacePrefixesIterator::~LocalNamespacePrefixesIterator() {}
+
+LocalNamespacePrefixesIteratorState::LocalNamespacePrefixesIteratorState() {}
+
+
+void LocalNamespacePrefixesIteratorState::init(PlanState& planState) {
+ PlanIteratorState::init(planState);
+}
+// </LocalNamespacePrefixesIterator>
+
+
+
+}
+
+
=== added file 'src/runtime/store/pregenerated/pul.h'
--- src/runtime/store/pregenerated/pul.h 1970-01-01 00:00:00 +0000
+++ src/runtime/store/pregenerated/pul.h 2012-01-02 09:53:25 +0000
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+#ifndef ZORBA_RUNTIME_STORE_PUL_H
+#define ZORBA_RUNTIME_STORE_PUL_H
+
+
+#include "common/shared_types.h"
+
+
+
+#include "runtime/base/narybase.h"
+
+
+namespace zorba {
+
+/**
+ *
+ * Creates an XDM representation of a PUL
+ *
+ * Author: Federico Cavalieri
+ */
+class PulToXdmImplIterator : public NaryBaseIterator<PulToXdmImplIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(PulToXdmImplIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(PulToXdmImplIterator,
+ NaryBaseIterator<PulToXdmImplIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<PulToXdmImplIterator, PlanIteratorState>*)this);
+ }
+
+ PulToXdmImplIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<PulToXdmImplIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~PulToXdmImplIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Creates an XDM representation of a PUL with undo information.
+ *
+ * Author: Federico Cavalieri
+ */
+class PulToCompleteXdmImplIterator : public NaryBaseIterator<PulToCompleteXdmImplIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(PulToCompleteXdmImplIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(PulToCompleteXdmImplIterator,
+ NaryBaseIterator<PulToCompleteXdmImplIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<PulToCompleteXdmImplIterator, PlanIteratorState>*)this);
+ }
+
+ PulToCompleteXdmImplIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<PulToCompleteXdmImplIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~PulToCompleteXdmImplIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Restores a PUL from an XDM representation.
+ *
+ * Author: Federico Cavalieri
+ */
+class XdmToPulImplIterator : public NaryBaseIterator<XdmToPulImplIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(XdmToPulImplIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(XdmToPulImplIterator,
+ NaryBaseIterator<XdmToPulImplIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<XdmToPulImplIterator, PlanIteratorState>*)this);
+ }
+
+ XdmToPulImplIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<XdmToPulImplIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~XdmToPulImplIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Used for retrieving the local namespace bindings of an element
+ *
+ * Author: Federico Cavalieri
+ */
+class LocalNamespacePrefixesIteratorState : public PlanIteratorState
+{
+public:
+ store::NsBindings theBindings; //vector of local namespace bindings
+ ulong thePosition; //current position
+
+ LocalNamespacePrefixesIteratorState();
+
+ ~LocalNamespacePrefixesIteratorState();
+
+ void init(PlanState&);
+ void reset(PlanState&);
+};
+
+class LocalNamespacePrefixesIterator : public NaryBaseIterator<LocalNamespacePrefixesIterator, LocalNamespacePrefixesIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(LocalNamespacePrefixesIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(LocalNamespacePrefixesIterator,
+ NaryBaseIterator<LocalNamespacePrefixesIterator, LocalNamespacePrefixesIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<LocalNamespacePrefixesIterator, LocalNamespacePrefixesIteratorState>*)this);
+ }
+
+ LocalNamespacePrefixesIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<LocalNamespacePrefixesIterator, LocalNamespacePrefixesIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~LocalNamespacePrefixesIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+}
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== added file 'src/runtime/store/pul_impl.cpp'
--- src/runtime/store/pul_impl.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/store/pul_impl.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "system/globalenv.h"
+#include "runtime/store/pul.h"
+#include "runtime/core/apply_updates.h"
+
+#include "store/api/pul.h"
+#include "store/api/store.h"
+#include "store/api/item_factory.h"
+#include "store/api/item.h"
+#include "store/api/copymode.h"
+#include "store/api/pul_visitor_factory.h"
+#include "context/static_context.h"
+#include "compiler/api/compilercb.h"
+#include "api/staticcontextimpl.h"
+#include "api/unmarshaller.h"
+#include "zorba/zorba.h"
+#include "zorba/singleton_item_sequence.h"
+
+#include "diagnostics/user_exception.h"
+namespace zorba {
+
+/*******************************************************************************
+ ********************************************************************************/
+bool PulToXdmImplIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ store::Item_t arg;
+ store::Item_t encode;
+ PlanIteratorState* state;
+ store::PULVisitor_t visitor;
+
+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+ consumeNext(encode, theChildren[1].getp(), aPlanState);
+ visitor=GENV_PUL_VISITOR_FACTORY->createSimplePULVisitor(result,encode->getBooleanValue());
+
+ while (consumeNext(arg, theChildren[0].getp(), aPlanState))
+ {
+ if (arg->isPul())
+ {
+ try
+ {
+ visitor->visit(arg);
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e,loc);
+ throw;
+ }
+ }
+ else
+ {
+ static const char *err_ns = "http://www.zorba-xquery.com/modules/store/pul/errors";
+ static const char *err_msg = "The first argument of the pul-to-xdm function must be a PUL";
+ store::Item_t err_qname;
+ GENV_ITEMFACTORY->createQName(err_qname, err_ns, "err", "PUL001");
+ throw USER_EXCEPTION(err_qname, err_msg, ERROR_LOC( loc ));
+ }
+ }
+
+ if (encode->getBooleanValue())
+ {
+ ItemFactory* lFactory = Zorba::getInstance(0)->getItemFactory();
+ Item lFunctionName = lFactory->createQName("http://www.zorba-xquery.com/modules/store/pul/representation", "encode-xdm-pul-impl");
+ SingletonItemSequence* lReqSeq = new SingletonItemSequence(Item(result));
+ std::vector<ItemSequence_t> lArgs;
+ lArgs.push_back(lReqSeq);
+ StaticContext_t lStatic = Zorba::getInstance(0)->createStaticContext();
+ lStatic->setRevalidationMode(zorba::validate_skip);
+ Zorba_CompilerHints_t lHints;
+ lStatic->loadProlog("import module namespace pulr = \"http://www.zorba-xquery.com/modules/store/pul/representation\";",
+ lHints);
+ ItemSequence_t lResults = lStatic->invoke(lFunctionName, lArgs);
+ Iterator_t lResultIter = lResults->getIterator();
+ Item res;
+ lResultIter->open();
+ lResultIter->next(res);
+ lResultIter->close();
+ result=Unmarshaller::getInternalItem(res);
+ }
+
+ STACK_PUSH(true,state);
+ STACK_END(state);
+}
+
+bool PulToCompleteXdmImplIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ store::Item_t arg;
+ store::Item_t encode;
+ store::Item_t mergedPul=GENV_ITEMFACTORY->createPendingUpdateList();
+ store::PULVisitor_t visitor;
+ PlanIteratorState* state;
+
+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+ while (consumeNext(arg, theChildren[0].getp(), aPlanState))
+ {
+ if (arg->isPul())
+ {
+ try
+ {
+ static_cast<store::PUL*>(mergedPul.getp())->mergeUpdates(arg.getp());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e,loc);
+ throw;
+ }
+ }
+ else
+ {
+ static const char *err_ns = "http://www.zorba-xquery.com/modules/store/pul/errors";
+ static const char *err_msg= "The argument provided to the pul-to-complete-xdm function must be a PUL";
+ store::Item_t err_qname;
+ GENV_ITEMFACTORY->createQName(err_qname, err_ns, "err", "PUL001");
+ throw USER_EXCEPTION(err_qname, err_msg, ERROR_LOC( loc ));
+ }
+ }
+
+ try
+ {
+ visitor= GENV_PUL_VISITOR_FACTORY->createCompletePULVisitor(result);
+ visitor->visit(mergedPul);
+
+ apply_updates(
+ aPlanState.theCompilerCB,
+ aPlanState.theGlobalDynCtx,
+ theSctx,
+ static_cast<store::PUL*>(mergedPul.getp()),
+ loc);
+
+ visitor->visit(mergedPul);
+
+ ItemFactory* lFactory = Zorba::getInstance(0)->getItemFactory();
+ Item lFunctionName = lFactory->createQName("http://www.zorba-xquery.com/modules/store/pul/representation", "encode-complete-xdm-pul-impl");
+ SingletonItemSequence* lReqSeq = new SingletonItemSequence(Item(result));
+ std::vector<ItemSequence_t> lArgs;
+ lArgs.push_back(lReqSeq);
+ StaticContext_t lStatic= Zorba::getInstance(0)->createStaticContext();
+ lStatic->setRevalidationMode(zorba::validate_skip);
+ Zorba_CompilerHints_t lHints;
+ lStatic->loadProlog("import module namespace pulr = \"http://www.zorba-xquery.com/modules/store/pul/representation\";",
+ lHints);
+
+ ItemSequence_t lResults = lStatic->invoke(lFunctionName, lArgs);
+ Iterator_t lResultIter = lResults->getIterator();
+ Item res;
+ lResultIter->open();
+ lResultIter->next(res);
+ lResultIter->close();
+
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e,loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+ STACK_END(state);
+}
+
+bool XdmToPulImplIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ store::Item_t arg;
+ store::Item_t decode;
+ store::Item_t restoreTypes;
+ store::Item_t decodedPul;
+ store::Item_t targetMapName;
+ PlanIteratorState* state;
+ store::PUL_t res=GENV_ITEMFACTORY->createPendingUpdateList();
+ store::PULVisitor_t visitor;
+
+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+ consumeNext(decode, theChildren[1].getp(), aPlanState);
+ consumeNext(restoreTypes, theChildren[2].getp(), aPlanState);
+
+ consumeNext(arg, theChildren[0].getp(), aPlanState);
+ decodedPul=arg->copy(NULL,store::CopyMode());
+
+ if (decode->getBooleanValue())
+ {
+ visitor=GENV_PUL_VISITOR_FACTORY->createXMLPULVisitor(theSctx,restoreTypes->getBooleanValue());
+ try
+ {
+ visitor->visit(decodedPul);
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e,loc);
+ throw;
+ }
+ }
+
+ try
+ {
+ if (theChildren.size() == 4)
+ {
+ consumeNext(targetMapName, theChildren[1].getp(), aPlanState);
+ visitor=GENV_PUL_VISITOR_FACTORY->createXDMPULVisitor(res,theSctx,targetMapName);
+ }
+ else
+ {
+ visitor=GENV_PUL_VISITOR_FACTORY->createXDMPULVisitor(res,theSctx);
+ }
+ visitor->visit(decodedPul);
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e,loc);
+ throw;
+ }
+
+ result=res;
+
+ STACK_PUSH(true,state);
+ STACK_END(state);
+}
+
+LocalNamespacePrefixesIteratorState::~LocalNamespacePrefixesIteratorState()
+{
+}
+
+
+void LocalNamespacePrefixesIteratorState::reset(PlanState& planState)
+{
+ PlanIteratorState::reset(planState);
+ thePosition = 0;
+ theBindings.clear();
+}
+
+bool LocalNamespacePrefixesIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ store::Item_t elem;
+ LocalNamespacePrefixesIteratorState* lState;
+ zstring prefix;
+
+ DEFAULT_STACK_INIT(LocalNamespacePrefixesIteratorState, lState, aPlanState);
+
+ consumeNext(elem, theChildren[0].getp(), aPlanState);
+
+ elem->getNamespaceBindings(lState->theBindings,store::StoreConsts::ONLY_LOCAL_NAMESPACES);
+ lState->thePosition = 0;
+
+ while (lState->thePosition < lState->theBindings.size())
+ {
+ prefix = lState->theBindings[lState->thePosition].first;
+ STACK_PUSH(GENV_ITEMFACTORY->createString(result, prefix), lState);
+ ++lState->thePosition;
+ }
+
+ STACK_END (lState);
+}
+
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2011-12-21 14:40:33 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-01-02 09:53:25 +0000
@@ -526,6 +526,14 @@
class AvailableMapsIterator;
+ class PulToXdmImplIterator;
+
+ class PulToCompleteXdmImplIterator;
+
+ class XdmToPulImplIterator;
+
+ class LocalNamespacePrefixesIterator;
+
class CodepointsToStringIterator;
class StringToCodepointsIterator;
@@ -1339,6 +1347,18 @@
virtual void beginVisit ( const AvailableMapsIterator& ) = 0;
virtual void endVisit ( const AvailableMapsIterator& ) = 0;
+ virtual void beginVisit ( const PulToXdmImplIterator& ) = 0;
+ virtual void endVisit ( const PulToXdmImplIterator& ) = 0;
+
+ virtual void beginVisit ( const PulToCompleteXdmImplIterator& ) = 0;
+ virtual void endVisit ( const PulToCompleteXdmImplIterator& ) = 0;
+
+ virtual void beginVisit ( const XdmToPulImplIterator& ) = 0;
+ virtual void endVisit ( const XdmToPulImplIterator& ) = 0;
+
+ virtual void beginVisit ( const LocalNamespacePrefixesIterator& ) = 0;
+ virtual void endVisit ( const LocalNamespacePrefixesIterator& ) = 0;
+
virtual void beginVisit ( const CodepointsToStringIterator& ) = 0;
virtual void endVisit ( const CodepointsToStringIterator& ) = 0;
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2011-12-21 14:40:33 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-01-02 09:53:25 +0000
@@ -62,6 +62,7 @@
#include "runtime/sequences/sequences.h"
#include "runtime/store/documents.h"
#include "runtime/store/maps.h"
+#include "runtime/store/pul.h"
#include "runtime/strings/strings.h"
#include "runtime/xqdoc/xqdoc.h"
@@ -3569,6 +3570,62 @@
// </AvailableMapsIterator>
+// <PulToXdmImplIterator>
+void PrinterVisitor::beginVisit ( const PulToXdmImplIterator& a) {
+ thePrinter.startBeginVisit("PulToXdmImplIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const PulToXdmImplIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </PulToXdmImplIterator>
+
+
+// <PulToCompleteXdmImplIterator>
+void PrinterVisitor::beginVisit ( const PulToCompleteXdmImplIterator& a) {
+ thePrinter.startBeginVisit("PulToCompleteXdmImplIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const PulToCompleteXdmImplIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </PulToCompleteXdmImplIterator>
+
+
+// <XdmToPulImplIterator>
+void PrinterVisitor::beginVisit ( const XdmToPulImplIterator& a) {
+ thePrinter.startBeginVisit("XdmToPulImplIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const XdmToPulImplIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </XdmToPulImplIterator>
+
+
+// <LocalNamespacePrefixesIterator>
+void PrinterVisitor::beginVisit ( const LocalNamespacePrefixesIterator& a) {
+ thePrinter.startBeginVisit("LocalNamespacePrefixesIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const LocalNamespacePrefixesIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </LocalNamespacePrefixesIterator>
+
+
// <CodepointsToStringIterator>
void PrinterVisitor::beginVisit ( const CodepointsToStringIterator& a) {
thePrinter.startBeginVisit("CodepointsToStringIterator", ++theId);
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2011-12-21 14:40:33 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-01-02 09:53:25 +0000
@@ -792,6 +792,18 @@
void beginVisit( const AvailableMapsIterator& );
void endVisit ( const AvailableMapsIterator& );
+ void beginVisit( const PulToXdmImplIterator& );
+ void endVisit ( const PulToXdmImplIterator& );
+
+ void beginVisit( const PulToCompleteXdmImplIterator& );
+ void endVisit ( const PulToCompleteXdmImplIterator& );
+
+ void beginVisit( const XdmToPulImplIterator& );
+ void endVisit ( const XdmToPulImplIterator& );
+
+ void beginVisit( const LocalNamespacePrefixesIterator& );
+ void endVisit ( const LocalNamespacePrefixesIterator& );
+
void beginVisit( const CodepointsToStringIterator& );
void endVisit ( const CodepointsToStringIterator& );
=== modified file 'src/store/api/copymode.h'
--- src/store/api/copymode.h 2011-10-07 11:55:43 +0000
+++ src/store/api/copymode.h 2012-01-02 09:53:25 +0000
@@ -34,13 +34,15 @@
bool theTypePreserve;
bool theNsPreserve;
bool theNsInherit;
+ bool theCopyReference;
CopyMode()
:
theDoCopy(true),
theTypePreserve(true),
theNsPreserve(true),
- theNsInherit(true)
+ theNsInherit(true),
+ theCopyReference(false)
{
}
@@ -49,7 +51,8 @@
theDoCopy(aCopyMode.theDoCopy),
theTypePreserve(aCopyMode.theTypePreserve),
theNsPreserve(aCopyMode.theNsPreserve),
- theNsInherit(aCopyMode.theNsInherit)
+ theNsInherit(aCopyMode.theNsInherit),
+ theCopyReference(aCopyMode.theCopyReference)
{
}
@@ -57,12 +60,14 @@
bool copy,
bool typePreserve,
bool nsPreserve,
- bool nsInherit)
+ bool nsInherit,
+ bool copyReference=false)
{
theDoCopy = copy;
theTypePreserve = typePreserve;
theNsPreserve = nsPreserve;
theNsInherit = nsInherit;
+ theCopyReference= copyReference;
}
std::string toString() const
@@ -76,6 +81,8 @@
s += (theNsPreserve ? "T" : "F");
s += " ";
s += (theNsInherit ? "T" : "F");
+ s += " ";
+ s += (theCopyReference ? "T" : "F");
s += "]";
return s;
}
=== modified file 'src/store/api/pul.h'
--- src/store/api/pul.h 2011-10-12 20:59:49 +0000
+++ src/store/api/pul.h 2012-01-02 09:53:25 +0000
@@ -42,7 +42,7 @@
class IndexEntryCreator;
class Index;
class SchemaValidator;
-
+class PULVisitor;
/*******************************************************************************
@@ -294,9 +294,10 @@
virtual store::SchemaValidator* getValidator() const = 0;
virtual void setICChecker(ICChecker* icChecker) = 0;
+
+ virtual void accept(PULVisitor* visitor) = 0;
};
-
}
}
=== added file 'src/store/api/pul_visitor.h'
--- src/store/api/pul_visitor.h 1970-01-01 00:00:00 +0000
+++ src/store/api/pul_visitor.h 2012-01-02 09:53:25 +0000
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_STORE_PULVISITOR_H
+#define ZORBA_STORE_PULVISITOR_H
+
+#include "zorbamisc/config/platform.h"
+
+#include "store/api/shared_types.h"
+#include "store/api/item.h"
+
+
+namespace zorba
+{
+
+namespace store
+{
+
+/**
+ * General PUL Visitor interface. Used in the PUL accept mehtod.
+ * It is wrapped into a rchandle object for garbage collection.
+ */
+class PULVisitor : virtual public SimpleRCObject
+{
+ public:
+ enum VisitorKind
+ {
+ SIMPLE_PUL_ENCODER,
+ COMPLETE_PUL_ENCODER,
+ XML_PUL_DECODER,
+ XDM_PUL_DECODER
+ };
+
+ PULVisitor() {};
+
+ virtual void visit(store::Item_t&) = 0;
+
+ virtual VisitorKind getVisitorKind() = 0;
+
+};
+
+}//store
+}//zorba
+#endif
=== added file 'src/store/api/pul_visitor_factory.h'
--- src/store/api/pul_visitor_factory.h 1970-01-01 00:00:00 +0000
+++ src/store/api/pul_visitor_factory.h 2012-01-02 09:53:25 +0000
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_STORE_PULVISITOR_FACTORY_H
+#define ZORBA_STORE_PULVISITOR_FACTORY_H
+
+
+#include "store/api/pul_visitor.h"
+
+
+namespace zorba {
+
+class static_context;
+
+namespace store {
+
+
+class PULVisitorFactory
+{
+public:
+ virtual ~PULVisitorFactory() {}
+
+ /**
+ * Creates a PUL visitor which generates a representation of a PUL
+ * before its application. If willBeEncoded is true, the identifiers of
+ * the nodes are duplicated.
+ */
+ virtual PULVisitor* createSimplePULVisitor(store::Item_t& result, bool willBeEncoded) = 0;
+
+ /**
+ * Creates a PUL visitor which generates a representation of a PUL
+ * after its application. This includes undo information and a
+ * representation of the text node merges occurred during application.
+ */
+ virtual PULVisitor* createCompletePULVisitor(store::Item_t& result) = 0;
+
+ /**
+ * Creates an XDM PUL visitor which parses an XDM PUL representation.
+ */
+ virtual PULVisitor* createXDMPULVisitor(store::PUL_t& result, static_context * sctx) = 0;
+
+ /**
+ * Creates an XDM PUL visitor which parses an XDM PUL representation.
+ * The name of an index from node references to nodes is provided.
+ */
+ virtual PULVisitor* createXDMPULVisitor(store::PUL_t& result, static_context * sctx, store::Item_t referenceIndexName) = 0;
+
+ /**
+ * Creates an XML PUL visitor which parses an XML PUL representation.
+ */
+ virtual PULVisitor* createXMLPULVisitor(static_context * sctx, bool restoreTypes) = 0;
+};
+
+
+}
+}
+
+#endif
+
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
+/* vim:set et sw=2 ts=2: */
=== modified file 'src/store/api/shared_types.h'
--- src/store/api/shared_types.h 2011-12-21 14:40:33 +0000
+++ src/store/api/shared_types.h 2012-01-02 09:53:25 +0000
@@ -59,6 +59,11 @@
class ItemIterator;
typedef rchandle<ItemIterator> ItemIterator_t;
+class PULVisitorFactory;
+
+class PULVisitor;
+typedef rchandle<PULVisitor> PULVisitor_t;
+
class TempSeq;
typedef rchandle<TempSeq> TempSeq_t;
=== modified file 'src/store/api/store.h'
--- src/store/api/store.h 2011-12-21 14:40:33 +0000
+++ src/store/api/store.h 2012-01-02 09:53:25 +0000
@@ -37,6 +37,7 @@
class IndexSpecification;
class IteratorFactory;
+class PULVisitorFactory;
/**
@@ -60,6 +61,11 @@
*/
virtual IteratorFactory* getIteratorFactory() const = 0;
+ /**
+ * Get the PUL Visitor factory used by this store.
+ */
+ virtual PULVisitorFactory* getPULVisitorFactory() const = 0;
+
SYNC_CODE(virtual Lock& getGlobalLock() = 0;)
/**
=== modified file 'src/store/naive/CMakeLists.txt'
--- src/store/naive/CMakeLists.txt 2011-06-22 17:30:15 +0000
+++ src/store/naive/CMakeLists.txt 2012-01-02 09:53:25 +0000
@@ -47,6 +47,14 @@
inmemorystore.cpp
inmemorystorec.cpp
dataguide.cpp
+ simple_pul_visitor_factory.cpp
+ pul_encoding.cpp
+ pul_xdm_encoding.cpp
+ pul_cxdm_encoding.cpp
+ pul_decoding.cpp
+ pul_xdm_decoding.cpp
+ pul_xml_decoding.cpp
+ pul_visitors.cpp
)
IF (NOT ZORBA_NO_FULL_TEXT)
=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp 2011-11-28 19:07:13 +0000
+++ src/store/naive/node_items.cpp 2012-01-02 09:53:25 +0000
@@ -1053,6 +1053,39 @@
}
}
+/*******************************************************************************
+ Updates the node OrdPath and the OrdPaths of the nodes in its subtree according
+ to their current position.
+********************************************************************************/
+void OrdPathNode::refreshOrdPath()
+{
+ if (theParent==NULL)
+ theOrdPath.setAsRoot();
+
+ if (getNodeKind()==store::StoreConsts::elementNode || getNodeKind()==store::StoreConsts::documentNode)
+ {
+ InternalNode* thisNode=static_cast<InternalNode *>(this);
+ for (size_t i=0; i<thisNode->theNodes.size();++i)
+ {
+#ifndef TEXT_ORDPATH
+ if (thisNode->theNodes[i]->getNodeKind()!=store::StoreConsts::textNode)
+ {
+ static_cast<OrdPathNode*>(thisNode->theNodes[i])->theOrdPath=theOrdPath;
+ static_cast<OrdPathNode*>(thisNode->theNodes[i])->theOrdPath.appendComp(i*2+1);
+ }
+#else
+ static_cast<OrdPathNode*>(thisNode->theNodes[i])->theOrdPath=theOrdPath;
+ static_cast<OrdPathNode*>(thisNode->theNodes[i])->theOrdPath.appendComp(i*2+1);
+#endif
+ if (thisNode->theNodes[i]->getNodeKind()!=store::StoreConsts::elementNode)
+ static_cast<OrdPathNode*>(thisNode->theNodes[i])->refreshOrdPath();
+ }
+ }
+
+
+
+}
+
/*******************************************************************************
Return true if "aOther" is an ancestore of "this".
@@ -1583,7 +1616,7 @@
{
if ((*ite)->isConnectorNode())
{
- ZORBA_ASSERT(copymode.theNsPreserve == false);
+ //ZORBA_ASSERT(copymode.theNsPreserve == false);
static_cast<ConnectorNode*>(*ite)->getNode()->
copyInternal(rootParent, copyNode, 0, NULL, copymode);
}
@@ -1604,6 +1637,10 @@
throw;
}
+ if (copymode.theCopyReference)
+ GET_STORE().copyReference(this, copyNode);
+
+
NODE_TRACE1("}");
NODE_TRACE1("Copied doc node " << this << " to node " << copyNode);
@@ -2217,7 +2254,7 @@
if (child->isConnectorNode())
{
- ZORBA_ASSERT(copymode.theNsPreserve == false);
+ //ZORBA_ASSERT(copymode.theNsPreserve == false);
static_cast<ConnectorNode*>(child)->getNode()->
copyInternal(rootParent, copyNode, 0, rootCopy, copymode);
}
@@ -2241,6 +2278,9 @@
throw;
}
+ if (copymode.theCopyReference)
+ GET_STORE().copyReference(this,copyNode);
+
NODE_TRACE1("Copied elem node " << this << " to node " << copyNode
<< " name = " << theName->getStringValue() << " parent = "
<< (parent ? parent : 0x0)
@@ -3415,6 +3455,9 @@
throw;
}
+ if (copymode.theCopyReference)
+ GET_STORE().copyReference(this,copyNode);
+
NODE_TRACE1("Copied attribute node " << this << " to node " << copyNode
<< " name = " << theName->show() << " parent = "
<< std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
@@ -3883,6 +3926,9 @@
throw;
}
+ if (copymode.theCopyReference)
+ GET_STORE().copyReference(this,copyNode);
+
NODE_TRACE1("Copied text node " << this << " to node " << copyNode
<< " parent = " << std::hex << (parent ? (ulong)parent : 0)
<< " pos = " << pos);
@@ -4441,6 +4487,9 @@
throw;
}
+ if (copymode.theCopyReference)
+ GET_STORE().copyReference(this,copyNode);
+
NODE_TRACE1("Copied pi node " << this << " to node " << copyNode
<< " parent = " << std::hex << (parent ? (ulong)parent : 0)
<< " pos = " << pos);
@@ -4564,6 +4613,9 @@
throw;
}
+ if (copymode.theCopyReference)
+ GET_STORE().copyReference(this,copyNode);
+
NODE_TRACE1("Copied coment node " << this << " to node " << copyNode
<< " parent = " << std::hex << (parent ? (ulong)parent : 0)
<< " pos = " << pos);
=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h 2011-12-22 14:14:53 +0000
+++ src/store/naive/node_items.h 2012-01-02 09:53:25 +0000
@@ -300,6 +300,10 @@
friend class FastXmlLoader;
friend class DtdXmlLoader;
+ friend class PULEncodingVisitor;
+ friend class XDMPULVisitorImpl;
+ friend class XMLPULVisitorImpl;
+
public:
enum NodeFlags
{
@@ -664,6 +668,8 @@
csize pos,
store::StoreConsts::NodeKind nodeKind);
+ void refreshOrdPath();
+
virtual bool
isAncestor(const store::Item_t&) const;
@@ -712,6 +718,8 @@
friend class UpdPut;
friend class CollectionPul;
friend class SimpleStore;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
public:
typedef std::vector<XmlNode*> NodeVector;
@@ -953,6 +961,7 @@
friend class NodeFactory;
friend class UpdSetElementType;
friend class UpdReplaceContent;
+ friend class XMLPULVisitorImpl;
protected:
store::Item_t theName;
@@ -1150,6 +1159,7 @@
friend class DtdXmlLoader;
friend class UpdSetAttributeType;
friend class NodeFactory;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theName;
@@ -1288,6 +1298,7 @@
friend class UpdSetElementType;
friend class NodeFactory;
friend class CollectionPul;
+ friend class CompletePULVisitorImpl;
protected:
TextNodeContent theContent;
@@ -1437,6 +1448,7 @@
friend class FastXmlLoader;
friend class DtdXmlLoader;
friend class NodeFactory;
+ friend class CompletePULVisitorImpl;
protected:
zstring theTarget;
=== added file 'src/store/naive/pul_cxdm_encoding.cpp'
--- src/store/naive/pul_cxdm_encoding.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_cxdm_encoding.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,1419 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "store/api/item_factory.h"
+
+#include "store/naive/node_items.h"
+#include "store/naive/simple_store.h"
+#include "store/naive/simple_collection.h"
+#include "store/naive/store_defs.h"
+#include "store/naive/pul_visitors.h"
+#include "store/naive/node_factory.h"
+#include "diagnostics/user_exception.h"
+#include "zorba/singleton_item_sequence.h"
+
+namespace zorba {
+namespace simplestore {
+
+CompletePULVisitorImpl::CompletePULVisitorImpl(store::Item_t & result) : PULEncodingVisitor(true)
+{
+ createElementNode(result, "complete-pending-update-list", NULL);
+ ELEM_NODE(result)->addLocalBinding("xs","http://www.w3.org/2001/XMLSchema");
+ theResult=result;
+ store::Item_t test;
+ theIsPostProcessing=false;
+}
+
+void CompletePULVisitorImpl::visit(store::Item_t& pul)
+{
+ static_cast<PULImpl*>(pul.getp())->accept(this);
+ if (!theIsPostProcessing)
+ theIsPostProcessing=true;
+ else
+ processDocumentNodesMerges();
+}
+
+#ifdef PUL_SETTYPE
+/*
+ * This methods visit the type undo information stored in an update primitive and produces
+ * all the data which describes the type change occurred in a "type-undo-list" element which
+ * is attached as the last children of "operation".
+ */
+void CompletePULVisitorImpl::visitTypeUndoList(store::Item_t& operation, const TypeUndoList& typeUndoList)
+{
+ TypeUndoList::const_iterator it=typeUndoList.begin();
+ TypeUndoList::const_iterator end=typeUndoList.end();
+ store::Item_t typeUndoListElem;
+
+ for (;it!=end;++it)
+ {
+ ZORBA_FATAL((*it).theNode,"Incomplete type undo information. Target node missing.");
+ if ((*it).theNode->getNodeKind()==store::StoreConsts::elementNode)
+ {
+ if (typeUndoListElem==NULL)
+ createElementNode(typeUndoListElem, "type-undo-list", operation);
+ visitElementTypeUndo(typeUndoListElem,(*it));
+ }
+ else if ((*it).theNode->getNodeKind()==store::StoreConsts::attributeNode && (*it).theTypeName!=NULL)
+ {
+ if (typeUndoListElem==NULL)
+ createElementNode(typeUndoListElem, "type-undo-list", operation);
+ visitAttributeTypeUndo(typeUndoListElem,(*it));
+ }
+ }
+}
+
+/*
+ * This methods visit the type undo information for a single element and produces
+ * all the data which describes the type change occurred in a "element-type" element which
+ * is attached as the last children of typeUndoListElem.
+ */
+void CompletePULVisitorImpl::visitElementTypeUndo(store::Item_t& typeUndoListElem, const NodeTypeInfo& elementTypeInfo)
+{
+ store::Item_t result;
+ createElementNode(result, "element-type", typeUndoListElem);
+ encodeTarget(result, elementTypeInfo.theNode);
+ encodeQName(result, "type-name", elementTypeInfo.theTypeName);
+ if ((elementTypeInfo.theChildFlags & XmlNode::IsTyped))
+ {
+ encodeItem(result,"value",elementTypeInfo.theTextContent.getValue(),elementTypeInfo.theTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,(elementTypeInfo.theChildFlags & XmlNode::HaveListValue));
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+ }
+
+ encodeBoolean(result, "have-value", (elementTypeInfo.theFlags & XmlNode::HaveTypedValue));
+ encodeBoolean(result, "have-empty-value", (elementTypeInfo.theFlags & XmlNode::HaveEmptyTypedValue));
+ encodeBoolean(result, "is-in-substitution-group", (elementTypeInfo.theFlags & XmlNode::IsInSubstGroup));
+}
+
+/*
+ * This methods visit the type undo information for a single attribute and produces
+ * all the data which describes the type change occurred in a "attribute-type" element which
+ * is attached as the last children of "typeUndoListElem".
+ */
+void CompletePULVisitorImpl::visitAttributeTypeUndo(store::Item_t& typeUndoListElem, const NodeTypeInfo& attributeTypeInfo)
+{
+ store::Item_t result;
+ createElementNode(result, "attribute-type", typeUndoListElem);
+ encodeTarget(result, attributeTypeInfo.theNode);
+ encodeQName(result, "type-name", attributeTypeInfo.theTypeName);
+
+ std::map<AttributeNode*, zstring>::iterator it=theValueUndoMap.find(static_cast<AttributeNode*>(attributeTypeInfo.theNode));
+ ZORBA_FATAL(it!=theValueUndoMap.end(), "Value of node not found in map");
+ encodeItem(result, "value", (*it).second ,attributeTypeInfo.theTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,(attributeTypeInfo.theFlags & XmlNode::HaveListValue));
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+}
+
+#endif
+
+#ifndef TEXT_ORDPATH
+void CompletePULVisitorImpl::cacheTextNodeLabel(XmlNode* node)
+{
+ if (node->getNodeKind()==store::StoreConsts::textNode)
+ {
+ store::Item_t label;
+ theStore->getStructuralInformation(label,node);
+ theCachedLabels[node]=label;
+ }
+}
+#endif
+
+
+/*------------- Methods for visiting the XQU Update Primitives -------------------*/
+
+/*
+ * Visited before and after application.
+ *
+ * Before application:
+ * - If the target is a text node, its label is saved. (only if !TEXT_ORDPATH)
+ * - The left sibling of the target node (and its label if !TEXT_ORDPATH) are saved.
+ * - If some text nodes might be merged their left sibling (and their labels if
+ * !TEXT_ORDPATH) are saved.
+ *
+ * After application:
+ * - The type undo list is visited.
+ */
+void CompletePULVisitorImpl::visitUpdDelete(const UpdDelete * op)
+{
+ if (!theIsPostProcessing)
+ {
+ if (op->theTarget->getNodeKind()!=store::StoreConsts::attributeNode)
+ {
+ InternalNode* parent=static_cast<InternalNode*>(op->theTarget->getParent());
+ XmlNode* target=BASE_NODE(op->theTarget);
+ csize pos=parent->findChild(target);
+
+#ifndef TEXT_ORDPATH
+ cacheTextNodeLabel(target);
+ if (pos>0)
+ {
+ XmlNode * lsText=parent->getChild(pos-1);
+ store::Item_t lsTextLabel;
+ theStore->getStructuralInformation(lsTextLabel,lsText);
+ theRemovedNodeLeftSiblingMap[target]=std::pair<XmlNode*,store::Item_t>(lsText,lsTextLabel);
+ }
+#else
+ if (pos>0)
+ theRemovedNodeLeftSiblingMap[target]=parent->getChild(pos-1);
+#endif
+
+ //Cache merging information
+ if (pos == 0 || pos == parent->numChildren()-1)
+ return;
+
+ XmlNode* rsib = parent->getChild(pos + 1);
+ XmlNode* lsib = parent->getChild(pos - 1);
+
+ if (lsib->getNodeKind() != store::StoreConsts::textNode ||
+ rsib->getNodeKind() != store::StoreConsts::textNode)
+ return;
+
+#ifndef TEXT_ORDPATH
+ cacheTextNodeLabel(lsib);
+ cacheTextNodeLabel(rsib);
+ if (pos>1)
+ {
+ XmlNode * lsText=parent->getChild(pos-2);
+ store::Item_t lsTextLabel;
+ theStore->getStructuralInformation(lsTextLabel,lsText);
+ theRemovedNodeLeftSiblingMap[lsib]=std::pair<XmlNode*,store::Item_t>(lsText,lsTextLabel);
+ }
+ XmlNode * rsText=parent->getChild(pos);
+ store::Item_t rsTextLabel;
+ theStore->getStructuralInformation(rsTextLabel,rsText);
+ theRemovedNodeLeftSiblingMap[rsib]=std::pair<XmlNode*,store::Item_t>(rsText,rsTextLabel);
+#else
+ if (pos>1)
+ theRemovedNodeLeftSiblingMap[lsib]=parent->getChild(pos-2);
+ theRemovedNodeLeftSiblingMap[rsib]=parent->getChild(pos);
+#endif
+ }
+
+ }
+ else
+ {
+ if (op->theParent==NULL) return;
+ if (op->theTarget!=NULL &&
+ op->theTarget->getNodeKind()==store::StoreConsts::textNode &&
+ op->theTarget->getStringValue().empty()) return; //This kind of operations is generated by a repV on a text node with empty new content.
+
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+#ifndef TEXT_ORDPATH
+ if (op->theTarget->getNodeKind()==store::StoreConsts::textNode)
+ encodeTarget(result,op->theTarget,&theCachedLabels);
+ else
+ encodeTarget(result, op->theTarget);
+#else
+ encodeTarget(result, op->theTarget);
+#endif
+
+ XmlNode* target=BASE_NODE(op->theTarget);
+ InternalNode* parent=INTERNAL_NODE(op->theParent);
+ encodeTarget(result, parent,"parent");
+
+ if (op->theTarget->getNodeKind()!=store::StoreConsts::attributeNode)
+ {
+ std::map<const XmlNode*, std::pair<XmlNode*, store::Item_t> >::iterator it=theRemovedNodeLeftSiblingMap.find(target);
+ if (it!=theRemovedNodeLeftSiblingMap.end())
+ encodeTarget(result, it->second.first,"left-sibling",it->second.second);
+ }
+ encodeNode(result, "deleted-node", op->theTarget,false, true);
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+ }
+}
+
+/*
+ * Visited before and after application.
+ *
+ * Before application:
+ * - If the sibling in an insB/insA is a text node, its label is saved. (only if !TEXT_ORDPATH)
+ * - The predecessor and successor of the inserted node labels (only !TEXT_ORDPATH) are saved.
+ * - If some text nodes might be merged their left sibling (and their labels if
+ * !TEXT_ORDPATH) are saved.
+ *
+ * After application:
+ * - The type undo list is visited.
+ */
+void CompletePULVisitorImpl::visitUpdInsertChildren(const UpdInsertChildren * op)
+{
+ if (!theIsPostProcessing)
+ {
+ size_t numNewChildren=op->theNewChildren.size();
+ size_t insertPosition; //insertPosition-1 is the predecessor
+ //insertPosition is the successor
+ InternalNode* parent;
+ switch (op->getKind())
+ {
+ case store::UpdateConsts::UP_INSERT_INTO:
+ case store::UpdateConsts::UP_INSERT_INTO_LAST:
+ {
+ parent = INTERNAL_NODE(op->theTarget);
+ insertPosition=parent->numChildren();
+ break;
+ }
+ case store::UpdateConsts::UP_INSERT_INTO_FIRST:
+ {
+ parent = INTERNAL_NODE(op->theTarget);
+ insertPosition= 0;
+ break;
+ }
+ case store::UpdateConsts::UP_INSERT_BEFORE:
+ {
+ parent = static_cast<InternalNode*>(op->theSibling->getParent());
+ insertPosition = parent->findChild(BASE_NODE(op->theSibling));
+#ifndef TEXT_ORDPATH
+ cacheTextNodeLabel(BASE_NODE(op->theSibling));
+#endif
+ break;
+ }
+ case store::UpdateConsts::UP_INSERT_AFTER:
+ {
+ parent = static_cast<InternalNode*>(op->theSibling->getParent());
+ insertPosition = parent->findChild(BASE_NODE(op->theSibling))+1;
+#ifndef TEXT_ORDPATH
+ cacheTextNodeLabel(BASE_NODE(op->theSibling));
+#endif
+ break;
+ }
+ default:
+ ZORBA_FATAL(0, "");
+ }
+ assert(numNewChildren);
+
+#ifndef TEXT_ORDPATH
+ if (insertPosition>0)
+ cacheTextNodeLabel(parent->getChild(insertPosition-1));
+ if (parent->numChildren()>insertPosition)
+ cacheTextNodeLabel(parent->getChild(insertPosition));
+
+ //add the predecessor of the first inserted node to the map (if it is a text node)
+ if (insertPosition>1 && parent->getChild(insertPosition-1)->getNodeKind() ==store::StoreConsts::textNode)
+ {
+ XmlNode * lsText=parent->getChild(insertPosition-2);
+ store::Item_t lsTextLabel;
+ theStore->getStructuralInformation(lsTextLabel,lsText);
+ theRemovedNodeLeftSiblingMap[parent->getChild(insertPosition-1)]=std::pair<XmlNode*,store::Item_t>(lsText,lsTextLabel);
+ }
+
+ //add the successor of the inserted nodes to the map (if it is a text node)
+ if (insertPosition>0 && parent->numChildren()>insertPosition && parent->getChild(insertPosition)->getNodeKind() ==store::StoreConsts::textNode)
+ {
+ XmlNode * lsText=parent->getChild(insertPosition-1);
+ store::Item_t lsTextLabel;
+ theStore->getStructuralInformation(lsTextLabel,lsText);
+ theRemovedNodeLeftSiblingMap[parent->getChild(insertPosition)]=std::pair<XmlNode*,store::Item_t>(lsText,lsTextLabel);
+ }
+#else
+ //add the predecessor of the first inserted node to the map (if it is a text node)
+ if (insertPosition>1 && parent->getChild(insertPosition-1)->getNodeKind() ==store::StoreConsts::textNode)
+ theRemovedNodeLeftSiblingMap[parent->getChild(insertPosition-1)]=parent->getChild(insertPosition-2);
+
+ //add the successor of the inserted nodes to the map (if it is a text node)
+ if (insertPosition>0 && parent->numChildren()>insertPosition && parent->getChild(insertPosition)->getNodeKind() ==store::StoreConsts::textNode)
+ theRemovedNodeLeftSiblingMap[parent->getChild(insertPosition)]=parent->getChild(insertPosition-1);
+#endif
+ }
+ else
+ {
+
+ store::Item_t result;
+ switch (op->getKind()) {
+ case store::UpdateConsts::UP_INSERT_AFTER:
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theSibling,&theCachedLabels);
+ break;
+ case store::UpdateConsts::UP_INSERT_BEFORE:
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theSibling,&theCachedLabels);
+ break;
+ case store::UpdateConsts::UP_INSERT_INTO:
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ break;
+ case store::UpdateConsts::UP_INSERT_INTO_FIRST:
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ break;
+ case store::UpdateConsts::UP_INSERT_INTO_LAST:
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ break;
+ default:
+ break;
+ }
+ encodeNodes(result, "content", op->theNewChildren,false, true);
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+ }
+}
+
+/*
+ * Visited after application.
+ */
+void CompletePULVisitorImpl::visitUpdInsertAttributes(const UpdInsertAttributes * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeNodes(result, "content", op->theNewAttrs,false, true);
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+}
+
+/*
+ * Visited after application.
+ */
+void CompletePULVisitorImpl::visitUpdReplaceAttribute(const UpdReplaceAttribute * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theAttr);
+ encodeNodes(result, "replacement", op->theNewAttrs,false, true);
+
+ //for inversion
+ encodeTarget(result, op->theTarget,"parent");
+ encodeNode(result, "replaced-node", op->theAttr,false, true);
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+}
+
+/*
+ * Visited before and after application.
+ *
+ * Before application:
+ * - The predecessor and successor of the replaced node and the replaced node
+ * labels (only !TEXT_ORDPATH) are saved.
+ * - If some text nodes might be merged their left sibling (and their labels if
+ * !TEXT_ORDPATH) are saved.
+ *
+ * After application:
+ * - The type undo list is visited.
+ */
+void CompletePULVisitorImpl::visitUpdReplaceChild(const UpdReplaceChild * op)
+{
+
+ if (!theIsPostProcessing)
+ {
+ InternalNode* parent=INTERNAL_NODE(op->theTarget);
+ csize pos=parent->findChild(BASE_NODE(op->theChild)); //pos-1 is the predecessor
+ //pos+1 is the successor
+ size_t numNewChildren=op->theNewChildren.size();
+#ifndef TEXT_ORDPATH
+ cacheTextNodeLabel(BASE_NODE(op->theChild));
+ if (pos>0)
+ cacheTextNodeLabel(parent->getChild(pos-1));
+ if (parent->numChildren()>(pos+1))
+ cacheTextNodeLabel(parent->getChild(pos+1));
+
+ if (pos>0)
+ {
+ XmlNode * lsText=parent->getChild(pos-1);
+ store::Item_t lsTextLabel;
+ theStore->getStructuralInformation(lsTextLabel,lsText);
+ theRemovedNodeLeftSiblingMap[BASE_NODE(op->theChild)]=std::pair<XmlNode*,store::Item_t>(lsText,lsTextLabel);
+ }
+
+ //add the predecessor of the first inserted node to the map (if it is a text node)
+ if (pos>1 && parent->getChild(pos-1)->getNodeKind() ==store::StoreConsts::textNode)
+ {
+ XmlNode * lsText=parent->getChild(pos-2);
+ store::Item_t lsTextLabel;
+ theStore->getStructuralInformation(lsTextLabel,lsText);
+ theRemovedNodeLeftSiblingMap[parent->getChild(pos-1)]=std::pair<XmlNode*,store::Item_t>(lsText,lsTextLabel);
+ }
+ //add the last children of the parent to the map (if it is a text node)
+ if (numNewChildren>1 && pos>0 && parent->numChildren()>(pos+1) && parent->getChild(pos+1)->getNodeKind() ==store::StoreConsts::textNode)
+ {
+ XmlNode * lsText=parent->getChild(pos);
+ store::Item_t lsTextLabel;
+ theStore->getStructuralInformation(lsTextLabel,lsText);
+ theRemovedNodeLeftSiblingMap[parent->getChild(pos+1)]=std::pair<XmlNode*,store::Item_t>(lsText,lsTextLabel);
+ }
+
+#else
+ if (pos>0)
+ theRemovedNodeLeftSiblingMap[BASE_NODE(op->theChild)]=parent->getChild(pos-1);
+
+ //add the predecessor of the first inserted node to the map (if it is a text node)
+ if (pos>1 && parent->getChild(pos-1)->getNodeKind() ==store::StoreConsts::textNode)
+ theRemovedNodeLeftSiblingMap[parent->getChild(pos-1)]=parent->getChild(pos-2);
+
+ //add the last children of the parent to the map (if it is a text node)
+ if (numNewChildren>1 && pos>0 && parent->numChildren()>(pos+1) && parent->getChild(pos+1)->getNodeKind() ==store::StoreConsts::textNode)
+ theRemovedNodeLeftSiblingMap[parent->getChild(pos+1)]=parent->getChild(pos);
+#endif
+ }
+ else
+ {
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+#ifndef TEXT_ORDPATH
+ encodeTarget(result,op->theChild,&theCachedLabels);
+#else
+ encodeTarget(result, op->theChild);
+#endif
+ encodeNodes(result, "replacement", op->theNewChildren,false, true);
+
+
+ encodeTarget(result, op->theTarget,"parent");
+ std::map<const XmlNode*, std::pair<XmlNode*, store::Item_t> >::iterator it=theRemovedNodeLeftSiblingMap.find(static_cast<const XmlNode*>(op->theChild.getp()));
+ if (it!=theRemovedNodeLeftSiblingMap.end())
+ encodeTarget(result, it->second.first,"left-sibling",it->second.second);
+ encodeNode(result, "replaced-node", op->theChild,false, true);
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+ }
+}
+
+/*
+ * Visited before and after application.
+ *
+ * Before application:
+ * - The to be removed children of the target node are saved.
+ *
+ * After application:
+ * - The type undo list is visited
+ */
+void CompletePULVisitorImpl::visitUpdReplaceElemContent(const UpdReplaceElemContent * op)
+{
+ if (!theIsPostProcessing)
+ {
+ store::Iterator_t oldch=op->theTarget->getChildren();
+ store::Item_t ch;
+ while (oldch->next(ch))
+ theReplaceContentOldChildrenList.push_back(ch);
+ }
+ else
+ {
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ if(ELEM_NODE(op->theTarget)->numChildren())
+ encodeNode(result, "text", ELEM_NODE(op->theTarget)->getChild(0), false, true);
+ else
+ {
+ store::Item_t textNode;
+ createElementNode(textNode,"text",result.getp());
+ }
+ encodeNodes(result, "replaced-nodes", op->theOldChildren, false, true);
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+ }
+}
+
+/*
+ * Visited before and after application.
+ *
+ * Before application:
+ * - The previous value of the attribute is stored.
+ *
+ * After application:
+ * - The type undo list is visited.
+ */
+void CompletePULVisitorImpl::visitUpdReplaceAttrValue(const UpdReplaceAttrValue * op)
+{
+ if (theIsPostProcessing)
+ {
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theTarget->getStringValue());
+
+ encodeString(result, "old-string-value", op->theOldValue->getStringValue());
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+ }
+}
+
+/*
+ * Visited before and after application.
+ * Before application:
+ * - the position of the target node is saved (
+ */
+void CompletePULVisitorImpl::visitUpdReplaceTextValue(const UpdReplaceTextValue * op)
+{
+#ifndef TEXT_ORDPATH
+ if (!theIsPostProcessing)
+ {
+ cacheTextNodeLabel(TEXT_NODE(op->theTarget));
+ }
+ else
+ {
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget,&theCachedLabels);
+ encodeString(result, "string-value", op->theTarget->getStringValue());
+ encodeString(result, "old-string-value", op->theOldContent.getText());
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+ }
+#else
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theTarget->getStringValue());
+
+ encodeString(result, "old-string-value", op->theOldContent.getText());
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdReplacePiValue(const UpdReplacePiValue * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theTarget->getStringValue());
+
+ //for inversion
+ encodeString(result, "old-string-value", op->theOldValue);
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdReplaceCommentValue(const UpdReplaceCommentValue * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theTarget->getStringValue());
+
+ //for inversion
+ encodeString(result, "old-string-value", op->theOldValue);
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdRenameElem(const UpdRenameElem * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "newName", op->theTarget->getNodeName());
+
+ //for inversion
+ encodeQName(result, "oldName", op->theOldName);
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdRenameAttr(const UpdRenameAttr * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "newName", op->theTarget->getNodeName());
+
+ //for inversion
+ encodeQName(result, "oldName", op->theOldName);
+#ifdef PUL_SETTYPE
+ visitTypeUndoList(result,op->theTypeUndoList);
+#endif
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdRenamePi(const UpdRenamePi * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "newName", (static_cast<PiNode *>(op->theTarget.getp()))->theTarget);
+
+ //for inversion
+ encodeString(result, "oldName", op->theOldName);
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdPut(const UpdPut * op)
+{
+ if (!theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeString(result, "uri", op->theTargetUri->getStringValue());
+ encodeNode(result, "node", op->theTarget,true, true);
+}
+
+/*------------- Methods for visiting the Zorba Update Primitives -----------------*/
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdActivateForeignKeyIC(const UpdActivateForeignKeyIC * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theQName);
+ encodeQName(result, "from-collection-name", op->theFromCollectionName);
+ encodeQName(result, "to-collection-name", op->theToCollectionName);
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdActivateIC(const UpdActivateIC * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theQName);
+ encodeQName(result, "collection-name", op->theCollectionName);
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdDeActivateIC(const UpdDeActivateIC * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theQName);
+
+ switch (op->theICKind)
+ {
+ case store::IC::ic_collection:
+ encodeQName(result, "collection-name", op->theFromCollectionName);
+ break;
+ case store::IC::ic_foreignkey:
+ encodeQName(result, "from-collection-name", op->theFromCollectionName);
+ encodeQName(result, "to-collection-name", op->theFromCollectionName);
+ break;
+ default:
+ ZORBA_ASSERT(false);
+ break;
+ }
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdCreateCollection(const UpdCreateCollection * op)
+{
+ assert(!theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeCollectionAnnotations(result,"annotations",op->theAnnotations);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+ if (op->theNodeType)
+ encodeQName(result, "node-type", op->theNodeType);
+
+ if (op->theDynamicCollection)
+ theCreatedDynamicCollections[op->theName]=result;
+ else
+ theCreatedStaticCollections[op->theName]=result;
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdDeleteCollection(const UpdDeleteCollection * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+
+ SimpleCollection * deletedCollection=static_cast<SimpleCollection *>(op->theCollection.getp());
+ std::vector<store::Annotation_t> annotations;
+ deletedCollection->getAnnotations(annotations);
+ encodeCollectionAnnotations(result,"old-annotations",annotations);
+
+ if (deletedCollection->getNodeType())
+ encodeQName(result, "old-node-type",deletedCollection->getNodeType()->copy(NULL,store::CopyMode()) );
+
+ encodeNodes(result, "deleted-nodes", deletedCollection->getIterator(),true, true);
+}
+
+/*
+ * Visited before application
+ */
+void CompletePULVisitorImpl::visitUpdInsertAfterIntoCollection(const UpdInsertAfterIntoCollection * op)
+{
+ if (theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeTarget(result, op->theTarget);
+ encodeNodes(result, "nodes", op->theNodes,true, true);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+/*
+ * Visited before application
+ */
+void CompletePULVisitorImpl::visitUpdInsertBeforeIntoCollection(const UpdInsertBeforeIntoCollection * op)
+{
+ if (theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeTarget(result, op->theTarget);
+ encodeNodes(result, "nodes", op->theNodes,true, true);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+/*
+ * Visited before application
+ */
+void CompletePULVisitorImpl::visitUpdInsertFirstIntoCollection(const UpdInsertFirstIntoCollection * op)
+{
+ if (theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeNodes(result, "nodes", op->theNodes,true, true);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+/*
+ * Visited before application
+ */
+void CompletePULVisitorImpl::visitUpdInsertLastIntoCollection(const UpdInsertLastIntoCollection * op)
+{
+ if (theIsPostProcessing) return;
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeNodes(result, "nodes", op->theNodes,true, true);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+/*
+ * Visited before application
+ */
+void CompletePULVisitorImpl::visitUpdInsertIntoCollection(const UpdInsertIntoCollection * op)
+{
+ if (theIsPostProcessing) return;
+ if (op->theDynamicCollection && theCreatedDynamicCollections[op->theName]!=NULL)
+ encodeNodes(theCreatedDynamicCollections[op->theName], "nodes", op->theNodes,true, true);
+ else if (!op->theDynamicCollection && theCreatedStaticCollections[op->theName]!=NULL)
+ encodeNodes(theCreatedStaticCollections[op->theName], "nodes", op->theNodes,true, true);
+ else
+ {
+
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeNodes(result, "nodes", op->theNodes,true, true);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+ }
+}
+
+/*
+ * Visited before application
+ */
+void CompletePULVisitorImpl::visitUpdDeleteNodesFromCollection(const UpdDeleteNodesFromCollection * op)
+{
+ if (theIsPostProcessing) return;
+
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ store::Item_t nodes;
+ store::Item_t positions;
+ store::Item_t deletednodes;
+ createElementNode(nodes, "targets", result);
+
+ std::vector<store::Item_t>::const_iterator iter = op->theNodes.begin();
+ std::vector<store::Item_t>::const_iterator end = op->theNodes.end();
+ for (; iter != end; ++iter)
+ {
+ encodeTarget(nodes, *iter, "target");
+ }
+
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+
+ //for inversion
+ createElementNode(deletednodes, "deleted-nodes", result);
+
+ iter = op->theNodes.begin();
+ end = op->theNodes.end();
+ for (; iter != end; ++iter)
+ {
+ store::Item_t curr=(*iter);
+ store::Item_t deletednode=encodeNode(deletednodes, "deleted-node", curr,true, true);
+ ulong pos=BASE_NODE(curr)->getTree()->getPosition();
+ store::Collection* lColl=const_cast<store::Collection*>(BASE_NODE(curr)->getCollection());
+ if (pos)
+ encodeTarget(deletednode,lColl->nodeAt(xs_integer(pos-1)),"left-sibling");
+ }
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdCreateDocument(const UpdCreateDocument * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeString(result, "uri", op->theUri->getStringValue());
+ encodeTarget(result,op->theDoc,"document-reference");
+ //encodeNode(result, "document", op->theDoc,true, true);
+}
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdDeleteDocument(const UpdDeleteDocument * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeString(result, "uri", op->theUri->getStringValue());
+
+ //for inversion
+ //if (op->theDoc->getCollection())
+ //encodeTarget(result,op->theDoc,"deleted-document-reference");
+ //else
+ encodeNode(result,"deleted-document",op->theDoc,true, true);
+}
+
+void CompletePULVisitorImpl::visitUpdCreateIndex(const UpdCreateIndex * op)
+{
+ visitUnsupported(op);
+}
+
+void CompletePULVisitorImpl::visitUpdDeleteIndex(const UpdDeleteIndex * op)
+{
+ visitUnsupported(op);
+}
+
+void CompletePULVisitorImpl::visitUpdRefreshIndex(const UpdRefreshIndex * op)
+{
+ visitUnsupported(op);
+}
+
+#ifdef PUL_SETTYPE
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdSetAttributeType(const UpdSetAttributeType * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "type-name", op->theTypeName);
+ encodeItem(result,"value",ATTR_NODE(op->theTarget)->theTypedValue,op->theTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,op->theHaveListValue);
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+
+ //for inversion
+ encodeQName(result, "old-type-name", op->theOldTypeName);
+ encodeItem(result,"old-value",op->theOldTypedValue,op->theOldTypeName,true,false);
+ store::Item_t oldAttr;
+ store::Item_t oldValue;
+ theItemFactory->createBoolean(oldValue,op->theOldHaveListValue);
+ createAttributeNode(
+ oldAttr,
+ "have-list-value",
+ oldValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+}
+
+
+/*
+ * Visited after application
+ */
+void CompletePULVisitorImpl::visitUpdSetElementType(const UpdSetElementType * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "type-name", op->theTypeName);
+ if (op->theHaveTypedTypedValue)
+ {
+ TextNode* textChild = ELEM_NODE(op->theTarget)->getUniqueTextChild();
+ encodeItem(result,"value",textChild->theContent.getValue(),op->theTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,op->theHaveListTypedValue);
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+ }
+
+ encodeBoolean(result, "have-value", op->theHaveTypedValue);
+ encodeBoolean(result, "have-empty-value", op->theHaveEmptyTypedValue);
+ encodeBoolean(result, "is-in-substitution-group", op->theIsInSubstitutionGroup);
+
+ //for inversion
+ encodeQName(result, "old-type-name", op->theOldTypeName);
+ if (op->theOldHaveTypedTypedValue)
+ {
+ encodeItem(result,"old-value",op->theOldTypedValue,op->theOldTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,op->theOldHaveListTypedValue);
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+ }
+
+ encodeBoolean(result, "old-have-value", op->theOldHaveTypedValue);
+ encodeBoolean(result, "old-have-empty-value", op->theOldHaveEmptyTypedValue);
+ encodeBoolean(result, "old-is-in-substitution-group", op->theOldIsInSubstitutionGroup);
+}
+
+#else
+
+void CompletePULVisitorImpl::visitUpdSetAttributeType(const UpdSetAttributeType * op)
+{
+ visitUnsupported(op);
+}
+
+
+void CompletePULVisitorImpl::visitUpdSetElementType(const UpdSetElementType * op)
+{
+ visitUnsupported(op);
+}
+
+
+#endif
+
+void CompletePULVisitorImpl::visitUpdRevalidate(const UpdRevalidate * op)
+{
+ assert(theIsPostProcessing);
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+
+#ifdef PUL_SETTYPE
+ store::Item_t undoRoot;
+ createElementNode(undoRoot, "type-undo-list", result);
+
+ std::vector<UpdatePrimitive*>& validationList= static_cast<PULImpl*>(op->theRevalidationPul.getp())->theValidationList;
+ std::vector<UpdatePrimitive*>::iterator it=validationList.begin();
+ std::vector<UpdatePrimitive*>::iterator end=validationList.end();
+ for (;it!=end;++it)
+ {
+ switch ((*it)->getKind())
+ {
+ case store::UpdateConsts::UP_SET_ATTRIBUTE_TYPE:
+ extractUndoInformation(undoRoot,static_cast<UpdSetAttributeType*>(*it));
+ break;
+ case store::UpdateConsts::UP_SET_ELEMENT_TYPE:
+ extractUndoInformation(undoRoot,static_cast<UpdSetElementType*>(*it));
+ break;
+ default:
+ ZORBA_FATAL(0,"");
+ }
+ }
+#endif
+}
+
+#ifdef PUL_SETTYPE
+void CompletePULVisitorImpl::extractUndoInformation(store::Item_t& undoRoot, const UpdSetAttributeType * op)
+{
+ store::Item_t result;
+ createElementNode(result, "attribute-type", undoRoot);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "type-name", op->theOldTypeName);
+
+ encodeItem(result, "value", op->theOldTypedValue, op->theOldTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,op->theHaveListValue);
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+}
+
+void CompletePULVisitorImpl::extractUndoInformation(store::Item_t& undoRoot, const UpdSetElementType * op)
+{
+ store::Item_t result;
+ createElementNode(result, "element-type", undoRoot);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "type-name", op->theOldTypeName);
+ if (op->theOldHaveTypedTypedValue)
+ {
+ encodeItem(result,"value", op->theOldTypedValue,op->theOldTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,op->theOldHaveListTypedValue);
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+ }
+
+ encodeBoolean(result, "have-value", op->theOldHaveTypedValue);
+ encodeBoolean(result, "have-empty-value", op->theOldHaveEmptyTypedValue);
+ encodeBoolean(result, "is-in-substitution-group", op->theIsInSubstitutionGroup);
+}
+#endif
+
+/*
+ * This function visits the operation map in a collection PUL.
+ * It consider each XQU operation on the same node together.
+ */
+void CompletePULVisitorImpl::visitNodeUpdatesMap(const NodeToUpdatesMap& map)
+{
+ NodeToUpdatesMap::iterator iter=map.begin();
+ NodeToUpdatesMap::iterator end=map.end();
+ for (; iter != end; ++iter)
+ {
+ NodeUpdates* group= (*iter).second;
+ if (group->size()==0)
+ continue;
+ else
+ {
+ InsertionGroup mergedGroup;
+ NodeUpdates::const_iterator iiter=group->begin();
+ NodeUpdates::const_iterator iend=group->end();
+ for (; iiter != iend; ++iiter)
+ {
+ addToNodeUpdatesGroup(mergedGroup,(*iiter));
+ }
+ visitMergedGroup(mergedGroup);
+ }
+ }
+}
+
+
+/*
+ * This function visits an operation which effect can be modified by text node merging.
+ * The operation is either added to the given group of operations or visited immediately.
+ * Either way, the nodes which were removed by text node merges and that were inserted
+ * by the PUL are removed from the operation inserting them.
+ * It consider each XQU operation on the same node together.
+ */
+void CompletePULVisitorImpl::addToNodeUpdatesGroup(InsertionGroup& mergedGroup, UpdatePrimitive* op)
+{
+ switch(op->getKind())
+ {
+ case store::UpdateConsts::UP_INSERT_INTO:
+ {
+ UpdInsertChildren* ch=static_cast<UpdInsertChildren*>(op);
+ if (mergedGroup.insertInto!=NULL)
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ {
+ mergedGroup.insertInto->theNewChildren.insert(mergedGroup.insertInto->theNewChildren.end(),ch->theNewChildren.begin(),ch->theNewChildren.end());
+ mergedGroup.insertInto->theTypeUndoList.insert(mergedGroup.insertInto->theTypeUndoList.end(),ch->theTypeUndoList.begin(),ch->theTypeUndoList.end());
+ }
+ }
+ else
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ mergedGroup.insertInto=ch;
+ }
+ break;
+ }
+ case store::UpdateConsts::UP_INSERT_INTO_FIRST:
+ {
+ UpdInsertChildren* ch=static_cast<UpdInsertChildren*>(op);
+ if (mergedGroup.insertIntoAsFirst!=NULL)
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ {
+ mergedGroup.insertIntoAsFirst->theNewChildren.insert(mergedGroup.insertIntoAsFirst->theNewChildren.begin(),ch->theNewChildren.begin(),ch->theNewChildren.end());
+ mergedGroup.insertIntoAsFirst->theTypeUndoList.insert(mergedGroup.insertIntoAsFirst->theTypeUndoList.end(),ch->theTypeUndoList.begin(),ch->theTypeUndoList.end());
+ }
+ }
+ else
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ mergedGroup.insertIntoAsFirst=ch;
+ }
+ break;
+ }
+ case store::UpdateConsts::UP_INSERT_INTO_LAST:
+ {
+ UpdInsertChildren* ch=static_cast<UpdInsertChildren*>(op);
+ if (mergedGroup.insertIntoAsLast!=NULL)
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ {
+ mergedGroup.insertIntoAsLast->theNewChildren.insert(mergedGroup.insertIntoAsLast->theNewChildren.end(),ch->theNewChildren.begin(),ch->theNewChildren.end());
+ mergedGroup.insertIntoAsLast->theTypeUndoList.insert(mergedGroup.insertIntoAsLast->theTypeUndoList.end(),ch->theTypeUndoList.begin(),ch->theTypeUndoList.end());
+ }
+ }
+ else
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ mergedGroup.insertIntoAsLast=ch;
+ }
+ break;
+ }
+ case store::UpdateConsts::UP_INSERT_BEFORE:
+ {
+ UpdInsertChildren* ch=static_cast<UpdInsertChildren*>(op);
+ std::map<XmlNode*,UpdInsertChildren *>::iterator it=mergedGroup.insertBeforeMap.find(BASE_NODE(ch->theSibling));
+ if (it!=mergedGroup.insertBeforeMap.end())
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ {
+ (*it).second->theNewChildren.insert((*it).second->theNewChildren.end(),ch->theNewChildren.begin(),ch->theNewChildren.end());
+ (*it).second->theTypeUndoList.insert((*it).second->theTypeUndoList.end(),ch->theTypeUndoList.begin(),ch->theTypeUndoList.end());
+ }
+ }
+ else
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ mergedGroup.insertBeforeMap[BASE_NODE(ch->theSibling)]=ch;
+ }
+ break;
+ }
+ case store::UpdateConsts::UP_INSERT_AFTER:
+ {
+ UpdInsertChildren* ch=static_cast<UpdInsertChildren*>(op);
+ std::map<XmlNode*,UpdInsertChildren *>::iterator it=mergedGroup.insertAfterMap.find(BASE_NODE(ch->theSibling));
+ if (it!=mergedGroup.insertAfterMap.end())
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ {
+ (*it).second->theNewChildren.insert((*it).second->theNewChildren.begin(),ch->theNewChildren.begin(),ch->theNewChildren.end());
+ (*it).second->theTypeUndoList.insert((*it).second->theTypeUndoList.begin(),ch->theTypeUndoList.begin(),ch->theTypeUndoList.end());
+ }
+ }
+ else
+ {
+ if (applyTextNodeMerges(ch->theNewChildren))
+ mergedGroup.insertAfterMap[BASE_NODE(ch->theSibling)]=ch;
+ }
+ break;
+ }
+ case store::UpdateConsts::UP_REPLACE_CHILD:
+ {
+ applyTextNodeMerges(static_cast<UpdReplaceChild*>(op)->theNewChildren);
+ op->accept(*this);
+ break;
+ }
+ default:
+ {
+ op->accept(*this);
+ break;
+ }
+ }
+}
+
+/*
+ * This function removes from a vector of nodes all the nodes which were merged.
+ * If a new node has been inserted in place the new node is placed into the array
+ * in the same position.
+ */
+size_t CompletePULVisitorImpl::applyTextNodeMerges(std::vector<store::Item_t>& nodes)
+{
+ size_t numNodes=nodes.size();
+ if (numNodes==0)
+ return 0;
+ if (numNodes>=1)
+ {
+ std::map<XmlNode*, std::pair<XmlNode*, XmlNode*> >::iterator it=theMergedNodes.find(BASE_NODE(nodes[0]));
+ if (it!=theMergedNodes.end())
+ {
+ if (it->second.first)
+ nodes[0]=it->second.first;
+ else
+ {
+ nodes.erase(nodes.begin());
+ }
+ theMergedNodes.erase(it);
+ }
+ }
+ if (numNodes>1)
+ {
+ std::map<XmlNode*, std::pair<XmlNode*, XmlNode*> >::iterator it=theMergedNodes.find(BASE_NODE(nodes[nodes.size()-1]));
+ if (it!=theMergedNodes.end())
+ {
+ if (it->second.first)
+ nodes[nodes.size()-1]=it->second.first;
+ else
+ {
+ nodes.erase(--nodes.end());
+ }
+ theMergedNodes.erase(it);
+ }
+ }
+ return nodes.size();
+}
+
+/*
+ * This function removes from a vector of nodes all the nodes which were merged.
+ * If a new node has been inserted in place the new node is placed into the array
+ * in the same position.
+ */
+void CompletePULVisitorImpl::visitMergedGroup(InsertionGroup& mergedGroup)
+{
+ if (mergedGroup.insertInto && mergedGroup.insertIntoAsLast)
+ mergedGroup.insertIntoAsLast->theNewChildren.insert(mergedGroup.insertIntoAsLast->theNewChildren.begin(),mergedGroup.insertInto->theNewChildren.begin(),mergedGroup.insertInto->theNewChildren.end());
+ else if (mergedGroup.insertInto)
+ {
+ mergedGroup.insertInto->theKind=store::UpdateConsts::UP_INSERT_INTO_LAST;
+ mergedGroup.insertIntoAsLast=mergedGroup.insertInto;
+ mergedGroup.insertInto=NULL;
+ }
+
+
+ std::map<XmlNode*,UpdInsertChildren*>::iterator it;
+ std::map<XmlNode*,UpdInsertChildren*>::iterator end;
+ for (it=mergedGroup.insertAfterMap.begin(),end=mergedGroup.insertAfterMap.end();it!=end;++it)
+ (*it).second->accept(*this);
+ for (it=mergedGroup.insertBeforeMap.begin(),end=mergedGroup.insertBeforeMap.end();it!=end;++it)
+ (*it).second->accept(*this);
+ if (mergedGroup.insertIntoAsFirst)
+ mergedGroup.insertIntoAsFirst->accept(*this);
+ if (mergedGroup.insertIntoAsLast)
+ mergedGroup.insertIntoAsLast->accept(*this);
+}
+
+/*
+ * This function visits a merge operation and adds each affected node (along with its replacement and parent) to
+ * the theMergedNodes map.
+ */
+void CompletePULVisitorImpl::visitMerge(InternalNode * theParent, ulong& thePos, const std::vector<XmlNode_t>& aMergedNodes)
+{
+ ZORBA_FATAL(aMergedNodes.size(),"Unexpected error during merged nodes visit");
+ ZORBA_FATAL(theParent->numChildren()>thePos,"Unexpected error during merged nodes visit");
+ ZORBA_FATAL(theParent->getChild(thePos)->getNodeKind()==store::StoreConsts::textNode,"Unexpected error during merged nodes visit");
+ theMergedNodes[aMergedNodes[0].getp()]=std::pair<XmlNode*,XmlNode*>(theParent->getChild(thePos), theParent);
+ for (size_t i=1;i<aMergedNodes.size();++i)
+ theMergedNodes[aMergedNodes[i].getp()]=std::pair<XmlNode*,XmlNode*>(NULL,theParent);
+}
+
+/*
+ * This function generates delete/replaceNode operations for representing text node merges effect
+ * on document nodes.
+ */
+void CompletePULVisitorImpl::processDocumentNodesMerges()
+{
+ std::map<XmlNode*, std::pair<XmlNode*, XmlNode*> >::iterator it=theMergedNodes.begin();
+ std::map<XmlNode*, std::pair<XmlNode*, XmlNode*> >::iterator end=theMergedNodes.end();
+ for (;it!=end;++it)
+ {
+ XmlNode * removed=(*it).first;
+ XmlNode * inserted=(*it).second.first;
+ XmlNode * parent=(*it).second.second;
+
+ if (removed && inserted)
+ {
+ store::Item_t result;
+ createElementNode(result, "replaceNode", theResult);
+ encodeTarget(result, removed,&theCachedLabels);
+ std::vector<store::Item_t> insertedNodes;
+ insertedNodes.push_back(inserted);
+ encodeNodes(result, "replacement", insertedNodes,false, true);
+
+ //for inversion
+ encodeTarget(result, parent,"parent");
+ std::map<const XmlNode*, std::pair<XmlNode*, store::Item_t> >::iterator lsit=theRemovedNodeLeftSiblingMap.find(static_cast<const XmlNode*>(removed));
+ if (lsit!=theRemovedNodeLeftSiblingMap.end())
+ {
+ encodeTarget(result, lsit->second.first,"left-sibling",lsit->second.second);
+ ZORBA_ASSERT(!lsit->second.second->isText());
+ }
+ encodeNode(result, "replaced-node", removed,false, true);
+ }
+ else
+ {
+ store::Item_t result;
+ createElementNode(result, "delete", theResult);
+ encodeTarget(result, removed,&theCachedLabels);
+ encodeTarget(result, parent,"parent"); //for inversion
+ std::map<const XmlNode*, std::pair<XmlNode*, store::Item_t> >::iterator lsit=theRemovedNodeLeftSiblingMap.find(static_cast<const XmlNode*>(removed));
+ if (lsit!=theRemovedNodeLeftSiblingMap.end())
+ {
+ encodeTarget(result, lsit->second.first,"left-sibling",lsit->second.second);
+ ZORBA_ASSERT(!lsit->second.second->isText());
+ }
+ encodeNode(result, "deleted-node", removed,false, true);
+ }
+ }
+}
+
+void CompletePULVisitorImpl::visitUpdCreateHashMap (const UpdCreateHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+void CompletePULVisitorImpl::visitUpdDestroyHashMap (const UpdDestroyHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+void CompletePULVisitorImpl::visitUpdInsertIntoHashMap (const UpdInsertIntoHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+void CompletePULVisitorImpl::visitUpdRemoveFromHashMap (const UpdRemoveFromHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+
+} //simplestore
+} //zorba
+
=== added file 'src/store/naive/pul_decoding.cpp'
--- src/store/naive/pul_decoding.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_decoding.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,375 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "store/api/item_factory.h"
+#include "store/naive/atomic_items.h"
+#include "store/naive/node_items.h"
+#include "store/naive/pul_visitors.h"
+#include "store/naive/simple_store.h"
+#include "diagnostics/user_exception.h"
+#include "diagnostics/diagnostic.h"
+#include "context/namespace_context.h"
+#include "types/casting.h"
+#include "types/typeops.h"
+
+namespace zorba{
+namespace simplestore{
+
+PULDecodingVisitor::PULDecodingVisitor(static_context* sctx)
+{
+ theSctx=sctx;
+ theTypeManager = theSctx->get_parent()->get_typemanager();
+ theValidator= new SchemaValidatorImpl (theQueryLoc, theSctx->get_parent());
+}
+
+PULDecodingVisitor::~PULDecodingVisitor()
+{
+ if (theValidator!=NULL)
+ {
+ delete theValidator;
+ }
+}
+
+/*
+ * Parses the string content of the given element node as a QName.
+ * Namespace bindings are resolved with respect to the given element bindings.
+ *
+ * isAttribute = specifies whether the string represents an attribute name
+ */
+void PULDecodingVisitor::parseAsQName(store::Item_t& result,
+ const ElementNode* contentNode,
+ bool isAttribute) const
+{
+ parseAsQName(result,contentNode,contentNode,isAttribute);
+}
+
+/*
+ * Parses the string content of the given attribute as a QName.
+ * Namespace bindings are resolved with respect to the given attribute parent bindings.
+ *
+ * isAttribute = specifies whether the string represents an attribute name
+ */
+void PULDecodingVisitor::parseAsQName(store::Item_t& result,
+ const AttributeNode* contentNode,
+ bool isAttribute) const
+{
+ assert(contentNode->getParent());
+ parseAsQName(result,contentNode,static_cast<ElementNode*>(contentNode->getParent()),isAttribute);
+}
+
+/*
+ * Parses the string content of the given attribute or element node as a QName.
+ * Namespace bindings are resolved with respect to the specified element node bindings.
+ *
+ * isAttribute = specifies whether the string represents an attribute name
+ */
+void PULDecodingVisitor::parseAsQName(store::Item_t& result,
+ const XmlNode* contentNode,
+ const ElementNode* parentNode,
+ bool isAttribute) const
+{
+ assert(contentNode->isNode());
+ if (contentNode->getType()==theStore->theSchemaTypeNames[XS_QNAME])
+ {
+ store::Iterator_t iter;
+ contentNode->getTypedValue(result,iter);
+ }
+ if (result)
+ {
+ if (isAttribute && result->getPrefix()=="")
+ theItemFactory->createQName(result,"","",result->getLocalName());
+ return;
+ }
+ zstring content;
+ contentNode->getStringValue2(content);
+ parseAsQName(result,content, parentNode, isAttribute);
+}
+
+/*
+ * Parses the given string as a QName.
+ * Namespace bindings are resolved with respect to the specified element node bindings.
+ *
+ * isAttribute = specifies whether the string represents an attribute name
+ */
+void PULDecodingVisitor::parseAsQName(store::Item_t& result,
+ zstring& content,
+ const ElementNode* parentNode,
+ bool isAttribute) const
+{
+
+ store::NsBindings bindings;
+ parentNode->getNamespaceBindings(bindings);
+ namespace_context nsCtx = namespace_context(theSctx, bindings);
+
+ store::Item_t untypedAtomic;
+ theItemFactory->createUntypedAtomic(untypedAtomic,content);
+
+ GenericCast::instance()->castToQName(result,untypedAtomic,&nsCtx,isAttribute,theTypeManager,theQueryLoc);
+}
+
+/*
+ * Parses the given string as a boolean.
+ *
+ * isAttribute = specifies whether the string represents an attribute name
+ */
+bool PULDecodingVisitor::parseAsBoolean(const store::Item_t& contentNode) const
+{
+ assert(contentNode->isNode());
+ if (contentNode->getType()==theStore->theSchemaTypeNames[XS_BOOLEAN])
+ {
+ store::Item_t val;
+ store::Iterator_t iter;
+ contentNode->getTypedValue(val,iter);
+ return val->getBooleanValue();
+ }
+ store::Item_t untypedAtomic;
+ zstring value;
+ contentNode->getStringValue2(value);
+ theItemFactory->createUntypedAtomic(untypedAtomic,value);
+ store::Item_t result;
+ if (!static_cast<UntypedAtomicItem*>(untypedAtomic.getp())->castToBoolean(result))
+ {
+ std::stringstream err_msg;
+ err_msg << value << " cannot be cast to boolean.";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ return result->getBooleanValue();
+}
+
+/*
+ * Parses an element representing a single operation.
+ *
+ * operation = The operation to parse as an element node.
+ */
+void PULDecodingVisitor::parseOperation(const ElementNode* operation)
+{
+ const zstring& opName=operation->getNodeName()->getLocalName();
+ if (opName== "delete")
+ parseDelete(operation);
+ else if (opName== "insertInto")
+ parseInsertInto(operation);
+ else if (opName== "insertIntoAsFirst")
+ parseInsertIntoAsFirst(operation);
+ else if (opName== "insertIntoAsLast")
+ parseInsertIntoAsLast(operation);
+ else if (opName== "insertBefore")
+ parseInsertBefore(operation);
+ else if (opName== "insertAfter")
+ parseInsertAfter(operation);
+ else if (opName== "insertAttributes")
+ parseInsertAttributes(operation);
+ else if (opName== "replaceNode")
+ parseReplaceNode(operation);
+ else if (opName== "replaceElementContent")
+ parseReplaceElementContent(operation);
+ else if (opName== "replaceValue")
+ parseReplaceValue(operation);
+ else if (opName== "rename")
+ parseRename(operation);
+ else if (opName== "put")
+ parsePut(operation);
+ else if (opName == "createCollection")
+ parseCreateCollection(operation);
+ else if (opName == "insertIntoCollection")
+ parseInsertIntoCollection(operation);
+ else if (opName == "insertFirstIntoCollection")
+ parseInsertFirstIntoCollection(operation);
+ else if (opName == "insertLastIntoCollection")
+ parseInsertLastIntoCollection(operation);
+ else if (opName == "insertAfterIntoCollection")
+ parseInsertAfterIntoCollection(operation);
+ else if (opName == "insertBeforeIntoCollection")
+ parseInsertBeforeIntoCollection(operation);
+ else if (opName == "removeFromCollection")
+ parseDeleteNodesFromCollection(operation);
+ else if (opName == "deleteCollection")
+ parseDeleteCollection(operation);
+ else if (opName == "activateForeignKeyIC")
+ parseActivateForeignKeyIC(operation);
+ else if (opName == "activateIC")
+ parseActivateIC(operation);
+ else if (opName == "deactivateIC")
+ parseDeactivateIC(operation);
+#ifdef PUL_SETTYPE
+ else if (opName == "setAttributeType")
+ parseSetAttributeType(operation);
+ else if (opName == "setElementType")
+ parseSetElementType(operation);
+#endif
+ else if (opName == "createDocument")
+ parseCreateDocument(operation);
+ else if (opName == "deleteDocument")
+ parseDeleteDocument(operation);
+ else if (opName == "revalidate")
+ parseRevalidate(operation);
+ else
+ {
+ std::stringstream err_msg;
+ err_msg << "Unknown operation: " << opName;
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+}
+
+/*
+ * Parses a string with respect to the specified type definition and returns a
+ * typed item(s). Namespaces are resolved with respect to the provided decodedElemParent
+ * node. Returns whether the item is a list or not.
+ *
+ * resultList = The typed item(s)
+ * value = The value to parse
+ * typeName = The type QName
+ * decodedElemParent = The element node respect to which namespaces have to be resolved
+ */
+bool PULDecodingVisitor::parseTypedString(std::vector<store::Item_t>& resultList,
+ zstring& value,
+ store::Item_t& typeName,
+ const ElementNode* decodedElemParent) const
+{
+ xqtref_t schemaType = theTypeManager->create_named_type(typeName);
+
+ if ( schemaType==NULL )
+ {
+ std::stringstream err_msg;
+ err_msg << "Missing type definition: " << typeName;
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+
+ if (!schemaType->content_kind()==XQType::SIMPLE_CONTENT_KIND)
+ {
+ std::stringstream err_msg;
+ err_msg << "Type definition must be a simple type definition: " << typeName;
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+
+ if (schemaType->is_builtin())
+ {
+ return parseBuiltinTypedString(resultList,value,schemaType,decodedElemParent);
+ }
+ else
+ {
+ return parseUserDefinedTypedString(resultList,value,schemaType);
+ }
+}
+
+/*
+ * Parses a string with respect to the specified type definition and returns a
+ * typed item(s). Namespaces are resolved with respect to the provided decodedElemParent
+ * node. Returns whether the text is of list kind. The type definition must exist
+ * and it must be user defined.
+ *
+ * resultList = The typed item(s)
+ * value = The value to parse
+ * typeName = The type QName
+ * decodedElemParent = The element node respect to which namespaces have to be resolved
+ */
+bool PULDecodingVisitor::parseUserDefinedTypedString(std::vector<store::Item_t>& resultList,
+ zstring& value,
+ const xqtref_t& schemaType) const
+{
+ ZORBA_ASSERT(!(schemaType==NULL) && schemaType->content_kind()==XQType::SIMPLE_CONTENT_KIND && !schemaType->is_builtin());
+
+ //isPossibleSimpleContentRevalidation is not tested intentionally
+ try
+ {
+ theValidator->validateSimpleContent(schemaType->get_qname(),value,resultList);
+ }
+ catch (XQueryException&)
+ {
+ std::stringstream err_msg;
+ err_msg << value << " cannot be cast to type " << schemaType->get_qname()->getStringValue();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+
+ const UserDefinedXQType* udType = static_cast<const UserDefinedXQType*>(schemaType.getp());
+ return udType->isList();
+}
+
+/*
+ * Parses a string with respect to the specified type definition and returns a
+ * typed item(s). Namespaces are resolved with respect to the provided decodedElemParent
+ * node. Returns whether the text is of list kind. The type definition must exist
+ * and it must be builtin.
+ *
+ * resultList = The typed item(s)
+ * value = The value to parse
+ * typeName = The type QName
+ * decodedElemParent = The element node respect to which namespaces have to be resolved
+ */
+bool PULDecodingVisitor::parseBuiltinTypedString(std::vector<store::Item_t>& resultList,
+ zstring& value,
+ const xqtref_t& schemaType,
+ const ElementNode* decodedElemParent) const
+{
+ ZORBA_ASSERT(!(schemaType==NULL) && schemaType->content_kind()==XQType::SIMPLE_CONTENT_KIND && schemaType->is_builtin());
+ store::Item_t valueItem;
+ if (schemaType->type_kind()==XQType::ATOMIC_TYPE_KIND)
+ {
+ TypeConstants::atomic_type_code_t schemaTypeCode = TypeOps::get_atomic_type_code(*schemaType);
+ store::Item_t untypedValue;
+ switch (schemaTypeCode)
+ {
+ case TypeConstants::XS_ANY_ATOMIC:
+ case TypeConstants::XS_UNTYPED_ATOMIC:
+ theItemFactory->createUntypedAtomic(valueItem,value);
+ break;
+ default:
+ store::NsBindings bindings;
+ decodedElemParent->getNamespaceBindings(bindings);
+ namespace_context nsCtx = namespace_context(theSctx, bindings);
+ try
+ {
+ if (!GenericCast::castToAtomic(valueItem,value,schemaType.getp(),theTypeManager,&nsCtx,theQueryLoc))
+ {
+ std::stringstream err_msg;
+ err_msg << value << " cannot be cast to type " << schemaType->get_qname()->getStringValue();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ }
+ catch (XQueryException&)
+ {
+ std::stringstream err_msg;
+ err_msg << value << " cannot be cast to type " << schemaType->get_qname()->getStringValue();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ break;
+ }
+ }
+ else if (schemaType->type_kind()==XQType::ANY_TYPE_KIND || schemaType->type_kind()==XQType::ANY_SIMPLE_TYPE_KIND)
+ {
+ theItemFactory->createUntypedAtomic(valueItem,value);
+ }
+ resultList.push_back(valueItem);
+ return false;
+}
+
+
+
+}//simplestore
+}//zorba
+
=== added file 'src/store/naive/pul_encoding.cpp'
--- src/store/naive/pul_encoding.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_encoding.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,558 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "store/api/item_factory.h"
+#include "diagnostics/user_exception.h"
+#include "diagnostics/diagnostic.h"
+#include "store/naive/node_items.h"
+#include "store/naive/simple_store.h"
+#include "store/naive/store_defs.h"
+#include "store/naive/pul_visitors.h"
+#include "store/naive/pul_primitives.h"
+
+
+namespace zorba{
+namespace simplestore{
+
+#ifndef TEXT_ORDPATH
+/*
+ * Creates a new element node, containing the reference and position of a given node.
+ *
+ * parent = The parent element of the constructed element
+ * target = The node which reference/identifier is represented
+ * cachedLabels = A map from nodes to structural informations. If the target node is
+ * found here, the corresponding position is used.
+ * Otherwise the structural information is computed.
+ * nodename = The local name of the constructed element (default: pul:target)
+ */
+void PULEncodingVisitor::encodeTarget(
+ store::Item_t& parent,
+ const store::Item_t& target,
+ const std::map<XmlNode*, store::Item_t>* cachedLabels,
+ const zorba::zstring& nodename)
+{
+ std::map<XmlNode*,store::Item_t>::const_iterator it= cachedLabels->find(BASE_NODE(target));
+ if (it!=cachedLabels->end())
+ encodeTarget(parent, target,nodename,(*it).second);
+ else
+ encodeTarget(parent, target);
+}
+#endif
+
+#ifdef TEXT_ORDPATH
+/*
+ * Creates a new element node, containing the reference and position of a given node.
+ *
+ * parent = The parent element
+ * target = The node which reference/identifier is represented
+ * nodename = The local name of the constructed element (default: pul:target)
+ */
+void PULEncodingVisitor::encodeTarget(
+ store::Item_t& parent,
+ const store::Item_t& target,
+ const zorba::zstring& nodename)
+#else
+
+/*
+ * Creates a new element node, containing the reference and position of a given node.
+ *
+ * parent = The parent element
+ * target = The node which reference/identifier is represented
+ * nodename = The local name of the constructed element (default: pul:target)
+ * cachedLabels = A map from nodes to structural informations. If the target node is
+ * found here, the corresponding position is used.
+ * Otherwise the structural information is computed.
+ *
+ */
+void PULEncodingVisitor::encodeTarget(
+ store::Item_t& parent,
+ const store::Item_t& target,
+ const zorba::zstring& nodename,
+ store::Item_t cachedLabel)
+#endif
+{
+ ZORBA_FATAL(target!=NULL, "Cannot encode an empty target");
+ store::Item_t targetNode;
+ createElementNode(targetNode,nodename,parent.getp());
+
+ store::Item_t identifierNode;
+ createElementNode(identifierNode,"reference",targetNode,theStore->theSchemaTypeNames[XS_ANY_URI]);
+
+ store::Item_t labelNode;
+ createElementNode(labelNode,"position",targetNode,theStore->theSchemaTypeNames[XS_ANY_URI]);
+
+ store::Item_t identifierStr;
+ theStore->getNodeReference(identifierStr,target.getp());
+ store::Item_t identifierText;
+ theItemFactory->createTextNode(identifierText, identifierNode.getp(), identifierStr);
+
+ store::Item_t labelAnyURI;
+#ifdef TEXT_ORDPATH
+ theStore->getStructuralInformation(labelAnyURI,target.getp());
+#else
+ if (cachedLabel!=NULL)
+ labelAnyURI=cachedLabel.getp();
+ else
+ theStore->getStructuralInformation(labelAnyURI,target.getp());
+#endif
+
+ store::Item_t labelText;
+ theItemFactory->createTextNode(labelText, labelNode.getp(), labelAnyURI);
+}
+
+/*
+ * Attaches a parent-less node (and its subtree) as the last children of another node.
+ *
+ * child = subtree to attach
+ * parent = parent to attach to
+ * makeCopy determines if a copy of the given node (or the node itself) is attached
+ * The copy duplicates identifiers if the PUL is going to be encoded.
+ * partialEncoding determines if the node has to be encapsulated into an element node.
+ * Encapsulation must be used to attach document nodes and to preserve
+ * attribute order.
+ * Document nodes are represented with a "document" element node, while all
+ * other nodes are inserted into a "non-document" element node.
+ */
+void PULEncodingVisitor::attachNode(
+ const store::Item_t& child,
+ ElementNode* parent,
+ bool partialEncoding,
+ bool makeCopy)
+{
+ if (child.getp()==NULL)
+ return;
+
+ ZORBA_FATAL(child->isNode(),"Only nodes can be attached");
+ ZORBA_FATAL(
+ !(child->getNodeKind()==store::StoreConsts::documentNode && !partialEncoding),
+ "Cannot attach document nodes without encoding.");
+
+ if (partialEncoding)
+ {
+ if (child->getNodeKind()==store::StoreConsts::documentNode)
+ {
+ DocumentNode* doc=dynamic_cast<DocumentNode *>(child.getp());
+
+ store::Item_t docContainer;
+ createElementNode(docContainer,"document",parent);
+
+ zstring baseURIValue;
+ store::Item_t baseURIAttr;
+ doc->getBaseURI(baseURIValue);
+ createAttributeNode(baseURIAttr,"base-uri",baseURIValue,docContainer);
+
+ zstring documentURIValue;
+ store::Item_t documentURIAttr;
+ doc->getDocumentURI(documentURIValue);
+ createAttributeNode(documentURIAttr,"document-uri",documentURIValue,docContainer);
+
+ if (theWillBeEncoded)
+ {
+ store::Item_t nodeIdentifierValue;
+ store::Item_t nodeIdentifierAttr;
+ theStore->getNodeReference(nodeIdentifierValue,doc);
+ createAttributeNode(nodeIdentifierAttr,"reference",nodeIdentifierValue,docContainer);
+ }
+
+ if (doc->numChildren()>0)
+ {
+ store::Item_t childrenContainer;
+ createElementNode(childrenContainer,"children",docContainer);
+
+ store::Iterator_t children=doc->getChildren();
+ store::Item_t docChild;
+ XmlNode* childNode;
+
+ children->open();
+ while (children->next(docChild))
+ {
+ if (makeCopy)
+ attachNode(docChild,ELEM_NODE(childrenContainer),false,makeCopy);
+ else
+ {
+ childNode=BASE_NODE(docChild);
+ childNode->detach();
+ attachNode(docChild,ELEM_NODE(childrenContainer),false, makeCopy);
+ }
+ }
+ children->close();
+ }
+ }
+ else
+ {
+ store::Item_t nonDocContainer;
+ createElementNode(nonDocContainer,"non-document",parent);
+ attachNode(child,ELEM_NODE(nonDocContainer),false,makeCopy);
+ }
+ }
+ else
+ {
+ XmlNode* childNode;
+ if (makeCopy)
+ {
+ requireReference(BASE_NODE(child));
+ store::CopyMode copyMode=store::CopyMode();
+ copyMode.set(true,true,true,true,theWillBeEncoded);
+ childNode=static_cast<XmlNode*>(child->copy(NULL,copyMode));
+ }
+ else
+ {
+ childNode=BASE_NODE(child);
+ requireReference(childNode);
+ }
+
+ if (childNode->getNodeKind()==store::StoreConsts::attributeNode)
+ childNode->attach(parent,parent->numAttrs());
+ else
+ childNode->attach(parent,parent->numChildren());
+ }
+}
+
+
+/*
+ * Generates a reference (if not already generated) for each node
+ * in the subtree rooted at the given node.
+ */
+void PULEncodingVisitor::requireReference(XmlNode* root)
+{
+ InternalNode::const_iterator iter;
+ InternalNode::const_iterator end;
+ InternalNode* intNode;
+
+ if (!theStore->hasReference(root))
+ {
+ store::Item_t ref;
+ theStore->getNodeReference(ref,root);
+ }
+
+ switch (root->getNodeKind())
+ {
+ case store::StoreConsts::elementNode:
+ intNode=static_cast<InternalNode *>(root);
+ for (iter= intNode->attrsBegin(),end = intNode->attrsEnd(); iter != end; ++iter)
+ requireReference(*iter);
+ for (iter= intNode->childrenBegin(),end = intNode->childrenEnd(); iter != end; ++iter)
+ requireReference(*iter);
+ break;
+ case store::StoreConsts::documentNode:
+ intNode=static_cast<InternalNode *>(root);
+ for (iter= intNode->childrenBegin(),end = intNode->childrenEnd(); iter != end; ++iter)
+ requireReference(*iter);
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * Creates a new element with local name "containerName" having as children the nodes
+ * in the sequence "content".
+ * The created node is then added as the last children of the node "parent".
+ * "content" can be a mixed sequence of attributes, elements, processing-instructions,
+ * comments or text nodes.
+ *
+ * makeCopy determines if a copy of "content" (or "content" itself) are attached in "containerName"
+ * The copy duplicates identifiers if the PUL is going to be encoded.
+ * partialEncoding determines if the nodes in "content" have to be encapsulated into element nodes.
+ * Encapsulation must be used to attach document nodes and to preserve attribute order.
+ * Document nodes are represented with a "document" element node, while all other nodes
+ * are inserted into a "non-document" element node.
+ *
+ */
+void PULEncodingVisitor::encodeNodes(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const std::vector<store::Item_t>& content,
+ bool partialEncoding,
+ bool makeCopy)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp());
+
+ std::vector<store::Item_t>::const_iterator iter = content.begin();
+ std::vector<store::Item_t>::const_iterator end = content.end();
+ for (; iter != end; ++iter)
+ attachNode(*iter,ELEM_NODE(containerNode), partialEncoding, makeCopy);
+}
+
+/*
+ * Creates a new element with local name "containerName" having as children the nodes
+ * in the sequence "content".
+ * The created node is then added as the last children of the node "parent".
+ * "content" can be a mixed sequence of attributes, elements, processing-instructions,
+ * comments or text nodes.
+ *
+ * makeCopy determines if a copy of "content" (or "content" itself) are attached in "containerName"
+ * The copy duplicates identifiers if the PUL is going to be encoded.
+ * partialEncoding determines if the nodes in "content" have to be encapsulated into element nodes.
+ * Encapsulation must be used to attach document nodes and to preserve attribute order.
+ * Document nodes are represented with a "document" element node, while all other nodes
+ * are inserted into a "non-document" element node.
+ *
+ */
+void PULEncodingVisitor::encodeNodes(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const std::vector<XmlNode*>& content,
+ bool partialEncoding,
+ bool makeCopy)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp());
+
+ std::vector<XmlNode*>::const_iterator iter = content.begin();
+ std::vector<XmlNode*>::const_iterator end = content.end();
+ for (; iter != end; ++iter)
+ attachNode(*iter,ELEM_NODE(containerNode), partialEncoding, makeCopy);
+}
+
+/*
+ * Creates a new element with local name "containerName" having as children the nodes
+ * in the sequence "content".
+ * The created node is then added as the last children of the node "parent".
+ * "content" can be a mixed sequence of attributes, elements, processing-instructions,
+ * comments or text nodes.
+ *
+ * makeCopy determines if a copy of "content" (or "content" itself) are attached in "containerName"
+ * The copy duplicates identifiers if the PUL is going to be encoded.
+ * partialEncoding determines if the nodes in "content" have to be encapsulated into element nodes.
+ * Encapsulation must be used to attach document nodes and to preserve attribute order.
+ * Document nodes are represented with a "document" element node, while all other nodes
+ * are inserted into a "non-document" element node.
+ *
+ */
+void PULEncodingVisitor::encodeNodes(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Iterator_t& content,
+ bool partialEncoding,
+ bool makeCopy)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp());
+
+
+ store::Item_t containedNode;
+ content->open();
+ while(content->next(containedNode))
+ attachNode(containedNode,ELEM_NODE(containerNode), partialEncoding, makeCopy);
+
+ content->close();
+
+}
+
+/*
+ * Creates a new element with local name "containerName" having as children the
+ * specified node "content".
+ * "content" can be an attribute, element, processing-instruction, comment or text node.
+ * The created node is then added as the last children of the node "parent".
+ *
+ * makeCopy determines if a copy of "content" (or "content" itself) are attached in "containerName"
+ * The copy duplicates identifiers if the PUL is going to be encoded.
+ * partialEncoding determines if the nodes in "content" have to be encapsulated into element nodes.
+ * Encapsulation must be used to attach document nodes and to preserve attribute order.
+ * Document nodes are represented with a "document" element node, while all other nodes
+ * are inserted into a "non-document" element node.
+ *
+ */
+ElementNode* PULEncodingVisitor::encodeNode(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Item_t& content,
+ bool partialEncoding,
+ bool makeCopy)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp());
+ attachNode(content,ELEM_NODE(containerNode), partialEncoding, makeCopy);
+ return ELEM_NODE(containerNode);
+}
+
+/*
+ * Creates a new element with local name "containerName" containing typed item in "content".
+ * The created node is then added as the last children of the node "parent".
+ * "content" must be a single atomic item.
+ */
+void PULEncodingVisitor::encodeItem(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Item_t& content,
+ const store::Item_t& contentType,
+ bool haveTypedValue,
+ bool haveEmptyValue)
+{
+ zstring pulURI="http://www.zorba-xquery.com/modules/store/pul/representation";
+ zstring pulPrefix="pul";
+ zstring baseURI="";
+ store::Item_t inodeName;
+ theItemFactory->createQName(inodeName, theNS, pulPrefix, containerName);
+ store::NsBindings bindings;
+
+ store::Item_t containerNode;
+ store::Item_t type=contentType;
+ theItemFactory->createElementNode(
+ containerNode,parent.getp(),
+ inodeName,
+ type,
+ haveTypedValue,
+ haveEmptyValue,
+ bindings,
+ baseURI);
+
+ store::Item_t textContentNode;
+ store::Item_t contentCopy=content;
+ theItemFactory->createTextNode(textContentNode,ELEM_NODE(containerNode),contentCopy);
+}
+
+/*
+ * Creates a new element with local name "containerName" having as child
+ * a textNode with the string specified in "textContent" as content.
+ * The created node is then added as the last children of the node "parent".
+ * "content" can be a mixed sequence of attributes, elements, processing-instructions,
+ * comments or text nodes.
+ */
+void PULEncodingVisitor::encodeBoolean(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const bool booleanContent)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp(),theStore->theSchemaTypeNames[XS_BOOLEAN]);
+
+ store::Item_t value;
+ theItemFactory->createBoolean(value,booleanContent);
+
+ store::Item_t textContentNode;
+ theItemFactory->createTextNode(textContentNode,containerNode.getp(),value);
+}
+
+
+/*
+ * Creates a new element with local name "containerName" having as child
+ * a textNode with the string specified in "textContent" as content.
+ * The created node is then added as the last children of the node "parent".
+ * "content" can be a mixed sequence of attributes, elements, processing-instructions,
+ * comments or text nodes.
+ */
+void PULEncodingVisitor::encodeString(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const zorba::zstring& textContent)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp());
+
+ store::Item_t textContentNode;
+ zorba::zstring tc=textContent;
+ theItemFactory->createTextNode(textContentNode,containerNode.getp(),tc);
+}
+
+/*
+ * Creates a new element with local name "containerName" with type xs:Qname
+ * having as child a qname textNode with the specified qname as content.
+ * The created node is then added as the last children of the node "parent".
+ * qname must have type QName.
+ */
+void PULEncodingVisitor::encodeQName(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Item_t& qname)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp(), theStore->theSchemaTypeNames[XS_QNAME]);
+
+ ELEM_NODE(containerNode)->addLocalBinding(qname->getPrefix(),qname->getNamespace());
+
+ store::Item_t textContentNode;
+ store::Item_t qnameCopy=qname;
+ theItemFactory->createTextNode(textContentNode,ELEM_NODE(containerNode),qnameCopy);
+}
+
+/*
+ * Creates a new element with local name "containerName" having as child a sequence
+ * of "annotation" elements one for each annotation.
+ * The created node is then added as the last children of the node "parent".
+ */
+void PULEncodingVisitor::encodeCollectionAnnotations(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const std::vector<store::Annotation_t> annotations)
+{
+ store::Item_t containerNode;
+ createElementNode(containerNode,containerName,parent.getp());
+
+ std::vector<store::Annotation_t>::const_iterator iter = annotations.begin();
+ std::vector<store::Annotation_t>::const_iterator end = annotations.end();
+
+ for (; iter != end; ++iter)
+ {
+ store::Item_t annotationNode;
+ createElementNode(annotationNode,"annotation",containerNode.getp());
+ encodeQName(annotationNode,"name",(*iter)->theName);
+ encodeLiterals((*iter)->theLiterals,annotationNode);
+ }
+}
+
+/*
+ * Creates a new element with local name "literals" having as child a sequence
+ * of element named "literal" one for each given literal.
+ * The created node is then added as the last children of the node "annotationNode".
+ */
+void PULEncodingVisitor::encodeLiterals(std::vector<store::Item_t>& literals, store::Item_t annotationNode)
+{
+ if (!literals.size())
+ return;
+
+ store::Item_t literalsElem;
+ createElementNode(literalsElem,"literals",annotationNode);
+
+ std::vector<store::Item_t>::const_iterator litIter;
+ std::vector<store::Item_t>::const_iterator litEnd;
+
+ litIter=literals.begin();
+ litEnd=literals.end();
+ for (; litIter != litEnd; ++litIter)
+ {
+ store::Item_t literalNode;
+ createElementNode(literalNode,"literal",literalsElem.getp());
+
+ store::Item_t textContentNode;
+ zorba::zstring tc;
+ (*litIter)->getStringValue2(tc);
+
+ store::Item_t typeName=(*litIter)->getType();
+ store::Item_t annotationTypeAttribute;
+ createAttributeNode(annotationTypeAttribute,"type",typeName,literalNode.getp());
+
+ theItemFactory->createTextNode(textContentNode,literalNode.getp(),tc);
+ }
+}
+
+/*
+ * Raises an operation not supported error.
+ */
+void PULEncodingVisitor::visitUnsupported(const UpdatePrimitive * op)
+{
+ std::stringstream err_msg;
+ err_msg << "The provided PUL contains an unsupported operation: " << store::UpdateConsts::toString(op->getKind());
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL002");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+}
+
+
+
+}//simplestore
+}//zorba
=== modified file 'src/store/naive/pul_primitives.cpp'
--- src/store/naive/pul_primitives.cpp 2011-11-02 17:19:09 +0000
+++ src/store/naive/pul_primitives.cpp 2012-01-02 09:53:25 +0000
@@ -29,6 +29,7 @@
#include "store/naive/node_factory.h"
#include "store/naive/simple_index.h"
#include "store/naive/simple_index_value.h"
+#include "store/naive/pul_visitors.h"
#include "store/api/iterator.h"
#include "store/api/copymode.h"
@@ -166,6 +167,10 @@
}
}
+void UpdDelete::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdDelete(this);
+}
/*******************************************************************************
@@ -275,6 +280,11 @@
}
}
+void UpdInsertChildren::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertChildren(this);
+}
+
/*******************************************************************************
@@ -323,6 +333,10 @@
}
}
+void UpdInsertAttributes::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertAttributes(this);
+}
/*******************************************************************************
@@ -374,6 +388,10 @@
}
}
+void UpdReplaceAttribute::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdReplaceAttribute(this);
+}
/*******************************************************************************
@@ -427,6 +445,10 @@
INTERNAL_NODE(theTarget)->restoreChild(*this);
}
+void UpdReplaceChild::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdReplaceChild(this);
+}
/*******************************************************************************
@@ -443,6 +465,10 @@
ELEM_NODE(theTarget)->restoreContent(*this);
}
+void UpdReplaceElemContent::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdReplaceElemContent(this);
+}
/*******************************************************************************
@@ -459,6 +485,10 @@
ELEM_NODE(theTarget)->restoreName(*this);
}
+void UpdRenameElem::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdRenameElem(this);
+}
/*******************************************************************************
@@ -577,6 +607,11 @@
}
}
+void UpdSetElementType::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdSetElementType(this);
+}
+
/*******************************************************************************
********************************************************************************/
@@ -592,6 +627,10 @@
ATTR_NODE(theTarget)->restoreValue(*this);
}
+void UpdReplaceAttrValue::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdReplaceAttrValue(this);
+}
/*******************************************************************************
@@ -627,6 +666,10 @@
}
}
+void UpdRenameAttr::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdRenameAttr(this);
+}
/*******************************************************************************
@@ -668,6 +711,10 @@
}
}
+void UpdSetAttributeType::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdSetAttributeType(this);
+}
/*******************************************************************************
@@ -707,6 +754,10 @@
#endif
}
+void UpdRevalidate::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdRevalidate(this);
+}
/*******************************************************************************
@@ -732,6 +783,10 @@
TEXT_NODE(theTarget)->restoreValue(*this);
}
+void UpdReplaceTextValue::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdReplaceTextValue(this);
+}
/*******************************************************************************
@@ -748,6 +803,10 @@
PI_NODE(theTarget)->restoreValue(*this);
}
+void UpdReplacePiValue::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdReplacePiValue(this);
+}
/*******************************************************************************
@@ -764,6 +823,10 @@
PI_NODE(theTarget)->restoreName(*this);
}
+void UpdRenamePi::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdRenamePi(this);
+}
/*******************************************************************************
@@ -780,6 +843,10 @@
COMMENT_NODE(theTarget)->restoreValue(*this);
}
+void UpdReplaceCommentValue::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdReplaceCommentValue(this);
+}
/////////////////////////////////////////////////////////////////////////////////
// //
@@ -814,13 +881,15 @@
store::Item_t docItem;
GET_FACTORY().createDocumentNode(docItem, targetUri, targetUri);
- theTarget = theTarget->copy(docItem.getp(), copymode);
+ if (theCopyOnApply)
+ theTarget = theTarget->copy(docItem.getp(), copymode);
theTarget.transfer(docItem);
}
else
{
- theTarget = theTarget->copy(NULL, copymode);
+ if (theCopyOnApply)
+ theTarget = theTarget->copy(NULL, copymode);
}
store->addNode(targetUri, theTarget);
@@ -854,6 +923,10 @@
store->addNode(theTargetUri->getStringValue(), theOldDocument);
}
+void UpdPut::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdPut(this);
+}
/////////////////////////////////////////////////////////////////////////////////
// //
@@ -939,6 +1012,10 @@
}
}
+void UpdCreateCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdCreateCollection(this);
+}
/*******************************************************************************
UpdDeleteCollection
@@ -1006,6 +1083,10 @@
GET_STORE().addCollection(theCollection);
}
+void UpdDeleteCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdDeleteCollection(this);
+}
/*******************************************************************************
UpdInsertIntoCollection
@@ -1055,6 +1136,10 @@
}
}
+void UpdInsertIntoCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertIntoCollection(this);
+}
/*******************************************************************************
UpdInsertFirstIntoCollection
@@ -1092,6 +1177,10 @@
}
}
+void UpdInsertFirstIntoCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertFirstIntoCollection(this);
+}
/*******************************************************************************
UpdInsertLastIntoCollection
@@ -1140,6 +1229,10 @@
}
}
+void UpdInsertLastIntoCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertLastIntoCollection(this);
+}
/*******************************************************************************
UpdInsertBeforeIntoCollection
@@ -1170,6 +1263,10 @@
lColl->removeNodes(theFirstPos, (uint64_t)theNodes.size());
}
+void UpdInsertBeforeIntoCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertBeforeIntoCollection(this);
+}
/*******************************************************************************
UpdInsertAfterIntoCollection
@@ -1201,6 +1298,10 @@
lColl->removeNodes(theFirstPos, (uint64_t)theNodes.size());
}
+void UpdInsertAfterIntoCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertAfterIntoCollection(this);
+}
/*******************************************************************************
UpdRemoveNodesFromCollection
@@ -1275,6 +1376,10 @@
}
}
+void UpdDeleteNodesFromCollection::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdDeleteNodesFromCollection(this);
+}
/////////////////////////////////////////////////////////////////////////////////
@@ -1336,6 +1441,10 @@
}
}
+void UpdCreateIndex::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdCreateIndex(this);
+}
/*******************************************************************************
@@ -1376,6 +1485,10 @@
}
}
+void UpdDeleteIndex::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdDeleteIndex(this);
+}
/*******************************************************************************
@@ -1426,6 +1539,10 @@
}
}
+void UpdRefreshIndex::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdRefreshIndex(this);
+};
/*******************************************************************************
@@ -1466,6 +1583,10 @@
}
}
+void UpdActivateIC::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdActivateIC(this);
+}
/*******************************************************************************
@@ -1508,6 +1629,10 @@
}
}
+void UpdActivateForeignKeyIC::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdActivateForeignKeyIC(this);
+}
/*******************************************************************************
@@ -1573,6 +1698,10 @@
}
}
+void UpdDeActivateIC::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdDeActivateIC(this);
+}
/*******************************************************************************
@@ -1611,6 +1740,10 @@
}
}
+void UpdCreateDocument::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdCreateDocument(this);
+}
/*******************************************************************************
@@ -1652,6 +1785,10 @@
}
}
+void UpdDeleteDocument::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdDeleteDocument(this);
+}
/*******************************************************************************
@@ -1716,6 +1853,10 @@
}
}
+void UpdCreateHashMap::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdCreateHashMap(this);
+};
/*******************************************************************************
@@ -1745,6 +1886,10 @@
}
}
+void UpdDestroyHashMap::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdDestroyHashMap(this);
+};
/*******************************************************************************
@@ -1804,6 +1949,10 @@
{
}
+void UpdInsertIntoHashMap::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdInsertIntoHashMap(this);
+};
/*******************************************************************************
@@ -1852,6 +2001,11 @@
{
}
+void UpdRemoveFromHashMap::accept(PULEncodingVisitor & visitor)
+{
+ visitor.visitUpdRemoveFromHashMap(this);
+};
+
} // namespace simplestore
} // namespace zorba
/* vim:set et sw=2 ts=2: */
=== modified file 'src/store/naive/pul_primitives.h'
--- src/store/naive/pul_primitives.h 2011-12-21 14:40:33 +0000
+++ src/store/naive/pul_primitives.h 2012-01-02 09:53:25 +0000
@@ -40,6 +40,7 @@
class CollectionPul;
class XmlNode;
class InternalNode;
+class PULEncodingVisitor;
/*******************************************************************************
@@ -108,6 +109,9 @@
friend class XmlNode;
friend class InternalNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
+ friend class XDMPULVisitorImpl;
protected:
PULImpl * thePul;
@@ -141,6 +145,8 @@
virtual void check() {}
bool isApplied() const { return theIsApplied; }
+
+ virtual void accept(PULEncodingVisitor & visitor) = 0;
};
@@ -161,6 +167,7 @@
friend class XmlNode;
friend class InternalNode;
friend class PULPrimitiveFactory;
+ friend class CompletePULVisitorImpl;
protected:
store::ItemHandle<InternalNode> theParent;
@@ -177,6 +184,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -219,6 +227,8 @@
friend class XmlNode;
friend class InternalNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::UpdateConsts::UpdPrimKind theKind;
@@ -240,6 +250,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -258,6 +269,8 @@
friend class PULImpl;
friend class ElementNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
std::vector<store::Item_t> theNewAttrs;
@@ -280,6 +293,7 @@
void apply();
void undo();
void check();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -292,6 +306,8 @@
friend class CollectionPul;
friend class ElementNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theAttr;
@@ -317,6 +333,7 @@
void apply();
void undo();
void check();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -330,6 +347,8 @@
friend class XmlNode;
friend class InternalNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theChild;
@@ -354,6 +373,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -367,6 +387,8 @@
friend class CollectionPul;
friend class ElementNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theNewChild;
@@ -394,6 +416,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -407,6 +430,8 @@
friend class PULImpl;
friend class ElementNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theNewName;
@@ -436,6 +461,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -447,6 +473,8 @@
friend class PULImpl;
friend class AttributeNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
zstring theNewValue;
@@ -472,6 +500,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -490,6 +519,8 @@
friend class PULImpl;
friend class AttributeNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theNewName;
@@ -519,6 +550,7 @@
void apply();
void undo();
void check();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -530,6 +562,8 @@
friend class PULImpl;
friend class TextNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
zstring theNewContent;
@@ -561,6 +595,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -572,6 +607,8 @@
friend class PULImpl;
friend class PiNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
zstring theNewValue;
@@ -596,6 +633,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -607,6 +645,8 @@
friend class PULImpl;
friend class PiNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
zstring theNewName;
@@ -631,6 +671,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -642,6 +683,8 @@
friend class PULImpl;
friend class CommentNode;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
zstring theNewValue;
@@ -666,6 +709,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -713,6 +757,8 @@
{
friend class PULImpl;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theTypeName;
@@ -765,6 +811,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -775,6 +822,8 @@
{
friend class PULImpl;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theTypeName;
@@ -808,6 +857,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -819,6 +869,7 @@
{
friend class PULImpl;
friend class PULPrimitiveFactory;
+ friend class CompletePULVisitorImpl;
protected:
store::PUL_t theRevalidationPul;
@@ -838,6 +889,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -855,15 +907,19 @@
{
friend class PULImpl;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
+ friend class XDMPULVisitorImpl;
protected:
store::Item_t theTargetUri;
-
store::Item_t theOldDocument;
+ bool theCopyOnApply;
UpdPut(PULImpl* pul, const QueryLoc* aLoc, store::Item_t& target, store::Item_t& uri)
:
- UpdatePrimitive(pul, aLoc, target)
+ UpdatePrimitive(pul, aLoc, target),
+ theCopyOnApply(true)
{
theTargetUri.transfer(uri);
}
@@ -876,6 +932,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -892,6 +949,8 @@
class UpdCollection : public UpdatePrimitive
{
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
store::Item_t theName;
@@ -942,6 +1001,8 @@
class UpdCreateCollection : public UpdCollection
{
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
const std::vector<store::Annotation_t> theAnnotations;
@@ -970,6 +1031,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -979,6 +1041,7 @@
class UpdDeleteCollection : public UpdCollection
{
friend class PULPrimitiveFactory;
+ friend class CompletePULVisitorImpl;
protected:
store::Collection_t theCollection; // only used for undo
@@ -1001,6 +1064,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1034,6 +1098,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1067,6 +1132,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1100,6 +1166,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1134,6 +1201,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1168,6 +1236,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1177,6 +1246,8 @@
class UpdDeleteNodesFromCollection: public UpdCollection
{
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
bool theIsLast;
@@ -1207,6 +1278,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1249,6 +1321,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1275,6 +1348,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1308,6 +1382,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1325,6 +1400,8 @@
{
friend class PULImpl;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
const store::Item_t theQName;
@@ -1346,6 +1423,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1356,6 +1434,8 @@
{
friend class PULImpl;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
const store::Item_t theQName;
@@ -1379,6 +1459,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1389,6 +1470,8 @@
{
friend class PULImpl;
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
const store::Item_t theQName;
@@ -1411,6 +1494,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1420,6 +1504,8 @@
class UpdCreateDocument : public UpdatePrimitive
{
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
const store::Item_t theUri;
@@ -1440,6 +1526,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
/*******************************************************************************
@@ -1448,6 +1535,8 @@
class UpdDeleteDocument : public UpdatePrimitive
{
friend class PULPrimitiveFactory;
+ friend class SimplePULVisitorImpl;
+ friend class CompletePULVisitorImpl;
protected:
const store::Item_t theUri;
@@ -1468,6 +1557,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
@@ -1515,6 +1605,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
/*******************************************************************************
@@ -1541,6 +1632,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
/*******************************************************************************
@@ -1571,6 +1663,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
/*******************************************************************************
@@ -1598,6 +1691,7 @@
void apply();
void undo();
+ void accept(PULEncodingVisitor & visitor);
};
} /* namespace simplestore */
=== added file 'src/store/naive/pul_visitors.cpp'
--- src/store/naive/pul_visitors.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_visitors.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "store/naive/pul_visitors.h"
+#include "store/api/iterator.h"
+#include "store/naive/simple_store.h"
+#include "diagnostics/diagnostic.h"
+#include "diagnostics/user_exception.h"
+#include "store/naive/pul_primitives.h"
+#include "store/naive/simple_item_factory.h"
+#include "zorba/static_context.h"
+#include "zorba/iterator.h"
+#include "zorba/zorba.h"
+#include "context/static_context.h"
+
+namespace zorba{
+namespace simplestore{
+
+
+
+PULVisitor::PULVisitor()
+{
+ theStore=&GET_STORE();
+ theItemFactory=theStore->getItemFactory();
+}
+
+const QueryLoc PULVisitor::theQueryLoc=QueryLoc();
+const std::string PULVisitor::theNS = "http://www.zorba-xquery.com/modules/store/pul/representation";
+const char* PULVisitor::theErrNS = "http://www.zorba-xquery.com/modules/store/pul/errors";
+
+/*
+ * Searches the attributes of node nodeElem for an attribute whose local name is attrLocalName.
+ * If a matching attribute is found it is returned, otherwise:
+ * - if mandatory is true, error PUL011 is raised
+ * - if mandatory is false, NULL is returned.
+ */
+AttributeNode* PULVisitor::getAttributeByName(
+ const ElementNode* nodeElem,
+ const zstring& attrLocalName,
+ const bool mandatory) const
+{
+ store::Iterator_t itattr=nodeElem->getAttributes();
+ store::Item_t attribute;
+ AttributeNode* attrNode;
+ itattr->open();
+ while(itattr->next(attribute))
+ {
+ attrNode=ATTR_NODE(attribute);
+ if (attrNode->getNodeName()->getLocalName()==attrLocalName)
+ {
+ itattr->close();
+ return attrNode;
+ }
+ }
+ itattr->close();
+ if (mandatory)
+ {
+ std::stringstream err_msg;
+ err_msg << "The mandatory attribute \""<<attrLocalName <<"\" is missing from the element \"" << nodeElem->getNodeName()->getLocalName();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ return NULL;
+}
+
+/*
+ * Searches the children of node nodeElem for an element node whose local name is elemLocalName.
+ * It is possible to specify a position hint. If so the specified position (if valid) is checked first.
+ * If a matching element is found it is returned, otherwise:
+ * - if mandatory is true, error PUL011 is raised
+ * - if mandatory is false, NULL is returned.
+ */
+ElementNode* PULVisitor::getChildByName(
+ const ElementNode* nodeElem,
+ const zstring& elemLocalName,
+ const ulong& hint,
+ const bool mandatory) const
+{
+ if (hint<nodeElem->numChildren())
+ {
+ XmlNode* candidate=nodeElem->getChild(hint);
+ if (candidate->getNodeKind()==store::StoreConsts::elementNode && candidate->getNodeName()->getLocalName()==elemLocalName)
+ return static_cast<ElementNode *>(candidate);
+ }
+
+ store::Iterator_t itch=nodeElem->getChildren();
+ store::Item_t child;
+ itch->open();
+ while(itch->next(child))
+ {
+ if (child->getNodeKind()==store::StoreConsts::elementNode && child->getNodeName()->getLocalName()==elemLocalName)
+ {
+ itch->close();
+ return ELEM_NODE(child);
+ }
+ }
+ itch->close();
+ if (mandatory)
+ {
+ std::stringstream err_msg;
+ err_msg << "The mandatory element \""<<elemLocalName <<"\" is missing from the element \"" << nodeElem->getNodeName()->getLocalName();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ ZORBA_FATAL(0,"");
+ }
+ else
+ return NULL;
+}
+
+
+/*
+ * Searches the children of node nodeElem for an element node whose local name is elemLocalName.
+ * It is possible to specify a position hint. If so the specified position (if valid) is checked first.
+ * If a matching element is found its position is returned, otherwise:
+ * - if mandatory is true, error PUL011 is raised
+ * - if mandatory is false, the total number of children is returned.
+ */
+ElementNode* PULVisitor::getChildByName(
+ csize& index,
+ const ElementNode* nodeElem,
+ const zstring& elemLocalName,
+ const ulong& hint,
+ const bool mandatory) const
+{
+ if (hint<nodeElem->numChildren())
+ {
+ XmlNode* candidate=nodeElem->getChild(hint);
+ if (candidate->getNodeKind()==store::StoreConsts::elementNode && candidate->getNodeName()->getLocalName()==elemLocalName)
+ {
+ index=hint;
+ return static_cast<ElementNode*>(candidate);
+ }
+ }
+
+ for (csize pos=0; pos<nodeElem->numChildren(); ++pos)
+ {
+ if (pos!=hint && nodeElem->getChild(pos)->getNodeKind()==store::StoreConsts::elementNode && nodeElem->getChild(pos)->getNodeName()->getLocalName()==elemLocalName)
+ {
+ index=pos;
+ return static_cast<ElementNode*>(nodeElem->getChild(pos));
+ }
+ }
+ if (mandatory)
+ {
+ std::stringstream err_msg;
+ err_msg << "The mandatory element \""<<elemLocalName <<"\" is missing from the element \"" << nodeElem->getNodeName()->getLocalName();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ else
+ {
+ index=nodeElem->numChildren();
+ return NULL;
+ }
+}
+
+/*
+ * Creates a new element node as child with type xs:anyType. The local
+ * name of the node is the name of the specified operation in the
+ * "http://www.zorba-xquery.com/modules/store/pul/representation" namespace.
+ * The node is attached as the last children of "parent".
+ *
+ * result = The created element
+ * operation = The operation
+ * parent = The parent of the created element
+ */
+void PULVisitor::createElementNode(
+ store::Item_t & result,
+ const UpdatePrimitive* operation,
+ store::Item* parent) const
+{
+ createElementNode(result,store::UpdateConsts::toString(operation->getKind()),parent);
+}
+
+/*
+ * Creates a new element node with the specified local name in the
+ * "http://www.zorba-xquery.com/modules/store/pul/representation" namespace.
+ * The node is attached as the last children of "parent".
+ *
+ * result = The created element
+ * nodeName = The local name of the created element
+ * parent = The parent of the created element
+ * typeName = If null an xs:any-typed node is created.
+ * A non-empty, element only content is expected.
+ * Otherwise a typed element node with is created.
+ * A non-empty, simple content is expected.
+ */
+void PULVisitor::createElementNode(
+ store::Item_t & result,
+ const zorba::zstring& nodeName,
+ store::Item* parent,
+ store::Item_t typeName) const
+{
+ zstring pulURI="http://www.zorba-xquery.com/modules/store/pul/representation";
+ zstring pulPrefix="pul";
+ zstring baseURI="";
+ store::Item_t inodeName;
+ theItemFactory->createQName(inodeName, theNS, pulPrefix, nodeName);
+ store::NsBindings bindings;
+
+ if (typeName==NULL)
+ theItemFactory->createElementNode(result,parent, inodeName,theStore->theSchemaTypeNames[XS_ANY],false,false,bindings,baseURI);
+ else
+ theItemFactory->createElementNode(result,parent, inodeName,typeName,true,false,bindings,baseURI);
+}
+
+
+/*
+ * Creates a new typed attribute node with the specified local name and empty
+ * prefix and namespace. Its type is UNTYPED_ATOMIC.
+ * The created node is attached to the specified parent node.
+ *
+ *
+ * result = The created element
+ * nodeName = The local name of the created attribute
+ * value = The value of the created attribute
+ * parent = The parent of the created attribute
+ */
+void PULVisitor::createAttributeNode(
+ store::Item_t & result,
+ const zstring& name,
+ zstring& value,
+ store::Item* parent) const
+{
+ store::Item_t attributeName;
+ store::Item_t attributeValue;
+ theItemFactory->createQName(attributeName,"","",name);
+ theItemFactory->createString(attributeValue,value);
+ theItemFactory->createAttributeNode(result,parent,attributeName,theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC], attributeValue);
+}
+
+/*
+ * Creates a new typed attribute node with the specified local name and empty
+ * prefix and namespace. Its type is the type of the given item value.
+ * The created node is attached to the specified parent node.
+ *
+ *
+ * result = The created element
+ * nodeName = The local name of the created attribute
+ * value = The value of the created attribute
+ * parent = The parent of the created attribute
+ */
+void PULVisitor::createAttributeNode(
+ store::Item_t & result,
+ const zstring& name,
+ store::Item_t& value,
+ store::Item* parent) const
+{
+ store::Item_t attributeName;
+ theItemFactory->createQName(attributeName,"","",name);
+ store::Item_t attributeType=value->getType();
+ theItemFactory->createAttributeNode(result,parent,attributeName,attributeType, value);
+}
+
+}//simplestore
+}//zorba
+
=== added file 'src/store/naive/pul_visitors.h'
--- src/store/naive/pul_visitors.h 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_visitors.h 2012-01-02 09:53:25 +0000
@@ -0,0 +1,1047 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_STORE_PUL_VISITORS
+#define ZORBA_STORE_PUL_VISITORS
+
+#include "compiler/parser/query_loc.h"
+#include "store/naive/pul_primitives.h"
+#include "store/naive/node_items.h"
+#include "store/naive/atomic_items.h"
+#include "store/naive/node_factory.h"
+#include "store/naive/simple_pul.h"
+#include "store/api/copymode.h"
+#include "store/api/pul.h"
+#include "store/api/pul_visitor.h"
+#include "zorba/item_sequence.h"
+#include "zorba/static_context.h"
+#include "context/static_context.h"
+#include "types/schema/schema.h"
+#include "types/schema/revalidateUtils.h"
+#include "annotations/annotations.h"
+
+namespace zorba{
+namespace simplestore{
+
+//#define PUL_SETTYPE
+//If this is enabled PULs may contain primitives which directly set the type of
+//a node in form of type undo or setElementTypes/setAttributeTypes
+
+class PULVisitor: public store::PULVisitor
+{
+protected:
+ SimpleStore* theStore;
+ store::ItemFactory* theItemFactory;
+ store::Item_t theResult;
+ static const std::string theNS;
+ static const char* theErrNS;
+ static const QueryLoc theQueryLoc;
+ TypeManager* theTypeManager;
+ SchemaValidatorImpl* theValidator;
+ PULVisitor();
+
+public:
+
+ virtual void visit(store::Item_t&) = 0;
+
+ virtual VisitorKind getVisitorKind() = 0;
+
+ AttributeNode* getAttributeByName(
+ const ElementNode* nodeElem,
+ const zstring& attrLocalName,
+ const bool mandatory=false) const;
+
+ ElementNode* getChildByName(
+ const ElementNode* nodeElem,
+ const zstring& childLocalName,
+ const ulong& hint=0,
+ const bool mandatory=false) const;
+
+ ElementNode* getChildByName(
+ csize& index,
+ const ElementNode* nodeElem,
+ const zstring& elemLocalName,
+ const ulong& hint=0,
+ const bool mandatory=false) const;
+
+ void createElementNode(
+ store::Item_t & result,
+ const UpdatePrimitive* operation,
+ store::Item* parent) const;
+
+ void createElementNode(
+ store::Item_t & result,
+ const zorba::zstring& nodeName,
+ store::Item* parent,
+ store::Item_t typeName=NULL) const;
+
+ void createAttributeNode(
+ store::Item_t & result,
+ const zstring& name,
+ zstring& value,
+ store::Item* parent) const;
+
+ void createAttributeNode(
+ store::Item_t & result,
+ const zstring& name,
+ store::Item_t& value,
+ store::Item* parent) const;
+};
+
+class PULEncodingVisitor: public PULVisitor
+{
+protected:
+ bool theWillBeEncoded;
+
+ std::map<store::Item_t, store::Item_t> theCreatedDynamicCollections;
+ std::map<store::Item_t, store::Item_t> theCreatedStaticCollections;
+
+public:
+ virtual void visit(store::Item_t&) = 0;
+
+ virtual VisitorKind getVisitorKind() = 0;
+
+protected:
+#ifdef TEXT_ORDPATH
+ void encodeTarget(
+ store::Item_t& parent,
+ const store::Item_t& reference,
+ const zorba::zstring& nodename="target");
+#else
+ void encodeTarget(
+ store::Item_t& parent,
+ const store::Item_t& target,
+ const std::map<XmlNode*, store::Item_t>* cachedLabels,
+ const zorba::zstring& nodename="target");
+
+ void encodeTarget(store::Item_t& parent,
+ const store::Item_t& reference,
+ const zorba::zstring& nodename="target",
+ store::Item_t cachedLabel=NULL);
+#endif
+
+ void encodeNodes(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const std::vector<XmlNode*>& content,
+ bool partialEncoding,
+ bool makeCopy);
+
+ void encodeNodes(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const std::vector<store::Item_t>& content,
+ bool partialEncoding,
+ bool makeCopy);
+
+ void encodeNodes(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Iterator_t& content,
+ bool partialEncoding,
+ bool makeCopy);
+
+ ElementNode* encodeNode(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Item_t& content,
+ bool partialEncoding,
+ bool makeCopy);
+
+ void encodeItem(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Item_t& content,
+ const store::Item_t& contentType,
+ bool haveTypedValue,
+ bool haveEmptyValue);
+
+ void encodeBoolean(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const bool booleanContent);
+
+ void encodeString(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const zorba::zstring& content);
+
+ void encodeQName(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const store::Item_t& content);
+
+ void encodeCollectionAnnotations(
+ store::Item_t& parent,
+ const zorba::zstring& containerName,
+ const std::vector<store::Annotation_t>);
+
+ void encodeLiterals(
+ std::vector<store::Item_t>& literals,
+ store::Item_t annotationNode);
+
+ void visitUnsupported (const UpdatePrimitive * op);
+
+
+private:
+ void requireReference(XmlNode* root);
+
+ void attachNode(
+ const store::Item_t& child,
+ simplestore::ElementNode* parent,
+ bool partialEncoding,
+ bool makecopy);
+
+protected:
+ PULEncodingVisitor(bool willBeEncoded):
+ PULVisitor(),
+ theWillBeEncoded(willBeEncoded)
+ {
+ };
+
+public:
+ /*------------- Methods for visiting the XQU Update Primitives -------------------*/
+
+ virtual void visitUpdDelete(const UpdDelete * op) = 0;
+
+ virtual void visitUpdInsertChildren(const UpdInsertChildren * op) = 0;
+
+ virtual void visitUpdInsertAttributes(const UpdInsertAttributes * op) = 0;
+
+ virtual void visitUpdReplaceAttribute(const UpdReplaceAttribute * op) = 0;
+
+ virtual void visitUpdReplaceChild(const UpdReplaceChild * op) = 0;
+
+ virtual void visitUpdReplaceElemContent(const UpdReplaceElemContent * op) = 0;
+
+ virtual void visitUpdRenameElem(const UpdRenameElem * op) = 0;
+
+ virtual void visitUpdReplaceAttrValue(const UpdReplaceAttrValue * op) = 0;
+
+ virtual void visitUpdRenameAttr(const UpdRenameAttr * op) = 0;
+
+ virtual void visitUpdReplaceTextValue(const UpdReplaceTextValue * op) = 0;
+
+ virtual void visitUpdReplacePiValue(const UpdReplacePiValue * op) = 0;
+
+ virtual void visitUpdRenamePi(const UpdRenamePi * op) = 0;
+
+ virtual void visitUpdReplaceCommentValue(const UpdReplaceCommentValue * op) = 0;
+
+ virtual void visitUpdPut(const UpdPut * op) = 0;
+
+
+ /*------------- Methods for visiting the Zorba Update Primitives -----------------*/
+
+ virtual void visitUpdActivateForeignKeyIC (const UpdActivateForeignKeyIC * op) = 0;
+
+ virtual void visitUpdActivateIC (const UpdActivateIC * op) = 0;
+
+ virtual void visitUpdCreateCollection (const UpdCreateCollection * op) = 0;
+
+ virtual void visitUpdCreateDocument (const UpdCreateDocument * op) = 0;
+
+ virtual void visitUpdCreateIndex (const UpdCreateIndex * op) = 0;
+
+ virtual void visitUpdDeActivateIC (const UpdDeActivateIC * op) = 0;
+
+ virtual void visitUpdDeleteCollection (const UpdDeleteCollection * op) = 0;
+
+ virtual void visitUpdDeleteDocument (const UpdDeleteDocument * op) = 0;
+
+ virtual void visitUpdDeleteIndex (const UpdDeleteIndex * op) = 0;
+
+ virtual void visitUpdDeleteNodesFromCollection (const UpdDeleteNodesFromCollection * op) = 0;
+
+ virtual void visitUpdInsertAfterIntoCollection (const UpdInsertAfterIntoCollection * op) = 0;
+
+ virtual void visitUpdInsertBeforeIntoCollection (const UpdInsertBeforeIntoCollection * op) = 0;
+
+ virtual void visitUpdInsertFirstIntoCollection (const UpdInsertFirstIntoCollection * op) = 0;
+
+ virtual void visitUpdInsertIntoCollection (const UpdInsertIntoCollection * op) = 0;
+
+ virtual void visitUpdInsertLastIntoCollection (const UpdInsertLastIntoCollection * op) = 0;
+
+ virtual void visitUpdRefreshIndex (const UpdRefreshIndex * op) = 0;
+
+ virtual void visitUpdSetAttributeType (const UpdSetAttributeType * op) = 0;
+
+ virtual void visitUpdSetElementType (const UpdSetElementType * op) = 0;
+
+ virtual void visitUpdRevalidate (const UpdRevalidate * op) = 0;
+
+ virtual void visitUpdCreateHashMap (const UpdCreateHashMap * op) = 0;
+
+ virtual void visitUpdDestroyHashMap (const UpdDestroyHashMap * op) = 0;
+
+ virtual void visitUpdInsertIntoHashMap (const UpdInsertIntoHashMap * op) = 0;
+
+ virtual void visitUpdRemoveFromHashMap (const UpdRemoveFromHashMap * op) = 0;
+
+};
+
+class SimplePULVisitorImpl: public PULEncodingVisitor
+{
+ friend class SimplePULVisitorFactory;
+
+protected:
+ SimplePULVisitorImpl(store::Item_t& result, bool willBeEncoded);
+
+public:
+ void visit(store::Item_t&);
+
+ VisitorKind getVisitorKind() {return SIMPLE_PUL_ENCODER;}
+
+
+ /*------------- Methods for visiting the XQU Update Primitives -------------------*/
+ void visitUpdDelete(const UpdDelete * op);
+
+ void visitUpdInsertChildren(const UpdInsertChildren * op);
+
+ void visitUpdInsertAttributes(const UpdInsertAttributes * op);
+
+ void visitUpdReplaceAttribute(const UpdReplaceAttribute * op);
+
+ void visitUpdReplaceChild(const UpdReplaceChild * op);
+
+ void visitUpdReplaceElemContent(const UpdReplaceElemContent * op);
+
+ void visitUpdRenameElem(const UpdRenameElem * op);
+
+ void visitUpdReplaceAttrValue(const UpdReplaceAttrValue * op);
+
+ void visitUpdRenameAttr(const UpdRenameAttr * op);
+
+ void visitUpdReplaceTextValue(const UpdReplaceTextValue * op);
+
+ void visitUpdReplacePiValue(const UpdReplacePiValue * op);
+
+ void visitUpdRenamePi(const UpdRenamePi * op);
+
+ void visitUpdReplaceCommentValue(const UpdReplaceCommentValue * op);
+
+ void visitUpdPut(const UpdPut * op);
+
+ /*------------- Methods for visiting the Zorba Update Primitives -----------------*/
+
+ void visitUpdActivateForeignKeyIC (const UpdActivateForeignKeyIC * op);
+
+ void visitUpdActivateIC (const UpdActivateIC * op);
+
+ void visitUpdCreateCollection (const UpdCreateCollection * op);
+
+ void visitUpdCreateDocument (const UpdCreateDocument * op);
+
+ void visitUpdCreateIndex (const UpdCreateIndex * op);
+
+ void visitUpdDeActivateIC (const UpdDeActivateIC * op);
+
+ void visitUpdDeleteCollection (const UpdDeleteCollection * op);
+
+ void visitUpdDeleteDocument (const UpdDeleteDocument * op);
+
+ void visitUpdDeleteIndex (const UpdDeleteIndex * op);
+
+ void visitUpdDeleteNodesFromCollection (const UpdDeleteNodesFromCollection * op);
+
+ void visitUpdInsertAfterIntoCollection (const UpdInsertAfterIntoCollection * op);
+
+ void visitUpdInsertBeforeIntoCollection (const UpdInsertBeforeIntoCollection * op);
+
+ void visitUpdInsertFirstIntoCollection (const UpdInsertFirstIntoCollection * op);
+
+ void visitUpdInsertIntoCollection (const UpdInsertIntoCollection * op);
+
+ void visitUpdInsertLastIntoCollection (const UpdInsertLastIntoCollection * op);
+
+ void visitUpdRefreshIndex (const UpdRefreshIndex * op);
+
+ void visitUpdSetAttributeType (const UpdSetAttributeType * op);
+
+ void visitUpdSetElementType (const UpdSetElementType * op);
+
+ void visitUpdRevalidate (const UpdRevalidate * op);
+
+ void visitUpdCreateHashMap (const UpdCreateHashMap * op);
+
+ void visitUpdDestroyHashMap (const UpdDestroyHashMap * op);
+
+ void visitUpdInsertIntoHashMap (const UpdInsertIntoHashMap * op);
+
+ void visitUpdRemoveFromHashMap (const UpdRemoveFromHashMap * op);
+
+};
+
+struct InsertionGroup
+{
+ UpdInsertChildren * insertInto;
+ UpdInsertChildren * insertIntoAsFirst;
+ UpdInsertChildren * insertIntoAsLast;
+ std::map<XmlNode*,UpdInsertChildren *> insertBeforeMap;
+ std::map<XmlNode*,UpdInsertChildren *> insertAfterMap;
+ InsertionGroup(): insertInto(NULL),
+ insertIntoAsFirst(NULL),
+ insertIntoAsLast(NULL),
+ insertBeforeMap(),
+ insertAfterMap(){}
+};
+
+
+class CompletePULVisitorImpl: public PULEncodingVisitor
+{
+ friend class SimplePULVisitorFactory;
+
+private:
+ //This list is used to ensure that the nodes removed by a ReplaceElementContent
+ //are not destroyed.
+ std::list<store::Item_t> theReplaceContentOldChildrenList;
+
+#ifndef TEXT_ORDPATH
+ //This map is used to retrieve the left sibling in the original document of a node
+ std::map<const XmlNode*,std::pair<XmlNode*,store::Item_t> > theRemovedNodeLeftSiblingMap;
+#else
+ //This map is used to retrieve the left sibling in the original document of a node
+ std::map<const XmlNode*,XmlNode*> theRemovedNodeLeftSiblingMap;
+#endif
+
+ //This map is used to store the nodes which have been removed during merging
+ std::map<XmlNode*,std::pair<XmlNode*,XmlNode*> > theMergedNodes;
+
+#ifndef TEXT_ORDPATH
+ //This map is used to store the label of removed textnodes.
+ std::map<XmlNode*, store::Item_t> theCachedLabels;
+#endif
+
+ bool theIsPostProcessing;
+
+protected:
+ CompletePULVisitorImpl(store::Item_t& result);
+
+public:
+ void visit(store::Item_t&);
+
+ VisitorKind getVisitorKind() {return COMPLETE_PUL_ENCODER;}
+
+ #ifdef PUL_SETTYPE
+ void visitTypeUndoList(
+ store::Item_t& operation,
+ const TypeUndoList& typeUndoList);
+
+ void visitAttributeTypeUndo(
+ store::Item_t& typeUndoListElem,
+ const NodeTypeInfo& attributeTypeInfo);
+
+ void visitElementTypeUndo(
+ store::Item_t& typeUndoListElem,
+ const NodeTypeInfo& elementTypeInfo);
+
+ void extractUndoInformation(store::Item_t& undoRoot, const UpdSetElementType * op);
+
+ void extractUndoInformation(store::Item_t& undoRoot, const UpdSetAttributeType * op);
+#endif
+
+ void visitNodeUpdatesMap(const NodeToUpdatesMap& map);
+
+ void addToNodeUpdatesGroup(
+ InsertionGroup& mergedGroup,
+ UpdatePrimitive* op);
+
+ void visitMergedGroup(InsertionGroup& mergedGroup);
+
+ size_t applyTextNodeMerges(std::vector<store::Item_t>& nodes);
+
+ void visitMerge(
+ InternalNode * theParent,
+ ulong& thePos,
+ const std::vector<XmlNode_t>& theMergedNodes);
+
+ void processDocumentNodesMerges();
+
+#ifndef TEXT_ORDPATH
+ void cacheTextNodeLabel(XmlNode* node);
+#endif
+
+ /*------------- Methods for visiting the XQU Update Primitives -------------------*/
+ void visitUpdDelete(const UpdDelete * op);
+
+ void visitUpdInsertChildren(const UpdInsertChildren * op);
+
+ void visitUpdInsertAttributes(const UpdInsertAttributes * op);
+
+ void visitUpdReplaceAttribute(const UpdReplaceAttribute * op);
+
+ void visitUpdReplaceChild(const UpdReplaceChild * op);
+
+ void visitUpdReplaceElemContent(const UpdReplaceElemContent * op);
+
+ void visitUpdRenameElem(const UpdRenameElem * op);
+
+ void visitUpdReplaceAttrValue(const UpdReplaceAttrValue * op);
+
+ void visitUpdRenameAttr(const UpdRenameAttr * op);
+
+ void visitUpdReplaceTextValue(const UpdReplaceTextValue * op);
+
+ void visitUpdReplacePiValue(const UpdReplacePiValue * op);
+
+ void visitUpdRenamePi(const UpdRenamePi * op);
+
+ void visitUpdReplaceCommentValue(const UpdReplaceCommentValue * op);
+
+ void visitUpdPut(const UpdPut * op);
+
+ /*------------- Methods for visiting the Zorba Update Primitives -----------------*/
+
+ void visitUpdActivateForeignKeyIC (const UpdActivateForeignKeyIC * op);
+
+ void visitUpdActivateIC (const UpdActivateIC * op);
+
+ void visitUpdCreateCollection (const UpdCreateCollection * op);
+
+ void visitUpdCreateDocument (const UpdCreateDocument * op);
+
+ void visitUpdCreateIndex (const UpdCreateIndex * op);
+
+ void visitUpdDeActivateIC (const UpdDeActivateIC * op);
+
+ void visitUpdDeleteCollection (const UpdDeleteCollection * op);
+
+ void visitUpdDeleteDocument (const UpdDeleteDocument * op);
+
+ void visitUpdDeleteIndex (const UpdDeleteIndex * op);
+
+ void visitUpdDeleteNodesFromCollection (const UpdDeleteNodesFromCollection * op);
+
+ void visitUpdInsertAfterIntoCollection (const UpdInsertAfterIntoCollection * op);
+
+ void visitUpdInsertBeforeIntoCollection (const UpdInsertBeforeIntoCollection * op);
+
+ void visitUpdInsertFirstIntoCollection (const UpdInsertFirstIntoCollection * op);
+
+ void visitUpdInsertIntoCollection (const UpdInsertIntoCollection * op);
+
+ void visitUpdInsertLastIntoCollection (const UpdInsertLastIntoCollection * op);
+
+ void visitUpdRefreshIndex (const UpdRefreshIndex * op);
+
+ void visitUpdSetAttributeType (const UpdSetAttributeType * op);
+
+ void visitUpdSetElementType (const UpdSetElementType * op);
+
+ void visitUpdRevalidate (const UpdRevalidate * op);
+
+ void visitUpdCreateHashMap (const UpdCreateHashMap * op);
+
+ void visitUpdDestroyHashMap (const UpdDestroyHashMap * op);
+
+ void visitUpdInsertIntoHashMap (const UpdInsertIntoHashMap * op);
+
+ void visitUpdRemoveFromHashMap (const UpdRemoveFromHashMap * op);
+};
+
+class PULDecodingVisitor : public PULVisitor
+{
+protected:
+ store::PUL_t thePul;
+ static_context* theSctx;
+
+ PULDecodingVisitor(static_context* sctx);
+
+public:
+ ~PULDecodingVisitor();
+
+protected:
+
+ void parseAsQName(
+ store::Item_t& result,
+ const ElementNode* elemNode,
+ bool isAttribute=false) const;
+
+ void parseAsQName(
+ store::Item_t& result,
+ const AttributeNode* attrNode,
+ bool isAttribute=false) const;
+
+ void parseAsQName(
+ store::Item_t& result,
+ const XmlNode* contentNode,
+ const ElementNode* parentNode,
+ bool isAttribute=false) const;
+
+ void parseAsQName(
+ store::Item_t& result,
+ zstring& content,
+ const ElementNode* parentNode,
+ bool isAttribute=false) const;
+
+ bool parseAsBoolean(const store::Item_t& contentNode) const;
+
+ bool parseTypedString(
+ std::vector<store::Item_t>& resultList,
+ zstring& value,
+ store::Item_t& typeName,
+ const ElementNode* decodedParentElement) const;
+
+ bool parseTypedString(
+ std::vector<store::Item_t>& resultList,
+ zstring& value,
+ const xqtref_t& schemaType,
+ const ElementNode* decodedElemParent) const;
+
+ bool parseBuiltinTypedString(
+ std::vector<store::Item_t>& resultList,
+ zstring& value,
+ const xqtref_t& schemaType,
+ const ElementNode* decodedElemParent) const;
+
+ bool parseUserDefinedTypedString(
+ std::vector<store::Item_t>& resultList,
+ zstring& value,
+ const xqtref_t& schemaType) const;
+
+protected:
+ void parseOperation(const ElementNode* operation);
+
+ /*------------- Methods for parsing the XQU Update Primitives -------------------*/
+
+ virtual void parseDelete(const ElementNode* operation) =0;
+
+ virtual void parseInsertInto(const ElementNode* operation)=0;
+
+ virtual void parseInsertIntoAsFirst(const ElementNode* operation)=0;
+
+ virtual void parseInsertIntoAsLast(const ElementNode* operation)=0;
+
+ virtual void parseInsertBefore(const ElementNode* operation)=0;
+
+ virtual void parseInsertAfter(const ElementNode* operation)=0;
+
+ virtual void parseInsertAttributes(const ElementNode* operation)=0;
+
+ virtual void parseReplaceNode(const ElementNode* operation)=0;
+
+ virtual void parseReplaceElementContent(const ElementNode* operation)=0;
+
+ virtual void parseReplaceValue(const ElementNode* operation)=0;
+
+ virtual void parseRename(const ElementNode* operation)=0;
+
+ virtual void parsePut(const ElementNode* operation)=0;
+
+ /*------------- Methods for parsing the Zorba Update Primitives -----------------*/
+
+ virtual void parseCreateCollection(const ElementNode* operation)=0;
+
+ virtual void parseInsertIntoCollection(const ElementNode* operation)=0;
+
+ virtual void parseInsertFirstIntoCollection(const ElementNode* operation)=0;
+
+ virtual void parseInsertLastIntoCollection(const ElementNode* operation)=0;
+
+ virtual void parseInsertAfterIntoCollection(const ElementNode* operation)=0;
+
+ virtual void parseInsertBeforeIntoCollection(const ElementNode* operation)=0;
+
+ virtual void parseDeleteNodesFromCollection(const ElementNode* operation)=0;
+
+ virtual void parseDeleteCollection(const ElementNode* operation)=0;
+
+ virtual void parseActivateForeignKeyIC(const ElementNode* operation)=0;
+
+ virtual void parseActivateIC(const ElementNode* operation)=0;
+
+ virtual void parseDeactivateIC(const ElementNode* operation)=0;
+
+#ifdef PUL_SETTYPE
+ virtual void parseSetAttributeType(const ElementNode* operation)=0;
+
+ virtual void parseSetElementType(const ElementNode* operation)=0;
+#endif
+
+ virtual void parseRevalidate(const ElementNode* operation)=0;
+
+ virtual void parseCreateDocument(const ElementNode* operation)=0;
+
+ virtual void parseDeleteDocument(const ElementNode* operation)=0;
+
+};
+
+class XDMPULVisitorImpl : public PULDecodingVisitor
+{
+ friend class SimplePULVisitorFactory;
+
+private:
+ store::Index_t theIndex;
+ store::IndexSpecification theSpec;
+ store::Item_t theIdToNodeMapName;
+
+ enum AllowedNodeKind
+ {
+ documentNode = 1,
+ elementNode = 2,
+ attributeNode = 4,
+ textNode = 8,
+ piNode = 16,
+ commentNode = 32
+ };
+
+
+protected:
+ XDMPULVisitorImpl(store::PUL_t& result, static_context* sctx);
+
+ XDMPULVisitorImpl(store::PUL_t& result, static_context* sctx, store::Item_t referenceMapName);
+
+public:
+ void visit(store::Item_t&);
+
+ VisitorKind getVisitorKind() {return XDM_PUL_DECODER;}
+
+private:
+ uint resolveTarget(
+ store::Item_t& result,
+ const ElementNode* targetNode) const;
+
+ uint resolveTargetVector(
+ std::vector<store::Item_t>& result,
+ const ElementNode* targetNode) const;
+
+ StaticContextConsts::declaration_property_t getUpdateProperty(const store::Collection_t& collection);
+
+ StaticContextConsts::declaration_property_t getOrderProperty(const store::Collection_t& collection);
+
+ StaticContextConsts::node_modifier_t getNodeModifier(const store::Collection* collection);
+
+ bool containsAnnotation(AnnotationInternal::AnnotationId annotation, std::vector<store::Annotation_t>& annotations);
+
+ void checkNodeType(
+ const store::Item_t& node,
+ const store::Item* typeQName,
+ const store::Item_t& collName,
+ bool dyn_coll);
+
+ void checkNodeModifiers(
+ const store::Item_t& targetNode);
+
+ void decodeNodeVector(
+ std::vector<store::Item_t>& result,
+ const ElementNode* container,
+ bool resetOrdpaths);
+
+ void decodeSingleNode(
+ store::Item_t& result,
+ const ElementNode* container);
+
+ void decodeNode(
+ store::Item_t& result,
+ const ElementNode* encodedNode,
+ bool resetOrdpaths=false);
+
+ uint extractNodeVector(
+ std::vector<store::Item_t>& result,
+ const ElementNode* contentNode,
+ bool extractAttributes=true);
+
+ void extractTextNode(
+ store::Item_t& result,
+ const ElementNode* contentNode);
+
+ void decodeAnnotations(
+ std::vector<store::Annotation_t>& lAnnotations,
+ const ElementNode* annotationsNode);
+
+ void decodeAnnotation(
+ std::vector<store::Annotation_t>& lAnnotationsVector,
+ AnnotationList& lAnnotationsList,
+ const ElementNode* annotationNode);
+
+ void decodeLiterals(std::vector<rchandle<const_expr> >& lLiterals, std::vector<store::Item_t>& lAnnLiterals, const ElementNode* annotationNode);
+
+ uint detachNode(XmlNode* node, bool resetOrdpaths);
+
+protected:
+
+ /*------------- Methods for parsing the XQU Update Primitives -------------------*/
+ void parseDelete(const ElementNode* operation);
+
+ void parseInsertInto(const ElementNode* operation);
+
+ void parseInsertIntoAsFirst(const ElementNode* operation);
+
+ void parseInsertIntoAsLast(const ElementNode* operation);
+
+ void parseInsertBefore(const ElementNode* operation);
+
+ void parseInsertAfter(const ElementNode* operation);
+
+ void parseInsertAttributes(const ElementNode* operation);
+
+ void parseReplaceNode(const ElementNode* operation);
+
+ void parseReplaceElementContent(const ElementNode* operation);
+
+ void parseReplaceValue(const ElementNode* operation);
+
+ void parseRename(const ElementNode* operation);
+
+ void parsePut(const ElementNode* operation);
+
+ /*------------- Methods for parsing the Zorba Update Primitives -----------------*/
+
+ void parseCreateCollection(const ElementNode* operation);
+
+ void parseInsertIntoCollection(const ElementNode* operation);
+
+ void parseInsertFirstIntoCollection(const ElementNode* operation);
+
+ void parseInsertLastIntoCollection(const ElementNode* operation);
+
+ void parseInsertAfterIntoCollection(const ElementNode* operation);
+
+ void parseInsertBeforeIntoCollection(const ElementNode* operation);
+
+ void parseDeleteNodesFromCollection(const ElementNode* operation);
+
+ void parseDeleteCollection(const ElementNode* operation);
+
+ void parseActivateForeignKeyIC(const ElementNode* operation);
+
+ void parseActivateIC(const ElementNode* operation);
+
+ void parseDeactivateIC(const ElementNode* operation);
+
+ void parseSetAttributeType(const ElementNode* operation);
+
+ void parseSetElementType(const ElementNode* operation);
+
+ void parseRevalidate(const ElementNode* operation);
+
+ void parseCreateDocument(const ElementNode* operation);
+
+ void parseDeleteDocument(const ElementNode* operation);
+
+};
+
+class XMLPULVisitorImpl : public PULDecodingVisitor
+{
+ friend class SimplePULVisitorFactory;
+
+protected:
+ XMLPULVisitorImpl(static_context* sctx, bool restoreTypes):
+ PULDecodingVisitor(sctx)
+ {
+ theRestoreTypes=restoreTypes;
+ };
+
+public:
+ void visit(store::Item_t&);
+
+ VisitorKind getVisitorKind() {return XML_PUL_DECODER;}
+
+ void decode(ElementNode* result);
+
+private:
+ bool theRestoreTypes;
+
+ std::list<std::pair<XmlNode*, store::Item_t> > theExpectedTypes;
+
+ void decodeParameter(
+ const ElementNode* parentNode,
+ const zstring& childName,
+ ulong hint,
+ bool mandatory=true);
+
+ void decodeUnrestrictedParameter(
+ const ElementNode* parentNode,
+ const zstring& childName,
+ ulong hint,
+ bool mandatory=true);
+
+ void decodeUnrestrictedNode(
+ ElementNode* encodedRoot,
+ store::Item_t& newContentNode);
+
+ void decodeAttributes(
+ ElementNode* encodedElemContainer,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate);
+
+ void decodeChildren(
+ ElementNode* encodedElemContainer,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate);
+
+ void decodeSimpleContent(
+ xqtref_t simpleContentType,
+ ElementNode* encodedElemContainer,
+ ElementNode* decodedElemParent);
+
+ void decodeNode(
+ ElementNode* encodedElem,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate);
+
+ void decodeElement(
+ ElementNode* encodedElem,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate);
+
+ void decodeComment(
+ ElementNode* encodedElem,
+ ElementNode* decodedElemParent);
+
+ void decodeText(
+ ElementNode* encodedElem,
+ ElementNode* decodedElemParent);
+
+ void decodeProcessingInstruction(
+ ElementNode* encodedElem,
+ ElementNode* decodedElemParent);
+
+ void decodeAttribute(
+ ElementNode* encodedElem,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate);
+
+ void decodeNamespaces(
+ ElementNode* namespaceNodesParent,
+ store::NsBindings& bindings);
+
+protected:
+
+ /*------------- Methods for parsing the XQU Update Primitives -------------------*/
+ void parseDelete(const ElementNode* operation){};
+
+ void parseInsertInto(const ElementNode* operation)
+ {
+ decodeParameter(operation,"content",1);
+ }
+
+ void parseInsertIntoAsFirst(const ElementNode* operation)
+ {
+ decodeParameter(operation,"content",1);
+ }
+
+ void parseInsertIntoAsLast(const ElementNode* operation)
+ {
+ decodeParameter(operation,"content",1);
+ }
+
+ void parseInsertBefore(const ElementNode* operation)
+ {
+ decodeParameter(operation,"content",1);
+ }
+
+ void parseInsertAfter(const ElementNode* operation)
+ {
+ decodeParameter(operation,"content",1);
+ }
+
+ void parseInsertAttributes(const ElementNode* operation)
+ {
+ decodeParameter(operation,"content",1);
+ }
+
+ void parseReplaceNode(const ElementNode* operation)
+ {
+ decodeParameter(operation,"replacement",1);
+ }
+
+ void parseReplaceElementContent(const ElementNode* operation)
+ {
+ decodeParameter(operation,"text",1);
+ }
+
+ void parseReplaceValue(const ElementNode* operation){};
+
+ void parseRename(const ElementNode* operation){};
+
+ void parsePut(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"node",0);
+ }
+
+ /*------------- Methods for parsing the Zorba Update Primitives -----------------*/
+
+ void parseCreateCollection(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"nodes",4,false);
+ };
+
+ void parseInsertIntoCollection(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"nodes",1);
+ }
+
+ void parseInsertFirstIntoCollection(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"nodes",1);
+ }
+
+ void parseInsertLastIntoCollection(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"nodes",1);
+ }
+
+ void parseInsertAfterIntoCollection(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"nodes",2);
+ }
+
+ void parseInsertBeforeIntoCollection(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"nodes",2);
+ }
+
+ void parseDeleteNodesFromCollection(const ElementNode* operation) {};
+
+ void parseDeleteCollection(const ElementNode* operation) {};
+
+ void parseActivateForeignKeyIC(const ElementNode* operation){};
+
+ void parseActivateIC(const ElementNode* operation){};
+
+ void parseDeactivateIC(const ElementNode* operation){};
+
+#ifdef PUL_SETTYPE
+ void parseSetAttributeType(const ElementNode* operation){};
+
+ void parseSetElementType(const ElementNode* operation){};
+#endif
+
+ void parseRevalidate(const ElementNode* operation){};
+
+ void parseCreateDocument(const ElementNode* operation)
+ {
+ decodeUnrestrictedParameter(operation,"document",1,false);
+ }
+
+ void parseDeleteDocument(const ElementNode* operation){};
+};
+
+}//simplestore
+}//zorba
+#endif
+
=== added file 'src/store/naive/pul_xdm_decoding.cpp'
--- src/store/naive/pul_xdm_decoding.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_xdm_decoding.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,1594 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "zorba/query_location.h"
+#include "store/api/item_factory.h"
+#include "store/naive/node_items.h"
+#include "store/naive/pul_visitors.h"
+#include "store/naive/simple_collection.h"
+#include "store/naive/simple_store.h"
+#include "store/naive/simple_item_factory.h"
+#include "store/naive/pul_primitive_factory.h"
+
+#include "store/api/iterator_factory.h"
+#include "types/typeops.h"
+#include "types/root_typemanager.h"
+#include "system/globalenv.h"
+#include "diagnostics/user_exception.h"
+#include "zorbatypes/URI.h"
+#include "zorba/collection.h"
+#include "compiler/xqddf/collection_decl.h"
+#include "compiler/expression/expr.h"
+#include "annotations/annotations.h"
+
+namespace zorba{
+namespace simplestore{
+
+/*
+ * Creates an XDMPULVisitorImpl instance. The node references are resolved with
+ * respect to the store id to node map.
+ */
+XDMPULVisitorImpl::XDMPULVisitorImpl(
+ store::PUL_t& result,
+ static_context* sctx):
+ PULDecodingVisitor(sctx)
+{
+ thePul=result;
+}
+
+/*
+ * Creates an XDMPULVisitorImpl instance. The node references are resolved with
+ * respect to the provided store index.
+ */
+XDMPULVisitorImpl::XDMPULVisitorImpl(
+ store::PUL_t& result,
+ static_context* sctx,
+ store::Item_t referenceMapName) :
+ PULDecodingVisitor(sctx)
+{
+ thePul=result;
+ if (referenceMapName)
+ {
+ theIdToNodeMapName=referenceMapName;
+ theIndex = theStore->getMap(theIdToNodeMapName);
+ if (!theIndex)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
+ ERROR_PARAMS( theIdToNodeMapName->getStringValue() )
+ );
+ }
+ theSpec = theIndex->getSpecification();
+
+ if (theSpec.getNumColumns() != 1)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
+ ERROR_PARAMS( theIdToNodeMapName->getStringValue() )
+ );
+ }
+ }
+}
+
+/*
+ * Parses an xdm instance representing a PUL.
+ *
+ * pulxdm = The xdm instance to parse. It must be the root element node.
+ */
+void XDMPULVisitorImpl::visit(store::Item_t& pulxdm)
+{
+ assert(pulxdm->getNodeKind()==store::StoreConsts::elementNode);
+ store::Item_t operation;
+ store::Iterator_t itch=pulxdm->getChildren();
+ itch->open();
+ while (itch->next(operation))
+ {
+ if (operation->getNodeKind()==store::StoreConsts::elementNode)
+ parseOperation(ELEM_NODE(operation));
+ }
+ itch->close();
+}
+
+/*
+ * Parses a collection annotations.
+ *
+ * result = the parsed annotations
+ * annotationNode = the element node containing the annotations
+ */
+void XDMPULVisitorImpl::decodeAnnotations(std::vector<store::Annotation_t>& result,
+ const ElementNode* annotationsNode)
+{
+ store::Iterator_t itch=annotationsNode->getChildren();
+ store::Item_t containedNode;
+ AnnotationList lAnnotationsList;
+ itch->open();
+ while (itch->next(containedNode))
+ {
+ if (containedNode->getNodeKind()==store::StoreConsts::elementNode)
+ decodeAnnotation(result,lAnnotationsList, ELEM_NODE(containedNode));
+ }
+ itch->close();
+ lAnnotationsList.checkConflictingDeclarations(theQueryLoc);
+}
+
+/*
+ * Parses a single collection annotations.
+ *
+ * resultVector = the parsed annotation is pushed back into the result vector
+ * resultList = the parsed annotation is also pushed back into the result list
+ * annotationNode = the element node representing the annotation
+ */
+void XDMPULVisitorImpl::decodeAnnotation(std::vector<store::Annotation_t>& resultVector,
+ AnnotationList& resultList,
+ const ElementNode* annotationNode)
+{
+ ElementNode * name=getChildByName(annotationNode,"name",0,true);
+ store::Annotation_t lAnn=new store::Annotation();
+ parseAsQName(lAnn->theName,name);
+ std::vector<rchandle<const_expr> > lLiterals;
+
+ decodeLiterals(lLiterals,lAnn->theLiterals,annotationNode);
+
+ resultList.push_back(lAnn->theName,lLiterals);
+ resultVector.push_back(lAnn);
+}
+
+
+/*
+ * Parses a single collection annotation literals.
+ *
+ * resultExprVector = the parsed literals are pushed back into the result expr vector as const exprs
+ * resultItemVector = the parsed literals are also pushed back into the result item list as items
+ * annotationNode = the element node representing the annotation
+ */
+void XDMPULVisitorImpl::decodeLiterals(std::vector<rchandle<const_expr> >& resultExprVector,
+ std::vector<store::Item_t>& resultItemVector,
+ const ElementNode* annotationNode)
+{
+ ElementNode * literals=getChildByName(annotationNode,"literals",1,false);
+ if (!literals)
+ return;
+
+ store::Iterator_t itch=literals->getChildren();
+ store::Item_t containedNode;
+ itch->open();
+ while (itch->next(containedNode))
+ {
+ if (containedNode->getNodeKind()==store::StoreConsts::elementNode)
+ {
+ zstring literalValue=containedNode->getStringValue();
+ store::Item_t literalType;
+ parseAsQName(literalType,getAttributeByName(ELEM_NODE(containedNode),"type",true));
+
+ std::vector<store::Item_t> items;
+ parseTypedString(items,literalValue,literalType,ELEM_NODE(containedNode));
+
+ //TODO: can literals be of list type?
+ resultItemVector.push_back(items[0]);
+ zorba::rchandle<zorba::const_expr> ceh=new const_expr(theSctx,theQueryLoc,items[0]);
+ resultExprVector.push_back(ceh);
+ }
+ }
+ itch->close();
+}
+
+/*
+ * Retrieves a vector of nodes given a node containing their references.
+ * Raises an error if any of the item is not found.
+ * Returns a bitfield (see. AllowedNodeKind) indicating the kind of nodes retrieved
+ *
+ * result = The nodes retrieved
+ * targetNode = The item containing the reference sequence. Format:
+ * <pul:targets>
+ * ...
+ * <pul:target>
+ * ...
+ * <pul:identifier>id</pul:identifier>
+ * ...
+ * </pul:target>
+ * ...
+ * </pul:targets>
+ */
+uint XDMPULVisitorImpl::resolveTargetVector(std::vector<store::Item_t>& result,
+ const ElementNode* targetNode) const
+{
+ store::Iterator_t itch=targetNode->getChildren();
+ store::Item_t containedNode;
+ uint ret=0;
+ itch->open();
+
+ while (itch->next(containedNode))
+ {
+ if (containedNode->getNodeKind()==store::StoreConsts::elementNode)
+ {
+ store::Item_t targetNode;
+ ret |=resolveTarget(targetNode, ELEM_NODE(containedNode));
+ result.push_back(targetNode);
+ }
+ }
+ itch->close();
+ return ret;
+}
+
+/*
+ * Decodes and detaches the partially encoded (encapsulated) children of the
+ * given "container" node.
+ *
+ * result = the detached and decoded nodes
+ * container = the node containing the partially encoded elements
+ * resetOrdpaths = Since ordpaths do not change when a node is detached if the
+ * nodes are going to be put into a collection, their ordpath
+ * must be reset here.
+ */
+void XDMPULVisitorImpl::decodeNodeVector(std::vector<store::Item_t>& result,
+ const ElementNode* container,
+ bool resetOrdpaths)
+{
+ store::Iterator_t itch=container->getChildren();
+ store::Item_t containedNode;
+ itch->open();
+ while (itch->next(containedNode))
+ {
+ if (containedNode->getNodeKind()==store::StoreConsts::elementNode)
+ {
+ store::Item_t decodedNode;
+ decodeNode(decodedNode,ELEM_NODE(containedNode), resetOrdpaths);
+ result.push_back(decodedNode);
+ }
+ }
+ itch->close();
+}
+
+/*
+ * Decodes and detaches a single partially encoded (encapsulated) node from a tree.
+ * The considered node is the first children of the "container" element.
+ *
+ * result = the detached and decoded node
+ * container = the element node containing the partially encoded node
+ */
+void XDMPULVisitorImpl::decodeSingleNode(store::Item_t& result,
+ const ElementNode* container)
+{
+ store::Iterator_t itch=container->getChildren();
+ store::Item_t containedNode;
+ itch->open();
+ while (itch->next(containedNode))
+ {
+ if (containedNode->getNodeKind()==store::StoreConsts::elementNode)
+ {
+ decodeNode(result,ELEM_NODE(containedNode),false);
+ itch->close();
+ return;
+ }
+ }
+ itch->close();
+}
+
+/*
+ * Decodes and detaches the given partially encoded (encapsulated) node from a tree.
+ *
+ * result = the detached and decoded node
+ * encodedNode = the partially encoded node
+ * resetOrdpaths = Since ordpaths do not change when a node is detached if the
+ * nodes are going to be put into a collection, their ordpath
+ * must be reset here.
+ */
+void XDMPULVisitorImpl::decodeNode(store::Item_t& result,
+ const ElementNode* encodedNode,
+ bool resetOrdpaths)
+{
+ if (encodedNode->getNodeName()->getLocalName() == "document")
+ {
+ AttributeNode* baseURIAttr= getAttributeByName(encodedNode,"base-uri");
+ AttributeNode* documentURIAttr= getAttributeByName(encodedNode,"document-uri");
+ AttributeNode* nodeIdentifierAttr= getAttributeByName(encodedNode,"reference",false);
+
+ zstring baseURI=baseURIAttr ? baseURIAttr->getStringValue() : "";
+ zstring documentURI=documentURIAttr ? documentURIAttr->getStringValue() : "";
+ theItemFactory->createDocumentNode(result,baseURI,documentURI);
+
+ DocumentNode* doc=DOC_NODE(result);
+ if (nodeIdentifierAttr)
+ {
+ zstring identifier=nodeIdentifierAttr->getStringValue();
+ theStore->restoreReference(doc,identifier);
+ }
+
+ if (encodedNode->numChildren())
+ {
+ std::vector<store::Item_t> children;
+ extractNodeVector(children,getChildByName(encodedNode,"children",0,true),false);
+
+ std::vector<store::Item_t>::iterator iter = children.begin();
+ std::vector<store::Item_t>::iterator end = children.end();
+ for (; iter != end; ++iter)
+ {
+ (BASE_NODE(*iter))->attach(doc,doc->numChildren());
+ }
+ }
+ }
+ else
+ {
+ if (encodedNode->getNodeName()->getLocalName() != "non-document" || encodedNode->numChildren() + encodedNode->numAttrs()!=1)
+ {
+ static const char *err_msg = "Unexpected content in encoded node, only one node can be present";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg);
+ }
+ if (encodedNode->numAttrs())
+ result=encodedNode->getAttr(0);
+ else
+ result=encodedNode->getChild(0);
+ detachNode(BASE_NODE(result),resetOrdpaths);
+ }
+}
+
+/*
+ * Detaches and return all the children and attributes of a node.
+ * Returns a bitfield (see. AllowedNodeKind) indicating the kind of nodes detached
+ *
+ * result = The detached attributes and children
+ * contentNode = The parent node
+ * extractAttributes = If false attributes are not extracted
+ */
+uint XDMPULVisitorImpl::extractNodeVector(std::vector<store::Item_t>& result,
+ const ElementNode* contentNode,
+ bool extractAttributes)
+{
+ uint ret=0;
+ store::Iterator_t itch;
+ store::Item_t containedNode;
+ store::Item_t iterNode;
+
+ if (extractAttributes)
+ {
+ itch=contentNode->getAttributes();
+ itch->open();
+ while (itch->next(containedNode))
+ result.push_back(containedNode);
+ itch->close();
+ }
+
+ itch=contentNode->getChildren();
+ itch->open();
+ while (itch->next(containedNode))
+ result.push_back(containedNode);
+ itch->close();
+
+ std::vector<store::Item_t>::iterator iter = result.begin();
+ std::vector<store::Item_t>::iterator end = result.end();
+ for (; iter != end; ++iter)
+ ret =detachNode(BASE_NODE(*iter),false);
+ return ret;
+}
+
+/*
+ * Detaches and return the first text children of a node.
+ *
+ * result = The detached first children
+ * contentNode = The parent node
+ */
+void XDMPULVisitorImpl::extractTextNode(store::Item_t& result,
+ const ElementNode* contentNode)
+{
+ store::Iterator_t itch;
+ store::Item_t containedNode;
+ store::Item_t iterNode;
+
+ itch=contentNode->getChildren();
+ itch->open();
+ while (itch->next(containedNode))
+ {
+ if (containedNode->getNodeKind()==store::StoreConsts::textNode)
+ {
+ result=containedNode;
+ detachNode(BASE_NODE(result),false);
+ break;
+ }
+ }
+ itch->close();
+}
+
+/*
+ * Detaches a node from its parent.
+ * Returns the type (see. AllowedNodeKind) of the node detached
+ *
+ * node = the node to detach
+ * resetOrdpaths = Since ordpaths do not change when a node is detached if the
+ * nodes are going to be put into a collection, their ordpath
+ * must be reset here.
+ */
+uint XDMPULVisitorImpl::detachNode(XmlNode* node,
+ bool resetOrdpaths)
+{
+ ElementNode* elemnode;
+ uint ret;
+ store::StoreConsts::NodeKind nodeKind=node->getNodeKind();
+ switch (nodeKind)
+ {
+ case store::StoreConsts::attributeNode:
+ ret=XDMPULVisitorImpl::attributeNode;
+ break;
+ case store::StoreConsts::commentNode:
+ ret=XDMPULVisitorImpl::commentNode;
+ break;
+ case store::StoreConsts::elementNode:
+ elemnode=static_cast<ElementNode*>(node);
+ ZORBA_FATAL(elemnode->getParent(),"Detaching a parentless node");
+ elemnode->uninheritBinding((static_cast<ElementNode *>(elemnode->getParent()))->getNsContext(),"pul");
+ elemnode->uninheritBinding((static_cast<ElementNode *>(elemnode->getParent()))->getNsContext(),"xs");
+ ret=XDMPULVisitorImpl::elementNode;
+ break;
+ case store::StoreConsts::piNode:
+ ret=XDMPULVisitorImpl::piNode;
+ break;
+ case store::StoreConsts::textNode:
+ ret=XDMPULVisitorImpl::textNode;
+ break;
+ case store::StoreConsts::documentNode:
+ default:
+ assert(false);
+ }
+ node->detach();
+#ifndef TEXT_ORDPATH
+ if (nodeKind!=store::StoreConsts::textNode)
+ static_cast<OrdPathNode*>(node)->refreshOrdPath();
+#else
+ static_cast<OrdPathNode*>(node)->refreshOrdPath();
+#endif
+
+ return ret;
+}
+
+/*
+ * Retrieves a node given an item containing its reference.
+ * If no id-to-node index has been specified when the visitor has been created
+ * the store id-to-node map is used.
+ * Raises an error if the item is not found.
+ * Returns the type (see. AllowedNodeKind) of the node retrieved
+ *
+ * result = The item retrieved
+ * targetNode = The item containing the reference/identifier.
+ */
+uint XDMPULVisitorImpl::resolveTarget(store::Item_t& result,
+ const ElementNode* targetNode) const
+{
+ zstring uuid;
+ if (theIndex!=NULL)
+ {
+ store::IndexCondition_t lCond = theIndex->createCondition(store::IndexCondition::POINT_VALUE);
+
+ store::Item_t identifierNode=getChildByName(targetNode,"reference",0,true);
+ store::Item_t identifierString;
+ uuid=identifierNode->getStringValue();
+ theItemFactory->createString(identifierString,uuid);
+
+ xqtref_t searchKeyType = GENV_TYPESYSTEM.create_value_type(identifierString.getp());
+ xqtref_t indexKeyType = GENV_TYPESYSTEM.create_named_type(theSpec.theKeyTypes[0].getp(), TypeConstants::QUANT_ONE, theQueryLoc);
+
+ if (indexKeyType != NULL && !TypeOps::is_subtype(&GENV_TYPESYSTEM, *searchKeyType, *indexKeyType))
+ {
+ throw XQUERY_EXCEPTION(err::XPTY0004,
+ ERROR_PARAMS(ZED(SearchKeyTypeMismatch_234),
+ *searchKeyType,
+ theIdToNodeMapName->getStringValue(),
+ *indexKeyType));
+ }
+
+ lCond->pushItem(identifierString);
+ store::IndexProbeIterator* lProbe = GENV_STORE.getIteratorFactory()->createIndexProbeIterator(theIndex);
+ lProbe->init(lCond);
+ lProbe->open();
+ if (!lProbe->next(result))
+ {
+ std::stringstream err_msg;
+ err_msg << "The node with identifier \""<< identifierString <<"\" cannot be retrieved through the specified map.";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL021");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ lProbe->close();
+ delete lProbe;
+ }
+ else
+ {
+ uuid=getChildByName(targetNode,"reference",0,true)->getStringValue();
+
+ if (!theStore->getNodeByReference(result,uuid))
+ {
+ std::stringstream err_msg;
+ err_msg << "The node with identifier: \""<< uuid <<"\" cannot be retrieved.";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL020");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+
+ }
+ ZORBA_FATAL(result->isNode(),"UUID must resolve to nodes");
+ assert(result->getNodeKind()>=1 && result->getNodeKind()<=6);
+ return pow(2,result->getNodeKind()-1);
+}
+
+void XDMPULVisitorImpl::checkNodeType(
+ const store::Item_t& node,
+ const store::Item* typeQName,
+ const store::Item_t& collName,
+ bool dyn_coll)
+{
+ if (dyn_coll)
+ return;
+
+ if(!typeQName)
+ return;
+
+ /* Type checking currently disabled
+ store::Item_t typeNameCopy;
+ theItemFactory->createQName(typeNameCopy,typeQName->getNamespace(),typeQName->getPrefix(),typeQName->getLocalName());
+ xqtref_t type=theTypeManager->create_named_type(typeNameCopy.getp()); //can be null raise error
+
+ if (!TypeOps::is_treatable(theTypeManager, node, *(type.getp()), theQueryLoc))
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDTY0001_COLLECTION_INVALID_NODE_TYPE,
+ ERROR_PARAMS(
+ TypeOps::toString( *theTypeManager->create_value_type( node ) ),
+ collName->getStringValue()
+ ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+ */
+}
+
+/*
+ * Raises an error if the given node is in a read-only collection.
+ */
+void XDMPULVisitorImpl::checkNodeModifiers(const store::Item_t& targetNode)
+{
+ const store::Collection* lColl = targetNode->getCollection();
+ if (lColl != 0 && !lColl->isDynamic())
+ {
+ if (getNodeModifier(lColl)== StaticContextConsts::read_only)
+ {
+ throw XQUERY_EXCEPTION(zerr::ZDDY0010_COLLECTION_CONST_NODE_UPDATE,
+ ERROR_PARAMS( lColl->getName()->getStringValue() ),
+ ERROR_LOC(theQueryLoc));
+ }
+ }
+}
+
+
+/*------------- Methods for parsing the XQU Update Primitives -------------------*/
+
+void XDMPULVisitorImpl::parseDelete(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ checkNodeModifiers(opTarget);
+
+
+ store::PUL_t newPul=GENV_ITEMFACTORY->createPendingUpdateList();
+ newPul->addDelete(&theQueryLoc,opTarget);
+ thePul->mergeUpdates(newPul.getp());
+}
+
+void XDMPULVisitorImpl::parseInsertInto(const ElementNode* operation)
+{
+ uint allowedNodes=documentNode | elementNode;
+ store::Item_t opTarget;
+ std::vector<store::Item_t> insertedNodes;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION( err::XUTY0005, ERROR_LOC( theQueryLoc ) );
+
+ checkNodeModifiers(opTarget);
+
+ extractNodeVector(insertedNodes, getChildByName(operation,"content",1,true));
+ thePul->addInsertInto(&theQueryLoc,opTarget,insertedNodes);
+}
+
+void XDMPULVisitorImpl::parseInsertIntoAsFirst(const ElementNode* operation)
+{
+ uint allowedNodes=documentNode | elementNode;
+ store::Item_t opTarget;
+ std::vector<store::Item_t> insertedNodes;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION( err::XUTY0005, ERROR_LOC( theQueryLoc ) );
+
+ checkNodeModifiers(opTarget);
+
+ extractNodeVector(insertedNodes, getChildByName(operation,"content",1,true));
+ thePul->addInsertFirst(&theQueryLoc,opTarget,insertedNodes);
+}
+
+void XDMPULVisitorImpl::parseInsertIntoAsLast(const ElementNode* operation)
+{
+ uint allowedNodes=documentNode | elementNode;
+ store::Item_t opTarget;
+ std::vector<store::Item_t> insertedNodes;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION( err::XUTY0005, ERROR_LOC( theQueryLoc ) );
+
+ checkNodeModifiers(opTarget);
+
+ extractNodeVector(insertedNodes, getChildByName(operation,"content",1,true));
+ thePul->addInsertLast(&theQueryLoc,opTarget,insertedNodes);
+}
+
+void XDMPULVisitorImpl::parseInsertBefore(const ElementNode* operation)
+{
+ uint allowedNodes=elementNode | textNode | piNode | commentNode;
+ store::Item_t opTarget;
+ std::vector<store::Item_t> insertedNodes;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION( err::XUTY0006, ERROR_LOC( theQueryLoc ) );
+
+ if (opTarget->getParent() == NULL)
+ throw XQUERY_EXCEPTION( err::XUDY0029, ERROR_LOC( theQueryLoc ) );
+
+ checkNodeModifiers(opTarget);
+
+ extractNodeVector(insertedNodes, getChildByName(operation,"content",1,true));
+ thePul->addInsertBefore(&theQueryLoc,opTarget,insertedNodes);
+}
+
+void XDMPULVisitorImpl::parseInsertAfter(const ElementNode* operation)
+{
+ uint allowedNodes=elementNode | textNode | piNode | commentNode;
+ store::Item_t opTarget;
+ std::vector<store::Item_t> insertedNodes;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION( err::XUTY0006, ERROR_LOC( theQueryLoc ) );
+
+ if (opTarget->getParent() == NULL)
+ throw XQUERY_EXCEPTION( err::XUDY0029, ERROR_LOC( theQueryLoc ) );
+
+ checkNodeModifiers(opTarget);
+
+ extractNodeVector(insertedNodes, getChildByName(operation,"content",1,true));
+ thePul->addInsertAfter(&theQueryLoc,opTarget,insertedNodes);
+}
+
+void XDMPULVisitorImpl::parseInsertAttributes(const ElementNode* operation)
+{
+ uint allowedNodes=elementNode;
+ store::Item_t opTarget;
+ std::vector<store::Item_t> insertedNodes;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ if (!(targetKind & (allowedNodes | documentNode)))
+ throw XQUERY_EXCEPTION( err::XUTY0006, ERROR_LOC( theQueryLoc ) );
+
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION( err::XUTY0022, ERROR_LOC( theQueryLoc ) );
+ //Note XUDY0030 could be raised in place. The choice is arbitrary.
+
+ checkNodeModifiers(opTarget);
+
+ extractNodeVector(insertedNodes, getChildByName(operation,"content",1,true));
+ thePul->addInsertAttributes(&theQueryLoc,opTarget,insertedNodes);
+}
+
+void XDMPULVisitorImpl::parseReplaceNode(const ElementNode* operation)
+{
+ uint allowedNodes=elementNode | textNode | piNode | commentNode | attributeNode;
+ store::Item_t opTarget;
+ std::vector<store::Item_t> replacement;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION(err::XUTY0008, ERROR_LOC(theQueryLoc));
+
+ if (!opTarget->getParent())
+ throw XQUERY_EXCEPTION(err::XUDY0009, ERROR_LOC(theQueryLoc));
+
+ uint replacementNodeKinds=extractNodeVector(replacement, getChildByName(operation,"replacement",1,true));
+ if (targetKind==attributeNode && replacementNodeKinds!=attributeNode && replacementNodeKinds!=0)
+ throw XQUERY_EXCEPTION(err::XUTY0011, ERROR_LOC(theQueryLoc));
+ else if (targetKind!=attributeNode && (replacementNodeKinds & (attributeNode | documentNode)))
+ throw XQUERY_EXCEPTION(err::XUTY0010, ERROR_LOC(theQueryLoc));
+
+ checkNodeModifiers(opTarget);
+
+ store::PUL_t newPul=GENV_ITEMFACTORY->createPendingUpdateList();
+ newPul->addReplaceNode(&theQueryLoc,opTarget,replacement);
+ thePul->mergeUpdates(newPul.getp());
+}
+
+void XDMPULVisitorImpl::parseReplaceElementContent(const ElementNode* operation)
+{
+ uint allowedNodes=elementNode;
+ store::Item_t opTarget;
+ store::Item_t replacement;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION(err::XUTY0008, ERROR_LOC(theQueryLoc));
+
+ extractTextNode(replacement,getChildByName(operation,"text",1,true));
+
+ checkNodeModifiers(opTarget);
+
+ store::PUL_t newPul=GENV_ITEMFACTORY->createPendingUpdateList();
+ newPul->addReplaceContent(&theQueryLoc,opTarget,replacement);
+ thePul->mergeUpdates(newPul);
+}
+
+void XDMPULVisitorImpl::parseReplaceValue(const ElementNode* operation)
+{
+ uint allowedNodes=attributeNode | textNode | commentNode | piNode;
+ store::Item_t opTarget;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION(err::XUTY0008, ERROR_LOC(theQueryLoc));
+
+ zstring opContentString=getChildByName(operation,"string-value",1,true)->getStringValue();
+
+ if (targetKind == commentNode &&
+ (opContentString.find("--") != zstring::npos || ascii::ends_with(opContentString, "-", 1)))
+ {
+ throw XQUERY_EXCEPTION(err::XQDY0072, ERROR_LOC(theQueryLoc));
+ }
+
+ if (targetKind == piNode &&
+ opContentString.find("?>") != zstring::npos)
+ {
+ throw XQUERY_EXCEPTION(err::XQDY0026, ERROR_LOC(theQueryLoc));
+ }
+
+ checkNodeModifiers(opTarget);
+
+ store::PUL_t newPul=GENV_ITEMFACTORY->createPendingUpdateList();
+ newPul->addReplaceValue(&theQueryLoc,opTarget,opContentString);
+ thePul->mergeUpdates(newPul.getp());
+}
+
+void XDMPULVisitorImpl::parseRename(const ElementNode* operation)
+{
+ uint allowedNodes=elementNode | attributeNode | piNode;
+ store::Item_t opTarget;
+ store::Item_t name;
+ uint targetKind=resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+ if (!(targetKind & allowedNodes))
+ throw XQUERY_EXCEPTION(err::XUTY0012, ERROR_LOC(theQueryLoc));
+
+ checkNodeModifiers(opTarget);
+
+ try
+ {
+ parseAsQName(name,getChildByName(operation,"newName",1,targetKind==attributeNode));
+ }
+ catch (ZorbaException const& e)
+ {
+ if (e.diagnostic() != err::XPTY0004)
+ {
+ // the returned error codes are wrong for name casting => they must be changed
+ throw XQUERY_EXCEPTION(
+ err::XQDY0074, ERROR_PARAMS( "item" ), ERROR_LOC( theQueryLoc )
+ );
+ }
+ else
+ {
+ throw;
+ }
+ }
+
+ store::PUL_t newPul=GENV_ITEMFACTORY->createPendingUpdateList();
+ newPul->addRename(&theQueryLoc,opTarget,name);
+ thePul->mergeUpdates(newPul);
+}
+
+void XDMPULVisitorImpl::parsePut(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t uri;
+ decodeSingleNode(opTarget,getChildByName(operation,"node",0,true));
+ ElementNode * uriElem=getChildByName(operation,"uri",1,true);
+ zstring uriStr=uriElem->getStringValue();
+ store::Item_t resolvedUriItem;
+ GENV_ITEMFACTORY->createAnyURI(resolvedUriItem, uriStr);
+
+ UpdatePrimitive* upd = GET_STORE().getPULFactory().createUpdPut(static_cast<PULImpl*>(thePul.getp()), &theQueryLoc, opTarget, resolvedUriItem);
+
+ static_cast<UpdPut*>(upd)->theCopyOnApply=false;
+ static_cast<PULImpl*>(thePul.getp())->thePutList.push_back(upd);
+
+}
+
+/*------------- Methods for parsing the Zorba Update Primitives -----------------*/
+
+void XDMPULVisitorImpl::parseCreateCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ store::Item_t nameCopy;
+ parseAsQName(name,getChildByName(operation,"name",0,true));
+ nameCopy=name;
+
+ std::vector<store::Annotation_t> lAnnotations;
+ decodeAnnotations(lAnnotations,getChildByName(operation,"annotations",1,true));
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",2,true));
+
+ //zerr::ZDDY0001 (Collection not declared in static context not raised)
+
+ store::Collection_t collection = GENV_STORE.getCollection(name, dynamic);
+
+ if (collection != NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0002_COLLECTION_ALREADY_EXISTS,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ ElementNode * nodeType=getChildByName(operation,"node-type",3);
+ store::Item_t type;
+
+ if (nodeType)
+ parseAsQName(type,nodeType);
+
+ store::PUL_t newPul=GENV_ITEMFACTORY->createPendingUpdateList();
+ newPul->addCreateCollection(&theQueryLoc,name,lAnnotations,type,dynamic);
+ thePul->mergeUpdates(newPul.getp());
+
+ ElementNode* nodes=getChildByName(operation,"nodes",4,false);
+ if (nodes)
+ {
+ std::vector<store::Item_t> insertedNodes;
+ decodeNodeVector(insertedNodes,nodes ,true);
+
+ std::vector<store::Item_t>::iterator iter = insertedNodes.begin();
+ std::vector<store::Item_t>::iterator end = insertedNodes.end();
+ for (; iter != end; ++iter)
+ {
+ checkNodeType(*iter,type, name, dynamic);
+ }
+ thePul->addInsertIntoCollection(&theQueryLoc,name,insertedNodes,dynamic);
+ }
+}
+
+/*
+ * Retrieves the update property of a collection from the store (not the declaration)
+ */
+StaticContextConsts::declaration_property_t XDMPULVisitorImpl::getUpdateProperty(const store::Collection_t& collection)
+{
+ std::vector<store::Annotation_t> annotations;
+ collection->getAnnotations(annotations);
+
+ if (containsAnnotation(AnnotationInternal::zann_queue,annotations))
+ return StaticContextConsts::decl_queue;
+ else if (containsAnnotation(AnnotationInternal::zann_append_only,annotations))
+ return StaticContextConsts::decl_append_only;
+ else if (containsAnnotation(AnnotationInternal::zann_const,annotations))
+ return StaticContextConsts::decl_const;
+ else
+ return StaticContextConsts::decl_mutable;
+}
+
+/*
+ * Retrieves the order property of a collection from the store (not the declaration)
+ */
+StaticContextConsts::declaration_property_t XDMPULVisitorImpl::getOrderProperty(const store::Collection_t& collection)
+{
+ std::vector<store::Annotation_t> annotations;
+ collection->getAnnotations(annotations);
+
+ if (containsAnnotation(AnnotationInternal::zann_ordered,annotations))
+ return StaticContextConsts::decl_ordered;
+ else
+ return StaticContextConsts::decl_unordered;
+}
+
+/*
+ * Retrieves the node modifier property of a collection from the store (not the declaration)
+ */
+StaticContextConsts::node_modifier_t XDMPULVisitorImpl::getNodeModifier(const store::Collection* collection)
+{
+ std::vector<store::Annotation_t> annotations;
+ collection->getAnnotations(annotations);
+
+ if (containsAnnotation(AnnotationInternal::zann_read_only_nodes,annotations))
+ return StaticContextConsts::read_only;
+ else
+ return StaticContextConsts::mutable_node;
+}
+
+/*
+ * Determines if a vector of annotations contains a specific annotation
+ */
+bool XDMPULVisitorImpl::containsAnnotation(AnnotationInternal::AnnotationId annotation,
+ std::vector<store::Annotation_t>& annotations)
+{
+ store::Item* annotQName=AnnotationInternal::lookup(annotation);
+ std::vector<store::Annotation_t>::iterator iter = annotations.begin();
+ std::vector<store::Annotation_t>::iterator end = annotations.end();
+ for (; iter != end; ++iter)
+ {
+ if ((*iter)->theName->equals(annotQName))
+ return true;
+ }
+ return false;
+}
+
+void XDMPULVisitorImpl::parseInsertIntoCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ store::Item_t nameCopy;
+ std::vector<store::Item_t> insertedNodes;
+ parseAsQName(name,getChildByName(operation,"name",0,true));
+ decodeNodeVector(insertedNodes, getChildByName(operation,"nodes",1,true),true);
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",2,true));
+
+ store::Collection_t collection = GENV_STORE.getCollection(name, dynamic);
+ if (collection == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ if(!dynamic)
+ {
+ switch(getUpdateProperty(collection))
+ {
+ case StaticContextConsts::decl_const:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0004_COLLECTION_CONST_UPDATE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_append_only:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0005_COLLECTION_APPEND_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_queue:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0006_COLLECTION_QUEUE_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_mutable:
+ // good to go
+ break;
+
+ default:
+ ZORBA_ASSERT(false);
+ }
+ }
+
+ std::vector<store::Item_t>::iterator iter = insertedNodes.begin();
+ std::vector<store::Item_t>::iterator end = insertedNodes.end();
+ for (; iter != end; ++iter)
+ {
+ checkNodeType(*iter, static_cast<SimpleCollection*>(collection.getp())->getNodeType(), name, dynamic);
+ }
+
+ thePul->addInsertIntoCollection(&theQueryLoc,name,insertedNodes,dynamic);
+}
+
+void XDMPULVisitorImpl::parseInsertFirstIntoCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ std::vector<store::Item_t> insertedNodes;
+ parseAsQName(name,getChildByName(operation,"name",0,true));
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",2,true));
+
+ store::Collection_t collection = GENV_STORE.getCollection(name, dynamic);
+ if (collection == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ if (!dynamic) {
+ switch(getUpdateProperty(collection))
+ {
+ case StaticContextConsts::decl_const:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0004_COLLECTION_CONST_UPDATE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_append_only:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0005_COLLECTION_APPEND_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_queue:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0006_COLLECTION_QUEUE_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_mutable:
+ // good to go
+ break;
+
+ default:
+ ZORBA_ASSERT(false);
+ }
+ if (getOrderProperty(collection) == StaticContextConsts::decl_unordered)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0012_COLLECTION_UNORDERED_BAD_OPERATION,
+ ERROR_PARAMS( name->getStringValue(), "insert" ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+ }
+
+ decodeNodeVector(insertedNodes, getChildByName(operation,"nodes",1,true),true);
+
+ std::vector<store::Item_t>::iterator iter = insertedNodes.begin();
+ std::vector<store::Item_t>::iterator end = insertedNodes.end();
+ for (; iter != end; ++iter)
+ {
+ checkNodeType(*iter, static_cast<SimpleCollection*>(collection.getp())->getNodeType(), name, dynamic);
+ }
+
+ thePul->addInsertFirstIntoCollection(&theQueryLoc,name,insertedNodes,dynamic);
+}
+
+void XDMPULVisitorImpl::parseInsertLastIntoCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ std::vector<store::Item_t> insertedNodes;
+ parseAsQName(name,getChildByName(operation,"name",0,true));
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",2,true));
+
+
+ store::Collection_t collection = GENV_STORE.getCollection(name, dynamic);
+ if (collection == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ if (!dynamic) {
+ switch(getUpdateProperty(collection))
+ {
+ case StaticContextConsts::decl_const:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0004_COLLECTION_CONST_UPDATE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_append_only:
+ case StaticContextConsts::decl_queue:
+ case StaticContextConsts::decl_mutable:
+ // good to go
+ break;
+
+ default:
+ ZORBA_ASSERT(false);
+ }
+
+ if (getOrderProperty(collection) == StaticContextConsts::decl_unordered)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0012_COLLECTION_UNORDERED_BAD_OPERATION,
+ ERROR_PARAMS( name->getStringValue(), "insert" ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+ }
+
+ decodeNodeVector(insertedNodes, getChildByName(operation,"nodes",1,true),true);
+
+ std::vector<store::Item_t>::iterator iter = insertedNodes.begin();
+ std::vector<store::Item_t>::iterator end = insertedNodes.end();
+ for (; iter != end; ++iter)
+ {
+ checkNodeType(*iter, static_cast<SimpleCollection*>(collection.getp())->getNodeType(), name, dynamic);
+ }
+
+ thePul->addInsertLastIntoCollection(&theQueryLoc,name,insertedNodes,dynamic);
+}
+
+void XDMPULVisitorImpl::parseInsertAfterIntoCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ std::vector<store::Item_t> insertedNodes;
+ parseAsQName(name,getChildByName(operation,"name",1,true));
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",3,true));
+
+ store::Collection_t collection = GENV_STORE.getCollection(name, dynamic);
+ if (collection == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+
+ zorba::Integer targetPos;
+
+ if (!collection->findNode(opTarget.getp(), targetPos))
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0011_COLLECTION_NODE_NOT_FOUND,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ if (!dynamic) {
+ switch(getUpdateProperty(collection))
+ {
+ case StaticContextConsts::decl_const:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0004_COLLECTION_CONST_UPDATE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_append_only:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0005_COLLECTION_APPEND_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_queue:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0006_COLLECTION_QUEUE_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_mutable:
+ // good to go
+ break;
+
+ default:
+ ZORBA_ASSERT(false);
+ }
+
+ if (getOrderProperty(collection) == StaticContextConsts::decl_unordered)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0012_COLLECTION_UNORDERED_BAD_OPERATION,
+ ERROR_PARAMS( name->getStringValue(), "insert" ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+ }
+
+
+ decodeNodeVector(insertedNodes, getChildByName(operation,"nodes",2,true), true);
+
+ std::vector<store::Item_t>::iterator iter = insertedNodes.begin();
+ std::vector<store::Item_t>::iterator end = insertedNodes.end();
+ for (; iter != end; ++iter)
+ {
+ checkNodeType(*iter, static_cast<SimpleCollection*>(collection.getp())->getNodeType(), name, dynamic);
+ }
+ thePul->addInsertAfterIntoCollection(&theQueryLoc,name,opTarget,insertedNodes,dynamic);
+}
+
+void XDMPULVisitorImpl::parseInsertBeforeIntoCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ std::vector<store::Item_t> insertedNodes;
+ parseAsQName(name,getChildByName(operation,"name",1,true));
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",3,true));
+
+ store::Collection_t collection = GENV_STORE.getCollection(name, dynamic);
+ if (collection == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+ zorba::Integer targetPos;
+ if (!collection->findNode(opTarget.getp(), targetPos))
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0011_COLLECTION_NODE_NOT_FOUND,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ if (!dynamic) {
+ switch(getUpdateProperty(collection))
+ {
+ case StaticContextConsts::decl_const:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0004_COLLECTION_CONST_UPDATE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_append_only:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0005_COLLECTION_APPEND_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_queue:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0006_COLLECTION_QUEUE_BAD_INSERT,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_mutable:
+ // good to go
+ break;
+
+ default:
+ ZORBA_ASSERT(false);
+ }
+
+ if (getOrderProperty(collection) == StaticContextConsts::decl_unordered)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0012_COLLECTION_UNORDERED_BAD_OPERATION,
+ ERROR_PARAMS( name->getStringValue(), "insert" ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+ }
+
+ decodeNodeVector(insertedNodes, getChildByName(operation,"nodes",2,true), true);
+
+ std::vector<store::Item_t>::iterator iter = insertedNodes.begin();
+ std::vector<store::Item_t>::iterator end = insertedNodes.end();
+ for (; iter != end; ++iter)
+ {
+ checkNodeType(*iter, static_cast<SimpleCollection*>(collection.getp())->getNodeType(), name, dynamic);
+ }
+
+ thePul->addInsertBeforeIntoCollection(&theQueryLoc,name,opTarget,insertedNodes,dynamic);
+}
+
+void XDMPULVisitorImpl::parseDeleteNodesFromCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ std::vector<store::Item_t> deletedNodes;
+ parseAsQName(name,getChildByName(operation,"name",0,true));
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",3,true));
+
+ store::Collection_t collection = GENV_STORE.getCollection(name, dynamic);
+ if (collection == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ resolveTargetVector(deletedNodes, getChildByName(operation,"targets",1,true)); //allowed anything
+
+ if (!dynamic) {
+ switch(getUpdateProperty(collection))
+ {
+ case StaticContextConsts::decl_const:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0004_COLLECTION_CONST_UPDATE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_append_only:
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0007_COLLECTION_APPEND_BAD_DELETE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+
+ case StaticContextConsts::decl_queue:
+ //we check later if this is not a delete-first
+ case StaticContextConsts::decl_mutable:
+ // good to go
+ break;
+
+ default:
+ ZORBA_ASSERT(false);
+ }
+ }
+
+ std::vector<store::Item_t>::iterator iter = deletedNodes.begin();
+ std::vector<store::Item_t>::iterator end = deletedNodes.end();
+
+ bool isFirst=true;
+ int current=0;
+ xs_integer position;
+
+ for (; iter != end; ++iter)
+ {
+ if (! (*iter)->getCollection()) {
+ throw XQUERY_EXCEPTION( zerr::ZDDY0017_NODE_IS_ORPHAN, ERROR_LOC( theQueryLoc ) );
+ }
+ if (collection != (*iter)->getCollection()) {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0018_NODES_NOT_IN_SAME_COLLECTION, ERROR_LOC( theQueryLoc )
+ );
+ }
+ collection->findNode((*iter),position);
+ if (xs_integer(current++)!=position)
+ {
+ isFirst=false;
+ }
+ }
+
+ if (!isFirst && getUpdateProperty(collection)==StaticContextConsts::decl_queue)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0009_COLLECTION_QUEUE_BAD_DELETE,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ thePul->addDeleteFromCollection(&theQueryLoc,name,deletedNodes,false,dynamic);
+}
+
+void XDMPULVisitorImpl::parseDeleteCollection(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t name;
+ parseAsQName(name,getChildByName(operation,"name",0,true));
+ bool dynamic=parseAsBoolean(getChildByName(operation,"dynamic-collection",1,true));
+
+ //zerr::ZDDY0001_COLLECTION_NOT_DECLARED is not raised
+
+ if (GENV_STORE.getCollection(name, dynamic) == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
+ ERROR_PARAMS( name->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+ thePul->addDeleteCollection(&theQueryLoc,name,dynamic);
+}
+
+void XDMPULVisitorImpl::parseActivateForeignKeyIC(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t qname;
+ store::Item_t fromCollectionName;
+ store::Item_t toCollectionName;
+ parseAsQName(qname,getChildByName(operation,"name",0,true));
+ parseAsQName(fromCollectionName,getChildByName(operation,"from-collection-name",1,true));
+ parseAsQName(toCollectionName,getChildByName(operation,"to-collection-name",2,true));
+
+ //zerr::ZDDY0031_IC_NOT_DECLARED not raised
+
+ // already activated => noop
+ if (GENV_STORE.getIC(qname))
+ return;
+
+ thePul->addActivateForeignKeyIC(&theQueryLoc,qname,fromCollectionName,toCollectionName);
+}
+
+void XDMPULVisitorImpl::parseActivateIC(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t qname;
+ store::Item_t collectionName;
+ parseAsQName(qname,getChildByName(operation,"name",0,true));
+ parseAsQName(collectionName,getChildByName(operation,"collection-name",1,true));
+
+ //zerr::ZDDY0031_IC_NOT_DECLARED not raised
+
+ // already activated => noop
+ if (GENV_STORE.getIC(qname))
+ return;
+
+ thePul->addActivateIC(&theQueryLoc,qname,collectionName);
+}
+
+void XDMPULVisitorImpl::parseDeactivateIC(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ store::Item_t qname;
+ parseAsQName(qname,getChildByName(operation,"name",0,true));
+
+ //zerr::ZDDY0031_IC_NOT_DECLARED not raised
+
+ // already activated => noop
+ if (GENV_STORE.getIC(qname) == NULL)
+ {
+ throw XQUERY_EXCEPTION(
+ zerr::ZDDY0032_IC_NOT_ACTIVATED,
+ ERROR_PARAMS( qname->getStringValue() ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ thePul->addDeActivateIC(&theQueryLoc,qname);
+}
+
+#ifdef PUL_SETTYPE
+
+void XDMPULVisitorImpl::parseSetAttributeType(const ElementNode* operation)
+{
+ /* To avoid crashes in the store the target must be an attribute node */
+ uint allowedNodes=attributeNode;
+ store::Item_t opTarget;
+ store::Item_t type;
+ resolveTarget(opTarget,getChildByName(operation,"target",0,true),allowedNodes);
+ parseAsQName(type,getChildByName(operation,"type-name",1,true));
+
+ store::Item_t value;
+ store::Iterator_t listValue;
+ ElementNode* valueChild=getChildByName(operation,"value",2,true);
+ valueChild->getTypedValue(value,listValue);
+
+ bool haveListValue=parseAsBoolean(getAttributeByName(valueChild,"have-list-value",true));
+ if (!haveListValue)
+ thePul->addSetAttributeType(&theQueryLoc,opTarget,type,value);
+ else
+ {
+ std::vector<store::Item_t> values;
+ listValue->open();
+ while (listValue->next(value))
+ values.push_back(value);
+ listValue->close();
+ thePul->addSetAttributeType(&theQueryLoc,opTarget,type,values);
+ }
+}
+
+void XDMPULVisitorImpl::parseSetElementType(const ElementNode* operation)
+{
+ /* To avoid crashes in the store the target must be an element node */
+ uint allowedNodes=elementNode;
+ store::Item_t opTarget;
+ store::Item_t type;
+
+ resolveTarget(opTarget,getChildByName(operation,"target",0,true),allowedNodes);
+ parseAsQName(type,getChildByName(operation,"type-name",1,true));
+
+ store::Item_t value;
+ store::Iterator_t listValue;
+ ElementNode* valueChild=getChildByName(operation,"value",2,false);
+
+ bool haveTypedTypedValue;
+ bool haveListValue;
+ if (valueChild)
+ {
+ haveTypedTypedValue=true;
+ haveListValue=parseAsBoolean(getAttributeByName(valueChild,"have-list-value",true));
+ valueChild->getTypedValue(value,listValue);
+ }
+
+ bool haveTypedValue = parseAsBoolean(getChildByName(operation,"have-value",3,true));
+ bool haveEmptyValue = parseAsBoolean(getChildByName(operation,"have-empty-value",4,true));
+ bool isInSubstitutionGroup = parseAsBoolean(getChildByName(operation,"is-in-substitution-group",7,true));
+
+ if (!haveListValue)
+ thePul->addSetElementType(&theQueryLoc,opTarget,type,value,haveTypedValue,haveEmptyValue,haveTypedTypedValue,isInSubstitutionGroup);
+ else
+ {
+ std::vector<store::Item_t> values;
+ listValue->open();
+ while (listValue->next(value))
+ values.push_back(value);
+ listValue->close();
+ thePul->addSetElementType(&theQueryLoc,opTarget,type,values,haveTypedValue,haveEmptyValue,haveTypedTypedValue,isInSubstitutionGroup);
+ }
+}
+#endif
+
+void XDMPULVisitorImpl::parseRevalidate(const ElementNode* operation)
+{
+ store::Item_t opTarget;
+ resolveTarget(opTarget,getChildByName(operation,"target",0,true));
+ thePul->addRevalidate(&theQueryLoc,opTarget);
+}
+
+void XDMPULVisitorImpl::parseCreateDocument(const ElementNode* operation)
+{
+ store::Item_t uri;
+ store::Item_t doc;
+ ElementNode * uriElem=getChildByName(operation,"uri",0,true);
+ zstring uriStr=uriElem->getStringValue();
+
+ // check if document already exists in the store
+ if (GENV_STORE.getDocument(uriStr) != NULL) {
+ throw XQUERY_EXCEPTION(
+ zerr::ZAPI0020_DOCUMENT_ALREADY_EXISTS,
+ ERROR_PARAMS( uriStr ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ theItemFactory->createAnyURI(uri,uriStr);
+ ElementNode* documentContainerNode=getChildByName(operation,"document-reference",0,true);
+
+ uint targetKind=resolveTarget(doc,documentContainerNode);
+ if (!targetKind==documentNode)
+ {
+ const char *err_msg = "The target of a create document operation must be a document.";
+ store::Item_t err_qname;
+ GET_FACTORY().createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg);
+ }
+
+
+ thePul->addCreateDocument(&theQueryLoc,uri,doc);
+}
+
+void XDMPULVisitorImpl::parseDeleteDocument(const ElementNode* operation)
+{
+ store::Item_t uri;
+ ElementNode * uriElem=getChildByName(operation,"uri",0,true);
+ zstring uriStr;
+ uriElem->getStringValue2(uriStr);
+
+ // check if document exists in the store
+ if (theStore->getDocument(uriStr) == NULL) {
+ throw XQUERY_EXCEPTION(
+ zerr::ZXQD0002_DOCUMENT_NOT_VALID,
+ ERROR_PARAMS( uriStr, ZED( NoURIInStore ) ),
+ ERROR_LOC( theQueryLoc )
+ );
+ }
+
+ theItemFactory->createAnyURI(uri, uriStr);
+ thePul->addDeleteDocument(&theQueryLoc,uri);
+}
+
+
+}//simplestore
+}//zorba
+
=== added file 'src/store/naive/pul_xdm_encoding.cpp'
--- src/store/naive/pul_xdm_encoding.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_xdm_encoding.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,441 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "store/api/item_factory.h"
+
+#include "store/naive/node_items.h"
+#include "store/naive/simple_store.h"
+#include "store/naive/store_defs.h"
+#include "store/naive/pul_visitors.h"
+#include "store/naive/pul_primitives.h"
+#include "store/naive/node_factory.h"
+#include "diagnostics/user_exception.h"
+
+namespace zorba {
+namespace simplestore {
+
+/*
+ * Creates a new instance of a SimplePULVisitorImpl. The willBeEncoded parameter
+ * determines whether nodes identifiers are copied when nodes are copied in the PUL.
+ * If true, identifiers are copied and thus the XDM PUL must be encoded immediately
+ * after its generation, otherwise, multiple nodes with the same id will exist.
+ */
+SimplePULVisitorImpl::SimplePULVisitorImpl(store::Item_t& result, bool willBeEncoded): PULEncodingVisitor(willBeEncoded)
+{
+ createElementNode(result, "pending-update-list", NULL);
+ ELEM_NODE(result)->addLocalBinding("xs","http://www.w3.org/2001/XMLSchema");
+ theResult=result;
+}
+
+void SimplePULVisitorImpl::visit(store::Item_t& pul)
+{
+ static_cast<PULImpl*>(pul.getp())->accept(this);
+}
+
+
+/*------------- Methods for visiting the XQU Update Primitives -------------------*/
+
+void SimplePULVisitorImpl::visitUpdDelete(const UpdDelete * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+}
+
+void SimplePULVisitorImpl::visitUpdInsertChildren(const UpdInsertChildren * op)
+{
+ store::Item_t result;
+ switch (op->getKind())
+ {
+ case store::UpdateConsts::UP_INSERT_AFTER:
+ case store::UpdateConsts::UP_INSERT_BEFORE:
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theSibling);
+ break;
+ case store::UpdateConsts::UP_INSERT_INTO:
+ case store::UpdateConsts::UP_INSERT_INTO_FIRST:
+ case store::UpdateConsts::UP_INSERT_INTO_LAST:
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ break;
+ default:
+ ZORBA_FATAL(0, "Unknown insert children operation");
+ }
+ encodeNodes(result, "content", op->theNewChildren,false, false);
+}
+
+void SimplePULVisitorImpl::visitUpdInsertAttributes(const UpdInsertAttributes * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeNodes(result, "content", op->theNewAttrs,false, false);
+}
+
+void SimplePULVisitorImpl::visitUpdReplaceAttribute(const UpdReplaceAttribute * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theAttr);
+ encodeNodes(result, "replacement", op->theNewAttrs,false, false);
+}
+
+void SimplePULVisitorImpl::visitUpdReplaceChild(const UpdReplaceChild * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theChild);
+ encodeNodes(result, "replacement", op->theNewChildren,false, false);
+}
+
+void SimplePULVisitorImpl::visitUpdReplaceElemContent(const UpdReplaceElemContent * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeNode(result, "text", op->theNewChild,false, false);
+}
+
+void SimplePULVisitorImpl::visitUpdReplaceAttrValue(const UpdReplaceAttrValue * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theNewValue);
+}
+
+void SimplePULVisitorImpl::visitUpdReplaceTextValue(const UpdReplaceTextValue * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theNewContent);
+}
+
+void SimplePULVisitorImpl::visitUpdReplacePiValue(const UpdReplacePiValue * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theNewValue);
+}
+
+void SimplePULVisitorImpl::visitUpdReplaceCommentValue(const UpdReplaceCommentValue * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "string-value", op->theNewValue);
+}
+
+void SimplePULVisitorImpl::visitUpdRenameElem(const UpdRenameElem * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "newName", op->theNewName);
+}
+
+void SimplePULVisitorImpl::visitUpdRenameAttr(const UpdRenameAttr * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "newName", op->theNewName);
+}
+
+void SimplePULVisitorImpl::visitUpdRenamePi(const UpdRenamePi * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeString(result, "newName", op->theNewName);
+}
+
+void SimplePULVisitorImpl::visitUpdPut(const UpdPut * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeString(result, "uri", op->theTargetUri->getStringValue());
+
+ store::CopyMode copymode;
+ store::Item_t copy = op->theTarget->copy(NULL, copymode);
+
+ if (copy->getNodeKind() != store::StoreConsts::documentNode)
+ {
+ XmlNode* target = BASE_NODE(copy);
+
+ DocumentNode* doc = GET_STORE().getNodeFactory().createDocumentNode();
+ doc->setId(target->getTree(), NULL);
+ doc->insertChild(target, 0);
+ doc->getTree()->setRoot(doc);
+
+ store::Item_t docItem(doc);
+
+ encodeNode(result, "node", docItem, true, false);
+ }
+ else
+ encodeNode(result, "node", copy, true, false);
+
+}
+
+/*------------- Methods for visiting the Zorba Update Primitives -----------------*/
+
+void SimplePULVisitorImpl::visitUpdActivateForeignKeyIC(const UpdActivateForeignKeyIC * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theQName);
+ encodeQName(result, "from-collection-name", op->theFromCollectionName);
+ encodeQName(result, "to-collection-name", op->theToCollectionName);
+}
+
+
+void SimplePULVisitorImpl::visitUpdActivateIC(const UpdActivateIC * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theQName);
+ encodeQName(result, "collection-name", op->theCollectionName);
+}
+
+
+void SimplePULVisitorImpl::visitUpdDeActivateIC(const UpdDeActivateIC * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theQName);
+}
+
+void SimplePULVisitorImpl::visitUpdCreateCollection(const UpdCreateCollection * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeCollectionAnnotations(result,"annotations",op->theAnnotations);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+ if (op->theNodeType)
+ encodeQName(result, "node-type", op->theNodeType);
+
+ if (op->theDynamicCollection)
+ theCreatedDynamicCollections[op->theName]=result;
+ else
+ theCreatedStaticCollections[op->theName]=result;
+
+}
+
+void SimplePULVisitorImpl::visitUpdDeleteCollection(const UpdDeleteCollection * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+
+void SimplePULVisitorImpl::visitUpdInsertAfterIntoCollection(const UpdInsertAfterIntoCollection * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeTarget(result, op->theTarget);
+ encodeNodes(result, "nodes", op->theNodes,true, false);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+
+void SimplePULVisitorImpl::visitUpdInsertBeforeIntoCollection(const UpdInsertBeforeIntoCollection * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeTarget(result, op->theTarget);
+ encodeNodes(result, "nodes", op->theNodes,true, false);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+
+void SimplePULVisitorImpl::visitUpdInsertFirstIntoCollection(const UpdInsertFirstIntoCollection * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeNodes(result, "nodes", op->theNodes,true, false);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+
+void SimplePULVisitorImpl::visitUpdInsertLastIntoCollection(const UpdInsertLastIntoCollection * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeNodes(result, "nodes", op->theNodes,true, false);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+
+void SimplePULVisitorImpl::visitUpdInsertIntoCollection(const UpdInsertIntoCollection * op)
+{
+ if (op->theDynamicCollection && theCreatedDynamicCollections[op->theName]!=NULL)
+ encodeNodes(theCreatedDynamicCollections[op->theName], "nodes", op->theNodes,true, false);
+ else if (!op->theDynamicCollection && theCreatedStaticCollections[op->theName]!=NULL)
+ encodeNodes(theCreatedStaticCollections[op->theName], "nodes", op->theNodes,true, false);
+ else
+ {
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ encodeNodes(result, "nodes", op->theNodes,true, false);
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+ }
+
+}
+
+
+void SimplePULVisitorImpl::visitUpdDeleteNodesFromCollection(const UpdDeleteNodesFromCollection * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeQName(result, "name", op->theName);
+ store::Item_t nodes;
+ createElementNode(nodes, "targets", result);
+ std::vector<store::Item_t>::const_iterator iter = op->theNodes.begin();
+ std::vector<store::Item_t>::const_iterator end = op->theNodes.end();
+ for (; iter != end; ++iter)
+ encodeTarget(nodes, *iter, "target");
+ encodeBoolean(result, "dynamic-collection", op->theDynamicCollection);
+}
+
+void SimplePULVisitorImpl::visitUpdCreateDocument(const UpdCreateDocument * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeString(result, "uri", op->theUri->getStringValue());
+ encodeTarget(result,op->theDoc,"document-reference");
+}
+
+
+void SimplePULVisitorImpl::visitUpdDeleteDocument(const UpdDeleteDocument * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeString(result, "uri", op->theUri->getStringValue());
+}
+
+void SimplePULVisitorImpl::visitUpdCreateIndex(const UpdCreateIndex * op)
+{
+ visitUnsupported(op);
+}
+
+
+void SimplePULVisitorImpl::visitUpdDeleteIndex(const UpdDeleteIndex * op)
+{
+ visitUnsupported(op);
+}
+
+
+void SimplePULVisitorImpl::visitUpdRefreshIndex(const UpdRefreshIndex * op)
+{
+ visitUnsupported(op);
+}
+
+#ifdef PUL_SETTYPE
+void SimplePULVisitorImpl::visitUpdSetAttributeType(const UpdSetAttributeType * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "type-name", op->theTypeName);
+ encodeItem(result,"value",op->theTypedValue,op->theTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,op->theHaveListValue);
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+}
+
+
+void SimplePULVisitorImpl::visitUpdSetElementType(const UpdSetElementType * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+ encodeQName(result, "type-name", op->theTypeName);
+ if (op->theHaveTypedTypedValue)
+ {
+ encodeItem(result,"value",op->theTypedValue,op->theTypeName,true,false);
+ store::Item_t attr;
+ store::Item_t attrValue;
+ theItemFactory->createBoolean(attrValue,op->theHaveListTypedValue);
+ createAttributeNode(
+ attr,
+ "have-list-value",
+ attrValue,
+ ELEM_NODE(result)->getChild(ELEM_NODE(result)->numChildren()-1));
+ }
+
+ encodeBoolean(result, "have-value", op->theHaveTypedValue);
+ encodeBoolean(result, "have-empty-value", op->theHaveEmptyTypedValue);
+ encodeBoolean(result, "is-in-substitution-group", op->theIsInSubstitutionGroup);
+}
+
+#else
+
+void SimplePULVisitorImpl::visitUpdSetAttributeType(const UpdSetAttributeType * op)
+{
+ visitUnsupported(op);
+}
+
+
+void SimplePULVisitorImpl::visitUpdSetElementType(const UpdSetElementType * op)
+{
+ visitUnsupported(op);
+}
+
+#endif
+
+void SimplePULVisitorImpl::visitUpdRevalidate(const UpdRevalidate * op)
+{
+ store::Item_t result;
+ createElementNode(result, op, theResult);
+ encodeTarget(result, op->theTarget);
+}
+
+void SimplePULVisitorImpl::visitUpdCreateHashMap (const UpdCreateHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+void SimplePULVisitorImpl::visitUpdDestroyHashMap (const UpdDestroyHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+void SimplePULVisitorImpl::visitUpdInsertIntoHashMap (const UpdInsertIntoHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+void SimplePULVisitorImpl::visitUpdRemoveFromHashMap (const UpdRemoveFromHashMap * op)
+{
+ visitUnsupported(op);
+}
+
+} //simplestore
+} //zorba
=== added file 'src/store/naive/pul_xml_decoding.cpp'
--- src/store/naive/pul_xml_decoding.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/pul_xml_decoding.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,584 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "zorba/store_consts.h"
+#include "system/globalenv.h"
+#include "store/api/item_factory.h"
+#include "api/staticcontextimpl.h"
+#include "store/naive/simple_item_factory.h"
+#include "store/naive/atomic_items.h"
+#include "store/api/copymode.h"
+#include "store/naive/simple_store.h"
+#include "store/naive/store_defs.h"
+#include "store/naive/node_factory.h"
+#include "store/naive/nsbindings.h"
+#include "store/naive/pul_visitors.h"
+#include "diagnostics/user_exception.h"
+#include "diagnostics/diagnostic.h"
+#include "context/namespace_context.h"
+#include "context/static_context.h"
+#include "types/casting.h"
+#include "types/typeimpl.h"
+#include "types/typeops.h"
+#include "types/schema/schema.h"
+#include "types/schema/validate.h"
+#include "types/schema/revalidateUtils.h"
+#include "zorbatypes/URI.h"
+
+
+namespace zorba{
+namespace simplestore{
+
+/*
+ * Decodes an encoded PUL. The encode PUL should already be validated,
+ * however, the method will fail gracefully in any case.
+ *
+ * pulxdm = The encoded XDM PUL. It must be the root element node and should be
+ * validated.
+ */
+void XMLPULVisitorImpl::visit(store::Item_t& pulxdm)
+{
+ store::Item_t operation;
+
+ store::Iterator_t itch=pulxdm->getChildren();
+ itch->open();
+ while (itch->next(operation))
+ {
+ if (operation->getNodeKind()==store::StoreConsts::elementNode)
+ parseOperation(ELEM_NODE(operation));
+ }
+ itch->close();
+}
+
+
+/*
+ * Decodes an encoded operation parameter. The encoded parameter is replaced by
+ * the decoded one.
+ *
+ * parentNode = The operation element node. (i.e. a <insertInto> element)
+ * childName = The local name of the children of the operation element node to
+ * decode (i.e. "content")
+ * hint = An optional hint indicating the index at which the child should be found.
+ * It must not be necessarily correct.
+ */
+void XMLPULVisitorImpl::decodeParameter(const simplestore::ElementNode* parentNode,
+ const zstring& childName,
+ ulong hint,
+ bool mandatory)
+{
+ csize childPos;
+ ElementNode * contentNode=getChildByName(childPos,parentNode,childName,hint,mandatory);
+ if (!contentNode)
+ return;
+
+ store::Item_t newContentNode;
+ createElementNode(newContentNode,childName,NULL);
+
+ store::Iterator_t itch=contentNode->getChildren();
+ store::Item_t childNode;
+
+ itch->open();
+ while(itch->next(childNode))
+ {
+ if (childNode->getNodeKind()==store::StoreConsts::elementNode)
+ decodeNode(ELEM_NODE(childNode),ELEM_NODE(newContentNode),theRestoreTypes,true,true);
+ }
+ itch->close();
+ ElementNode* contentParent=static_cast<ElementNode*>(contentNode->getParent());
+ parentNode->getChild(childPos)->destroy(true);
+ ELEM_NODE(newContentNode)->attach(contentParent,childPos);
+}
+
+/*
+ * Decodes an unrestricted encoded operation parameter. The unrestricted encoded
+ * parameter is replaced by the decoded one.
+ *
+ * parentNode = The operation element node. (i.e. a <insertInto> element)
+ * childName = The local name of the children of the operation element node to
+ * decode (i.e. "content")
+ * hint = An optional hint indicating the index at which the child should be found.
+ * It must not be necessarily correct.
+ */
+void XMLPULVisitorImpl::decodeUnrestrictedParameter(const simplestore::ElementNode* parentNode, const zstring& childName, ulong hint, bool mandatory)
+{
+ csize childPos;
+ ElementNode * contentNode=getChildByName(childPos,parentNode,childName,hint,mandatory);
+ if (!contentNode)
+ return;
+
+ store::Item_t newContentNode;
+ createElementNode(newContentNode,childName,NULL);
+
+ store::Iterator_t itch=contentNode->getChildren();
+ store::Item_t childNode;
+
+ itch->open();
+ while(itch->next(childNode))
+ {
+ if (childNode->getNodeKind()==store::StoreConsts::elementNode)
+ decodeUnrestrictedNode(ELEM_NODE(childNode),newContentNode);
+ }
+ itch->close();
+ ElementNode* contentParent=static_cast<ElementNode *>(contentNode->getParent());
+ parentNode->getChild(childPos)->destroy(true);
+ ELEM_NODE(newContentNode)->attach(contentParent,childPos);
+}
+
+/*
+ * Decodes an unrestricted encoded node, that is a "document" or "non-document" node.
+ * The decoded node is inserted as last children of the newContentNode node.
+ *
+ * encodedRoot = Unrestricted encoded node.
+ * newContentNode = The parent of the decoded node
+ */
+void XMLPULVisitorImpl::decodeUnrestrictedNode(ElementNode* encodedRoot,
+ store::Item_t& newContentNode)
+{
+ store::Item_t newEncodedRoot;
+ if (encodedRoot->getNodeName()->getLocalName() == "document")
+ {
+ createElementNode(newEncodedRoot,"document",newContentNode);
+ for (csize pos=0; pos<encodedRoot->numAttrs();++pos)
+ encodedRoot->getAttr(pos)->copy(newEncodedRoot,store::CopyMode());
+ ElementNode* childrenContainer;
+ if (encodedRoot->numChildren()>0)
+ {
+ childrenContainer=getChildByName(encodedRoot,"children",0,true);
+ store::Item_t newChildrenContainer;
+ createElementNode(newChildrenContainer,"children",newEncodedRoot);
+ store::Iterator_t iitch=childrenContainer->getChildren();
+ iitch->open();
+ store::Item_t childrenNode;
+ while (iitch->next(childrenNode))
+ {
+ if (childrenNode->getNodeKind()==store::StoreConsts::elementNode)
+ decodeNode(ELEM_NODE(childrenNode),ELEM_NODE(newChildrenContainer),theRestoreTypes,true,true);
+ }
+ iitch->close();
+ }
+ }
+ else
+ {
+ createElementNode(newEncodedRoot,"non-document",newContentNode);
+ decodeNode(encodedRoot,ELEM_NODE(newEncodedRoot),theRestoreTypes,true,true);
+ }
+}
+
+/*
+ * Decodes all the encoded attributes children of the "encodedElemContainer" node and
+ * attaches the decoded nodes to "decodedElemParent" node.
+ */
+void XMLPULVisitorImpl::decodeAttributes(ElementNode* encodedElemContainer, ElementNode* decodedElemParent, bool restoreType, bool typesAllowed, bool validate)
+{
+ store::Iterator_t itch=encodedElemContainer->getChildren();
+ store::Item_t child;
+ itch->open();
+ while(itch->next(child))
+ {
+ if (child->getNodeKind()==store::StoreConsts::elementNode)
+ decodeAttribute(ELEM_NODE(child),decodedElemParent,restoreType,typesAllowed,validate);
+ }
+ itch->close();
+}
+
+/*
+ * Decodes all the children of the "encodedElemContainer" node and
+ * attaches the decoded nodes to "decodedElemParent".
+ */
+void XMLPULVisitorImpl::decodeChildren(ElementNode* encodedElemContainer,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate)
+{
+ store::Iterator_t itch=encodedElemContainer->getChildren();
+ store::Item_t child;
+ itch->open();
+ while(itch->next(child))
+ {
+ if (child->getNodeKind()==store::StoreConsts::elementNode)
+ {
+ decodeNode(ELEM_NODE(child),decodedElemParent, restoreType,typesAllowed,validate);
+ }
+ }
+ itch->close();
+}
+
+/*
+ * Decodes an encoded node and attaches the decoded node as attribute/last child
+ * of the "decodedElemParent" node.
+ *
+ * encodedNode = The encoded node
+ * decodedElemParent = The parent of the decoded node
+ * restoreType = Whether the typing information should be restored or not.
+ * typesAllowed = Whether the encoded node can be typed or not (i.e. its parent is untyped).
+ * validate = Whether the encoded node is the root of the encoded subtree and
+ * thus it must be validated after
+ */
+void XMLPULVisitorImpl::decodeNode(ElementNode* encodedNode,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate)
+{
+ const zstring& nodeKind=encodedNode->getNodeName()->getLocalName();
+ if (nodeKind == "element")
+ decodeElement(encodedNode,decodedElemParent,restoreType,typesAllowed,validate);
+ else if (nodeKind == "comment")
+ decodeComment(encodedNode,decodedElemParent);
+ else if (nodeKind == "text")
+ decodeText(encodedNode,decodedElemParent);
+ else if (nodeKind == "processing-instruction")
+ decodeProcessingInstruction(encodedNode,decodedElemParent);
+ else if (nodeKind == "attribute")
+ decodeAttribute(encodedNode,decodedElemParent,restoreType,typesAllowed,validate);
+ else
+ {
+ std::stringstream err_msg;
+ err_msg << "Unexpected element \"" <<nodeKind << "\" found in PUL";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL0011");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+}
+
+/*
+ * Decodes an encoded element and attaches the decoded element as last child
+ * of the "decodedElemParent" node.
+ *
+ * encodedNode = The encoded node
+ * decodedElemParent = The parent of the decoded node
+ * restoreType = Whether the typing information should be restored or not.
+ * typesAllowed = Whether the encoded node can be typed or not (i.e. its parent is untyped).
+ * validate = Whether the encoded node is the root of the encoded subtree and
+ * thus it must be validated after
+ */
+void XMLPULVisitorImpl::decodeElement(ElementNode* encodedElem,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate)
+{
+ store::Item_t nodeNameValue;
+ store::Item_t typeNameValue;
+
+ store::NsBindings bindings;
+ ElementNode* namespaceNodes=getChildByName(encodedElem,"namespace-nodes");
+ if (namespaceNodes!=NULL)
+ decodeNamespaces(namespaceNodes,bindings);
+
+ AttributeNode* nodeName=getAttributeByName(encodedElem,"node-name",true);
+ parseAsQName(nodeNameValue,nodeName);
+
+ if (restoreType)
+ {
+ AttributeNode* typeName=getAttributeByName(encodedElem,"type-name");
+ if (typeName==NULL)
+ typeNameValue=theStore->theSchemaTypeNames[XS_UNTYPED];
+ else
+ parseAsQName(typeNameValue,typeName,false);
+
+ if (!typesAllowed &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED]) &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC]))
+ {
+ static const char *err_msg = "A typed node cannot be a descendant of an untyped node.";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg);
+ }
+
+ }
+ bool haveTypedValue=true;
+ bool haveEmptyValue=false;
+ bool isInSubstGroup=false;
+
+ zstring baseUri="";
+
+ store::Item_t elem;
+ if (typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED]))
+ {
+ theItemFactory->createElementNode(elem,NULL,nodeNameValue,theStore->theSchemaTypeNames[XS_UNTYPED],haveTypedValue,
+ haveEmptyValue,bindings,baseUri,isInSubstGroup);
+ typesAllowed=false;
+ }
+ else
+ {
+ theItemFactory->createElementNode(elem,NULL,nodeNameValue,theStore->theSchemaTypeNames[XS_ANY],haveTypedValue,
+ haveEmptyValue,bindings,baseUri,isInSubstGroup);
+ typesAllowed=true;
+ }
+
+ if (!validate && restoreType)
+ {
+ theExpectedTypes.push_back(std::pair<XmlNode*, store::Item_t>(BASE_NODE(elem),typeNameValue));
+ }
+
+ ElementNode* attributesNodes=getChildByName(encodedElem,"attributes");
+ if (attributesNodes!=NULL)
+ decodeAttributes(attributesNodes,ELEM_NODE(elem),restoreType,typesAllowed,false);
+
+ ElementNode* childrenNodes=getChildByName(encodedElem,"children");
+ if (childrenNodes !=NULL)
+ decodeChildren(childrenNodes,ELEM_NODE(elem),restoreType,typesAllowed,false);
+
+ if (restoreType && validate &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_ANY])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_ANY_ATOMIC])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_ANY_SIMPLE])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC])
+ )
+ {
+ try
+ {
+ zstring nodeIdentifier=getAttributeByName(encodedElem,"reference",true)->getStringValue();
+ theStore->restoreReference(BASE_NODE(elem),nodeIdentifier);
+
+ store::PUL_t pul = GENV_ITEMFACTORY->createPendingUpdateList();
+
+ if (!theValidator->validateElementByTypeName(elem.getp(),typeNameValue.getp(),*pul.getp()))
+ {
+ std::stringstream err_msg;
+ err_msg << "Missing type definition: " << typeNameValue->getStringValue();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ pul->applyUpdates(true);
+ }
+ catch (XQueryException&)
+ {
+ std::stringstream err_msg;
+ err_msg << "Element " << nodeName->getStringValue() << " cannot be validated as " << typeNameValue->getStringValue();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+
+ std::list<std::pair<XmlNode*, store::Item_t> >::iterator it;
+ for ( it=theExpectedTypes.begin() ; it != theExpectedTypes.end(); it++ )
+ {
+ if (it->first->getType() && !it->first->getType()->equals(it->second))
+ {
+ std::stringstream err_msg;
+ err_msg << "Element " << it->first->getNodeName()->getStringValue() << " has been validated as " << it->first->getType()->getStringValue() << ", expected type: " << it->second->getStringValue();
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ }
+ theExpectedTypes.clear();
+ }
+ else
+ {
+ zstring nodeIdentifier=getAttributeByName(encodedElem,"reference",true)->getStringValue();
+ theStore->restoreReference(BASE_NODE(elem),nodeIdentifier);
+ }
+
+ ELEM_NODE(elem)->attach(decodedElemParent,decodedElemParent->numChildren());
+
+}
+
+/*
+ * Decodes an encoded attribute and attaches the decoded attribute as last child
+ * of the "decodedElemParent" node.
+ *
+ * encodedNode = The encoded node
+ * decodedElemParent = The parent of the decoded node
+ * restoreType = Whether the typing information should be restored or not.
+ * typesAllowed = Whether the encoded node can be typed or not (i.e. its parent is untyped).
+ * validate = Whether the encoded node is the root of the encoded subtree and
+ * thus it must be validated after
+ */
+void XMLPULVisitorImpl::decodeAttribute(ElementNode* encodedElem,
+ ElementNode* decodedElemParent,
+ bool restoreType,
+ bool typesAllowed,
+ bool validate)
+{
+ store::Item_t nodeNameValue;
+ AttributeNode* nodeName=getAttributeByName(encodedElem,"node-name",true);
+ parseAsQName(nodeNameValue,nodeName,true);
+
+ store::Item_t attr;
+ zstring attrValueText;
+ encodedElem->getStringValue2(attrValueText);
+
+ if (restoreType)
+ {
+ AttributeNode* typeName=getAttributeByName(encodedElem,"type-name");
+ store::Item_t typeNameValue;
+ if (typeName==NULL)
+ typeNameValue=theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC];
+ else
+ parseAsQName(typeNameValue,typeName,false);
+
+ if (!typesAllowed &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED]) &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC]))
+ {
+ static const char *err_msg = "A typed node cannot be a descendant of an untyped node.";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg);
+ }
+
+ std::vector<store::Item_t> parsedItem;
+
+ if (!typeNameValue->equals(theStore->theSchemaTypeNames[XS_ANY])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_ANY_ATOMIC])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_ANY_SIMPLE])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED])
+ &&
+ !typeNameValue->equals(theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC])
+ )
+ {
+ bool isList=parseTypedString(parsedItem,attrValueText,typeNameValue,decodedElemParent); //raises exceptions
+
+ if (isList)
+ theItemFactory->createAttributeNode(attr,decodedElemParent,nodeNameValue,typeNameValue,parsedItem);
+ else
+ theItemFactory->createAttributeNode(attr,decodedElemParent,nodeNameValue,typeNameValue,parsedItem[0]);
+ }
+ else
+ {
+ store::Item_t attrValue;
+ theItemFactory->createUntypedAtomic(attrValue,attrValueText);
+ theItemFactory->createAttributeNode(attr,decodedElemParent,nodeNameValue,theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC],attrValue);
+ }
+ }
+ else
+ {
+ //Ignore any type information and restore as untyped atomic
+ store::Item_t attrValue;
+ theItemFactory->createUntypedAtomic(attrValue,attrValueText);
+ theItemFactory->createAttributeNode(attr,decodedElemParent,nodeNameValue,theStore->theSchemaTypeNames[XS_UNTYPED_ATOMIC],attrValue);
+ }
+
+ zstring nodeIdentifier=getAttributeByName(encodedElem,"reference",true)->getStringValue();
+ theStore->restoreReference(BASE_NODE(attr),nodeIdentifier);
+}
+
+/*
+ * Decodes an encoded comment and attaches the decoded comment as last child
+ * of the "decodedElemParent" node.
+ *
+ * encodedNode = The encoded node
+ * decodedElemParent = The parent of the decoded node
+ */
+void XMLPULVisitorImpl::decodeComment(ElementNode* encodedElem, ElementNode* decodedElemParent)
+{
+ zstring commentValue=encodedElem->getStringValue();
+ store::Item_t comment;
+ theItemFactory->createCommentNode(comment,decodedElemParent,commentValue);
+
+ zstring nodeIdentifier=getAttributeByName(encodedElem,"reference",true)->getStringValue();
+ theStore->restoreReference(BASE_NODE(comment),nodeIdentifier);
+}
+
+/*
+ * Decodes an encoded processing instruction and attaches the decoded processing
+ * instruction as last child of the "decodedElemParent" node.
+ *
+ * encodedNode = The encoded node
+ * decodedElemParent = The parent of the decoded node
+ */
+void XMLPULVisitorImpl::decodeProcessingInstruction(ElementNode* encodedElem, ElementNode* decodedElemParent)
+{
+ zstring processingInstructionValue=encodedElem->getStringValue();
+ store::Iterator_t listValue;
+ store::Item_t nodeNameValue;
+ AttributeNode* nodeName=getAttributeByName(encodedElem,"node-name",true);
+ zstring target=nodeName->getStringValue();
+ zstring baseUri="";//unused
+ store::Item_t pi;
+ theItemFactory->createPiNode(pi,decodedElemParent,target,processingInstructionValue,baseUri);
+ zstring nodeIdentifier=getAttributeByName(encodedElem,"reference",true)->getStringValue();
+ theStore->restoreReference(BASE_NODE(pi),nodeIdentifier);
+}
+
+/*
+ * Decodes an encoded text node and attaches the decoded attribute as last child
+ * of the "decodedElemParent" node.
+ *
+ * encodedNode = The encoded node
+ * decodedElemParent = The parent of the decoded node
+ */
+void XMLPULVisitorImpl::decodeText(ElementNode* encodedElem, ElementNode* decodedElemParent)
+{
+ zstring textValue=encodedElem->getStringValue();
+ store::Item_t text;
+
+ theItemFactory->createTextNode(text,decodedElemParent,textValue);
+ zstring nodeIdentifier=getAttributeByName(encodedElem,"reference",true)->getStringValue();
+ theStore->restoreReference(BASE_NODE(text),nodeIdentifier);
+}
+
+/*
+ * Decodes all namespaces encoded as children of the specified element.
+ *
+ * namespaceNodesParent = The node containing the encoded namespaces
+ * bindings = The decoded namespaces
+ */
+void XMLPULVisitorImpl::decodeNamespaces(ElementNode* namespaceNodesParent, store::NsBindings& bindings)
+{
+ store::Iterator_t itch=namespaceNodesParent->getChildren();
+ store::Item_t child;
+
+ std::set<zstring> prefixes;
+
+ itch->open();
+ while (itch->next(child))
+ {
+ if (child->getNodeKind()==store::StoreConsts::elementNode)
+ {
+ zstring uri = ELEM_NODE(child)->getStringValue();
+ zstring name=getAttributeByName(ELEM_NODE(child),"node-name",true)->getStringValue();
+ if (name!="" && !GenericCast::castableToNCName(name))
+ {
+ std::stringstream err_msg;
+ err_msg << name << " is not a valid namespace prefix.";
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL012");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ if (prefixes.find(name)!=prefixes.end())
+ {
+ std::stringstream err_msg;
+ err_msg << "Multiple namespace bindings for prefix "<< name;
+ store::Item_t err_qname;
+ theItemFactory->createQName(err_qname, theErrNS, "err", "PUL011");
+ throw USER_EXCEPTION(err_qname, err_msg.str().c_str());
+ }
+ bindings.push_back(std::pair<zstring, zstring>(name,uri));
+ }
+ }
+ itch->close();
+}
+
+}//simplestore
+}//zorba
+
+
+
+
=== modified file 'src/store/naive/simple_collection.h'
--- src/store/naive/simple_collection.h 2011-09-12 22:42:28 +0000
+++ src/store/naive/simple_collection.h 2012-01-02 09:53:25 +0000
@@ -92,6 +92,8 @@
const store::Item* getName() const { return theName.getp(); }
+ const store::Item* getNodeType() const { return theNodeType.getp(); }
+
xs_integer size() const { return theXmlTrees.size(); }
bool isDynamic() const { return theIsDynamic; }
=== modified file 'src/store/naive/simple_pul.cpp'
--- src/store/naive/simple_pul.cpp 2011-10-30 00:18:34 +0000
+++ src/store/naive/simple_pul.cpp 2012-01-02 09:53:25 +0000
@@ -28,6 +28,7 @@
#include "store/naive/node_items.h"
#include "store/naive/atomic_items.h"
#include "store/naive/pul_primitive_factory.h"
+#include "store/naive/pul_visitors.h"
#include "store/naive/node_factory.h"
#include "store/api/iterator.h"
@@ -42,7 +43,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void cleanList(std::vector<UpdatePrimitive*>& aVector)
{
std::vector<UpdatePrimitive*>::iterator ite = aVector.begin();
@@ -57,7 +58,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void cleanIndexDeltas(std::vector<store::IndexDelta>& deltas)
{
std::vector<store::IndexDelta>::iterator ite = deltas.begin();
@@ -79,7 +80,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void applyList(std::vector<UpdatePrimitive*>& aVector)
{
std::vector<UpdatePrimitive*>::iterator iter = aVector.begin();
@@ -91,10 +92,24 @@
}
}
-
-/*******************************************************************************
-
-********************************************************************************/
+/*******************************************************************************
+
+ ********************************************************************************/
+void acceptList(std::vector<UpdatePrimitive*>& aVector, PULEncodingVisitor * visitor)
+{
+ std::vector<UpdatePrimitive*>::iterator iter = aVector.begin();
+ std::vector<UpdatePrimitive*>::iterator end = aVector.end();
+
+ for (; iter != end; ++iter)
+ {
+ (*iter)->accept(*visitor);
+ }
+}
+
+
+/*******************************************************************************
+
+ ********************************************************************************/
void undoList(std::vector<UpdatePrimitive*>& list)
{
ulong size = (ulong)list.size();
@@ -109,7 +124,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
NodeToUpdatesMap::~NodeToUpdatesMap()
{
NodeToUpdatesMap::iterator ite = theMap.begin();
@@ -124,22 +139,23 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
PULImpl::PULImpl()
- :
- PUL(),
- theNoCollectionPul(NULL),
- theLastPul(NULL),
- theLastCollection(NULL),
- theValidator(NULL),
- theInheritNSBindings(false)
+:
+ PUL(),
+ theNoCollectionPul(NULL),
+ theLastPul(NULL),
+ theLastCollection(NULL),
+ theValidator(NULL),
+ theInheritNSBindings(false),
+ theIsApplied(false)
{
}
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
PULImpl::~PULImpl()
{
cleanList(thePutList);
@@ -171,16 +187,16 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::setValidator(store::SchemaValidator* validator)
{
theValidator = validator;
}
-
+
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
CollectionPul* PULImpl::getCollectionPul(const store::Item* target)
{
const QNameItem* collName;
@@ -250,7 +266,7 @@
/*******************************************************************************
Create a delete primitive in "this" pul for the given node, if another delete
for the same node does not exist already.
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addDelete(const QueryLoc* aQueryLoc, store::Item_t& target)
{
CollectionPul* pul = getCollectionPul(target.getp());
@@ -287,7 +303,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addInsertInto(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -295,10 +311,10 @@
{
store::Item_t sibling;
addInsertChildren(aQueryLoc,
- store::UpdateConsts::UP_INSERT_INTO,
- target,
- sibling,
- children);
+ store::UpdateConsts::UP_INSERT_INTO,
+ target,
+ sibling,
+ children);
}
@@ -309,10 +325,10 @@
{
store::Item_t sibling;
addInsertChildren(aQueryLoc,
- store::UpdateConsts::UP_INSERT_INTO_FIRST,
- target,
- sibling,
- children);
+ store::UpdateConsts::UP_INSERT_INTO_FIRST,
+ target,
+ sibling,
+ children);
}
@@ -323,7 +339,7 @@
{
store::Item_t sibling;
addInsertChildren(aQueryLoc, store::UpdateConsts::UP_INSERT_INTO_LAST,
- target, sibling, children);
+ target, sibling, children);
}
@@ -362,7 +378,7 @@
bool found = pul->theNodeToUpdatesMap.get(n, updates);
UpdInsertChildren* upd = GET_STORE().getPULFactory().
- createUpdInsertChildren(pul, aQueryLoc, kind, target, sibling, children);
+ createUpdInsertChildren(pul, aQueryLoc, kind, target, sibling, children);
if (kind == store::UpdateConsts::UP_INSERT_INTO)
pul->theDoFirstList.push_back(upd);
@@ -384,7 +400,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addInsertAttributes(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -404,7 +420,7 @@
bool found = pul->theNodeToUpdatesMap.get(n, updates);
UpdInsertAttributes* upd = GET_STORE().getPULFactory().
- createUpdInsertAttributes(pul, aQueryLoc, target, attrs);
+ createUpdInsertAttributes(pul, aQueryLoc, target, attrs);
pul->theDoFirstList.push_back(upd);
@@ -424,7 +440,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addReplaceNode(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -456,21 +472,21 @@
}
upd = GET_PUL_FACTORY().
- createUpdReplaceAttribute(pul, aQueryLoc, parent, target, newNodes);
+ createUpdReplaceAttribute(pul, aQueryLoc, parent, target, newNodes);
kind = store::UpdateConsts::UP_REPLACE_ATTRIBUTE;
}
else
{
upd = GET_PUL_FACTORY().
- createUpdReplaceChild(pul, aQueryLoc, parent, target, newNodes);
+ createUpdReplaceChild(pul, aQueryLoc, parent, target, newNodes);
kind = store::UpdateConsts::UP_REPLACE_CHILD;
}
if (!found)
{
- updates = new NodeUpdates(1);
+ updates = new NodeUpdates(1);
(*updates)[0] = upd;
pul->theNodeToUpdatesMap.insert(n, updates);
}
@@ -490,13 +506,13 @@
updates->push_back(upd);
}
- pul->theReplaceNodeList.push_back(upd);
+ pul->theReplaceNodeList.push_back(upd);
}
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addReplaceContent(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -536,7 +552,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addReplaceValue(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -553,26 +569,26 @@
UpdatePrimitive* upd;
switch (targetKind)
{
- case store::StoreConsts::attributeNode:
- {
- upd = GET_STORE().getPULFactory().
- createUpdReplaceAttrValue(pul, aQueryLoc, target, newValue);
- break;
- }
- case store::StoreConsts::textNode:
- upd = GET_STORE().getPULFactory().
- createUpdReplaceTextValue(pul, aQueryLoc, target, newValue);
- break;
- case store::StoreConsts::piNode:
- upd = GET_STORE().getPULFactory().
- createUpdReplacePiValue(pul, aQueryLoc, target, newValue);
- break;
- case store::StoreConsts::commentNode:
- upd = GET_STORE().getPULFactory().
- createUpdReplaceCommentValue(pul, aQueryLoc, target, newValue);
- break;
- default:
- ZORBA_FATAL(0, "");
+ case store::StoreConsts::attributeNode:
+ {
+ upd = GET_STORE().getPULFactory().
+ createUpdReplaceAttrValue(pul, aQueryLoc, target, newValue);
+ break;
+ }
+ case store::StoreConsts::textNode:
+ upd = GET_STORE().getPULFactory().
+ createUpdReplaceTextValue(pul, aQueryLoc, target, newValue);
+ break;
+ case store::StoreConsts::piNode:
+ upd = GET_STORE().getPULFactory().
+ createUpdReplacePiValue(pul, aQueryLoc, target, newValue);
+ break;
+ case store::StoreConsts::commentNode:
+ upd = GET_STORE().getPULFactory().
+ createUpdReplaceCommentValue(pul, aQueryLoc, target, newValue);
+ break;
+ default:
+ ZORBA_FATAL(0, "");
}
if (!found)
@@ -603,7 +619,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addRename(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -620,34 +636,34 @@
UpdatePrimitive* upd;
switch (targetKind)
{
- case store::StoreConsts::elementNode:
- {
- ElementNode* elemTarget = ELEM_NODE(target);
- elemTarget->checkNamespaceConflict(newName.getp(), err::XUDY0023);
-
- upd = GET_STORE().getPULFactory().
- createUpdRenameElem(pul, aQueryLoc, target, newName);
- break;
- }
- case store::StoreConsts::attributeNode:
- {
- ElementNode* elemParent = reinterpret_cast<ElementNode*>(n->theParent);
-
- if (elemParent != NULL)
- elemParent->checkNamespaceConflict(newName.getp(), err::XUDY0023);
-
- upd = GET_STORE().getPULFactory().createUpdRenameAttr(pul, aQueryLoc, target, newName);
- break;
- }
- case store::StoreConsts::piNode:
- {
- zstring tmp;
- newName->getStringValue2(tmp);
- upd = GET_STORE().getPULFactory().createUpdRenamePi(pul, aQueryLoc, target, tmp);
- break;
- }
- default:
- ZORBA_FATAL(0, "");
+ case store::StoreConsts::elementNode:
+ {
+ ElementNode* elemTarget = ELEM_NODE(target);
+ elemTarget->checkNamespaceConflict(newName.getp(), err::XUDY0023);
+
+ upd = GET_STORE().getPULFactory().
+ createUpdRenameElem(pul, aQueryLoc, target, newName);
+ break;
+ }
+ case store::StoreConsts::attributeNode:
+ {
+ ElementNode* elemParent = reinterpret_cast<ElementNode*>(n->theParent);
+
+ if (elemParent != NULL)
+ elemParent->checkNamespaceConflict(newName.getp(), err::XUDY0023);
+
+ upd = GET_STORE().getPULFactory().createUpdRenameAttr(pul, aQueryLoc, target, newName);
+ break;
+ }
+ case store::StoreConsts::piNode:
+ {
+ zstring tmp;
+ newName->getStringValue2(tmp);
+ upd = GET_STORE().getPULFactory().createUpdRenamePi(pul, aQueryLoc, target, tmp);
+ break;
+ }
+ default:
+ ZORBA_FATAL(0, "");
}
if (!found)
@@ -678,7 +694,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addPut(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -693,7 +709,7 @@
if (upd->theTargetUri == uri)
{
throw XQUERY_EXCEPTION(
- err::XUDY0031, ERROR_PARAMS( uri->getStringValue() )
+ err::XUDY0031, ERROR_PARAMS( uri->getStringValue() )
);
}
}
@@ -706,7 +722,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addSetElementType(
const QueryLoc* aQueryLoc,
store::Item_t& target,
@@ -718,16 +734,16 @@
bool isInSubstitutionGroup)
{
UpdatePrimitive* upd =
- GET_STORE().getPULFactory().createUpdSetElementType(this,
- aQueryLoc,
- target,
- typeName,
- value,
- haveValue,
- haveEmptyValue,
- haveTypedValue,
- false,
- isInSubstitutionGroup);
+ GET_STORE().getPULFactory().createUpdSetElementType(this,
+ aQueryLoc,
+ target,
+ typeName,
+ value,
+ haveValue,
+ haveEmptyValue,
+ haveTypedValue,
+ false,
+ isInSubstitutionGroup);
theValidationList.push_back(upd);
}
@@ -746,16 +762,16 @@
store::Item_t typedValue = new ItemVector(valueV);
UpdatePrimitive* upd =
- GET_STORE().getPULFactory().createUpdSetElementType(this,
- aQueryLoc,
- target,
- typeName,
- typedValue,
- haveValue,
- haveEmptyValue,
- haveTypedValue,
- true,
- isInSubstitutionGroup);
+ GET_STORE().getPULFactory().createUpdSetElementType(this,
+ aQueryLoc,
+ target,
+ typeName,
+ typedValue,
+ haveValue,
+ haveEmptyValue,
+ haveTypedValue,
+ true,
+ isInSubstitutionGroup);
theValidationList.push_back(upd);
}
@@ -768,12 +784,12 @@
store::Item_t& typedValue)
{
UpdatePrimitive* upd =
- GET_STORE().getPULFactory().createUpdSetAttributeType(this,
- aQueryLoc,
- target,
- typeName,
- typedValue,
- false);
+ GET_STORE().getPULFactory().createUpdSetAttributeType(this,
+ aQueryLoc,
+ target,
+ typeName,
+ typedValue,
+ false);
theValidationList.push_back(upd);
}
@@ -788,12 +804,12 @@
store::Item_t typedValue = new ItemVector(typedValueV);
UpdatePrimitive* upd =
- GET_STORE().getPULFactory().createUpdSetAttributeType(this,
- aQueryLoc,
- target,
- typeName,
- typedValue,
- true);
+ GET_STORE().getPULFactory().createUpdSetAttributeType(this,
+ aQueryLoc,
+ target,
+ typeName,
+ typedValue,
+ true);
theValidationList.push_back(upd);
}
@@ -811,7 +827,7 @@
bool found = pul->theNodeToUpdatesMap.get(n, updates);
UpdRevalidate* upd = GET_STORE().getPULFactory().
- createUpdRevalidate(this, aQueryLoc, target);
+ createUpdRevalidate(this, aQueryLoc, target);
pul->theRevalidateList.push_back(upd);
@@ -830,24 +846,24 @@
/*******************************************************************************
Collection primitives
-********************************************************************************/
-void PULImpl::addCreateCollection(
- const QueryLoc* aQueryLoc,
- store::Item_t& name,
- const std::vector<store::Annotation_t>& annotations,
- const store::Item_t& nodeType,
- bool dyn_collection)
+ ********************************************************************************/
+ void PULImpl::addCreateCollection(
+ const QueryLoc* aQueryLoc,
+ store::Item_t& name,
+ const std::vector<store::Annotation_t>& annotations,
+ const store::Item_t& nodeType,
+ bool dyn_collection)
{
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theCreateCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdCreateCollection(
- pul,
- aQueryLoc,
- name,
- annotations,
- nodeType,
- dyn_collection));
+ GET_STORE().getPULFactory().createUpdCreateCollection(
+ pul,
+ aQueryLoc,
+ name,
+ annotations,
+ nodeType,
+ dyn_collection));
}
@@ -859,7 +875,7 @@
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theDeleteCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdDeleteCollection(pul, aQueryLoc, name, dyn_collection));
+ GET_STORE().getPULFactory().createUpdDeleteCollection(pul, aQueryLoc, name, dyn_collection));
}
@@ -872,7 +888,7 @@
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theInsertIntoCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdInsertIntoCollection(pul, aQueryLoc, name, nodes, dyn_collection));
+ GET_STORE().getPULFactory().createUpdInsertIntoCollection(pul, aQueryLoc, name, nodes, dyn_collection));
}
@@ -885,7 +901,7 @@
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theInsertIntoCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdInsertFirstIntoCollection(pul, aQueryLoc, name, nodes, dyn_collection));
+ GET_STORE().getPULFactory().createUpdInsertFirstIntoCollection(pul, aQueryLoc, name, nodes, dyn_collection));
}
@@ -898,7 +914,7 @@
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theInsertIntoCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdInsertLastIntoCollection(pul, aQueryLoc, name, nodes, dyn_collection));
+ GET_STORE().getPULFactory().createUpdInsertLastIntoCollection(pul, aQueryLoc, name, nodes, dyn_collection));
}
@@ -912,7 +928,7 @@
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theInsertIntoCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdInsertBeforeIntoCollection(pul, aQueryLoc, name, target, nodes, dyn_collection));
+ GET_STORE().getPULFactory().createUpdInsertBeforeIntoCollection(pul, aQueryLoc, name, target, nodes, dyn_collection));
}
@@ -926,7 +942,7 @@
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theInsertIntoCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdInsertAfterIntoCollection(pul, aQueryLoc, name, target, nodes, dyn_collection));
+ GET_STORE().getPULFactory().createUpdInsertAfterIntoCollection(pul, aQueryLoc, name, target, nodes, dyn_collection));
}
@@ -940,13 +956,13 @@
CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
pul->theDeleteFromCollectionList.push_back(
- GET_STORE().getPULFactory().createUpdDeleteNodesFromCollection(pul, aQueryLoc, name, nodes, isLast, dyn_collection));
+ GET_STORE().getPULFactory().createUpdDeleteNodesFromCollection(pul, aQueryLoc, name, nodes, isLast, dyn_collection));
}
/*******************************************************************************
Index primitives
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addCreateIndex(
const QueryLoc* aQueryLoc,
const store::Item_t& qname,
@@ -963,7 +979,7 @@
const store::Item_t& qname)
{
UpdatePrimitive* upd =
- GET_STORE().getPULFactory().createUpdDeleteIndex(this, aQueryLoc, qname);
+ GET_STORE().getPULFactory().createUpdDeleteIndex(this, aQueryLoc, qname);
theDeleteIndexList.push_back(upd);
}
@@ -975,7 +991,7 @@
store::Iterator* sourceIter)
{
UpdatePrimitive* upd =
- GET_STORE().getPULFactory().createUpdRefreshIndex(this, aQueryLoc, qname, sourceIter);
+ GET_STORE().getPULFactory().createUpdRefreshIndex(this, aQueryLoc, qname, sourceIter);
theRefreshIndexList.push_back(upd);
}
@@ -983,23 +999,23 @@
/*******************************************************************************
Integrity Constraint Primitives
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addActivateIC(
const QueryLoc* aQueryLoc,
- const store::Item_t& qname,
- const store::Item_t& aCollectionName)
+ const store::Item_t& qname,
+ const store::Item_t& aCollectionName)
{
UpdatePrimitive* upd =
- GET_STORE().getPULFactory().createUpdActivateIC(this, aQueryLoc, qname, aCollectionName);
+ GET_STORE().getPULFactory().createUpdActivateIC(this, aQueryLoc, qname, aCollectionName);
theICActivationList.push_back(upd);
}
void PULImpl::addActivateForeignKeyIC(
const QueryLoc* aQueryLoc,
- const store::Item_t& qname,
- const store::Item_t& aFromCollectionName,
- const store::Item_t& aToCollectionName)
+ const store::Item_t& qname,
+ const store::Item_t& aFromCollectionName,
+ const store::Item_t& aToCollectionName)
{
UpdatePrimitive* upd = GET_STORE().getPULFactory().createUpdActivateForeignKeyIC(this,
aQueryLoc,
@@ -1011,7 +1027,7 @@
void PULImpl::addDeActivateIC(
const QueryLoc* aQueryLoc,
- const store::Item_t& qname)
+ const store::Item_t& qname)
{
UpdatePrimitive* upd = GET_STORE().getPULFactory().createUpdDeActivateIC(this, aQueryLoc, qname);
theICActivationList.push_back(upd);
@@ -1020,7 +1036,7 @@
/*******************************************************************************
Document PULs
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addCreateDocument(
const QueryLoc* aQueryLoc,
const store::Item_t& uri,
@@ -1044,7 +1060,7 @@
/*******************************************************************************
HashMap PULs
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addCreateHashMap(
const QueryLoc* aQueryLoc,
const store::Item_t& aQName,
@@ -1079,8 +1095,8 @@
void PULImpl::addRemoveFromHashMap(
const QueryLoc* aQueryLoc,
- const store::Item_t& aQName,
- const std::vector<store::Item_t>& aKey)
+ const store::Item_t& aQName,
+ const std::vector<store::Item_t>& aKey)
{
UpdatePrimitive* upd = GET_STORE().getPULFactory().createUpdRemoveFromHashMap(
this, aQueryLoc, aQName, aKey);
@@ -1090,7 +1106,7 @@
/*******************************************************************************
Merge PULs
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::mergeUpdates(store::Item* other)
{
PULImpl* otherp = reinterpret_cast<PULImpl*>(other);
@@ -1110,56 +1126,56 @@
// Merge XQUF primitives
mergeUpdateList(thisPul,
- thisPul->theDoFirstList,
- otherPul->theDoFirstList,
- UP_LIST_DO_FIRST);
-
- mergeUpdateList(thisPul,
- thisPul->theInsertList,
- otherPul->theInsertList,
- UP_LIST_NONE);
-
- mergeUpdateList(thisPul,
- thisPul->theReplaceNodeList,
- otherPul->theReplaceNodeList,
- UP_LIST_REPLACE_NODE);
-
- mergeUpdateList(thisPul,
- thisPul->theReplaceContentList,
- otherPul->theReplaceContentList,
- UP_LIST_REPLACE_CONTENT);
-
- mergeUpdateList(thisPul,
- thisPul->theDeleteList,
- otherPul->theDeleteList,
- UP_LIST_DELETE);
+ thisPul->theDoFirstList,
+ otherPul->theDoFirstList,
+ UP_LIST_DO_FIRST);
+
+ mergeUpdateList(thisPul,
+ thisPul->theInsertList,
+ otherPul->theInsertList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(thisPul,
+ thisPul->theReplaceNodeList,
+ otherPul->theReplaceNodeList,
+ UP_LIST_REPLACE_NODE);
+
+ mergeUpdateList(thisPul,
+ thisPul->theReplaceContentList,
+ otherPul->theReplaceContentList,
+ UP_LIST_REPLACE_CONTENT);
+
+ mergeUpdateList(thisPul,
+ thisPul->theDeleteList,
+ otherPul->theDeleteList,
+ UP_LIST_DELETE);
// Merge revalidation primitives
mergeUpdateList(thisPul,
- thisPul->theRevalidateList,
- otherPul->theRevalidateList,
- UP_LIST_NONE);
+ thisPul->theRevalidateList,
+ otherPul->theRevalidateList,
+ UP_LIST_NONE);
// Merge collection primitives
mergeUpdateList(thisPul,
- thisPul->theCreateCollectionList,
- otherPul->theCreateCollectionList,
- UP_LIST_CREATE_COLLECTION);
-
- mergeUpdateList(thisPul,
- thisPul->theInsertIntoCollectionList,
- otherPul->theInsertIntoCollectionList,
- UP_LIST_NONE);
-
- mergeUpdateList(thisPul,
- thisPul->theDeleteFromCollectionList,
- otherPul->theDeleteFromCollectionList,
- UP_LIST_NONE);
-
- mergeUpdateList(thisPul,
- thisPul->theDeleteCollectionList,
- otherPul->theDeleteCollectionList,
- UP_LIST_NONE);
+ thisPul->theCreateCollectionList,
+ otherPul->theCreateCollectionList,
+ UP_LIST_CREATE_COLLECTION);
+
+ mergeUpdateList(thisPul,
+ thisPul->theInsertIntoCollectionList,
+ otherPul->theInsertIntoCollectionList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(thisPul,
+ thisPul->theDeleteFromCollectionList,
+ otherPul->theDeleteFromCollectionList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(thisPul,
+ thisPul->theDeleteCollectionList,
+ otherPul->theDeleteCollectionList,
+ UP_LIST_NONE);
++thisIte;
++otherIte;
@@ -1196,11 +1212,11 @@
for (csize j = 0; j < numPuts; ++j)
{
UpdPut* upd = static_cast<UpdPut*>(thePutList[j]);
-
+
if (upd->theTargetUri->equals(otherUpd->theTargetUri))
{
throw XQUERY_EXCEPTION(err::XUDY0031,
- ERROR_PARAMS(upd->theTargetUri->getStringValue()));
+ ERROR_PARAMS(upd->theTargetUri->getStringValue()));
}
}
@@ -1210,62 +1226,62 @@
// merge index primitives
mergeUpdateList(NULL,
- theCreateIndexList,
- otherp->theCreateIndexList,
- UP_LIST_CREATE_INDEX);
-
- mergeUpdateList(NULL,
- theDeleteIndexList,
- otherp->theDeleteIndexList,
- UP_LIST_NONE);
-
- mergeUpdateList(NULL,
- theRefreshIndexList,
- otherp->theRefreshIndexList,
- UP_LIST_NONE);
-
- mergeUpdateList(NULL,
- theICActivationList,
- otherp->theICActivationList,
- UP_LIST_NONE);
+ theCreateIndexList,
+ otherp->theCreateIndexList,
+ UP_LIST_CREATE_INDEX);
+
+ mergeUpdateList(NULL,
+ theDeleteIndexList,
+ otherp->theDeleteIndexList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(NULL,
+ theRefreshIndexList,
+ otherp->theRefreshIndexList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(NULL,
+ theICActivationList,
+ otherp->theICActivationList,
+ UP_LIST_NONE);
// merge document primitives
mergeUpdateList(NULL,
- theCreateDocumentList,
- otherp->theCreateDocumentList,
- UP_LIST_NONE);
+ theCreateDocumentList,
+ otherp->theCreateDocumentList,
+ UP_LIST_NONE);
mergeUpdateList(NULL,
- theDeleteDocumentList,
- otherp->theDeleteDocumentList,
- UP_LIST_NONE);
+ theDeleteDocumentList,
+ otherp->theDeleteDocumentList,
+ UP_LIST_NONE);
// merge hashmap primitives
mergeUpdateList(NULL,
- theCreateHashMapList,
- otherp->theCreateHashMapList,
- UP_LIST_NONE);
-
- mergeUpdateList(NULL,
- theDestroyHashMapList,
- otherp->theDestroyHashMapList,
- UP_LIST_NONE);
-
- mergeUpdateList(NULL,
- theInsertIntoHashMapList,
- otherp->theInsertIntoHashMapList,
- UP_LIST_NONE);
-
- mergeUpdateList(NULL,
- theRemoveFromHashMapList,
- otherp->theRemoveFromHashMapList,
- UP_LIST_NONE);
+ theCreateHashMapList,
+ otherp->theCreateHashMapList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(NULL,
+ theDestroyHashMapList,
+ otherp->theDestroyHashMapList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(NULL,
+ theInsertIntoHashMapList,
+ otherp->theInsertIntoHashMapList,
+ UP_LIST_NONE);
+
+ mergeUpdateList(NULL,
+ theRemoveFromHashMapList,
+ otherp->theRemoveFromHashMapList,
+ UP_LIST_NONE);
// merge validation primitives
mergeUpdateList(NULL,
- theValidationList,
- otherp->theValidationList,
- UP_LIST_NONE);
+ theValidationList,
+ otherp->theValidationList,
+ UP_LIST_NONE);
}
@@ -1294,9 +1310,9 @@
if (upd->getName()->equals(otherUpd->getName()))
{
throw XQUERY_EXCEPTION(
- zerr::ZDDY0016_COLLECTION_MULTIPLE_CREATES,
- ERROR_PARAMS( upd->getName()->getStringValue() ),
- ERROR_LOC( *upd->theLoc )
+ zerr::ZDDY0016_COLLECTION_MULTIPLE_CREATES,
+ ERROR_PARAMS( upd->getName()->getStringValue() ),
+ ERROR_LOC( *upd->theLoc )
);
}
}
@@ -1313,9 +1329,9 @@
if (upd->getName()->equals(otherUpd->getName()))
{
throw XQUERY_EXCEPTION(
- zerr::ZDDY0027_INDEX_MULTIPLE_CREATES,
- ERROR_PARAMS( upd->getName()->getStringValue() ),
- ERROR_LOC( *upd->theLoc )
+ zerr::ZDDY0027_INDEX_MULTIPLE_CREATES,
+ ERROR_PARAMS( upd->getName()->getStringValue() ),
+ ERROR_LOC( *upd->theLoc )
);
}
}
@@ -1340,8 +1356,8 @@
NodeUpdates* targetUpdates = NULL;
bool found = (target == NULL || myPul == NULL?
- false :
- myPul->theNodeToUpdatesMap.get(target, targetUpdates));
+ false :
+ myPul->theNodeToUpdatesMap.get(target, targetUpdates));
if (!found)
{
@@ -1359,81 +1375,81 @@
{
switch (listKind)
{
- case UP_LIST_DO_FIRST:
- {
- if (store::UpdateConsts::isRename(updKind))
- {
- ulong numTargetUpdates = (ulong)targetUpdates->size();
- for (ulong j = 0; j < numTargetUpdates; j++)
- {
- if (store::UpdateConsts::isRename((*targetUpdates)[j]->getKind()))
- throw XQUERY_EXCEPTION(err::XUDY0015,
- ERROR_LOC((*targetUpdates)[j]->theLoc));
- }
- }
- else if (store::UpdateConsts::isReplaceValue(updKind))
- {
- csize numTargetUpdates = targetUpdates->size();
- for (csize j = 0; j < numTargetUpdates; j++)
- {
- if (store::UpdateConsts::isReplaceValue((*targetUpdates)[j]->getKind()))
- throw XQUERY_EXCEPTION(err::XUDY0017,
- ERROR_LOC((*targetUpdates)[j]->theLoc));
- }
- }
- break;
- }
- case UP_LIST_REPLACE_NODE:
- {
- if (store::UpdateConsts::isReplaceNode(updKind))
- {
- csize numTargetUpdates = (ulong)targetUpdates->size();
- for (csize j = 0; j < numTargetUpdates; ++j)
- {
- if (store::UpdateConsts::isReplaceNode((*targetUpdates)[j]->getKind()))
- throw XQUERY_EXCEPTION(err::XUDY0016,
- ERROR_LOC((*targetUpdates)[j]->theLoc));
- }
- }
- break;
- }
- case UP_LIST_REPLACE_CONTENT:
- {
- if (updKind == store::UpdateConsts::UP_REPLACE_CONTENT)
- {
- csize numTargetUpdates = targetUpdates->size();
- for (csize j = 0; j < numTargetUpdates; ++j)
- {
- if ((*targetUpdates)[j]->getKind() == store::UpdateConsts::UP_REPLACE_CONTENT)
- throw XQUERY_EXCEPTION(err::XUDY0017,
- ERROR_LOC((*targetUpdates)[j]->theLoc));
- }
- }
- break;
- }
- case UP_LIST_DELETE:
- {
- if (updKind == store::UpdateConsts::UP_DELETE)
- {
- csize numTargetUpdates = targetUpdates->size();
- csize j;
- for (j = 0; j < numTargetUpdates; ++j)
- {
- if ((*targetUpdates)[j]->getKind() == store::UpdateConsts::UP_DELETE)
- break;
- }
+ case UP_LIST_DO_FIRST:
+ {
+ if (store::UpdateConsts::isRename(updKind))
+ {
+ ulong numTargetUpdates = (ulong)targetUpdates->size();
+ for (ulong j = 0; j < numTargetUpdates; j++)
+ {
+ if (store::UpdateConsts::isRename((*targetUpdates)[j]->getKind()))
+ throw XQUERY_EXCEPTION(err::XUDY0015,
+ ERROR_LOC((*targetUpdates)[j]->theLoc));
+ }
+ }
+ else if (store::UpdateConsts::isReplaceValue(updKind))
+ {
+ csize numTargetUpdates = targetUpdates->size();
+ for (csize j = 0; j < numTargetUpdates; j++)
+ {
+ if (store::UpdateConsts::isReplaceValue((*targetUpdates)[j]->getKind()))
+ throw XQUERY_EXCEPTION(err::XUDY0017,
+ ERROR_LOC((*targetUpdates)[j]->theLoc));
+ }
+ }
+ break;
+ }
+ case UP_LIST_REPLACE_NODE:
+ {
+ if (store::UpdateConsts::isReplaceNode(updKind))
+ {
+ csize numTargetUpdates = (ulong)targetUpdates->size();
+ for (csize j = 0; j < numTargetUpdates; ++j)
+ {
+ if (store::UpdateConsts::isReplaceNode((*targetUpdates)[j]->getKind()))
+ throw XQUERY_EXCEPTION(err::XUDY0016,
+ ERROR_LOC((*targetUpdates)[j]->theLoc));
+ }
+ }
+ break;
+ }
+ case UP_LIST_REPLACE_CONTENT:
+ {
+ if (updKind == store::UpdateConsts::UP_REPLACE_CONTENT)
+ {
+ csize numTargetUpdates = targetUpdates->size();
+ for (csize j = 0; j < numTargetUpdates; ++j)
+ {
+ if ((*targetUpdates)[j]->getKind() == store::UpdateConsts::UP_REPLACE_CONTENT)
+ throw XQUERY_EXCEPTION(err::XUDY0017,
+ ERROR_LOC((*targetUpdates)[j]->theLoc));
+ }
+ }
+ break;
+ }
+ case UP_LIST_DELETE:
+ {
+ if (updKind == store::UpdateConsts::UP_DELETE)
+ {
+ csize numTargetUpdates = targetUpdates->size();
+ csize j;
+ for (j = 0; j < numTargetUpdates; ++j)
+ {
+ if ((*targetUpdates)[j]->getKind() == store::UpdateConsts::UP_DELETE)
+ break;
+ }
- if (j < numTargetUpdates)
- {
- delete otherUpd;
- otherList[i] = NULL;
- continue;
+ if (j < numTargetUpdates)
+ {
+ delete otherUpd;
+ otherList[i] = NULL;
+ continue;
+ }
}
+ break;
}
- break;
- }
- default:
- break;
+ default:
+ break;
}
myList.push_back(otherUpd);
@@ -1450,7 +1466,7 @@
Check that each target node of this pul is inside one of the trees rooted at
the given root nodes (the root nodes are the copies of the nodes produced by
the source expr of a transform expr).
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::checkTransformUpdates(const std::vector<store::Item*>& rootNodes) const
{
ulong numRoots = (ulong)rootNodes.size();
@@ -1474,7 +1490,7 @@
for (ulong i = 0; i < numRoots; i++)
{
XmlNode* rootNode = reinterpret_cast<XmlNode*>(rootNodes[i]);
-
+
if (targetNode->getTree() == rootNode->getTree())
{
found = true;
@@ -1500,7 +1516,7 @@
This method is invoked by the ApplyIterator before any of the pul primitives
is applied.
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::getIndicesToRefresh(std::vector<store::Index*>& indices)
{
SimpleStore* store = &GET_STORE();
@@ -1541,7 +1557,7 @@
for (csize i = 0; i < numCollUpdates; ++i)
{
UpdCollection* upd = static_cast<UpdCollection*>
- (pul->theInsertIntoCollectionList[i]);
+ (pul->theInsertIntoCollectionList[i]);
csize numDocs = upd->numNodes();
for (csize j = 0; j < numDocs; ++j)
@@ -1553,7 +1569,7 @@
for (csize i = 0; i < numCollUpdates; ++i)
{
UpdCollection* upd = static_cast<UpdCollection*>
- (pul->theDeleteFromCollectionList[i]);
+ (pul->theDeleteFromCollectionList[i]);
csize numDocs = upd->numNodes();
for (csize j = 0; j < numDocs; ++j)
@@ -1600,7 +1616,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::addIndexEntryCreator(
const store::Item* collectionName,
store::Index* idx,
@@ -1615,7 +1631,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::setICChecker(store::ICChecker* icChecker)
{
theICChecker = icChecker;
@@ -1624,7 +1640,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::checkIC(const store::Item* collName)
{
theICChecker->check(collName);
@@ -1633,7 +1649,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::applyUpdates(bool inheritNSBindings)
{
CollectionPulMap::iterator collIte = theCollectionPuls.begin();
@@ -1725,12 +1741,13 @@
{
ZORBA_FATAL(0, "Unexpected error during application of integrity constraint PUL");
}
+ theIsApplied=true;
}
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void PULImpl::undoUpdates()
{
try
@@ -1766,23 +1783,104 @@
}
}
-
-/*******************************************************************************
-
-********************************************************************************/
+/*******************************************************************************
+
+ ********************************************************************************/
+void PULImpl::accept(store::PULVisitor* aVisitor)
+{
+ PULEncodingVisitor* lVisitor=static_cast<PULEncodingVisitor*>(aVisitor);
+ switch (aVisitor->getVisitorKind())
+ {
+ case store::PULVisitor::SIMPLE_PUL_ENCODER:
+ {
+ //These are unsupported, will raise an error if non empty
+ acceptList(theRefreshIndexList,lVisitor);
+ acceptList(theCreateIndexList,lVisitor);
+ acceptList(theDeleteIndexList,lVisitor);
+
+ CollectionPulMap::iterator collIte = theCollectionPuls.begin();
+ CollectionPulMap::iterator collEnd = theCollectionPuls.end();
+
+ for (; collIte != collEnd; ++collIte)
+ {
+ CollectionPul* pul = collIte->second;
+ pul->accept(lVisitor,theIsApplied);
+ }
+ acceptList(thePutList,lVisitor);
+
+ acceptList(theRefreshIndexList,lVisitor);
+ acceptList(theCreateIndexList,lVisitor);
+ acceptList(theDeleteIndexList,lVisitor);
+
+ acceptList(theCreateDocumentList,lVisitor);
+ acceptList(theDeleteDocumentList,lVisitor);
+ acceptList(theCreateHashMapList,lVisitor);
+ acceptList(theDestroyHashMapList,lVisitor);
+ acceptList(theInsertIntoHashMapList,lVisitor);
+ acceptList(theRemoveFromHashMapList,lVisitor);
+
+ acceptList(theValidationList,lVisitor);
+ acceptList(theICActivationList,lVisitor);
+ break;
+ }
+ case store::PULVisitor::COMPLETE_PUL_ENCODER:
+ {
+ if (!theIsApplied)
+ {
+ //These are unsupported, will raise an error if non empty
+ acceptList(theRefreshIndexList,lVisitor);
+ acceptList(theCreateIndexList,lVisitor);
+ acceptList(theDeleteIndexList,lVisitor);
+ }
+
+ CollectionPulMap::iterator collIte = theCollectionPuls.begin();
+ CollectionPulMap::iterator collEnd = theCollectionPuls.end();
+
+ for (; collIte != collEnd; ++collIte)
+ {
+ CollectionPul* pul = collIte->second;
+ pul->accept(lVisitor,theIsApplied);
+ }
+
+ if (theIsApplied)
+ {
+ acceptList(thePutList,lVisitor);
+
+ acceptList(theCreateDocumentList,lVisitor);
+ acceptList(theDeleteDocumentList,lVisitor);
+ acceptList(theCreateHashMapList,lVisitor);
+ acceptList(theDestroyHashMapList,lVisitor);
+ acceptList(theInsertIntoHashMapList,lVisitor);
+ acceptList(theRemoveFromHashMapList,lVisitor);
+#ifdef PUL_SETTYPE
+ acceptList(theValidationList,lVisitor);
+#endif
+ acceptList(theICActivationList,lVisitor);
+ }
+ break;
+ }
+ default:
+ ZORBA_FATAL(0,"Unknown PUL visitor");
+ }
+}
+
+
+/*******************************************************************************
+
+ ********************************************************************************/
CollectionPul::CollectionPul(PULImpl* pul, SimpleCollection* collection)
- :
- theCollection(collection),
- thePul(pul),
- theAdjustTreePositions(false),
- theIsApplied(false)
+:
+ theCollection(collection),
+ thePul(pul),
+ theAdjustTreePositions(false),
+ theIsApplied(false)
{
}
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
CollectionPul::~CollectionPul()
{
cleanList(theDoFirstList);
@@ -1806,7 +1904,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::switchPul(PULImpl* pul)
{
thePul = pul;
@@ -1837,9 +1935,9 @@
/*******************************************************************************
The comparison function for sorting the entries of an IndexDelta by the doc node
-********************************************************************************/
+ ********************************************************************************/
static bool cmp(const std::pair<store::Item_t, store::IndexKey*>& e1,
- const std::pair<store::Item_t, store::IndexKey*>& e2)
+ const std::pair<store::Item_t, store::IndexKey*>& e2)
{
return e1.first.getp() < e2.first.getp();
}
@@ -1848,7 +1946,7 @@
/*******************************************************************************
Compute the index contents on the modified docs, before any modifications
are actually applied.
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::computeIndexBeforeDeltas()
{
computeIndexDeltas(theBeforeIndexDeltas);
@@ -1859,7 +1957,7 @@
Compute the index contents on the modified docs, after the modifications
are actually applied. Also, compute the index contents on the newly inserted
and the deleted docs.
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::computeIndexAfterDeltas()
{
computeIndexDeltas(theAfterIndexDeltas);
@@ -1907,7 +2005,7 @@
For each incrementally maintained index I and each collection doc D that is
modified by this pul, compute the index entries for I and D, and insert them
into the given deltas vector
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::computeIndexDeltas(std::vector<store::IndexDelta>& deltas)
{
ulong numIncrementalIndices = (ulong)theIncrementalIndices.size();
@@ -1942,7 +2040,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::refreshIndices()
{
csize numIncrementalIndices = theIncrementalIndices.size();
@@ -1955,9 +2053,9 @@
// Referesh the index w.r.t. modified docs.
//
ValueIndexCompareFunction keyCmp(index->getNumColumns(),
- index->getTimezone(),
- index->getCollations());
-
+ index->getTimezone(),
+ index->getCollations());
+
store::IndexDelta& beforeDelta = theBeforeIndexDeltas[idx];
store::IndexDelta& afterDelta = theAfterIndexDeltas[idx];
store::IndexDelta& insertedDelta = theInsertedDocsIndexDeltas[idx];
@@ -2035,7 +2133,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::applyUpdates()
{
// Don't apply anything if the collection is going to be deleted.
@@ -2110,7 +2208,7 @@
if (thePul->theValidator != NULL && !theValidationNodes.empty())
{
theValidationPul = GET_STORE().getItemFactory()->createPendingUpdateList();
-
+
thePul->theValidator->validate(theValidationNodes, *theValidationPul.getp());
try
@@ -2160,7 +2258,7 @@
have been executed already. This separation of actions into ones that may
raise errors and other that never raise errors makes it easier to implement
the undo actions for certain operations.
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::finalizeUpdates()
{
try
@@ -2257,7 +2355,7 @@
/*******************************************************************************
-********************************************************************************/
+ ********************************************************************************/
void CollectionPul::undoUpdates()
{
if (!theIsApplied)
@@ -2308,6 +2406,75 @@
}
}
+/*******************************************************************************
+
+ ********************************************************************************/
+void CollectionPul::accept(PULEncodingVisitor* aVisitor, bool isApplied)
+{
+ switch (aVisitor->getVisitorKind())
+ {
+ case store::PULVisitor::SIMPLE_PUL_ENCODER:
+ {
+ if (!theDeleteCollectionList.empty())
+ {
+ acceptList(theDeleteCollectionList, aVisitor);
+ return;
+ }
+ acceptList(theDoFirstList, aVisitor);
+ acceptList(theInsertList, aVisitor);
+ acceptList(theReplaceNodeList, aVisitor);
+ acceptList(theReplaceContentList, aVisitor);
+ acceptList(theDeleteList, aVisitor);
+ acceptList(theCreateCollectionList, aVisitor);
+ acceptList(theInsertIntoCollectionList, aVisitor);
+ acceptList(theDeleteFromCollectionList, aVisitor);
+ acceptList(theDeleteCollectionList, aVisitor);
+ acceptList(theRevalidateList, aVisitor);
+ break;
+ }
+ case store::PULVisitor::COMPLETE_PUL_ENCODER:
+ {
+ CompletePULVisitorImpl* lVisitor=static_cast<CompletePULVisitorImpl*>(aVisitor);
+ std::vector<TextNodeMerge>::iterator iter= theMergeList.begin();
+ std::vector<TextNodeMerge>::iterator end= theMergeList.end();
+ if (isApplied)
+ {
+ if (!theDeleteCollectionList.empty())
+ {
+ acceptList(theDeleteCollectionList, aVisitor);
+ return;
+ }
+ for (; iter!=end;++iter)
+ lVisitor->visitMerge((*iter).theParent,(*iter).thePos,(*iter).theMergedNodes);
+ lVisitor->visitNodeUpdatesMap(theNodeToUpdatesMap);
+ acceptList(theDeleteFromCollectionList, lVisitor);
+ acceptList(theDeleteCollectionList, lVisitor);
+#ifdef PUL_SETTYPE
+ if (theValidationPul)
+ theValidationPul->accept(lVisitor);
+#endif
+ acceptList(theRevalidateList, lVisitor);
+ }
+ else
+ {
+ if (!theDeleteCollectionList.empty())
+ return;
+
+ acceptList(theDoFirstList, lVisitor);
+ acceptList(theInsertList, lVisitor);
+ acceptList(theReplaceNodeList, lVisitor);
+ acceptList(theReplaceContentList, lVisitor);
+ acceptList(theDeleteList, lVisitor);
+ acceptList(theCreateCollectionList, lVisitor);
+ acceptList(theInsertIntoCollectionList, lVisitor);
+ acceptList(theDeleteFromCollectionList, lVisitor);
+ }
+ break;
+ }
+ default:
+ ZORBA_FATAL(0,"Unknown PUL visitor");
+ }
+}
} // namespace simplestore
} // namespace zorba
=== modified file 'src/store/naive/simple_pul.h'
--- src/store/naive/simple_pul.h 2011-10-12 20:59:49 +0000
+++ src/store/naive/simple_pul.h 2012-01-02 09:53:25 +0000
@@ -44,6 +44,7 @@
class PULImpl;
class QNameItem;
class SimpleCollection;
+class PULEncodingVisitor;
class InternalNode;
class TextNode;
@@ -225,6 +226,8 @@
void addToCheckForMerge(InternalNode* parent) { theMergeToCheckSet.insert(parent); }
+ void accept(PULEncodingVisitor* visitor, bool isApplied);
+
protected:
void switchPulInPrimitivesList(std::vector<UpdatePrimitive*>& list);
@@ -257,6 +260,8 @@
{
friend class CollectionPul;
friend class UpdRevalidate;
+ friend class CompletePULVisitorImpl;
+ friend class XDMPULVisitorImpl;
public:
enum UpdListKind
@@ -311,6 +316,8 @@
bool theInheritNSBindings;
+ bool theIsApplied;
+
public:
PULImpl();
@@ -556,6 +563,7 @@
void checkIC(const store::Item* collName);
+ void accept(store::PULVisitor * visitor);
protected:
void mergeUpdateList(
=== added file 'src/store/naive/simple_pul_visitor_factory.cpp'
--- src/store/naive/simple_pul_visitor_factory.cpp 1970-01-01 00:00:00 +0000
+++ src/store/naive/simple_pul_visitor_factory.cpp 2012-01-02 09:53:25 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "stdafx.h"
+
+#include "store/naive/simple_pul_visitor_factory.h"
+#include "store/naive/pul_visitors.h"
+
+
+namespace zorba { namespace simplestore {
+
+
+store::PULVisitor* SimplePULVisitorFactory::createSimplePULVisitor(store::Item_t& result, bool willBeEncoded)
+{
+ return static_cast<store::PULVisitor*>(new SimplePULVisitorImpl(result,willBeEncoded));
+}
+
+store::PULVisitor* SimplePULVisitorFactory::createCompletePULVisitor(store::Item_t& result)
+{
+ return static_cast<store::PULVisitor*>(new CompletePULVisitorImpl(result));
+}
+
+store::PULVisitor* SimplePULVisitorFactory::createXDMPULVisitor(store::PUL_t& result, static_context * sctx)
+{
+ return static_cast<store::PULVisitor*>(new XDMPULVisitorImpl(result,sctx));
+}
+
+store::PULVisitor* SimplePULVisitorFactory::createXDMPULVisitor(store::PUL_t& result,static_context * sctx, store::Item_t referenceIndexName)
+{
+ return static_cast<store::PULVisitor*>(new XDMPULVisitorImpl(result,sctx, referenceIndexName));
+}
+
+store::PULVisitor* SimplePULVisitorFactory::createXMLPULVisitor(static_context * sctx, bool restoreTypes)
+{
+ return static_cast<store::PULVisitor*>(new XMLPULVisitorImpl(sctx,restoreTypes));
+}
+
+} // namespace store
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
=== added file 'src/store/naive/simple_pul_visitor_factory.h'
--- src/store/naive/simple_pul_visitor_factory.h 1970-01-01 00:00:00 +0000
+++ src/store/naive/simple_pul_visitor_factory.h 2012-01-02 09:53:25 +0000
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2006-2011 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_SIMPLE_STORE_PULVISITOR_FACTORY
+#define ZORBA_SIMPLE_STORE_PULVISITOR_FACTORY
+
+#include "store/api/pul_visitor_factory.h"
+
+
+namespace zorba
+{
+
+namespace simplestore
+{
+
+
+class SimplePULVisitorFactory : public store::PULVisitorFactory
+{
+public:
+ ~SimplePULVisitorFactory() { }
+
+ /**
+ * Creates a PUL visitor which generates a representation of a PUL
+ * before its application. If willBeEncoded is true, the identifiers of
+ * the nodes are duplicated.
+ */
+ store::PULVisitor* createSimplePULVisitor(store::Item_t& result, bool willBeEncoded);
+
+ /**
+ * Creates a PUL visitor which generates a representation of a PUL
+ * after its application, including undo information.
+ */
+ store::PULVisitor* createCompletePULVisitor(store::Item_t& result);
+
+ /**
+ * Creates an XDM PUL visitor which parses an XDM PUL representation.
+ */
+ store::PULVisitor* createXDMPULVisitor(store::PUL_t& result, static_context * sctx);
+
+ /**
+ * Creates an XDM PUL visitor which parses an XDM PUL representation.
+ * The name of an index from node references to nodes is provided.
+ */
+ store::PULVisitor* createXDMPULVisitor(store::PUL_t& result, static_context * sctx, store::Item_t referenceIndexName);
+
+ /**
+ * Creates an XML PUL visitor which parses an XML PUL representation.
+ */
+ store::PULVisitor* createXMLPULVisitor(static_context * sctx, bool restoreTypes);
+};
+
+}
+}
+#endif
+/* vim:set et sw=2 ts=2: */
=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp 2011-12-22 14:14:53 +0000
+++ src/store/naive/simple_store.cpp 2012-01-02 09:53:25 +0000
@@ -49,6 +49,7 @@
#include "store/naive/node_iterators.h"
#include "store/naive/simple_item_factory.h"
#include "store/naive/simple_iterator_factory.h"
+#include "store/naive/simple_pul_visitor_factory.h"
#include "store/naive/query_context.h"
#include "store/naive/item_iterator.h"
#include "store/naive/node_factory.h"
@@ -101,6 +102,7 @@
theIteratorFactory(NULL),
theNodeFactory(NULL),
thePULFactory(NULL),
+ thePULVisitorFactory(NULL),
theDocuments(CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true),
theCollections(0),
theIndices(0, NULL, CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true),
@@ -169,6 +171,8 @@
thePULFactory = createPULPrimitiveFactory();
+ thePULVisitorFactory = new SimplePULVisitorFactory();
+
theTraceLevel = store::Properties::instance()->storeTraceLevel();
theCollections = createCollectionSet();
@@ -337,6 +341,12 @@
theNodeFactory = NULL;
}
+ if (thePULVisitorFactory != NULL)
+ {
+ delete thePULVisitorFactory;
+ thePULVisitorFactory = NULL;
+ }
+
if (theNodeToReferencesMap.size() > 0)
{
NodeRefMap::iterator iter = theNodeToReferencesMap.begin();
@@ -1304,6 +1314,95 @@
/*******************************************************************************
+ Returns the already computed reference of the given node.
+
+ @param result reference as an item of type xs:string
+ @param node XDM node
+ @return whether the reference has been created successfully
+********************************************************************************/
+bool SimpleStore::getCurrentReference(store::Item_t& result, const store::Item* node)
+{
+ const XmlNode* xmlNode = static_cast<const XmlNode*>(node);
+ assert(xmlNode->haveReference());
+
+ NodeRefMap::iterator resIt = theNodeToReferencesMap.find(xmlNode);
+
+ ZORBA_FATAL(resIt != theNodeToReferencesMap.end(),"Node reference cannot be found");
+
+ zstring id = (*resIt).second;
+ return theItemFactory->createAnyURI(result, id);
+}
+
+
+/*******************************************************************************
+ Copies the reference of a source node to a target node. The source
+ node must already have a reference. The target nodes acquires the
+ source reference but it is not registered in the reference-to-node
+ map.
+
+ Used in PUL manipulation.
+
+ @param source source XDM node
+ @param target target XDM node
+********************************************************************************/
+void SimpleStore::copyReference(const XmlNode* source, XmlNode* target)
+{
+ store::Item_t reference;
+ getCurrentReference(reference, source);
+
+ unregisterNode(target);
+
+ target->setHaveReference();
+
+ zstring refStr;
+ reference->getStringValue2(refStr);
+
+ theNodeToReferencesMap.insert(target, refStr);
+}
+
+
+/*******************************************************************************
+ Sets the reference of a node to a given value.
+ Used in PUL manipulation.
+
+ @param node XDM node
+ @param reference the reference to set
+********************************************************************************/
+void SimpleStore::restoreReference(XmlNode* node, const zstring& reference)
+{
+ unregisterNode(node);
+ theNodeToReferencesMap.insert(std::pair<const XmlNode*, zstring>(node, reference));
+
+ node->setHaveReference();
+ registerReference(node);
+}
+
+
+/*******************************************************************************
+ Register the reference of a given node in the references to node map
+ The node must already have an reference.
+ The node reference must not be used for any other
+ node in the reference-to-node map, otherwise error ZAPI0029 is raised.
+ Used in PUL manipulation.
+
+ @param node XDM node
+********************************************************************************/
+void SimpleStore::registerReference(XmlNode* node)
+{
+ store::Item_t reference;
+ getCurrentReference(reference, node);
+
+ store::Item_t result;
+ if (getNodeByReference(result, reference->getStringValue()))
+ {
+ throw ZORBA_EXCEPTION(zerr::ZAPI0029_REFERENCE_ALREADY_PRESENT,
+ ERROR_PARAMS(reference->getStringValue()));
+ }
+
+ theReferencesToNodeMap[reference->getStringValue()] = node;
+}
+
+/*******************************************************************************
Computes the Structural Reference for the given node.
********************************************************************************/
bool SimpleStore::getStructuralInformation(
=== modified file 'src/store/naive/simple_store.h'
--- src/store/naive/simple_store.h 2011-12-21 14:40:33 +0000
+++ src/store/naive/simple_store.h 2012-01-02 09:53:25 +0000
@@ -46,6 +46,7 @@
{
class IteratorFactory;
class ValueIndexSpecification;
+ class PULVisitorFactory;
}
namespace simplestore
@@ -139,6 +140,7 @@
store::IteratorFactory * theIteratorFactory;
NodeFactory * theNodeFactory;
PULPrimitiveFactory * thePULFactory;
+ store::PULVisitorFactory * thePULVisitorFactory;
DocumentSet theDocuments;
CollectionSet* theCollections;
@@ -165,6 +167,8 @@
store::IteratorFactory* getIteratorFactory() const { return theIteratorFactory; }
+ store::PULVisitorFactory* getPULVisitorFactory() const { return thePULVisitorFactory; };
+
NodeFactory& getNodeFactory() const { return *theNodeFactory; }
PULPrimitiveFactory& getPULFactory() const { return *thePULFactory; }
@@ -333,12 +337,20 @@
bool getNodeReference(store::Item_t& result, store::Item* node);
+ bool getCurrentReference(store::Item_t& result, const store::Item* node);
+
bool hasReference(const store::Item* node);
bool getNodeByReference(store::Item_t& result, const zstring& reference);
bool unregisterNode(XmlNode* node);
+ void copyReference(const XmlNode* source, XmlNode* target);
+
+ void restoreReference(XmlNode* node, const zstring& reference);
+
+ void registerReference(XmlNode* node);
+
/* ------------------------ Temp Sequence Management ---------------------------*/
store::TempSeq_t createTempSeq(bool lazy);
=== modified file 'src/system/globalenv.cpp'
--- src/system/globalenv.cpp 2011-12-22 14:14:53 +0000
+++ src/system/globalenv.cpp 2012-01-02 09:53:25 +0000
@@ -300,6 +300,11 @@
return m_store->getIteratorFactory();
}
+store::PULVisitorFactory* GlobalEnvironment::getPULVisitorFactory()
+{
+ return m_store->getPULVisitorFactory();
+}
+
XQueryCompilerSubsystem& GlobalEnvironment::getCompilerSubsystem()
{
=== modified file 'src/system/globalenv.h'
--- src/system/globalenv.h 2011-12-21 14:40:33 +0000
+++ src/system/globalenv.h 2012-01-02 09:53:25 +0000
@@ -101,6 +101,8 @@
store::ItemFactory* getItemFactory();
+ store::PULVisitorFactory* getPULVisitorFactory();
+
store::IteratorFactory* getIteratorFactory();
internal::HTTPURLResolver* getHTTPURLResolver() const { return m_http_resolver; }
@@ -140,6 +142,8 @@
#define GENV_ITERATOR_FACTORY GlobalEnvironment::getInstance().getIteratorFactory()
+#define GENV_PUL_VISITOR_FACTORY GlobalEnvironment::getInstance().getPULVisitorFactory()
+
#define GENV_ROOT_STATIC_CONTEXT GlobalEnvironment::getInstance().getRootStaticContext()
#define GENV_DYNAMIC_LOADER GlobalEnvironment::getInstance().getDynamicLoader()
=== modified file 'src/types/schema/XercSchemaValidator.cpp'
--- src/types/schema/XercSchemaValidator.cpp 2011-06-14 17:26:33 +0000
+++ src/types/schema/XercSchemaValidator.cpp 2012-01-02 09:53:25 +0000
@@ -123,7 +123,11 @@
// to do to validate it.
//
// the top of the type stack always knows best...
- ComplexTypeInfo* currType = fTypeStack->pop();
+ ComplexTypeInfo* currType;
+ if (fTypeStack->size()>0)
+ currType = fTypeStack->pop();
+ else
+ currType=NULL;
const SchemaElementDecl::ModelTypes modelType = (currType)
? (SchemaElementDecl::ModelTypes)(currType->getContentType())
=== modified file 'src/types/schema/revalidateUtils.cpp'
--- src/types/schema/revalidateUtils.cpp 2011-07-01 05:22:12 +0000
+++ src/types/schema/revalidateUtils.cpp 2012-01-02 09:53:25 +0000
@@ -64,6 +64,78 @@
#endif
}
+#ifndef ZORBA_NO_XMLSCHEMA
+bool SchemaValidatorImpl::validateElementByTypeName(
+ store::Item* item,
+ store::Item* typeQName,
+ store::PUL& pul)
+{
+ ZORBA_ASSERT(item->isNode());
+
+ TypeManager* typeManager = theSctx->get_typemanager();
+
+ Schema* schema = typeManager->getSchema();
+
+ if ( !schema || typeManager->create_named_type(typeQName)==NULL )
+ {
+ return false;
+ }
+
+ bool isLax=true;
+
+ QueryLoc loc=QueryLoc::null;
+ EventSchemaValidator schemaValidator =
+ EventSchemaValidator(typeManager,
+ schema->getGrammarPool(),
+ isLax,
+ theLoc);
+
+ switch ( item->getNodeKind() )
+ {
+ case store::StoreConsts::documentNode:
+ {
+ schemaValidator.startType(typeQName);
+
+ store::NsBindings bindings;
+ namespace_context nsCtx = namespace_context(theSctx, bindings);
+
+ std::vector<store::Item_t> typedValues;
+ processChildren(&pul,
+ nsCtx,
+ typeManager,
+ schemaValidator,
+ item->getChildren(),
+ typedValues,
+ loc);
+
+ schemaValidator.endType();
+
+ return true;
+ }
+ case store::StoreConsts::elementNode:
+ {
+
+ schemaValidator.startType(typeQName);
+
+ processElement(&pul,
+ typeManager,
+ schemaValidator,
+ item,
+ loc);
+
+ schemaValidator.endType();
+
+ return true;
+ }
+ default:
+ throw XQUERY_EXCEPTION(
+ err::XQDY0061,
+ ERROR_PARAMS( ZED( NotDocOrElementNode ) ),
+ ERROR_LOC( theLoc )
+ );
+ }
+}
+#endif
#ifndef ZORBA_NO_XMLSCHEMA
void SchemaValidatorImpl::validateAfterUpdate(
@@ -612,7 +684,7 @@
schemaTypeCode==TypeConstants::XS_IDREF )
return false;
else
- return false; //true;
+ return true;
}
if ( schemaType->type_kind()==XQType::USER_DEFINED_KIND )
=== modified file 'src/types/schema/revalidateUtils.h'
--- src/types/schema/revalidateUtils.h 2011-07-28 19:36:33 +0000
+++ src/types/schema/revalidateUtils.h 2012-01-02 09:53:25 +0000
@@ -71,6 +71,16 @@
zstring newValue,
std::vector<store::Item_t>& resultList);
+ /**
+ * Validates a single element node respect to the indicated type definition.
+ * An error is thrown in case of invalid content.
+ * Returns false if the specified type definition cannot be found, true otherwise.
+ */
+ bool validateElementByTypeName(
+ store::Item* element,
+ store::Item* typeQName,
+ store::PUL& pul);
+
#else
void validate(
const std::set<store::Item*>& nodes,
@@ -89,6 +99,13 @@
std::vector<store::Item_t>& resultList)
{
}
+
+ void validateElementByTypeName(
+ store::Item* element,
+ store::Item* typeQName,
+ store::PUL& pul)
+ {
+ }
#endif //ZORBA_NO_XMLSCHEMA
private:
=== modified file 'src/types/typeimpl.h'
--- src/types/typeimpl.h 2011-07-01 05:22:12 +0000
+++ src/types/typeimpl.h 2012-01-02 09:53:25 +0000
@@ -550,6 +550,8 @@
store::Item* get_node_name() const { return m_node_name.getp(); }
+ store::Item_t get_qname() const { return store::ItemHandle<store::Item>(m_node_name.getp()); }
+
bool is_schema_test() const { return m_schema_test; }
xqtref_t get_content_type() const { return m_content_type; }
=== added directory 'test/rbkt/ExpQueryResults/zorba/pul'
=== added directory 'test/rbkt/ExpQueryResults/zorba/pul/errors'
=== added file 'test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_1.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_1.xml.res 2012-01-02 09:53:25 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+a zerr:ZDDY0004 a zerr:ZDDY0005 a zerr:ZDDY0006 b zerr:ZDDY0004 c zerr:ZDDY0004 c zerr:ZDDY0005 c zerr:ZDDY0006 d zerr:ZDDY0004 d zerr:ZDDY0005 d zerr:ZDDY0006<coll_1><x/><y/></coll_1><coll_2><x/><y/><b/></coll_2><coll_3><x/><y/><b/></coll_3>
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_2.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_2.xml.res 2012-01-02 09:53:25 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+a zerr:ZDDY0004 a zerr:ZDDY0007 a zerr:ZDDY0009<coll_1><a/><b/></coll_1><coll_2><a/><b/></coll_2><coll_3><c/><d/><e/><f/><g/><h/><i/><j/><k/></coll_3>
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_3.xml.res'
--- test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_3.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/pul/errors/pul_errors_modifiers_3.xml.res 2012-01-02 09:53:25 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+1 zerr:ZDDY0010 2 zerr:ZDDY0010 3 zerr:ZDDY0010 4 err:XUDY0009
\ No newline at end of file
=== added directory 'test/rbkt/ExpQueryResults/zorba/pul/namespaces'
=== added file 'test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_cxml.xml.res'
--- test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_cxml.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_cxml.xml.res 2012-01-02 09:53:25 +0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?processinginstruction someprocessinginstruction?><!-- This is a comment --><root>
+ <?processinginstruction someprocessinginstruction1?>
+ <?processinginstruction someprocessinginstruction2?>
+ <?processinginstruction someprocessinginstruction3?>
+ <?processinginstruction someprocessinginstruction4?>
+ <!-- This is a comment1 -->
+ <!-- This is a comment2 -->
+ <!-- This is a comment3 -->
+ <nonEmptyElement1 emptyAttribute2="" emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ <pul:e xmlns:pul="http://somethingpul"/><type:e xmlns:type="http://somethingtype"/><type:e xmlns:pul="http://somethingpul" xmlns:type="http://somethingtype" pul:pul="pul"/><pul:e xmlns:pul="http://somethingpul" xmlns:type="http://somethingtype" type:type="type"/></nonEmptyElement1>
+
+ <nonEmptyElement2 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement2>
+
+ <nonEmptyElement3 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement3>
+
+ <nonEmptyElement4 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement4>
+
+ <nonEmptyElement5 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement5>
+</root>
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_xdm.xml.res'
--- test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_xdm.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_xdm.xml.res 2012-01-02 09:53:25 +0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?processinginstruction someprocessinginstruction?><!-- This is a comment --><root>
+ <?processinginstruction someprocessinginstruction1?>
+ <?processinginstruction someprocessinginstruction2?>
+ <?processinginstruction someprocessinginstruction3?>
+ <?processinginstruction someprocessinginstruction4?>
+ <!-- This is a comment1 -->
+ <!-- This is a comment2 -->
+ <!-- This is a comment3 -->
+ <nonEmptyElement1 emptyAttribute2="" emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ <pul:e xmlns:pul="http://somethingpul"/><type:e xmlns:type="http://somethingtype"/><type:e xmlns:pul="http://somethingpul" xmlns:type="http://somethingtype" pul:pul="pul"/><pul:e xmlns:pul="http://somethingpul" xmlns:type="http://somethingtype" type:type="type"/></nonEmptyElement1>
+
+ <nonEmptyElement2 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement2>
+
+ <nonEmptyElement3 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement3>
+
+ <nonEmptyElement4 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement4>
+
+ <nonEmptyElement5 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement5>
+</root>
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_xml.xml.res'
--- test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_xml.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/pul/namespaces/pul_ns_collision_xml.xml.res 2012-01-02 09:53:25 +0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?processinginstruction someprocessinginstruction?><!-- This is a comment --><root>
+ <?processinginstruction someprocessinginstruction1?>
+ <?processinginstruction someprocessinginstruction2?>
+ <?processinginstruction someprocessinginstruction3?>
+ <?processinginstruction someprocessinginstruction4?>
+ <!-- This is a comment1 -->
+ <!-- This is a comment2 -->
+ <!-- This is a comment3 -->
+ <nonEmptyElement1 emptyAttribute2="" emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ <pul:e xmlns:pul="http://somethingpul"/><type:e xmlns:type="http://somethingtype"/><type:e xmlns:pul="http://somethingpul" xmlns:type="http://somethingtype" pul:pul="pul"/><pul:e xmlns:pul="http://somethingpul" xmlns:type="http://somethingtype" type:type="type"/></nonEmptyElement1>
+
+ <nonEmptyElement2 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement2>
+
+ <nonEmptyElement3 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement3>
+
+ <nonEmptyElement4 emptyAttribute="" nonEmptyAttribute="someattrvalue">
+ <emptyElement/>
+ <textElement>sometext</textElement>
+ </nonEmptyElement4>
+
+ <nonEm
Follow ups