Initial import

git-svn-id: http://moon:8086/svn/software/trunk/libsrc/xerces-c-3.0.0@1 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-07-19 07:44:42 +00:00
commit adea0d681b
4108 changed files with 701993 additions and 0 deletions
+169
View File
@@ -0,0 +1,169 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
#
# $Id: Makefile.am 679340 2008-07-24 10:28:29Z borisk $
#
check_PROGRAMS = ${testprogs}
LDADD = ${top_builddir}/src/libxerces-c.la
# the -I${top_builddir}/src is needed to pick the xercesc/util/Xerces_autoconf_config.hpp
# header file when doing out-of-tree builds
AM_CPPFLAGS = -I${top_builddir}/src -I${top_srcdir}/src
EXTRA_DIST = src/DOM/Normalizer/expectedOutput \
src/DOM/TypeInfo/data/combined.dtd \
src/DOM/TypeInfo/data/combined.xml \
src/DOM/TypeInfo/data/combined.xsd \
src/DOM/TypeInfo/data/SecondSchema.xsd \
src/DOM/TypeInfo/data/TypeInfo.dtd \
src/DOM/TypeInfo/data/TypeInfo.xml \
src/DOM/TypeInfo/data/TypeInfo.xsd \
src/DOM/TypeInfo/data/TypeInfoJustDTD.xml \
src/DOM/TypeInfo/data/TypeInfoNoDTD.xml \
src/DOM/TypeInfo/data/TypeInfoNoDTD.xsd
testprogs =
testprogs += DOMTest
DOMTest_SOURCES = src/DOM/DOMTest/DTest.cpp \
src/DOM/DOMTest/DTest.h
testprogs += DOMMemTest
DOMMemTest_SOURCES = src/DOM/DOMMemTest/DOMMemTest.cpp
testprogs += Normalizer
Normalizer_SOURCES = src/DOM/Normalizer/Normalizer.cpp \
src/DOM/Normalizer/Normalizer.hpp
testprogs += RangeTest
RangeTest_SOURCES = src/DOM/RangeTest/RangeTest.cpp
testprogs += DOMTraversalTest
DOMTraversalTest_SOURCES = src/DOM/Traversal/Traversal.cpp
testprogs += DOMTypeInfoTest
DOMTypeInfoTest_SOURCES = src/DOM/TypeInfo/TypeInfo.cpp \
src/DOM/TypeInfo/TypeInfo.hpp
testprogs += EncodingTest
EncodingTest_SOURCES = src/EncodingTest/EncodingTest.cpp
testprogs += InitTermTest
InitTermTest_SOURCES = src/InitTermTest/InitTermTest.cpp \
src/InitTermTest/InitTermTest.hpp
testprogs += MemHandlerTest
MemHandlerTest_SOURCES = src/MemHandlerTest/MemoryMonitor.cpp \
src/MemHandlerTest/MemoryMonitor.hpp \
src/MemHandlerTest/SimpleValueHashTableOf.hpp
testprogs += NetAccessorTest
NetAccessorTest_SOURCES = src/NetAccessorTest/NetAccessorTest.cpp
# Doesn't compile under gcc4 for some reason
# dcargill says this is obsolete and we can delete it.
#testprogs += ParserTest
#ParserTest_SOURCES = src/ParserTest/ParserTest.cpp \
# src/ParserTest/ParserTest.hpp \
# src/ParserTest/ParserTest_Parser.cpp \
# src/ParserTest/ParserTest_Parser.hpp
testprogs += ThreadTest
ThreadTest_SOURCES = src/ThreadTest/ThreadTest.cpp
# Fails to compile under gcc 4 (ambiguous calls to NullPointerException)
# dcargill says this is obsolete and we can delete it.
#testprogs += UtilTests
#UtilTests_SOURCES = src/UtilTests/CoreTests_BitSet.cpp \
# src/UtilTests/CoreTests_CountedPointer.cpp \
# src/UtilTests/CoreTests_RefArray.cpp \
# src/UtilTests/CoreTests_RefHashTable.cpp \
# src/UtilTests/CoreTests_RefStack.cpp \
# src/UtilTests/CoreTests_RefVector.cpp \
# src/UtilTests/CoreTests_String.cpp \
# src/UtilTests/CoreTests_Transcoders.cpp \
# src/UtilTests/CoreTests_URL.cpp \
# src/UtilTests/CoreTests_ValueArray.cpp \
# src/UtilTests/CoreTests_ValueStack.cpp \
# src/UtilTests/CoreTests_ValueVector.cpp \
# src/UtilTests/CoreTestsMain.cpp \
# src/UtilTests/CoreTests.hpp
testprogs += XSerializerTest
XSerializerTest_SOURCES = src/XSerializerTest/XSerializerHandlers.cpp \
src/XSerializerTest/XSerializerHandlers.hpp \
src/XSerializerTest/XSerializerTest.cpp \
src/XSerializerTest/XSerializerTest.hpp
testprogs += XSTSHarness
XSTSHarness_SOURCES = src/XSTSHarness/XSTSHarness.cpp \
src/XSTSHarness/XSTSHarness.hpp \
src/XSTSHarness/XSTSHarnessHandlers.cpp \
src/XSTSHarness/XSTSHarnessHandlers.hpp
# Fails to compile under gcc4 (values too long for long type)
testprogs += XSValueTest
XSValueTest_SOURCES = src/XSValueTest/XSValueTest.cpp \
src/XSValueTest/XSValueTest.hpp
#
# Override generated rules to provide prettier make rules
#
# Warning: If Automake changes sufficiently, these rules may need to
# be regenerated from the (new) default output of Automake
#
if XERCES_PRETTY_MAKE
.cpp.o:
@am__fastdepCXX_TRUE@ @depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`; \
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Po"; else rm -f "$$depbase.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ @source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ @depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`; \
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Po"; else rm -f "$$depbase.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ @source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ @depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`; \
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Plo"; else rm -f "$$depbase.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ @source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
PRETTY_MAKE=${top_srcdir}/config/pretty-make
PRETTY_COMPILE=${PRETTY_MAKE} Compiling
endif
CXXCOMPILE = ${PRETTY_COMPILE} \
$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = ${PRETTY_COMPILE} \
$(LIBTOOL) --quiet --tag=CXX --mode=compile \
$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+918
View File
@@ -0,0 +1,918 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
#
# $Id: Makefile.am 679340 2008-07-24 10:28:29Z borisk $
#
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
check_PROGRAMS = $(am__EXEEXT_1)
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/cxx_have_bool.m4 \
$(top_srcdir)/m4/cxx_have_lstring.m4 \
$(top_srcdir)/m4/cxx_have_namespaces.m4 \
$(top_srcdir)/m4/cxx_have_std_libs.m4 \
$(top_srcdir)/m4/cxx_have_std_namespace.m4 \
$(top_srcdir)/m4/xerces_curl_prefix.m4 \
$(top_srcdir)/m4/xerces_filemgr_selection.m4 \
$(top_srcdir)/m4/xerces_icu_prefix.m4 \
$(top_srcdir)/m4/xerces_int_types.m4 \
$(top_srcdir)/m4/xerces_link_darwin_framework.m4 \
$(top_srcdir)/m4/xerces_msgloader_selection.m4 \
$(top_srcdir)/m4/xerces_mutexmgr_selection.m4 \
$(top_srcdir)/m4/xerces_netaccessor_selection.m4 \
$(top_srcdir)/m4/xerces_no_threads.m4 \
$(top_srcdir)/m4/xerces_path_delimiters.m4 \
$(top_srcdir)/m4/xerces_pretty_make.m4 \
$(top_srcdir)/m4/xerces_transcoder_selection.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h \
$(top_builddir)/src/xercesc/util/Xerces_autoconf_config.hpp
CONFIG_CLEAN_FILES =
am__EXEEXT_1 = DOMTest$(EXEEXT) DOMMemTest$(EXEEXT) \
Normalizer$(EXEEXT) RangeTest$(EXEEXT) \
DOMTraversalTest$(EXEEXT) DOMTypeInfoTest$(EXEEXT) \
EncodingTest$(EXEEXT) InitTermTest$(EXEEXT) \
MemHandlerTest$(EXEEXT) NetAccessorTest$(EXEEXT) \
ThreadTest$(EXEEXT) XSerializerTest$(EXEEXT) \
XSTSHarness$(EXEEXT) XSValueTest$(EXEEXT)
am__dirstamp = $(am__leading_dot)dirstamp
am_DOMMemTest_OBJECTS = src/DOM/DOMMemTest/DOMMemTest.$(OBJEXT)
DOMMemTest_OBJECTS = $(am_DOMMemTest_OBJECTS)
DOMMemTest_LDADD = $(LDADD)
DOMMemTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_DOMTest_OBJECTS = src/DOM/DOMTest/DTest.$(OBJEXT)
DOMTest_OBJECTS = $(am_DOMTest_OBJECTS)
DOMTest_LDADD = $(LDADD)
DOMTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_DOMTraversalTest_OBJECTS = src/DOM/Traversal/Traversal.$(OBJEXT)
DOMTraversalTest_OBJECTS = $(am_DOMTraversalTest_OBJECTS)
DOMTraversalTest_LDADD = $(LDADD)
DOMTraversalTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_DOMTypeInfoTest_OBJECTS = src/DOM/TypeInfo/TypeInfo.$(OBJEXT)
DOMTypeInfoTest_OBJECTS = $(am_DOMTypeInfoTest_OBJECTS)
DOMTypeInfoTest_LDADD = $(LDADD)
DOMTypeInfoTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_EncodingTest_OBJECTS = src/EncodingTest/EncodingTest.$(OBJEXT)
EncodingTest_OBJECTS = $(am_EncodingTest_OBJECTS)
EncodingTest_LDADD = $(LDADD)
EncodingTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_InitTermTest_OBJECTS = src/InitTermTest/InitTermTest.$(OBJEXT)
InitTermTest_OBJECTS = $(am_InitTermTest_OBJECTS)
InitTermTest_LDADD = $(LDADD)
InitTermTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_MemHandlerTest_OBJECTS = \
src/MemHandlerTest/MemoryMonitor.$(OBJEXT)
MemHandlerTest_OBJECTS = $(am_MemHandlerTest_OBJECTS)
MemHandlerTest_LDADD = $(LDADD)
MemHandlerTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_NetAccessorTest_OBJECTS = \
src/NetAccessorTest/NetAccessorTest.$(OBJEXT)
NetAccessorTest_OBJECTS = $(am_NetAccessorTest_OBJECTS)
NetAccessorTest_LDADD = $(LDADD)
NetAccessorTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_Normalizer_OBJECTS = src/DOM/Normalizer/Normalizer.$(OBJEXT)
Normalizer_OBJECTS = $(am_Normalizer_OBJECTS)
Normalizer_LDADD = $(LDADD)
Normalizer_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_RangeTest_OBJECTS = src/DOM/RangeTest/RangeTest.$(OBJEXT)
RangeTest_OBJECTS = $(am_RangeTest_OBJECTS)
RangeTest_LDADD = $(LDADD)
RangeTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_ThreadTest_OBJECTS = src/ThreadTest/ThreadTest.$(OBJEXT)
ThreadTest_OBJECTS = $(am_ThreadTest_OBJECTS)
ThreadTest_LDADD = $(LDADD)
ThreadTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_XSTSHarness_OBJECTS = src/XSTSHarness/XSTSHarness.$(OBJEXT) \
src/XSTSHarness/XSTSHarnessHandlers.$(OBJEXT)
XSTSHarness_OBJECTS = $(am_XSTSHarness_OBJECTS)
XSTSHarness_LDADD = $(LDADD)
XSTSHarness_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_XSValueTest_OBJECTS = src/XSValueTest/XSValueTest.$(OBJEXT)
XSValueTest_OBJECTS = $(am_XSValueTest_OBJECTS)
XSValueTest_LDADD = $(LDADD)
XSValueTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
am_XSerializerTest_OBJECTS = \
src/XSerializerTest/XSerializerHandlers.$(OBJEXT) \
src/XSerializerTest/XSerializerTest.$(OBJEXT)
XSerializerTest_OBJECTS = $(am_XSerializerTest_OBJECTS)
XSerializerTest_LDADD = $(LDADD)
XSerializerTest_DEPENDENCIES = ${top_builddir}/src/libxerces-c.la
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/src/xercesc/util
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(DOMMemTest_SOURCES) $(DOMTest_SOURCES) \
$(DOMTraversalTest_SOURCES) $(DOMTypeInfoTest_SOURCES) \
$(EncodingTest_SOURCES) $(InitTermTest_SOURCES) \
$(MemHandlerTest_SOURCES) $(NetAccessorTest_SOURCES) \
$(Normalizer_SOURCES) $(RangeTest_SOURCES) \
$(ThreadTest_SOURCES) $(XSTSHarness_SOURCES) \
$(XSValueTest_SOURCES) $(XSerializerTest_SOURCES)
DIST_SOURCES = $(DOMMemTest_SOURCES) $(DOMTest_SOURCES) \
$(DOMTraversalTest_SOURCES) $(DOMTypeInfoTest_SOURCES) \
$(EncodingTest_SOURCES) $(InitTermTest_SOURCES) \
$(MemHandlerTest_SOURCES) $(NetAccessorTest_SOURCES) \
$(Normalizer_SOURCES) $(RangeTest_SOURCES) \
$(ThreadTest_SOURCES) $(XSTSHarness_SOURCES) \
$(XSValueTest_SOURCES) $(XSerializerTest_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_SHARED = @BUILD_SHARED@
BUILD_STATIC = @BUILD_STATIC@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_PREFIX = @CURL_PREFIX@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
ICU_CXXFLAGS = @ICU_CXXFLAGS@
ICU_PREFIX = @ICU_PREFIX@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SHREXT = @SHREXT@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
acx_pthread_config = @acx_pthread_config@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
LDADD = ${top_builddir}/src/libxerces-c.la
# the -I${top_builddir}/src is needed to pick the xercesc/util/Xerces_autoconf_config.hpp
# header file when doing out-of-tree builds
AM_CPPFLAGS = -I${top_builddir}/src -I${top_srcdir}/src
EXTRA_DIST = src/DOM/Normalizer/expectedOutput \
src/DOM/TypeInfo/data/combined.dtd \
src/DOM/TypeInfo/data/combined.xml \
src/DOM/TypeInfo/data/combined.xsd \
src/DOM/TypeInfo/data/SecondSchema.xsd \
src/DOM/TypeInfo/data/TypeInfo.dtd \
src/DOM/TypeInfo/data/TypeInfo.xml \
src/DOM/TypeInfo/data/TypeInfo.xsd \
src/DOM/TypeInfo/data/TypeInfoJustDTD.xml \
src/DOM/TypeInfo/data/TypeInfoNoDTD.xml \
src/DOM/TypeInfo/data/TypeInfoNoDTD.xsd
# Doesn't compile under gcc4 for some reason
# dcargill says this is obsolete and we can delete it.
#testprogs += ParserTest
#ParserTest_SOURCES = src/ParserTest/ParserTest.cpp \
# src/ParserTest/ParserTest.hpp \
# src/ParserTest/ParserTest_Parser.cpp \
# src/ParserTest/ParserTest_Parser.hpp
# Fails to compile under gcc 4 (ambiguous calls to NullPointerException)
# dcargill says this is obsolete and we can delete it.
#testprogs += UtilTests
#UtilTests_SOURCES = src/UtilTests/CoreTests_BitSet.cpp \
# src/UtilTests/CoreTests_CountedPointer.cpp \
# src/UtilTests/CoreTests_RefArray.cpp \
# src/UtilTests/CoreTests_RefHashTable.cpp \
# src/UtilTests/CoreTests_RefStack.cpp \
# src/UtilTests/CoreTests_RefVector.cpp \
# src/UtilTests/CoreTests_String.cpp \
# src/UtilTests/CoreTests_Transcoders.cpp \
# src/UtilTests/CoreTests_URL.cpp \
# src/UtilTests/CoreTests_ValueArray.cpp \
# src/UtilTests/CoreTests_ValueStack.cpp \
# src/UtilTests/CoreTests_ValueVector.cpp \
# src/UtilTests/CoreTestsMain.cpp \
# src/UtilTests/CoreTests.hpp
# Fails to compile under gcc4 (values too long for long type)
testprogs = DOMTest DOMMemTest Normalizer RangeTest DOMTraversalTest \
DOMTypeInfoTest EncodingTest InitTermTest MemHandlerTest \
NetAccessorTest ThreadTest XSerializerTest XSTSHarness \
XSValueTest
DOMTest_SOURCES = src/DOM/DOMTest/DTest.cpp \
src/DOM/DOMTest/DTest.h
DOMMemTest_SOURCES = src/DOM/DOMMemTest/DOMMemTest.cpp
Normalizer_SOURCES = src/DOM/Normalizer/Normalizer.cpp \
src/DOM/Normalizer/Normalizer.hpp
RangeTest_SOURCES = src/DOM/RangeTest/RangeTest.cpp
DOMTraversalTest_SOURCES = src/DOM/Traversal/Traversal.cpp
DOMTypeInfoTest_SOURCES = src/DOM/TypeInfo/TypeInfo.cpp \
src/DOM/TypeInfo/TypeInfo.hpp
EncodingTest_SOURCES = src/EncodingTest/EncodingTest.cpp
InitTermTest_SOURCES = src/InitTermTest/InitTermTest.cpp \
src/InitTermTest/InitTermTest.hpp
MemHandlerTest_SOURCES = src/MemHandlerTest/MemoryMonitor.cpp \
src/MemHandlerTest/MemoryMonitor.hpp \
src/MemHandlerTest/SimpleValueHashTableOf.hpp
NetAccessorTest_SOURCES = src/NetAccessorTest/NetAccessorTest.cpp
ThreadTest_SOURCES = src/ThreadTest/ThreadTest.cpp
XSerializerTest_SOURCES = src/XSerializerTest/XSerializerHandlers.cpp \
src/XSerializerTest/XSerializerHandlers.hpp \
src/XSerializerTest/XSerializerTest.cpp \
src/XSerializerTest/XSerializerTest.hpp
XSTSHarness_SOURCES = src/XSTSHarness/XSTSHarness.cpp \
src/XSTSHarness/XSTSHarness.hpp \
src/XSTSHarness/XSTSHarnessHandlers.cpp \
src/XSTSHarness/XSTSHarnessHandlers.hpp
XSValueTest_SOURCES = src/XSValueTest/XSValueTest.cpp \
src/XSValueTest/XSValueTest.hpp
@XERCES_PRETTY_MAKE_TRUE@PRETTY_MAKE = ${top_srcdir}/config/pretty-make
@XERCES_PRETTY_MAKE_TRUE@PRETTY_COMPILE = ${PRETTY_MAKE} Compiling
CXXCOMPILE = ${PRETTY_COMPILE} \
$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = ${PRETTY_COMPILE} \
$(LIBTOOL) --quiet --tag=CXX --mode=compile \
$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign tests/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
src/DOM/DOMMemTest/$(am__dirstamp):
@$(MKDIR_P) src/DOM/DOMMemTest
@: > src/DOM/DOMMemTest/$(am__dirstamp)
src/DOM/DOMMemTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/DOM/DOMMemTest/$(DEPDIR)
@: > src/DOM/DOMMemTest/$(DEPDIR)/$(am__dirstamp)
src/DOM/DOMMemTest/DOMMemTest.$(OBJEXT): \
src/DOM/DOMMemTest/$(am__dirstamp) \
src/DOM/DOMMemTest/$(DEPDIR)/$(am__dirstamp)
DOMMemTest$(EXEEXT): $(DOMMemTest_OBJECTS) $(DOMMemTest_DEPENDENCIES)
@rm -f DOMMemTest$(EXEEXT)
$(CXXLINK) $(DOMMemTest_OBJECTS) $(DOMMemTest_LDADD) $(LIBS)
src/DOM/DOMTest/$(am__dirstamp):
@$(MKDIR_P) src/DOM/DOMTest
@: > src/DOM/DOMTest/$(am__dirstamp)
src/DOM/DOMTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/DOM/DOMTest/$(DEPDIR)
@: > src/DOM/DOMTest/$(DEPDIR)/$(am__dirstamp)
src/DOM/DOMTest/DTest.$(OBJEXT): src/DOM/DOMTest/$(am__dirstamp) \
src/DOM/DOMTest/$(DEPDIR)/$(am__dirstamp)
DOMTest$(EXEEXT): $(DOMTest_OBJECTS) $(DOMTest_DEPENDENCIES)
@rm -f DOMTest$(EXEEXT)
$(CXXLINK) $(DOMTest_OBJECTS) $(DOMTest_LDADD) $(LIBS)
src/DOM/Traversal/$(am__dirstamp):
@$(MKDIR_P) src/DOM/Traversal
@: > src/DOM/Traversal/$(am__dirstamp)
src/DOM/Traversal/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/DOM/Traversal/$(DEPDIR)
@: > src/DOM/Traversal/$(DEPDIR)/$(am__dirstamp)
src/DOM/Traversal/Traversal.$(OBJEXT): \
src/DOM/Traversal/$(am__dirstamp) \
src/DOM/Traversal/$(DEPDIR)/$(am__dirstamp)
DOMTraversalTest$(EXEEXT): $(DOMTraversalTest_OBJECTS) $(DOMTraversalTest_DEPENDENCIES)
@rm -f DOMTraversalTest$(EXEEXT)
$(CXXLINK) $(DOMTraversalTest_OBJECTS) $(DOMTraversalTest_LDADD) $(LIBS)
src/DOM/TypeInfo/$(am__dirstamp):
@$(MKDIR_P) src/DOM/TypeInfo
@: > src/DOM/TypeInfo/$(am__dirstamp)
src/DOM/TypeInfo/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/DOM/TypeInfo/$(DEPDIR)
@: > src/DOM/TypeInfo/$(DEPDIR)/$(am__dirstamp)
src/DOM/TypeInfo/TypeInfo.$(OBJEXT): src/DOM/TypeInfo/$(am__dirstamp) \
src/DOM/TypeInfo/$(DEPDIR)/$(am__dirstamp)
DOMTypeInfoTest$(EXEEXT): $(DOMTypeInfoTest_OBJECTS) $(DOMTypeInfoTest_DEPENDENCIES)
@rm -f DOMTypeInfoTest$(EXEEXT)
$(CXXLINK) $(DOMTypeInfoTest_OBJECTS) $(DOMTypeInfoTest_LDADD) $(LIBS)
src/EncodingTest/$(am__dirstamp):
@$(MKDIR_P) src/EncodingTest
@: > src/EncodingTest/$(am__dirstamp)
src/EncodingTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/EncodingTest/$(DEPDIR)
@: > src/EncodingTest/$(DEPDIR)/$(am__dirstamp)
src/EncodingTest/EncodingTest.$(OBJEXT): \
src/EncodingTest/$(am__dirstamp) \
src/EncodingTest/$(DEPDIR)/$(am__dirstamp)
EncodingTest$(EXEEXT): $(EncodingTest_OBJECTS) $(EncodingTest_DEPENDENCIES)
@rm -f EncodingTest$(EXEEXT)
$(CXXLINK) $(EncodingTest_OBJECTS) $(EncodingTest_LDADD) $(LIBS)
src/InitTermTest/$(am__dirstamp):
@$(MKDIR_P) src/InitTermTest
@: > src/InitTermTest/$(am__dirstamp)
src/InitTermTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/InitTermTest/$(DEPDIR)
@: > src/InitTermTest/$(DEPDIR)/$(am__dirstamp)
src/InitTermTest/InitTermTest.$(OBJEXT): \
src/InitTermTest/$(am__dirstamp) \
src/InitTermTest/$(DEPDIR)/$(am__dirstamp)
InitTermTest$(EXEEXT): $(InitTermTest_OBJECTS) $(InitTermTest_DEPENDENCIES)
@rm -f InitTermTest$(EXEEXT)
$(CXXLINK) $(InitTermTest_OBJECTS) $(InitTermTest_LDADD) $(LIBS)
src/MemHandlerTest/$(am__dirstamp):
@$(MKDIR_P) src/MemHandlerTest
@: > src/MemHandlerTest/$(am__dirstamp)
src/MemHandlerTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/MemHandlerTest/$(DEPDIR)
@: > src/MemHandlerTest/$(DEPDIR)/$(am__dirstamp)
src/MemHandlerTest/MemoryMonitor.$(OBJEXT): \
src/MemHandlerTest/$(am__dirstamp) \
src/MemHandlerTest/$(DEPDIR)/$(am__dirstamp)
MemHandlerTest$(EXEEXT): $(MemHandlerTest_OBJECTS) $(MemHandlerTest_DEPENDENCIES)
@rm -f MemHandlerTest$(EXEEXT)
$(CXXLINK) $(MemHandlerTest_OBJECTS) $(MemHandlerTest_LDADD) $(LIBS)
src/NetAccessorTest/$(am__dirstamp):
@$(MKDIR_P) src/NetAccessorTest
@: > src/NetAccessorTest/$(am__dirstamp)
src/NetAccessorTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/NetAccessorTest/$(DEPDIR)
@: > src/NetAccessorTest/$(DEPDIR)/$(am__dirstamp)
src/NetAccessorTest/NetAccessorTest.$(OBJEXT): \
src/NetAccessorTest/$(am__dirstamp) \
src/NetAccessorTest/$(DEPDIR)/$(am__dirstamp)
NetAccessorTest$(EXEEXT): $(NetAccessorTest_OBJECTS) $(NetAccessorTest_DEPENDENCIES)
@rm -f NetAccessorTest$(EXEEXT)
$(CXXLINK) $(NetAccessorTest_OBJECTS) $(NetAccessorTest_LDADD) $(LIBS)
src/DOM/Normalizer/$(am__dirstamp):
@$(MKDIR_P) src/DOM/Normalizer
@: > src/DOM/Normalizer/$(am__dirstamp)
src/DOM/Normalizer/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/DOM/Normalizer/$(DEPDIR)
@: > src/DOM/Normalizer/$(DEPDIR)/$(am__dirstamp)
src/DOM/Normalizer/Normalizer.$(OBJEXT): \
src/DOM/Normalizer/$(am__dirstamp) \
src/DOM/Normalizer/$(DEPDIR)/$(am__dirstamp)
Normalizer$(EXEEXT): $(Normalizer_OBJECTS) $(Normalizer_DEPENDENCIES)
@rm -f Normalizer$(EXEEXT)
$(CXXLINK) $(Normalizer_OBJECTS) $(Normalizer_LDADD) $(LIBS)
src/DOM/RangeTest/$(am__dirstamp):
@$(MKDIR_P) src/DOM/RangeTest
@: > src/DOM/RangeTest/$(am__dirstamp)
src/DOM/RangeTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/DOM/RangeTest/$(DEPDIR)
@: > src/DOM/RangeTest/$(DEPDIR)/$(am__dirstamp)
src/DOM/RangeTest/RangeTest.$(OBJEXT): \
src/DOM/RangeTest/$(am__dirstamp) \
src/DOM/RangeTest/$(DEPDIR)/$(am__dirstamp)
RangeTest$(EXEEXT): $(RangeTest_OBJECTS) $(RangeTest_DEPENDENCIES)
@rm -f RangeTest$(EXEEXT)
$(CXXLINK) $(RangeTest_OBJECTS) $(RangeTest_LDADD) $(LIBS)
src/ThreadTest/$(am__dirstamp):
@$(MKDIR_P) src/ThreadTest
@: > src/ThreadTest/$(am__dirstamp)
src/ThreadTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/ThreadTest/$(DEPDIR)
@: > src/ThreadTest/$(DEPDIR)/$(am__dirstamp)
src/ThreadTest/ThreadTest.$(OBJEXT): src/ThreadTest/$(am__dirstamp) \
src/ThreadTest/$(DEPDIR)/$(am__dirstamp)
ThreadTest$(EXEEXT): $(ThreadTest_OBJECTS) $(ThreadTest_DEPENDENCIES)
@rm -f ThreadTest$(EXEEXT)
$(CXXLINK) $(ThreadTest_OBJECTS) $(ThreadTest_LDADD) $(LIBS)
src/XSTSHarness/$(am__dirstamp):
@$(MKDIR_P) src/XSTSHarness
@: > src/XSTSHarness/$(am__dirstamp)
src/XSTSHarness/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/XSTSHarness/$(DEPDIR)
@: > src/XSTSHarness/$(DEPDIR)/$(am__dirstamp)
src/XSTSHarness/XSTSHarness.$(OBJEXT): \
src/XSTSHarness/$(am__dirstamp) \
src/XSTSHarness/$(DEPDIR)/$(am__dirstamp)
src/XSTSHarness/XSTSHarnessHandlers.$(OBJEXT): \
src/XSTSHarness/$(am__dirstamp) \
src/XSTSHarness/$(DEPDIR)/$(am__dirstamp)
XSTSHarness$(EXEEXT): $(XSTSHarness_OBJECTS) $(XSTSHarness_DEPENDENCIES)
@rm -f XSTSHarness$(EXEEXT)
$(CXXLINK) $(XSTSHarness_OBJECTS) $(XSTSHarness_LDADD) $(LIBS)
src/XSValueTest/$(am__dirstamp):
@$(MKDIR_P) src/XSValueTest
@: > src/XSValueTest/$(am__dirstamp)
src/XSValueTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/XSValueTest/$(DEPDIR)
@: > src/XSValueTest/$(DEPDIR)/$(am__dirstamp)
src/XSValueTest/XSValueTest.$(OBJEXT): \
src/XSValueTest/$(am__dirstamp) \
src/XSValueTest/$(DEPDIR)/$(am__dirstamp)
XSValueTest$(EXEEXT): $(XSValueTest_OBJECTS) $(XSValueTest_DEPENDENCIES)
@rm -f XSValueTest$(EXEEXT)
$(CXXLINK) $(XSValueTest_OBJECTS) $(XSValueTest_LDADD) $(LIBS)
src/XSerializerTest/$(am__dirstamp):
@$(MKDIR_P) src/XSerializerTest
@: > src/XSerializerTest/$(am__dirstamp)
src/XSerializerTest/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/XSerializerTest/$(DEPDIR)
@: > src/XSerializerTest/$(DEPDIR)/$(am__dirstamp)
src/XSerializerTest/XSerializerHandlers.$(OBJEXT): \
src/XSerializerTest/$(am__dirstamp) \
src/XSerializerTest/$(DEPDIR)/$(am__dirstamp)
src/XSerializerTest/XSerializerTest.$(OBJEXT): \
src/XSerializerTest/$(am__dirstamp) \
src/XSerializerTest/$(DEPDIR)/$(am__dirstamp)
XSerializerTest$(EXEEXT): $(XSerializerTest_OBJECTS) $(XSerializerTest_DEPENDENCIES)
@rm -f XSerializerTest$(EXEEXT)
$(CXXLINK) $(XSerializerTest_OBJECTS) $(XSerializerTest_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
-rm -f src/DOM/DOMMemTest/DOMMemTest.$(OBJEXT)
-rm -f src/DOM/DOMTest/DTest.$(OBJEXT)
-rm -f src/DOM/Normalizer/Normalizer.$(OBJEXT)
-rm -f src/DOM/RangeTest/RangeTest.$(OBJEXT)
-rm -f src/DOM/Traversal/Traversal.$(OBJEXT)
-rm -f src/DOM/TypeInfo/TypeInfo.$(OBJEXT)
-rm -f src/EncodingTest/EncodingTest.$(OBJEXT)
-rm -f src/InitTermTest/InitTermTest.$(OBJEXT)
-rm -f src/MemHandlerTest/MemoryMonitor.$(OBJEXT)
-rm -f src/NetAccessorTest/NetAccessorTest.$(OBJEXT)
-rm -f src/ThreadTest/ThreadTest.$(OBJEXT)
-rm -f src/XSTSHarness/XSTSHarness.$(OBJEXT)
-rm -f src/XSTSHarness/XSTSHarnessHandlers.$(OBJEXT)
-rm -f src/XSValueTest/XSValueTest.$(OBJEXT)
-rm -f src/XSerializerTest/XSerializerHandlers.$(OBJEXT)
-rm -f src/XSerializerTest/XSerializerTest.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@src/DOM/DOMMemTest/$(DEPDIR)/DOMMemTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/DOM/DOMTest/$(DEPDIR)/DTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/DOM/Normalizer/$(DEPDIR)/Normalizer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/DOM/RangeTest/$(DEPDIR)/RangeTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/DOM/Traversal/$(DEPDIR)/Traversal.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/DOM/TypeInfo/$(DEPDIR)/TypeInfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/EncodingTest/$(DEPDIR)/EncodingTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/InitTermTest/$(DEPDIR)/InitTermTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/MemHandlerTest/$(DEPDIR)/MemoryMonitor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/NetAccessorTest/$(DEPDIR)/NetAccessorTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/ThreadTest/$(DEPDIR)/ThreadTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/XSTSHarness/$(DEPDIR)/XSTSHarness.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/XSTSHarness/$(DEPDIR)/XSTSHarnessHandlers.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/XSValueTest/$(DEPDIR)/XSValueTest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/XSerializerTest/$(DEPDIR)/XSerializerHandlers.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/XSerializerTest/$(DEPDIR)/XSerializerTest.Po@am__quote@
@XERCES_PRETTY_MAKE_FALSE@.cpp.o:
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCXX_TRUE@ mv -f $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
@XERCES_PRETTY_MAKE_FALSE@.cpp.obj:
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCXX_TRUE@ mv -f $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@XERCES_PRETTY_MAKE_FALSE@.cpp.lo:
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCXX_TRUE@ mv -f $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-rm -f src/DOM/DOMMemTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/DOM/DOMMemTest/$(am__dirstamp)
-rm -f src/DOM/DOMTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/DOM/DOMTest/$(am__dirstamp)
-rm -f src/DOM/Normalizer/$(DEPDIR)/$(am__dirstamp)
-rm -f src/DOM/Normalizer/$(am__dirstamp)
-rm -f src/DOM/RangeTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/DOM/RangeTest/$(am__dirstamp)
-rm -f src/DOM/Traversal/$(DEPDIR)/$(am__dirstamp)
-rm -f src/DOM/Traversal/$(am__dirstamp)
-rm -f src/DOM/TypeInfo/$(DEPDIR)/$(am__dirstamp)
-rm -f src/DOM/TypeInfo/$(am__dirstamp)
-rm -f src/EncodingTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/EncodingTest/$(am__dirstamp)
-rm -f src/InitTermTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/InitTermTest/$(am__dirstamp)
-rm -f src/MemHandlerTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/MemHandlerTest/$(am__dirstamp)
-rm -f src/NetAccessorTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/NetAccessorTest/$(am__dirstamp)
-rm -f src/ThreadTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/ThreadTest/$(am__dirstamp)
-rm -f src/XSTSHarness/$(DEPDIR)/$(am__dirstamp)
-rm -f src/XSTSHarness/$(am__dirstamp)
-rm -f src/XSValueTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/XSValueTest/$(am__dirstamp)
-rm -f src/XSerializerTest/$(DEPDIR)/$(am__dirstamp)
-rm -f src/XSerializerTest/$(am__dirstamp)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -rf src/DOM/DOMMemTest/$(DEPDIR) src/DOM/DOMTest/$(DEPDIR) src/DOM/Normalizer/$(DEPDIR) src/DOM/RangeTest/$(DEPDIR) src/DOM/Traversal/$(DEPDIR) src/DOM/TypeInfo/$(DEPDIR) src/EncodingTest/$(DEPDIR) src/InitTermTest/$(DEPDIR) src/MemHandlerTest/$(DEPDIR) src/NetAccessorTest/$(DEPDIR) src/ThreadTest/$(DEPDIR) src/XSTSHarness/$(DEPDIR) src/XSValueTest/$(DEPDIR) src/XSerializerTest/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf src/DOM/DOMMemTest/$(DEPDIR) src/DOM/DOMTest/$(DEPDIR) src/DOM/Normalizer/$(DEPDIR) src/DOM/RangeTest/$(DEPDIR) src/DOM/Traversal/$(DEPDIR) src/DOM/TypeInfo/$(DEPDIR) src/EncodingTest/$(DEPDIR) src/InitTermTest/$(DEPDIR) src/MemHandlerTest/$(DEPDIR) src/NetAccessorTest/$(DEPDIR) src/ThreadTest/$(DEPDIR) src/XSTSHarness/$(DEPDIR) src/XSValueTest/$(DEPDIR) src/XSerializerTest/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean \
clean-checkPROGRAMS clean-generic clean-libtool ctags \
distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am
#
# Override generated rules to provide prettier make rules
#
# Warning: If Automake changes sufficiently, these rules may need to
# be regenerated from the (new) default output of Automake
#
@XERCES_PRETTY_MAKE_TRUE@.cpp.o:
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ @depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`; \
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Po"; else rm -f "$$depbase.Tpo"; exit 1; fi
@XERCES_PRETTY_MAKE_TRUE@@AMDEP_TRUE@@am__fastdepCXX_FALSE@ @source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@XERCES_PRETTY_MAKE_TRUE@@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
@XERCES_PRETTY_MAKE_TRUE@.cpp.obj:
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ @depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`; \
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Po"; else rm -f "$$depbase.Tpo"; exit 1; fi
@XERCES_PRETTY_MAKE_TRUE@@AMDEP_TRUE@@am__fastdepCXX_FALSE@ @source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@XERCES_PRETTY_MAKE_TRUE@@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@XERCES_PRETTY_MAKE_TRUE@.cpp.lo:
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ @depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`; \
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_TRUE@ then mv -f "$$depbase.Tpo" "$$depbase.Plo"; else rm -f "$$depbase.Tpo"; exit 1; fi
@XERCES_PRETTY_MAKE_TRUE@@AMDEP_TRUE@@am__fastdepCXX_FALSE@ @source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@XERCES_PRETTY_MAKE_TRUE@@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@XERCES_PRETTY_MAKE_TRUE@@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
File diff suppressed because it is too large Load Diff
+5192
View File
File diff suppressed because it is too large Load Diff
+161
View File
@@ -0,0 +1,161 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: DTest.h 570441 2007-08-28 14:18:18Z amassari $
*/
/**
* This class tests methods for XML DOM implementation
*
* DOMException errors are tested by calls to DOMExceptionsTest from: Main, docBuilder...
*
*/
#include <xercesc/dom/DOM.hpp>
// define null for compatibility with original Java source code.
#define null 0
XERCES_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_BEGIN
class XercesDOMParser;
XERCES_CPP_NAMESPACE_END
class DOMTest {
public:
static DOMElement *testElementNode;
static DOMAttr *testAttributeNode;
static DOMText *testTextNode;
static DOMCDATASection *testCDATASectionNode;
static DOMEntityReference *testEntityReferenceNode;
static DOMEntity *testEntityNode;
static DOMProcessingInstruction *testProcessingInstructionNode;
static DOMComment *testCommentNode;
static DOMDocument *testDocumentNode;
static DOMDocumentType *testDocumentTypeNode;
static DOMDocumentFragment *testDocumentFragmentNode;
static DOMNotation *testNotationNode;
DOMTest();
DOMDocument* createDocument();
DOMDocumentType* createDocumentType(DOMDocument* doc, XMLCh* name);
DOMEntity* createEntity(DOMDocument* doc, XMLCh* name);
DOMNotation* createNotation(DOMDocument* doc, XMLCh* name);
bool docBuilder(DOMDocument* document, XMLCh* name);
void findTestNodes(DOMDocument* document);
void findTestNodes(DOMNode* node);
bool testAttr(DOMDocument* document);
bool testCDATASection(DOMDocument* document);
bool testCharacterData(DOMDocument* document);
bool testChildNodeList(DOMDocument* document);
bool testComment(DOMDocument* document);
bool testDeepNodeList(DOMDocument* document);
/**
**** ALL DOMDocument create methods are run in docBuilder except createAttribute which is in testAttribute**
*/
bool testDocument(DOMDocument* document);
/**
********This really isn't needed, only exists to throw NO_MODIFICATION_ALLOWED_ERR ********
*/
bool testDocumentFragment(DOMDocument* document);
bool testDocumentType(DOMDocument* document);
bool testDOMerrors(DOMDocument* document);
bool testXPath(DOMDocument* document);
bool testDOMImplementation(DOMDocument* document);
bool testElement(DOMDocument* document);
bool testEntity(DOMDocument* document);
bool testEntityReference(DOMDocument* document);
/**
********* This is only for a test of cloneNode "deep"*******
********* And for error tests*********
*/
bool testNode(DOMDocument* document);
bool testNotation(DOMDocument* document);
bool testPI(DOMDocument* document);
bool testText(DOMDocument* document);
bool treeCompare(DOMNode* node, DOMNode* node2);
bool testBaseURI(XercesDOMParser* parser);
bool testWholeText(XercesDOMParser* parser);
bool testLSExceptions();
bool testRegex();
};
class myUserDataHandler : public DOMUserDataHandler {
private:
DOMOperationType currentType;
XMLCh* currentKey;
void* currentData;
DOMNode* currentSrc;
DOMNode* currentDst;
public:
myUserDataHandler() :
currentKey(0),
currentData(0),
currentSrc(0),
currentDst(0) {};
virtual void handle(DOMOperationType operation,
const XMLCh* const key,
void* data,
const DOMNode* src,
DOMNode* dst)
{
currentType = operation;
currentKey = (XMLCh*) key;
currentData = data;
currentSrc = (DOMNode*) src;
currentDst = dst;
};
DOMOperationType getCurrentType() {
return currentType;
};
XMLCh* getCurrentKey() const {
return currentKey;
};
void* getCurrentData() const {
return currentData;
};
DOMNode* getCurrentSrc() const {
return currentSrc;
};
DOMNode* getCurrentDst() const {
return currentDst;
};
};
+428
View File
@@ -0,0 +1,428 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 "Normalizer.hpp"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <xercesc/framework/XMLBuffer.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include "xercesc/dom/impl/DOMConfigurationImpl.hpp"
#include "xercesc/dom/impl/DOMDocumentImpl.hpp"
#include "xercesc/dom/impl/DOMEntityImpl.hpp"
#include "xercesc/dom/impl/DOMEntityReferenceImpl.hpp"
// ---------------------------------------------------------------------------
// This is a simple class that lets us do easy (though not terribly efficient)
// trancoding of char* data to XMLCh data.
// ---------------------------------------------------------------------------
class XStr
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XStr(const char* const toTranscode)
{
// Call the private transcoding method
fUnicodeForm = XMLString::transcode(toTranscode);
}
~XStr()
{
XMLString::release(&fUnicodeForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const XMLCh* unicodeForm() const
{
return fUnicodeForm;
}
private :
// -----------------------------------------------------------------------
// Private data members
//
// fUnicodeForm
// This is the Unicode XMLCh format of the string.
// -----------------------------------------------------------------------
XMLCh* fUnicodeForm;
};
#define X(str) XStr(str).unicodeForm()
// This is a simple class that lets us do easy (though not terribly efficient)
// trancoding of XMLCh data to local code page for display.
// ---------------------------------------------------------------------------
class StrX
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
StrX(const XMLCh* const toTranscode)
{
// Call the private transcoding method
fLocalForm = XMLString::transcode(toTranscode);
}
~StrX()
{
XMLString::release(&fLocalForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const char* localForm() const
{
return fLocalForm;
}
private :
// -----------------------------------------------------------------------
// Private data members
//
// fLocalForm
// This is the local code page form of the string.
// -----------------------------------------------------------------------
char* fLocalForm;
};
#define StrX(str) StrX(str).localForm()
Normalizer::Normalizer() {
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException &toCatch)
{
XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n"
<< " Exception message:"
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
}
parser = 0;
}
Normalizer::~Normalizer() {
XMLPlatformUtils::Terminate();
}
void Normalizer::printEntityRefNodes(DOMElement *ele) {
DOMNode *child = ele->getFirstChild();
while(child != 0) {
if(child->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE) {
XERCES_STD_QUALIFIER cout << "start of entity ref node" << XERCES_STD_QUALIFIER endl;
DOMNode *entChild = ((DOMEntityReference*)child)->getFirstChild();
while(entChild != 0) {
serializeNode(entChild);
entChild = entChild->getNextSibling();
}
XERCES_STD_QUALIFIER cout << "\nend of entity ref node\n\n" << XERCES_STD_QUALIFIER endl;
}
if(child->getNodeType() == DOMNode::ELEMENT_NODE) {
printEntityRefNodes((DOMElement*)child);
}
child = child->getNextSibling();
}
}
bool Normalizer::handleError(const DOMError& domError)
{
// Display whatever error message passed from the serializer
if (domError.getSeverity() == DOMError::DOM_SEVERITY_WARNING)
XERCES_STD_QUALIFIER cerr << "\nWarning Message: ";
else if (domError.getSeverity() == DOMError::DOM_SEVERITY_ERROR)
XERCES_STD_QUALIFIER cerr << "\nError Message: ";
else
XERCES_STD_QUALIFIER cerr << "\nFatal Message: ";
char *msg = XMLString::transcode(domError.getMessage());
XERCES_STD_QUALIFIER cerr<< msg <<XERCES_STD_QUALIFIER endl;
XMLString::release(&msg);
XERCES_STD_QUALIFIER cerr << "Related data ";
msg = XMLString::transcode(((DOMNode*)domError.getRelatedData())->getNodeName());
XERCES_STD_QUALIFIER cerr << msg <<XERCES_STD_QUALIFIER endl;
XMLString::release(&msg);
// continue serialization if possible.
return true;
}
DOMDocument* Normalizer::createDocument() {
XMLCh coreStr[100];
XMLString::transcode("Core",coreStr,99);
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(coreStr);
return impl->createDocument();
};
void Normalizer::serializeNode(const DOMNode * const node) {
XMLCh tempStr[100];
XMLString::transcode("LS", tempStr, 99);
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
DOMLSOutput *theOutput = ((DOMImplementationLS*)impl)->createLSOutput();
theSerializer->getDomConfig()->setParameter(X("format-pretty-print"), true);
XMLFormatTarget *myFormTarget;
myFormTarget = new StdOutFormatTarget();
theOutput->setByteStream(myFormTarget);
theSerializer->write(node,theOutput);
delete myFormTarget;
theSerializer->release();
theOutput->release();
}
int main(int /*argc*/, char ** /*argv*/) {
Normalizer *normalizer = new Normalizer();
DOMDocument *doc = normalizer->createDocument();
bool *tmpTrue = new bool(true);
bool *tmpFalse = new bool(false);
DOMElement* docFirstElement = doc->createElementNS(X("http://www.test.com"),X("docEle"));
doc->appendChild(docFirstElement);
DOMElement* docFirstElementChild = doc->createElementNS(X("http://www.test2.com"),X("docEleChild"));
docFirstElement->appendChild(docFirstElementChild);
//create default ns
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//add in binding
docFirstElement->setPrefix(X("po"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//use default
DOMElement* docFirstElementChildChild = doc->createElementNS(X("http://www.test2.com"),X("docEleChildChild"));
docFirstElementChild->appendChild(docFirstElementChildChild);
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
// this block is needed to destroy the XMLBuffer
{
//use a binding
XMLBuffer buf;
buf.set(XMLUni::fgXMLNSString);
buf.append(chColon);
buf.append(X("po2"));
docFirstElementChild->removeAttributeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString);
docFirstElement->removeAttributeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString);
docFirstElement->setAttributeNS(XMLUni::fgXMLNSURIName, buf.getRawBuffer(), X("http://www.test2.com"));
docFirstElementChild->setPrefix(X("po2"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
}
//some siblngs to ensure the scope stacks are working
docFirstElementChildChild = doc->createElementNS(X("http://www.test3.com"),X("docEleChildChild2"));
docFirstElementChild->appendChild(docFirstElementChildChild);
docFirstElementChildChild = doc->createElementNS(X("http://www.test4.com"),X("po4:docEleChildChild3"));
docFirstElementChild->appendChild(docFirstElementChildChild);
docFirstElementChildChild = doc->createElementNS(X("http://www.test4.com"),X("po4:docEleChildChild4"));
docFirstElementChild->appendChild(docFirstElementChildChild);
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//conflicting prefix
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, X("po4"), X("conflict"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//conflicting default
docFirstElementChildChild = doc->createElementNS(X("http://www.test4.com"),X("docEleChildChild5"));
docFirstElementChild->appendChild(docFirstElementChildChild);
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString, X("conflict"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//set the xmlns to ""
DOMElement *noNamespaceEle = doc->createElementNS(X(""),X("noNamespace"));
docFirstElementChildChild->appendChild(noNamespaceEle);
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//now lets do a bit off attribute testing on the doc ele
docFirstElement->setAttributeNS(X("http://testattr.com"), X("attr1"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr.com"), X("attr2"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr2.com"), X("attr3"), X("value"));
docFirstElement->setAttributeNS(X("http://www.test.com"), X("attr4"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr2.com"), X("po:attr5"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr2.com"), X("poFake:attr6"), X("value"));
docFirstElement->setAttributeNS(X("http://testattr3.com"), X("po3:attr7"), X("value"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//and now on one of its children
docFirstElementChildChild->setAttributeNS(X("http://testattr.com"), X("attr1"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr.com"), X("attr2"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr2.com"), X("attr3"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://www.test.com"), X("attr4"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr2.com"), X("po:attr5"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr2.com"), X("poFake:attr6"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr3.com"), X("po3:attr7"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://testattr4.com"), X("po4:attr8"), X("value"));
//test for a clash with our NSx attrs
docFirstElementChildChild->setAttributeNS(X("http://testclash.com"), X("NS1:attr9"), X("value"));
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, X("xmlns:NS1"), X("http://testclash.com"));
//clash with standard prefix
docFirstElementChildChild->setAttributeNS(X("http://testattr5.com"), X("po:attr10"), X("value"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//2 prefix with the same uri
docFirstElementChildChild = doc->createElementNS(X("http://www.uri1.com"),X("docEleChildChild6"));
docFirstElementChild->appendChild(docFirstElementChildChild);
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, X("xmlns:uri1"), X("http://www.uri1.com"));
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, X("xmlns:uri1b"), X("http://www.uri1.com"));
docFirstElementChildChild->setAttributeNS(X("http://www.uri1.com"), X("uri1:attr1"), X("value"));
docFirstElementChildChild->setAttributeNS(X("http://www.uri1.com"), X("uri1b:attr2"), X("value"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//check to see we use the nearest binding and for more inheritence
DOMElement *docFirstElementChildChildChild = doc->createElementNS(X("http://www.uri1.com"),X("docEleChildChildChild"));
docFirstElementChildChild->appendChild(docFirstElementChildChildChild);
docFirstElementChildChild->setAttributeNS(XMLUni::fgXMLNSURIName, X("xmlns:nearerThanPo"), X("http://www.test.com"));
docFirstElementChildChildChild->setAttributeNS(X("http://testattr.com"), X("attr2"), X("value"));
docFirstElementChildChildChild->setAttributeNS(X("http://www.test.com"), X("attr1"), X("value"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
XERCES_STD_QUALIFIER cout << "\n\n";
//NS1.1 stuff
//test creating default prefix when NS1 has been set to ""
noNamespaceEle->setAttributeNS(XMLUni::fgXMLNSURIName, X("xmlns:NS1"), X(""));
DOMElement *noNamespaceChild = doc->createElementNS(X("http://testclash.com"),X("testing1.1Stuff"));
noNamespaceEle->appendChild(noNamespaceChild);
doc->normalizeDocument();
normalizer->serializeNode(doc);
noNamespaceChild = doc->createElementNS(X("http://testclash.com"),X("NS1:testing1.1Stuff"));
noNamespaceEle->appendChild(noNamespaceChild);
noNamespaceChild->setAttributeNS(X("http://www.someRandomUri.com"), X("attr"), X("value"));
doc->normalizeDocument();
normalizer->serializeNode(doc);
//check error conditions
XERCES_STD_QUALIFIER cout << "error conditions" << XERCES_STD_QUALIFIER endl;
DOMConfiguration *conf = doc->getDOMConfig();
conf->setParameter(XMLUni::fgDOMErrorHandler, normalizer);
conf->setParameter(XMLUni::fgDOMNamespaces, true);
DOMElement *level1Node = doc->createElement(X("level1Node"));
docFirstElement->appendChild(level1Node);
doc->normalizeDocument();
docFirstElement->removeChild(level1Node);
docFirstElement->setAttribute(X("level1Attr"), X("level1"));
doc->normalizeDocument();
docFirstElement->removeAttribute(X("level1Attr"));
//cant check this as Xerces does not let us do it
// noNamespaceChild->setAttributeNS(X("http://www.someRandomUri.com"), X("xmlns"), X("value"));
// doc->normalizeDocument();
//lets do a sanity test on a comment
DOMComment *comment = doc->createComment(X("some comment"));
docFirstElement->appendChild(comment);
doc->normalizeDocument();
normalizer->serializeNode(doc);
conf->setParameter(XMLUni::fgDOMComments, false);
docFirstElement->appendChild(comment);
doc->normalizeDocument();
normalizer->serializeNode(doc);
//and on a CDATA
DOMCDATASection *cData = doc->createCDATASection(X("some cdata"));
docFirstElement->appendChild(cData);
doc->normalizeDocument();
normalizer->serializeNode(doc);
conf->setParameter(XMLUni::fgDOMCDATASections, false);
docFirstElement->appendChild(cData);
doc->normalizeDocument();
normalizer->serializeNode(doc);
delete normalizer;
delete tmpTrue;
delete tmpFalse;
return 0;
}
+55
View File
@@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
// define null for compatibility with original Java source code.
#define null 0
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
XERCES_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_BEGIN
class XercesDOMParser;
XERCES_CPP_NAMESPACE_END
class Normalizer : public DOMErrorHandler {
public:
Normalizer();
~Normalizer();
DOMDocument* createDocument();
void serializeNode(const DOMNode *const node);
void printEntityRefNodes(DOMElement *ele);
bool handleError(const DOMError& domError);
void resetErrors(){};
private:
Normalizer(const Normalizer&);
void operator=(const Normalizer&);
XercesDOMParser *parser;
DOMDocument *doc;
};
+291
View File
@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<docEle xmlns="http://www.test.com">
<docEleChild xmlns="http://www.test2.com"/>
</docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns="http://www.test.com">
<docEleChild xmlns="http://www.test2.com"/>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns="http://www.test.com">
<docEleChild xmlns="http://www.test2.com">
<docEleChildChild/>
</docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com"/>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com">
<noNamespace xmlns=""/>
</docEleChildChild5>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com">
<noNamespace xmlns=""/>
</docEleChildChild5>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns=""/>
</docEleChildChild5>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns=""/>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value"/>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns=""/>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value" xmlns:nearerThanPo="http://www.test.com">
<docEleChildChildChild nearerThanPo:attr1="value" NS1:attr2="value"/>
</docEleChildChild6>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns="" xmlns:NS1="">
<testing1.1Stuff xmlns="http://testclash.com"/>
</noNamespace>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value" xmlns:nearerThanPo="http://www.test.com">
<docEleChildChildChild nearerThanPo:attr1="value" NS1:attr2="value"/>
</docEleChildChild6>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns="" xmlns:NS1="">
<testing1.1Stuff xmlns="http://testclash.com"/>
<NS1:testing1.1Stuff xmlns:NS5="http://www.someRandomUri.com" NS5:attr="value" xmlns:NS1="http://testclash.com"/>
</noNamespace>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value" xmlns:nearerThanPo="http://www.test.com">
<docEleChildChildChild nearerThanPo:attr1="value" NS1:attr2="value"/>
</docEleChildChild6>
</po2:docEleChild>
</po:docEle>
error conditions
Fatal Message: Namespace fixup cannot be performed on a DOM Level 1 Node.
Related data level1Node
Fatal Message: Namespace fixup cannot be performed on a DOM Level 1 Node.
Related data level1Attr
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns="" xmlns:NS1="">
<testing1.1Stuff xmlns="http://testclash.com"/>
<NS1:testing1.1Stuff xmlns:NS5="http://www.someRandomUri.com" NS5:attr="value" xmlns:NS1="http://testclash.com"/>
</noNamespace>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value" xmlns:nearerThanPo="http://www.test.com">
<docEleChildChildChild nearerThanPo:attr1="value" NS1:attr2="value"/>
</docEleChildChild6>
</po2:docEleChild>
<!--some comment-->
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns="" xmlns:NS1="">
<testing1.1Stuff xmlns="http://testclash.com"/>
<NS1:testing1.1Stuff xmlns:NS5="http://www.someRandomUri.com" NS5:attr="value" xmlns:NS1="http://testclash.com"/>
</noNamespace>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value" xmlns:nearerThanPo="http://www.test.com">
<docEleChildChildChild nearerThanPo:attr1="value" NS1:attr2="value"/>
</docEleChildChild6>
</po2:docEleChild>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns="" xmlns:NS1="">
<testing1.1Stuff xmlns="http://testclash.com"/>
<NS1:testing1.1Stuff xmlns:NS5="http://www.someRandomUri.com" NS5:attr="value" xmlns:NS1="http://testclash.com"/>
</noNamespace>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value" xmlns:nearerThanPo="http://www.test.com">
<docEleChildChildChild nearerThanPo:attr1="value" NS1:attr2="value"/>
</docEleChildChild6>
</po2:docEleChild>
<![CDATA[some cdata]]>
</po:docEle>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<po:docEle xmlns:po="http://www.test.com" xmlns:NS1="http://testattr.com" NS1:attr1="value" NS1:attr2="value" xmlns:NS2="http://testattr2.com" NS2:attr3="value" po:attr4="value" xmlns:po3="http://testattr3.com" po3:attr7="value" NS2:attr5="value" NS2:attr6="value" xmlns:po2="http://www.test2.com">
<po2:docEleChild>
<docEleChildChild xmlns="http://www.test2.com"/>
<docEleChildChild2 xmlns="http://www.test3.com"/>
<po4:docEleChildChild3 xmlns:po4="http://www.test4.com"/>
<po4:docEleChildChild4 xmlns:po4="http://www.test4.com"/>
<docEleChildChild5 xmlns="http://www.test4.com" xmlns:NS1="http://testclash.com" NS1:attr9="value" xmlns:NS3="http://testattr.com" NS3:attr1="value" NS3:attr2="value" NS2:attr3="value" po:attr4="value" po3:attr7="value" xmlns:po4="http://testattr4.com" po4:attr8="value" xmlns:NS4="http://testattr5.com" NS4:attr10="value" NS2:attr5="value" NS2:attr6="value">
<noNamespace xmlns="" xmlns:NS1="">
<testing1.1Stuff xmlns="http://testclash.com"/>
<NS1:testing1.1Stuff xmlns:NS5="http://www.someRandomUri.com" NS5:attr="value" xmlns:NS1="http://testclash.com"/>
</noNamespace>
</docEleChildChild5>
<docEleChildChild6 xmlns="http://www.uri1.com" xmlns:uri1="http://www.uri1.com" uri1:attr1="value" xmlns:uri1b="http://www.uri1.com" uri1b:attr2="value" xmlns:nearerThanPo="http://www.test.com">
<docEleChildChildChild nearerThanPo:attr1="value" NS1:attr2="value"/>
</docEleChildChild6>
</po2:docEleChild>some cdata
</po:docEle>
+969
View File
@@ -0,0 +1,969 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/**
* $Id: RangeTest.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
/** This IRangeTest tests all of the cases delineated as examples
* in the DOM Level 2 Range specification, and a few others.
* <p>These do not by any means completely test the API and
* corner cases.
*/
#include <stdio.h>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/dom/DOMRange.hpp>
XERCES_CPP_NAMESPACE_USE
bool errorOccurred = false;
#define UNUSED(x) { if(x!=0){} }
#define TASSERT(c) tassert((c), __FILE__, __LINE__)
void tassert(bool c, const char *file, int line)
{
if (!c) {
errorOccurred = true;
printf("Failure. Line %d, file %s\n", line, file);
}
};
#define EXCEPTION_TEST(operation, expected_exception) \
{ \
try { \
operation; \
printf(" Error: no exception thrown at line %d\n", __LINE__); \
errorOccurred = true; \
} \
catch (DOMRangeException &e) { \
if (e.code != (DOMRangeException::RangeExceptionCode)expected_exception) { \
printf(" Wrong RangeException code: %d at line %d\n", e.code, __LINE__); \
errorOccurred = true; \
} \
} \
catch (DOMException &e) { \
if (e.code != (DOMException::ExceptionCode)expected_exception) { \
printf(" Wrong exception code: %d at line %d\n", e.code, __LINE__); \
errorOccurred = true; \
} \
} \
catch (...) { \
printf(" Wrong exception thrown at line %d\n", __LINE__); \
errorOccurred = true; \
} \
}
//Define a bunch of XMLCh* string for comparison
XMLCh xa[] = {chLatin_a, chNull};
XMLCh xab[] = {chLatin_a, chLatin_b, chNull};
XMLCh xabHello[] = {chLatin_a, chLatin_b, chLatin_H, chLatin_e, chLatin_l, chLatin_l, chLatin_o, chNull};
XMLCh xabHellocd[] = {chLatin_a, chLatin_b, chLatin_H, chLatin_e, chLatin_l, chLatin_l, chLatin_o, chSpace, chLatin_c, chLatin_d, chNull};
XMLCh xAnotherText[] = {chLatin_A, chLatin_n, chLatin_o, chLatin_t, chLatin_h, chLatin_e, chLatin_r,
chLatin_T, chLatin_e, chLatin_x, chLatin_t, chNull};
XMLCh xb[] = {chLatin_b, chNull};
XMLCh xBlahxyz[] = {chLatin_B, chLatin_l, chLatin_a, chLatin_h, chSpace,
chLatin_x, chLatin_y, chLatin_z, chNull};
XMLCh xBody[] = {chLatin_B, chLatin_o, chLatin_d, chLatin_y, chNull};
XMLCh xbody2[] = {chLatin_b, chLatin_o, chLatin_d, chLatin_y, chDigit_2, chNull};
XMLCh xc[] = {chLatin_c, chNull};
XMLCh xcool[] = {chLatin_c, chLatin_o, chLatin_o, chLatin_l, chNull};
XMLCh xef[] = {chLatin_e, chLatin_f, chNull};
XMLCh xElement1[] = {chLatin_E, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chDigit_1, chNull};
XMLCh xElement2[] = {chLatin_E, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chDigit_2, chNull};
XMLCh xElement3[] = {chLatin_E, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chDigit_3, chNull};
XMLCh xell[] = {chLatin_e, chLatin_l, chLatin_l, chNull};
XMLCh xellocd[] = {chLatin_e, chLatin_l, chLatin_l, chLatin_o, chSpace, chLatin_c, chLatin_d, chNull};
XMLCh xellocdef[] = {chLatin_e, chLatin_l, chLatin_l, chLatin_o, chSpace, chLatin_c, chLatin_d, chLatin_e, chLatin_f, chNull};
XMLCh xeplacedTextInsertedTexttle[] = {chLatin_e, chLatin_p, chLatin_l, chLatin_a, chLatin_c, chLatin_e, chLatin_d,
chLatin_T, chLatin_e, chLatin_x, chLatin_t, chLatin_I, chLatin_n, chLatin_s, chLatin_e, chLatin_r, chLatin_t, chLatin_e, chLatin_d,
chLatin_T, chLatin_e, chLatin_x, chLatin_t, chLatin_t, chLatin_l, chLatin_e, chNull};
XMLCh xex[] = {chLatin_e, chLatin_x, chNull};
XMLCh xext1[] = {chLatin_e, chLatin_x, chLatin_t, chDigit_1, chNull};
XMLCh xext3[] = {chLatin_e, chLatin_x, chLatin_t, chDigit_3, chNull};
XMLCh xfoo[] = {chLatin_f, chLatin_o, chLatin_o, chNull};
XMLCh xH1[] = {chLatin_H, chDigit_1, chNull};
XMLCh xh2[] = {chLatin_h, chDigit_2, chNull};
XMLCh xh3[] = {chLatin_h, chDigit_3, chNull};
XMLCh xh4[] = {chLatin_h, chDigit_4, chNull};
XMLCh xHellocd[] = {chLatin_H, chLatin_e, chLatin_l, chLatin_l, chLatin_o, chSpace, chLatin_c, chLatin_d, chNull};
XMLCh xhead[] = {chLatin_h, chLatin_e, chLatin_a, chLatin_d, chNull};
XMLCh xhead2[] = {chLatin_h, chLatin_e, chLatin_a, chLatin_d, chDigit_2, chNull};
XMLCh xInsertedText[] = {chLatin_I, chLatin_n, chLatin_s, chLatin_e, chLatin_r, chLatin_t, chLatin_e, chLatin_d,
chLatin_T, chLatin_e, chLatin_x, chLatin_t, chNull};
XMLCh xInsertedTexttle[] = {chLatin_I, chLatin_n, chLatin_s, chLatin_e, chLatin_r, chLatin_t, chLatin_e, chLatin_d,
chLatin_T, chLatin_e, chLatin_x, chLatin_t, chLatin_t, chLatin_l, chLatin_e, chNull};
XMLCh xmoo[] = {chLatin_m, chLatin_o, chLatin_o, chNull};
XMLCh xroot[] = {chLatin_r, chLatin_o, chLatin_o, chLatin_t, chNull};
XMLCh xroot2[] = {chLatin_r, chLatin_o, chLatin_o, chLatin_t, chDigit_2, chNull};
XMLCh xP[] = {chLatin_P, chNull};
XMLCh xp1[] = {chLatin_p, chDigit_1, chNull};
XMLCh xp2[] = {chLatin_p, chDigit_2, chNull};
XMLCh xptext2[] = {chLatin_p, chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_2, chNull};
XMLCh xReplacedText[] = {chLatin_R, chLatin_e, chLatin_p, chLatin_l, chLatin_a, chLatin_c, chLatin_e, chLatin_d,
chLatin_T, chLatin_e, chLatin_x, chLatin_t, chNull};
XMLCh xSurroundNode1[] = {chLatin_S, chLatin_u, chLatin_r, chLatin_r, chLatin_o, chLatin_u, chLatin_n, chLatin_d,
chLatin_N, chLatin_o, chLatin_d, chLatin_e, chDigit_1, chNull};
XMLCh xt[] = {chLatin_t, chNull};
XMLCh xtl[] = {chLatin_t, chLatin_l, chNull};
XMLCh xtext1[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_1, chNull};
XMLCh xtext2[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_2, chNull};
XMLCh xtext2ex[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_2, chLatin_e, chLatin_x, chNull};
XMLCh xtext3[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_3, chNull};
XMLCh xtext4[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_4, chNull};
XMLCh xtext4ext3[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_4, chLatin_e, chLatin_x, chLatin_t, chDigit_3, chNull};
XMLCh xttext4ext3[] = {chLatin_t, chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_4, chLatin_e, chLatin_x, chLatin_t, chDigit_3, chNull};
XMLCh xtext5[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_5, chNull};
XMLCh xtext6[] = {chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_6, chNull};
XMLCh xTi[] = {chLatin_T, chLatin_i, chNull};
XMLCh xTitle[] = {chLatin_T, chLatin_i, chLatin_t, chLatin_l, chLatin_e, chNull};
XMLCh xtle[] = {chLatin_t, chLatin_l, chLatin_e, chNull};
XMLCh xu[] = {chLatin_u, chNull};
XMLCh xupbody[] = {chLatin_u, chLatin_p, chLatin_b, chLatin_o, chLatin_d, chLatin_y, chNull};
XMLCh xupbody2[] = {chLatin_u, chLatin_p, chLatin_b, chLatin_o, chLatin_d, chLatin_y, chDigit_2, chNull};
XMLCh xupp1[] = {chLatin_u, chLatin_p, chLatin_p, chDigit_1, chNull};
XMLCh xuptext1[] = {chLatin_u, chLatin_p, chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_1, chNull};
XMLCh xuptext2[] = {chLatin_u, chLatin_p, chLatin_t, chLatin_e, chLatin_x, chLatin_t, chDigit_2, chNull};
int main()
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
char *pMessage = XMLString::transcode(toCatch.getMessage());
fprintf(stderr, "Error during XMLPlatformUtils::Initialize(). \n"
" Message is: %s\n", pMessage);
XMLString::release(&pMessage);
return -1;
}
/*
Range tests include testing of
createRange
setStart, setStartBefore. setStartAfter,
setEnd, setEndBefore. setEndAfter
getStartContainer, getStartOffset
getEndContainer, getEndOffset
getCommonAncestorContainer
selectNode
selectNodeContents
insertNode
deleteContents
collapse
getCollapsed
surroundContents
compareBoundaryPoints
cloneRange
cloneContents
extractContents
toString
detach
removeChild
*/
{
XMLCh tempStr[100];
XMLString::transcode("Range",tempStr,99);
{
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMDocument* doc = impl->createDocument();
//Creating a root element
DOMElement* root = doc->createElement(xBody);
doc->appendChild(root);
//Creating the siblings of root
DOMElement* E11 = doc->createElement(xH1);
root->appendChild(E11);
DOMElement* E12 = doc->createElement(xP);
root->appendChild(E12);
//Attaching texts to siblings
DOMText* textNode1 = doc->createTextNode(xTitle);
E11->appendChild(textNode1);
DOMText* textNode11 = doc->createTextNode(xAnotherText);
E11->appendChild(textNode11);
DOMText* textNode2 = doc->createTextNode(xBlahxyz);
E12->appendChild(textNode2);
DOMText* E210 = doc->createTextNode(xInsertedText);
UNUSED(E210); // silence warning
doc->release();
}
{
//DOM Tree and some usable node creation
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMDocument* doc = impl->createDocument();
//Creating a root element
DOMElement* root = doc->createElement(xBody);
doc->appendChild(root);
//Creating the siblings of root
DOMElement* E11 = doc->createElement(xH1);
root->appendChild(E11);
DOMElement* E12 = doc->createElement(xP);
root->appendChild(E12);
//Attaching texts to siblings
DOMText* textNode1 = doc->createTextNode(xTitle);
E11->appendChild(textNode1);
DOMText* textNode11 = doc->createTextNode(xAnotherText);
E11->appendChild(textNode11);
DOMText* textNode2 = doc->createTextNode(xBlahxyz);
E12->appendChild(textNode2);
//experimental nodes
DOMElement* E120 = doc->createElement(xElement1);
DOMElement* E121 = doc->createElement(xElement2);
DOMElement* E122 = doc->createElement(xElement3);
DOMElement* E311 = doc->createElement(xSurroundNode1);
DOMText* E210 = doc->createTextNode(xInsertedText);
DOMNode* rt = doc->getDocumentElement();
DOMRange* range = ((DOMDocumentRange*)doc)->createRange();
//Tests start here
// Initial dom tree looks like :
// <Body><H1>TitleAnother Text</H1><P>Blah xyz</P></Body>
//i.e., Body(rt)
// _____________|________________
// | |
// ___H1(E11)___ P(E12)
// | | |
// "Title" "Another Text" "Blah xyz"
//test for start and end settings of a range
range->setStart(rt->getFirstChild(), 0);
TASSERT(range->getStartContainer() == rt->getFirstChild() );
TASSERT(range->getStartOffset() == 0);
range->setEnd(rt->getFirstChild(), 1);
TASSERT(range->getEndContainer() == rt->getFirstChild() );
TASSERT(range->getEndOffset() == 1);
//DOMNode* node = range->getCommonAncestorContainer();
TASSERT(range->getCommonAncestorContainer() == rt->getFirstChild());
//selection related test
range->selectNode(rt->getLastChild());
TASSERT(range->getStartContainer() == rt);
TASSERT(range->getStartOffset() == 1);
TASSERT(range->getEndContainer() == rt);
TASSERT(range->getEndOffset() == 2);
//insertion related tests
range->insertNode(E120);
//only end offset moves and new node gets into range as being inserted at boundary point
TASSERT(range->getStartContainer() == rt);
TASSERT(range->getStartOffset() == 1);
TASSERT(range->getEndContainer() == rt);
TASSERT(range->getEndOffset() == 3);
range->insertNode(E121);
//only end offset moves and new node gets into range as being inserted at boundary point
TASSERT(range->getStartContainer() == rt);
TASSERT(range->getStartOffset() == 1);
TASSERT(range->getEndContainer() == rt);
TASSERT(range->getEndOffset() == 4);
rt->insertBefore(E122, rt->getFirstChild());
//both offsets move as new node is not part of the range
TASSERT(range->getStartContainer() == rt);
TASSERT(range->getStartOffset() == 2);
TASSERT(range->getEndContainer() == rt);
TASSERT(range->getEndOffset() == 5);
//After above operations, now the tree looks like:
// <Body><Element3/><H1>TitleAnother Text</H1><Element2/><Element1/><P>Blah xyz</P></Body>
//i.e., Body(rt)
// _____________|_______________________________________________________________
// | | | | |
// Element3(E122) ___H1(E11)___ Element2(E121) Element1(E120) P(E12)
// | | |
// "Title" "Another Text" "Blah xyz"
//
// range has rt as start and end container, and 2 as start offset, 5 as end offset
//changing selection
range->selectNode(rt->getLastChild()->getPreviousSibling());
TASSERT(range->getStartContainer() == rt);
TASSERT(range->getStartOffset() == 3);
TASSERT(range->getEndContainer() == rt);
TASSERT(range->getEndOffset() == 4);
//deleting related tests
range->deleteContents();
TASSERT(rt->getLastChild()->getPreviousSibling() == E121);
range->setStart(rt->getFirstChild()->getNextSibling()->getFirstChild(), 2);
TASSERT(range->getStartContainer() == rt->getFirstChild()->getNextSibling()->getFirstChild());
TASSERT(!XMLString::compareString(range->getStartContainer()->getNodeValue(),xTitle));
TASSERT(range->getStartOffset() == 2);
range->setEnd(rt->getFirstChild()->getNextSibling()->getFirstChild(), 4);
TASSERT(range->getEndContainer() == rt->getFirstChild()->getNextSibling()->getFirstChild());
TASSERT(!XMLString::compareString(range->getEndContainer()->getNodeValue(),xTitle));
TASSERT(range->getEndOffset() == 4);
TASSERT(!XMLString::compareString(range->toString(),xtl));
//inserting text between a text node
range->insertNode(E210);
//only end offset moves and new node gets into range as being inserted at boundary point
TASSERT(range->getStartContainer() == rt->getFirstChild()->getNextSibling()->getFirstChild());
TASSERT(range->getStartOffset() == 2);
TASSERT(range->getEndContainer() == rt->getFirstChild()->getNextSibling()->getLastChild()->getPreviousSibling());
TASSERT(range->getEndOffset() == 2);
//inserting element node before the selected text node
range->insertNode(E120);
//only end offset moves and new node gets into range as being inserted at boundary point
TASSERT(range->getStartContainer() == rt->getFirstChild()->getNextSibling()->getFirstChild());
TASSERT(!XMLString::compareString(range->getStartContainer()->getNodeValue(),xTi));
TASSERT(range->getStartOffset() == 2);
TASSERT(range->getEndContainer() == rt->getFirstChild()->getNextSibling()->getLastChild()->getPreviousSibling());
TASSERT(!XMLString::compareString(range->getEndContainer()->getNodeValue(),xtle));
TASSERT(range->getEndOffset() == 2);
TASSERT(E11->getChildNodes()->getLength()==6);
//checking the text replacment
range->getStartContainer()->setNodeValue(xReplacedText);
//only the start offset is impact
TASSERT(range->getStartContainer() == rt->getFirstChild()->getNextSibling()->getFirstChild());
TASSERT(!XMLString::compareString(range->getStartContainer()->getNodeValue(),xReplacedText));
TASSERT(range->getStartOffset() == 0);
TASSERT(range->getEndContainer() == rt->getFirstChild()->getNextSibling()->getLastChild()->getPreviousSibling());
TASSERT(!XMLString::compareString(range->getEndContainer()->getNodeValue(),xtle));
TASSERT(range->getEndOffset() == 2);
//After above operations, now the tree looks like:
// <Body><Element3/><H1>ReplacedText<Element1/>InsertedTexttleAnother Text</H1><Element2/><P>Blah xyz</P></Body>
//i.e., Body(rt)
// _____________|_______________________________________________________________________________________________
// | | | |
// Element3(E122) ___H1(E11)___________________________________________________________ Element2(E121) P(E12)
// | | | | | | |
// "ReplacedText" "" Element1(E120) "InsertedText"(E210) "tle" "Another Text" "Blah xyz"
//
// range has "ReplacedText" as start container and "tle" as end container
// and 0 as start offset, 2 as end offset
//changing the selection. Preparing for 'surround'
range->setStart(range->getStartContainer()->getParentNode(), 2);
range->setEnd(range->getStartContainer(), 5);
TASSERT(!XMLString::compareString(range->getStartContainer()->getNodeName(),xH1));
TASSERT(!XMLString::compareString(range->getEndContainer()->getNodeName(),xH1));
TASSERT(!XMLString::compareString(range->toString(),xInsertedTexttle));
range->surroundContents(E311);
TASSERT(!XMLString::compareString(range->getStartContainer()->getNodeName(),xH1));
TASSERT(range->getStartOffset() == 2);
TASSERT(!XMLString::compareString(range->getEndContainer()->getNodeName(),xH1));
TASSERT(range->getEndOffset() == 3);
TASSERT(E11->getChildNodes()->getLength()==4);
TASSERT(E311->getChildNodes()->getLength()==3);
TASSERT(!XMLString::compareString(range->toString(),xInsertedTexttle));
//After above operations, now the tree looks like:
// <Body><Element3/><H1>ReplacedText<SurroundNode1><Element1/>InsertedTexttle</SurroundNode1>Another Text</H1><Element2/><P>Blah xyz</P></Body>
//i.e., Body(rt)
// _____________|_________________________________________________________________________
// | | | |
// Element3(E122) ___H1(E11)___________________________________ Element2(E121) P(E12)
// | | | | |
// "ReplacedText" "" SurroundNode1(E311) "Another Text" "Blah xyz"
// ____________ |_____________________________
// | | |
// Element1(E120) "InsertedText"(E210) "tle"
//
// range has H1 as start and end container and 2 as start offset, 3 as end offset
//testing cloning
DOMRange* aRange = range->cloneRange();
TASSERT(aRange->getStartContainer() == range->getStartContainer());
TASSERT(aRange->getEndContainer() == range->getEndContainer());
TASSERT(aRange->getStartOffset() == 2);
TASSERT(aRange->getEndOffset() == 3);
//changing the new ranges start
aRange->setStart(aRange->getStartContainer()->getFirstChild(), 1);
//comparing the ranges
short compVal = range->compareBoundaryPoints(DOMRange::END_TO_END, aRange);
TASSERT(compVal == 0);
compVal = range->compareBoundaryPoints(DOMRange::START_TO_START, aRange);
TASSERT(compVal == 1);
compVal = range->compareBoundaryPoints(DOMRange::START_TO_END, aRange);
TASSERT(compVal == 1);
compVal = range->compareBoundaryPoints(DOMRange::END_TO_START, aRange);
TASSERT(compVal == -1);
//testing collapse
//not collapsed
TASSERT(range->getCollapsed() == false);
TASSERT(range->getStartOffset() == 2);
TASSERT(range->getEndOffset() == 3);
//selectNodeContents
range->selectNodeContents(rt->getLastChild()->getFirstChild());
TASSERT(range->getStartContainer() == rt->getLastChild()->getFirstChild());
TASSERT(range->getEndContainer() == rt->getLastChild()->getFirstChild());
TASSERT(range->getStartOffset() == 0);
TASSERT(range->getEndOffset() == 8);
TASSERT(!XMLString::compareString(range->toString(),xBlahxyz));
//testing collapse
range->collapse(true); //collapse to start
TASSERT(range->getCollapsed() == true);
TASSERT(range->getStartOffset() == 0);
TASSERT(range->getEndOffset() == 0);
TASSERT(!XMLString::compareString(range->toString(),XMLUni::fgZeroLenString));
TASSERT(aRange->getEndOffset() == 3); //other range is unaffected
TASSERT(!XMLString::compareString(aRange->toString(),xeplacedTextInsertedTexttle));
//After above operations, now the tree looks like:
// <Body><Element3/><H1>ReplacedText<SurroundNode1><Element1/>InsertedTexttle</SurroundNode1>Another Text</H1><Element2/><P>Blah xyz</P></Body>
//i.e., Body(rt)
// _____________|_________________________________________________________________________
// | | | |
// Element3(E122) ___H1(E11)___________________________________ Element2(E121) P(E12)
// | | | | |
// "ReplacedText" "" SurroundNode1(E311) "Another Text" "Blah xyz"
// ____________ |_____________________________
// | | |
// Element1(E120) "InsertedText"(E210) "tle"
//
// range has "Blah xyz" as start and end container and 0 as start and end offset (collapsed)
// aRange has "ReplacedText" as start container and H1 as end container
// and 1 as start offset and 3 as end offset
DOMDocumentFragment* docFrag = aRange->cloneContents();
TASSERT( docFrag != 0);
range->selectNode(rt->getFirstChild());
TASSERT(range->getStartContainer() == rt);
TASSERT(range->getEndContainer() == rt);
TASSERT(range->getStartOffset() == 0);
TASSERT(range->getEndOffset() == 1);
//Testing toString()
const XMLCh* str = aRange->toString();
TASSERT(!XMLString::compareString(str, xeplacedTextInsertedTexttle));
//start and end before and after tests
range->setStartBefore(rt->getFirstChild());
TASSERT(range->getStartOffset() == 0);
range->setEndBefore(rt->getFirstChild());
TASSERT(range->getEndOffset() == 0);
range->setStartAfter(rt->getLastChild());
TASSERT(range->getStartOffset() == 4);
range->setStartAfter(rt->getFirstChild());
TASSERT(range->getStartOffset() == 1);
range->setEndBefore(rt->getLastChild());
TASSERT(range->getEndOffset() == 3);
range->setEndAfter(rt->getLastChild());
TASSERT(range->getEndOffset() == 4);
//testing extract()
DOMDocumentFragment* frag2 = range->extractContents();
TASSERT( frag2 != 0);
//After above operations, now the tree looks like:
// <Body><Element3/></Body>
//i.e., Body(rt)
// |
// Element3(E122)
//
// aRange has rt as start and end container, and 1 as start and end offset (collapsed)
// range has rt as start and end container, and 1 as start and end offset (collapsed)
//
//and frag2 looks:
// <Body>ReplacedText<SurroundNode1><Element1/>InsertedTexttle</SurroundNode1>Another Text</H1><Element2/><P>Blah xyz</P></Body>
//i.e., Body(rt)
// ______________|________________________________________________________
// | | |
// ___H1(E11)___________________________________ Element2(E121) P(E12)
// | | | | |
//"ReplacedText" "" SurroundNode1(E311) "Another Text" "Blah xyz"
// ____________ |_____________________________
// | | |
// Element1(E120) "InsertedText"(E210) "tle"
//
//the tree do not have those node anymore after extract
//only Element3 left
TASSERT(rt->getChildNodes()->getLength()==1);
//aRange is collapsed
TASSERT(aRange->getCollapsed() == true);
TASSERT(aRange->getStartContainer() == rt);
TASSERT(aRange->getStartOffset() == 1);
TASSERT(aRange->getEndContainer() == rt);
TASSERT(aRange->getEndOffset() == 1);
//range is collapsed as well
TASSERT(range->getCollapsed() == true);
TASSERT(range->getStartContainer() == rt);
TASSERT(range->getStartOffset() == 1);
TASSERT(range->getEndContainer() == rt);
TASSERT(range->getEndOffset() == 1);
//test the document fragment frag2
TASSERT(frag2->getChildNodes()->getLength()==3);
//detaching the other range
aRange->detach();
range->detach();
//***************************************************************
//another set of test
//TEST createRange, setStart and setEnd, insertnode
//***************************************************************
DOMImplementation* impl2 = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMDocument* doc2 = impl2->createDocument();
DOMElement* root2 = doc2->createElement(xroot2);
doc2->appendChild(root2);
//case 1: simple text node, start==end
// <body>text1</body>
DOMElement* body = doc2->createElement(xBody);
DOMText* text1 = doc2->createTextNode(xtext1);
body->appendChild(text1);
root2->appendChild(body);
//set range
DOMRange* range1 = doc2->createRange();
range1->setStart(text1,1);
range1->setEnd(text1,3);
TASSERT(!XMLString::compareString(range1->toString(),xex));
TASSERT(range1->getStartOffset()==1);
TASSERT(!XMLString::compareString(range1->getStartContainer()->getNodeValue(),xtext1));
TASSERT(range1->getEndOffset()==3);
TASSERT(!XMLString::compareString(range1->getEndContainer()->getNodeValue(),xtext1));
//now insert a text node
//<body>ttext2ext1</body>
DOMText* text2 = doc2->createTextNode(xtext2);
range1->insertNode(text2);
TASSERT(!XMLString::compareString(range1->toString(),xtext2ex));
TASSERT(range1->getStartOffset()==1);
TASSERT(!XMLString::compareString(range1->getStartContainer()->getNodeValue(),xt));
TASSERT(range1->getEndOffset()==2);
TASSERT(!XMLString::compareString(range1->getEndContainer()->getNodeValue(),xext1));
//now insert a non-text node
//<body>t<p1/>text2ext1</body>
DOMElement* p1 = doc2->createElement(xp1);
range1->insertNode(p1);
TASSERT(!XMLString::compareString(range1->toString(),xtext2ex));
TASSERT(range1->getStartOffset()==1);
TASSERT(!XMLString::compareString(range1->getStartContainer()->getNodeValue(),xt));
TASSERT(range1->getEndOffset()==2);
TASSERT(!XMLString::compareString(range1->getEndContainer()->getNodeValue(),xext1));
//case 2: non-text node, start==end
// <head><h1/></head>
DOMElement* head = doc2->createElement(xhead);
DOMElement* h1 = doc2->createElement(xH1);
head->appendChild(h1);
root2->appendChild(head);
//set range
DOMRange* range2 = doc2->createRange();
range2->setStart(head,0);
range2->setEnd(head,1);
TASSERT(!XMLString::compareString(range2->toString(),XMLUni::fgZeroLenString));
TASSERT(range2->getStartOffset()==0);
TASSERT(!XMLString::compareString(range2->getStartContainer()->getNodeName(),xhead));
TASSERT(range2->getEndOffset()==1);
TASSERT(!XMLString::compareString(range2->getEndContainer()->getNodeName(),xhead));
//now insert a non-text node
//<head><h2/><h1/></head>
DOMElement* h2 = doc2->createElement(xh2);
range2->insertNode(h2);
TASSERT(!XMLString::compareString(range2->toString(),XMLUni::fgZeroLenString));
TASSERT(range2->getStartOffset()==0);
TASSERT(!XMLString::compareString(range2->getStartContainer()->getNodeName(),xhead));
TASSERT(range2->getEndOffset()==2);
TASSERT(!XMLString::compareString(range2->getEndContainer()->getNodeName(),xhead));
//now insert a text node
//<head>text5<h2/><h1/></head>
DOMText* text5 = doc2->createTextNode(xtext5);
range2->insertNode(text5);
TASSERT(!XMLString::compareString(range2->toString(),xtext5));
TASSERT(range2->getStartOffset()==0);
TASSERT(!XMLString::compareString(range2->getStartContainer()->getNodeName(),xhead));
TASSERT(range2->getEndOffset()==3);
TASSERT(!XMLString::compareString(range2->getEndContainer()->getNodeName(),xhead));
//case 3: simple text node, start!=end
// <body2>text3</body2>
DOMElement* body2 = doc2->createElement(xbody2);
DOMText* text3 = doc2->createTextNode(xtext3);
body2->appendChild(text3);
root2->appendChild(body2);
//set range
DOMRange* range3 = ((DOMDocumentRange*)doc2)->createRange();
range3->setStart(text3,1);
range3->setEnd(body2,1);
TASSERT(!XMLString::compareString(range3->toString(),xext3));
TASSERT(range3->getStartOffset()==1);
TASSERT(!XMLString::compareString(range3->getStartContainer()->getNodeValue(),xtext3));
TASSERT(range3->getEndOffset()==1);
TASSERT(!XMLString::compareString(range3->getEndContainer()->getNodeName(),xbody2));
//now insert a textnode
//<body2>ttext4ext3</body2>
DOMText* text4 = doc2->createTextNode(xtext4);
range3->insertNode(text4);
TASSERT(!XMLString::compareString(range3->toString(),XMLUni::fgZeroLenString));
TASSERT(range3->getStartOffset()==1);
TASSERT(!XMLString::compareString(range3->getStartContainer()->getNodeValue(),xt));
TASSERT(range3->getEndOffset()==1);
TASSERT(!XMLString::compareString(range3->getEndContainer()->getNodeName(),xbody2));
//now insert a non-text node
//<body2>t<p2/>text4ext3</body2>
DOMElement* p2 = doc2->createElement(xp2);
range3->insertNode(p2);
//extra empty node caused by splitting 't'
TASSERT(!XMLString::compareString(range3->toString(),XMLUni::fgZeroLenString));
TASSERT(range3->getStartOffset()==1);
TASSERT(!XMLString::compareString(range3->getStartContainer()->getNodeValue(),xt));
TASSERT(range3->getEndOffset()==1);
TASSERT(!XMLString::compareString(range3->getEndContainer()->getNodeName(),xbody2));
//test toString a bit
range3->setStart(body2,1);
range3->setEnd(body2,5);
TASSERT(!XMLString::compareString(range3->toString(),xtext4ext3));
range3->setStart(body2,0);
range3->setEnd(body2,5);
TASSERT(!XMLString::compareString(range3->toString(),xttext4ext3));
//case 4: non-text node, start!=end
// <head2><h3/></head2>
DOMElement* head2 = doc2->createElement(xhead2);
DOMElement* h3 = doc2->createElement(xh3);
head2->appendChild(h3);
root2->appendChild(head2);
//set range
DOMRange* range4 = doc2->createRange();
range4->setStart(head2,0);
range4->setEnd(h3,0);
TASSERT(!XMLString::compareString(range4->toString(),XMLUni::fgZeroLenString));
TASSERT(range4->getStartOffset()==0);
TASSERT(!XMLString::compareString(range4->getStartContainer()->getNodeName(),xhead2));
TASSERT(range4->getEndOffset()==0);
TASSERT(!XMLString::compareString(range4->getEndContainer()->getNodeName(),xh3));
//now insert a non-text node
//<head2><h4/><h3/></head2>
DOMElement* h4 = doc2->createElement(xh4);
range4->insertNode(h4);
TASSERT(!XMLString::compareString(range4->toString(),XMLUni::fgZeroLenString));
TASSERT(range4->getStartOffset()==0);
TASSERT(!XMLString::compareString(range4->getStartContainer()->getNodeName(),xhead2));
TASSERT(range4->getEndOffset()==0);
TASSERT(!XMLString::compareString(range4->getEndContainer()->getNodeName(),xh3));
//now insert a text node
//<head2>text6<h4/><h3/></head2>
DOMText* text6 = doc2->createTextNode(xtext6);
range4->insertNode(text6);
TASSERT(!XMLString::compareString(range4->toString(),xtext6));
TASSERT(range4->getStartOffset()==0);
TASSERT(!XMLString::compareString(range4->getStartContainer()->getNodeName(),xhead2));
TASSERT(range4->getEndOffset()==0);
TASSERT(!XMLString::compareString(range4->getEndContainer()->getNodeName(),xh3));
//***************************************************************
// quick test of updating
//***************************************************************
// <upbody>text1</upbody>
DOMElement* upbody = doc2->createElement(xupbody);
DOMText* uptext1 = doc2->createTextNode(xuptext1);
upbody->appendChild(uptext1);
root2->appendChild(upbody);
DOMRange* uprange = ((DOMDocumentRange*)doc2)->createRange();
uprange->setStart(upbody,0);
uprange->setEnd(upbody,1);
TASSERT(!XMLString::compareString(uprange->toString(),xuptext1));
TASSERT(uprange->getStartOffset()==0);
TASSERT(!XMLString::compareString(uprange->getStartContainer()->getNodeName(),xupbody));
TASSERT(uprange->getEndOffset()==1);
TASSERT(!XMLString::compareString(uprange->getEndContainer()->getNodeName(),xupbody));
// split text
uptext1->splitText(1);
TASSERT(!XMLString::compareString(uprange->toString(),xu));
TASSERT(uprange->getStartOffset()==0);
TASSERT(!XMLString::compareString(uprange->getStartContainer()->getNodeName(),xupbody));
TASSERT(uprange->getEndOffset()==1);
TASSERT(!XMLString::compareString(uprange->getEndContainer()->getNodeName(),xupbody));
//insert node
DOMElement* upbody2 = doc2->createElement(xupbody2);
DOMText* uptext2 = doc2->createTextNode(xuptext2);
upbody2->appendChild(uptext2);
root2->appendChild(upbody2);
DOMRange* uprange2 = ((DOMDocumentRange*)doc2)->createRange();
uprange2->setStart(uptext2,1);
uprange2->setEnd(upbody2,1);
DOMRange* uprange3 = doc2->createRange();
uprange3->setStart(uptext2,1);
uprange3->setEnd(upbody2,1);
TASSERT(!XMLString::compareString(uprange2->toString(),xptext2));
TASSERT(uprange2->getStartOffset()==1);
TASSERT(!XMLString::compareString(uprange2->getStartContainer()->getNodeValue(),xuptext2));
TASSERT(uprange2->getEndOffset()==1);
TASSERT(!XMLString::compareString(uprange2->getEndContainer()->getNodeName(),xupbody2));
TASSERT(!XMLString::compareString(uprange3->toString(),xptext2));
TASSERT(uprange3->getStartOffset()==1);
TASSERT(!XMLString::compareString(uprange3->getStartContainer()->getNodeValue(),xuptext2));
TASSERT(uprange3->getEndOffset()==1);
TASSERT(!XMLString::compareString(uprange3->getEndContainer()->getNodeName(),xupbody2));
DOMElement* upp1 = doc2->createElement(xupp1);
uprange2->insertNode(upp1);
TASSERT(!XMLString::compareString(uprange2->toString(),XMLUni::fgZeroLenString));
TASSERT(uprange2->getStartOffset()==1);
TASSERT(!XMLString::compareString(uprange2->getStartContainer()->getNodeValue(),xu));
TASSERT(uprange2->getEndOffset()==1);
TASSERT(!XMLString::compareString(uprange2->getEndContainer()->getNodeName(),xupbody2));
TASSERT(!XMLString::compareString(uprange3->toString(),XMLUni::fgZeroLenString));
TASSERT(uprange3->getStartOffset()==1);
TASSERT(!XMLString::compareString(uprange3->getStartContainer()->getNodeValue(),xu));
TASSERT(uprange3->getEndOffset()==1);
TASSERT(!XMLString::compareString(uprange3->getEndContainer()->getNodeName(),xupbody2));
//***************************************************************
//another set of test
//<foo><c/><moo><b/></moo>ab<a>Hello cd</a><cool>ef</cool></foo>
//
// ______________________foo_____________________
// | | | | |
// c moo "ab" a cool
// | | |
// b "Hello cd" "ef"
//
DOMImplementation* impl3 = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMDocument* doc3 = impl3->createDocument();
DOMElement* root3 = doc3->createElement(xroot);
doc3->appendChild(root3);
DOMElement* foo = doc3->createElement(xfoo);
DOMElement* moo = doc3->createElement(xmoo);
DOMElement* cool = doc3->createElement(xcool);
DOMText* ab = doc3->createTextNode(xab);
DOMText* cd = doc3->createTextNode(xHellocd);
DOMText* ef = doc3->createTextNode(xef);
DOMElement* a = doc3->createElement(xa);
DOMElement* b = doc3->createElement(xb);
DOMElement* c = doc3->createElement(xc);
root3->appendChild(foo);
foo->appendChild(c);
foo->appendChild(moo);
foo->appendChild(ab);
foo->appendChild(a);
foo->appendChild(cool);
moo->appendChild(b);
a->appendChild(cd);
cool->appendChild(ef);
//***************************************************************
//TEST toString
//***************************************************************
DOMRange* newtestrange = ((DOMDocumentRange*)doc3)->createRange();
//case 1:
//start container is text node
// i) end container is also text node
// a) start==end
// b) start!=end
// ii) end container is not text node
// a) start==end => impossible
// b) start!=end
//
//case 2:
//start container is not text node
// i) end container is text node
// a) start==end => impossible
// b) start!=end
// ii) end container is not text node
// a) start==end
// b) start!=end
//case 1, i, a
newtestrange->setStart( cd, 1 );
newtestrange->setEnd( cd, 4 );
TASSERT(!XMLString::compareString(newtestrange->toString(),xell));
//case 1, i, b
newtestrange->setStart( cd, 1 );
newtestrange->setEnd( ef, 2 );
TASSERT(!XMLString::compareString(newtestrange->toString(),xellocdef));
//case 1, ii, b
newtestrange->setStart( cd, 1 );
newtestrange->setEnd( foo, 4 );
TASSERT(!XMLString::compareString(newtestrange->toString(),xellocd));
//case 2, i, b
newtestrange->setStart( foo, 1 );
newtestrange->setEnd( cd, 5 );
TASSERT(!XMLString::compareString(newtestrange->toString(),xabHello));
//case 2, ii, a
newtestrange->setStart( foo, 1 );
newtestrange->setEnd( foo, 4 );
TASSERT(!XMLString::compareString(newtestrange->toString(),xabHellocd));
//case 2, ii, b
newtestrange->setStart( moo, 1 );
newtestrange->setEnd( foo, 4 );
TASSERT(!XMLString::compareString(newtestrange->toString(),xabHellocd));
//***************************************************************
//test removeChild
//***************************************************************
DOMRange* newrange = doc3->createRange();
newrange->setStart( moo, 0 );
newrange->setEnd( foo, 4 );
TASSERT(newrange->getStartOffset()==0);
TASSERT(!XMLString::compareString(newrange->getStartContainer()->getNodeName(),xmoo));
TASSERT(newrange->getEndOffset()==4);
TASSERT(!XMLString::compareString(newrange->getEndContainer()->getNodeName(),xfoo));
TASSERT(!XMLString::compareString(newrange->toString(),xabHellocd));
DOMNode* n = newrange->cloneContents();
UNUSED(n); // silence warning
DOMNodeList* nol = foo->getChildNodes();
//removing moo
DOMNode* rem = foo->removeChild(nol->item(1));
rem->release();
TASSERT(newrange->getStartOffset()==1);
TASSERT(!XMLString::compareString(newrange->getStartContainer()->getNodeName(),xfoo));
TASSERT(newrange->getEndOffset()==3);
TASSERT(!XMLString::compareString(newrange->getEndContainer()->getNodeName(),xfoo));
TASSERT(!XMLString::compareString(newrange->toString(),xabHellocd));
TASSERT(newtestrange->getStartOffset()==1);
TASSERT(!XMLString::compareString(newtestrange->getStartContainer()->getNodeName(),xfoo));
TASSERT(newtestrange->getEndOffset()==3);
TASSERT(!XMLString::compareString(newtestrange->getEndContainer()->getNodeName(),xfoo));
TASSERT(!XMLString::compareString(newtestrange->toString(),xabHellocd));
// Now do some exception test
newrange->detach();
EXCEPTION_TEST(newrange->setStart( moo, 0 ), DOMException::INVALID_STATE_ERR);
EXCEPTION_TEST(newtestrange->setStartBefore(moo), DOMRangeException::INVALID_NODE_TYPE_ERR);
doc->release();
doc2->release();
doc3->release();
}
} //creating the dom tree and tests
// And call the termination method
XMLPlatformUtils::Terminate();
if (errorOccurred) {
printf("Test Failed\n");
return 4;
}
printf("Test Run Successfully\n");
return 0;
};
+557
View File
@@ -0,0 +1,557 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
//
// Various DOM tests.
// Contents include
// 1. NodeIterator tests
// 2. Tree Walker tests
// All individual are wrapped in a memory leak checker.
//
// This is NOT a complete test of DOM functionality.
//
/*
* $Id: Traversal.cpp 671894 2008-06-26 13:29:21Z borisk $
*/
#include <stdio.h>
#include <string.h>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
XERCES_CPP_NAMESPACE_USE
bool errorOccurred = false;
#define UNUSED(x) { if(x!=0){} }
#define TASSERT(c) tassert((c), __FILE__, __LINE__)
void tassert(bool c, const char *file, int line)
{
if (!c) {
printf("Failure. Line %d, file %s\n", line, file);
errorOccurred = true;
}
};
#define EXCEPTION_TEST(operation, expected_exception) \
{ \
try { \
operation; \
printf(" Error: no exception thrown at line %d\n", __LINE__); \
errorOccurred = true; \
} \
catch (DOMException &e) { \
if (e.code != expected_exception) { \
printf(" Wrong exception code: %d at line %d\n", e.code, __LINE__); \
errorOccurred = true; \
} \
} \
catch (...) { \
printf(" Wrong exception thrown at line %d\n", __LINE__); \
errorOccurred = true; \
} \
}
class MyFilter : public DOMNodeFilter {
public:
MyFilter(short nodeType, bool reject=false) : DOMNodeFilter(), fNodeType(nodeType), fReject(reject) {};
virtual FilterAction acceptNode(const DOMNode* node) const;
private:
short fNodeType;
bool fReject;
};
/*
Node Types can be of the following:
ELEMENT_NODE = 1,
ATTRIBUTE_NODE = 2,
TEXT_NODE = 3,
CDATA_SECTION_NODE = 4,
ENTITY_REFERENCE_NODE = 5,
ENTITY_NODE = 6,
PROCESSING_INSTRUCTION_NODE = 7,
COMMENT_NODE = 8,
DOCUMENT_NODE = 9,
DOCUMENT_TYPE_NODE = 10,
DOCUMENT_FRAGMENT_NODE = 11,
NOTATION_NODE = 12
*/
DOMNodeFilter::FilterAction MyFilter::acceptNode(const DOMNode* node) const {
if (fNodeType == 0)
return DOMNodeFilter::FILTER_ACCEPT;
if (node->getNodeType() == fNodeType) {
return DOMNodeFilter::FILTER_ACCEPT;
} else {
return fReject ? DOMNodeFilter::FILTER_REJECT : DOMNodeFilter::FILTER_SKIP;
}
}
int main()
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
char *pMessage = XMLString::transcode(toCatch.getMessage());
fprintf(stderr, "Error during XMLPlatformUtils::Initialize(). \n"
" Message is: %s\n", pMessage);
XMLString::release(&pMessage);
return -1;
}
// Create a XMLCh buffer for string manipulation
XMLCh tempStr[4000];
XMLCh featureStr[100];
XMLString::transcode("Traversal",featureStr,99);
//
// Doc - Create a small document tree
//
{
//creating a DOM Tree
/* Tests are based on the tree structure below
doc - root - E11 (attr01) - textNode1
- E111
- E112
- cdataSec
- E12 (attr02) - textNode2
- E121
- E122
- E13 - E131
- docPI
- comment
*/
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(featureStr);
DOMDocument* doc = impl->createDocument();
//Creating a root element
XMLString::transcode("RootElement", tempStr, 3999);
DOMElement* root = doc->createElement(tempStr);
doc->appendChild(root);
//Creating the siblings of root
XMLString::transcode("FirstSibling", tempStr, 3999);
DOMElement* E11 = doc->createElement(tempStr);
root->appendChild(E11);
XMLString::transcode("SecondSibling", tempStr, 3999);
DOMElement* E12 = doc->createElement(tempStr);
root->appendChild(E12);
XMLString::transcode("ThirdSibling", tempStr, 3999);
DOMElement* E13 = doc->createElement(tempStr);
root->appendChild(E13);
//Attaching texts to few siblings
XMLString::transcode("Text1", tempStr, 3999);
DOMText* textNode1 = doc->createTextNode(tempStr);
E11->appendChild(textNode1);
XMLString::transcode("Text2", tempStr, 3999);
DOMText* textNode2 = doc->createTextNode(tempStr);
E12->appendChild(textNode2);
//creating child of siblings
XMLString::transcode("FirstSiblingChild1", tempStr, 3999);
DOMElement* E111 = doc->createElement(tempStr);
E11->appendChild(E111);
XMLString::transcode("Attr01", tempStr, 3999);
DOMAttr* attr01 = doc->createAttribute(tempStr);
DOMNode* rem = E11->setAttributeNode(attr01);
if (rem)
rem->release();
XMLString::transcode("FirstSiblingChild2", tempStr, 3999);
DOMElement* E112 = doc->createElement(tempStr);
E11->appendChild(E112);
XMLString::transcode("SecondSiblingChild1", tempStr, 3999);
DOMElement* E121 = doc->createElement(tempStr);
E12->appendChild(E121);
XMLString::transcode("Attr01", tempStr, 3999);
DOMAttr* attr02 = doc->createAttribute(tempStr);
rem = E12->setAttributeNode(attr02);
if (rem)
rem->release();
XMLString::transcode("SecondSiblingChild2", tempStr, 3999);
DOMElement* E122 = doc->createElement(tempStr);
E12->appendChild(E122);
XMLString::transcode("ThirdSiblingChild1", tempStr, 3999);
DOMElement* E131 = doc->createElement(tempStr);
E13->appendChild(E131);
XMLString::transcode("DocComment", tempStr, 3999);
DOMComment* comment = doc->createComment(tempStr);
root->appendChild(comment);
XMLString::transcode("DocCDataSection", tempStr, 3999);
DOMCDATASection* cdataSec = doc->createCDATASection(tempStr);
E11->appendChild(cdataSec);
XMLString::transcode("DocPI", tempStr, 3999);
XMLCh piStr[] = {chLatin_D, chLatin_o, chLatin_c, chLatin_P, chLatin_I, chNull};
DOMProcessingInstruction* docPI = doc->createProcessingInstruction(piStr, tempStr);
E13->appendChild(docPI);
/*
following are whatToShow types:
SHOW_ALL = 0x0000FFFF,
SHOW_ELEMENT = 0x00000001,
SHOW_ATTRIBUTE = 0x00000002,
SHOW_TEXT = 0x00000004,
SHOW_CDATA_SECTION = 0x00000008,
SHOW_ENTITY_REFERENCE = 0x00000010,
SHOW_ENTITY = 0x00000020,
SHOW_PROCESSING_INSTRUCTION = 0x00000040,
SHOW_COMMENT = 0x00000080,
SHOW_DOCUMENT = 0x00000100,
SHOW_DOCUMENT_TYPE = 0x00000200,
SHOW_DOCUMENT_FRAGMENT = 0x00000400,
SHOW_NOTATION = 0x00000800
*/
////////// NodeIterator Test Cases ////////////////
{
// all node iterating test
DOMNode* node = doc->getFirstChild();
UNUSED(node); // silence warning
unsigned long whatToShow = DOMNodeFilter::SHOW_ALL;
MyFilter* filter = new MyFilter(0);
DOMNodeIterator* iter = ((DOMDocumentTraversal*)doc)->createNodeIterator(root, whatToShow, filter, true);
TASSERT(iter->getWhatToShow() == 65535);
TASSERT(iter->getExpandEntityReferences() == 1);
DOMNode* nd;
nd = iter->nextNode();
TASSERT (nd ==root);
nd = iter->nextNode();
TASSERT (nd ==E11);
nd = iter->nextNode();
TASSERT(nd == textNode1);
nd = iter->nextNode();
TASSERT(nd == E111);
nd = iter->nextNode();
TASSERT(nd == E112);
nd = iter->nextNode();
TASSERT(nd == cdataSec);
nd = iter->nextNode();
TASSERT(nd == E12);
nd = iter->nextNode();
TASSERT(nd == textNode2);
nd = iter->nextNode();
TASSERT(nd == E121);
nd = iter->nextNode();
TASSERT(nd == E122);
nd = iter->nextNode();
TASSERT(nd == E13);
nd = iter->nextNode();
TASSERT(nd == E131);
nd = iter->nextNode();
TASSERT(nd == docPI);
nd = iter->nextNode();
TASSERT(nd == comment);
nd = iter->previousNode();
TASSERT(nd == comment);
nd = iter->previousNode();
TASSERT(nd == docPI);
nd = iter->previousNode();
TASSERT(nd == E131);
//test getRoot
TASSERT(iter->getRoot() == root);
TASSERT(iter->getRoot() != doc);
delete filter;
}
{
//element node iterating test
DOMNode* node = doc->getFirstChild();
UNUSED(node); // silence warning
unsigned long whatToShow = DOMNodeFilter::SHOW_ELEMENT;
MyFilter* filter = new MyFilter(DOMNode::ELEMENT_NODE);
DOMNodeIterator* iter = doc->createNodeIterator(root, whatToShow, filter, true);
TASSERT(iter->getWhatToShow() == 1);
TASSERT(iter->getExpandEntityReferences() == 1);
DOMNode* nd;
nd = iter->nextNode();
TASSERT (nd ==root);
nd = iter->nextNode();
TASSERT (nd ==E11);
nd = iter->nextNode();
TASSERT(nd == E111);
nd = iter->nextNode();
TASSERT(nd == E112);
nd = iter->nextNode();
TASSERT(nd == E12);
nd = iter->nextNode();
TASSERT(nd == E121);
nd = iter->nextNode();
TASSERT(nd == E122);
nd = iter->nextNode();
TASSERT(nd == E13);
nd = iter->nextNode();
TASSERT(nd == E131);
nd = iter->previousNode();
TASSERT(nd == E131);
nd = iter->previousNode();
TASSERT(nd == E13);
nd = iter->previousNode();
TASSERT(nd == E122);
delete filter;
}
{
// Text node iterating test
DOMNode* node = doc->getFirstChild();
UNUSED(node); // silence warning
unsigned long whatToShow = DOMNodeFilter::SHOW_TEXT;
MyFilter* filter = new MyFilter(DOMNode::TEXT_NODE);
DOMNodeIterator* iter = ((DOMDocumentTraversal*)doc)->createNodeIterator(root, whatToShow, filter, true);
TASSERT(iter->getWhatToShow() == 4);
TASSERT(iter->getExpandEntityReferences() == 1);
DOMNode* nd;
nd = iter->nextNode();
TASSERT (nd ==textNode1);
nd = iter->nextNode();
TASSERT (nd ==textNode2);
nd = iter->previousNode();
TASSERT(nd == textNode2);
delete filter;
}
{
//CDataSection node itearating test
DOMNode* node = doc->getFirstChild();
UNUSED(node); // silence warning
unsigned long whatToShow = DOMNodeFilter::SHOW_CDATA_SECTION;
MyFilter* filter = new MyFilter(DOMNode::CDATA_SECTION_NODE);
DOMNodeIterator* iter = doc->createNodeIterator(root, whatToShow, filter, true);
TASSERT(iter->getWhatToShow() == 8);
TASSERT(iter->getExpandEntityReferences() == 1);
DOMNode* nd;
nd = iter->nextNode();
TASSERT(nd == cdataSec);
nd = iter->nextNode();
TASSERT(nd == 0);
delete filter;
}
{
// PI nodes iterating test
DOMNode* node = doc->getFirstChild();
UNUSED(node); // silence warning
unsigned long whatToShow = DOMNodeFilter::SHOW_PROCESSING_INSTRUCTION;
MyFilter* filter = new MyFilter(DOMNode::PROCESSING_INSTRUCTION_NODE);
DOMNodeIterator* iter = ((DOMDocumentTraversal*)doc)->createNodeIterator(root, whatToShow, filter, true);
TASSERT(iter->getWhatToShow() == 64);
TASSERT(iter->getExpandEntityReferences() == 1);
DOMNode* nd;
nd = iter->nextNode();
TASSERT(nd == docPI);
nd = iter->nextNode();
TASSERT(nd == 0);
delete filter;
}
{
DOMNode* node = doc->getFirstChild();
UNUSED(node); // silence warning
unsigned long whatToShow = DOMNodeFilter::SHOW_COMMENT;
MyFilter* filter = new MyFilter(DOMNode::COMMENT_NODE);
DOMNodeIterator* iter = doc->createNodeIterator(root, whatToShow, filter, true);
TASSERT(iter->getWhatToShow() == 128);
TASSERT(iter->getExpandEntityReferences() == 1);
DOMNode* nd;
nd = iter->nextNode();
TASSERT(nd == comment);
nd = iter->nextNode();
TASSERT(nd == 0);
delete filter;
}
////////// TreeWalker Test Cases ////////////////
{
unsigned long whatToShow = DOMNodeFilter::SHOW_ALL;
DOMTreeWalker* tw = ((DOMDocumentTraversal*)doc)->createTreeWalker(doc, whatToShow, 0, true);
TASSERT(tw->getCurrentNode() == doc);
TASSERT(tw->firstChild() == root);
TASSERT(tw->nextSibling() == 0);
TASSERT(tw->lastChild() == comment);
TASSERT(tw->firstChild() == 0);
TASSERT(tw->lastChild() == 0);
TASSERT(tw->nextSibling() == 0);
TASSERT(tw->nextNode() == 0);
TASSERT(tw->previousSibling() == E13);
TASSERT(tw->previousNode() == E122);
TASSERT(tw->parentNode() == E12);
TASSERT(tw->firstChild() == textNode2);
TASSERT(tw->previousSibling() == 0);
TASSERT(tw->nextSibling() == E121);
TASSERT(tw->nextNode() == E122);
TASSERT(tw->parentNode() == E12);
TASSERT(tw->previousSibling() == E11);
TASSERT(tw->previousNode() == root);
TASSERT(tw->previousNode() == doc);
TASSERT(tw->previousNode() == 0);
TASSERT(tw->parentNode() == 0);
TASSERT(tw->getCurrentNode() == doc);
}
{
MyFilter mf(DOMNode::ELEMENT_NODE);
unsigned long whatToShow = DOMNodeFilter::SHOW_ALL;
DOMTreeWalker* tw = doc->createTreeWalker(root, whatToShow, &mf, true);
TASSERT(tw->getCurrentNode() == root);
TASSERT(tw->parentNode() == 0); //should not change currentNode
TASSERT(tw->getCurrentNode() == root);
TASSERT(tw->nextNode() == E11);
TASSERT(tw->nextNode() == E111);
tw->setCurrentNode(E12);
//when first is not visible, should it go to its sibling?
TASSERT(tw->firstChild() == E121); //first visible child
TASSERT(tw->previousSibling() == 0);
}
{
MyFilter mf(DOMNode::ELEMENT_NODE, true);
unsigned long whatToShow = DOMNodeFilter::SHOW_ELEMENT;
DOMTreeWalker* tw = ((DOMDocumentTraversal*)doc)->createTreeWalker(root, whatToShow, &mf, true);
tw->setCurrentNode(E12);
TASSERT(tw->firstChild() == E121); //still first visible child
}
{
MyFilter mf(DOMNode::TEXT_NODE);
unsigned long whatToShow = DOMNodeFilter::SHOW_TEXT;
DOMTreeWalker* tw = doc->createTreeWalker(root, whatToShow, &mf, true);
//when first is not visible, should it go to its descendent?
TASSERT(tw->firstChild() == textNode1); //E11 skipped
TASSERT(tw->firstChild() == 0);
TASSERT(tw->nextNode() == textNode2);
TASSERT(tw->nextSibling() == 0);
TASSERT(tw->parentNode() == 0); //no visible ancestor
TASSERT(tw->getCurrentNode() == textNode2);
tw->setCurrentNode(root);
//when last is not visible, should it go to its sibling & descendent?
TASSERT(tw->lastChild() == textNode2); //last visible child
tw->setCurrentNode(E12);
//when next sibling is not visible, should it go to its descendent?
TASSERT(tw->nextSibling() == 0);
}
{
MyFilter mf(DOMNode::TEXT_NODE, true);
unsigned long whatToShow = DOMNodeFilter::SHOW_TEXT;
DOMTreeWalker* tw = ((DOMDocumentTraversal*)doc)->createTreeWalker(root, whatToShow, &mf, true);
TASSERT(tw->firstChild() == 0); //E11 rejected and no children is TEXT
TASSERT(tw->getCurrentNode() == root);
TASSERT(tw->nextNode() == 0); //E11 rejected so can't get to textNode1
//test getRoot
TASSERT(tw->getRoot() == root);
TASSERT(tw->getRoot() != doc);
}
doc->release();
};
// And call the termination method
XMLPlatformUtils::Terminate();
if (errorOccurred) {
printf("Test Failed\n");
return 4;
}
printf("Test Run Successfully\n");
return 0;
};
+982
View File
@@ -0,0 +1,982 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 "TypeInfo.hpp"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOMException.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
#define UNUSED(x) { if(x!=0){} }
#define DOMTYPEINFOTEST(info, type, uri, line) \
tmp = XMLString::equals(info->getTypeName(), type) && XMLString::equals(info->getTypeNamespace(), uri);\
if(!tmp) { \
XERCES_STD_QUALIFIER cerr << "DOMTypeInfo test failed at line, " << line << "\nExpected values : typename '" << XMLString::transcode((XMLCh*)type) << "', uri '" << XMLString::transcode((XMLCh*)uri); \
XERCES_STD_QUALIFIER cerr << "'\nActual values : typename '"; \
if(info->getTypeName()) \
XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getTypeName()); \
else \
XERCES_STD_QUALIFIER cerr << "(null)"; \
XERCES_STD_QUALIFIER cerr << "', uri '"; \
if(info->getTypeNamespace()) \
XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getTypeNamespace()); \
else \
XERCES_STD_QUALIFIER cerr << "(null)"; \
XERCES_STD_QUALIFIER cerr << "'\n" << XERCES_STD_QUALIFIER endl; \
passed = false; \
}
bool tmp;
// ---------------------------------------------------------------------------
// This is a simple class that lets us do easy (though not terribly efficient)
// trancoding of char* data to XMLCh data.
// ---------------------------------------------------------------------------
class XStr
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XStr(const char* const toTranscode)
{
// Call the private transcoding method
fUnicodeForm = XMLString::transcode(toTranscode);
}
~XStr()
{
XMLString::release(&fUnicodeForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const XMLCh* unicodeForm() const
{
return fUnicodeForm;
}
private :
// -----------------------------------------------------------------------
// Private data members
//
// fUnicodeForm
// This is the Unicode XMLCh format of the string.
// -----------------------------------------------------------------------
XMLCh* fUnicodeForm;
};
#define X(str) XStr(str).unicodeForm()
// This is a simple class that lets us do easy (though not terribly efficient)
// trancoding of XMLCh data to local code page for display.
// ---------------------------------------------------------------------------
class StrX
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
StrX(const XMLCh* const toTranscode)
{
// Call the private transcoding method
fLocalForm = XMLString::transcode(toTranscode);
}
~StrX()
{
XMLString::release(&fLocalForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const char* localForm() const
{
return fLocalForm;
}
private :
// -----------------------------------------------------------------------
// Private data members
//
// fLocalForm
// This is the local code page form of the string.
// -----------------------------------------------------------------------
char* fLocalForm;
};
#define StrX(str) StrX(str).localForm()
TypeInfo::TypeInfo() {
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException &toCatch)
{
XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n"
<< " Exception message:"
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
}
parser = 0;
}
TypeInfo::~TypeInfo() {
XMLPlatformUtils::Terminate();
}
bool TypeInfo::testInBuiltTypesOnAttributes(bool DTDPresent) {
bool passed = true;
DOMElement *testEle = findElement(X("attrTest"));
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("attrTestType"), X(""), __LINE__);
DOMAttr *testAttr;
testAttr = testEle->getAttributeNodeNS(0, X("anySimpleType"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("string"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("boolean"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_BOOLEAN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("decimal"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("float"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_FLOAT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("double"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DOUBLE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("duration"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DURATION, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("dateTime"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATETIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("time"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_TIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("date"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("gYearMonth"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEARMONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("gYear"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEAR, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("gMonthDay"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTHDAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("gDay"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("gMonth"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("hexBinary"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_HEXBINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("base64Binary"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_BASE64BINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("anyURI"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("QName"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_QNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("normalizedString"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NORMALIZEDSTRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("token"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_TOKEN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("language"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_LANGUAGE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("NMTOKEN"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgNmTokenString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("NMTOKENS"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgNmTokensString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("Name"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("NCName"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NCNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("ID"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgIDString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("IDREF"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgIDRefString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("IDREFS"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgIDRefsString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
if(DTDPresent) {
testAttr = testEle->getAttributeNodeNS(0, X("ENTITY"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgEntityString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("ENTITIES"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgEntitiesString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
}
testAttr = testEle->getAttributeNodeNS(0, X("integer"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("nonPositiveInteger"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONPOSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("negativeInteger"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("long"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_LONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("int"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("short"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_SHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("byte"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_BYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("nonNegativeInteger"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONNEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("unsignedLong"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ULONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("unsignedInt"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_UINT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("unsignedShort"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_USHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("unsignedByte"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_UBYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("positiveInteger"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_POSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
//couple of defaulted ones
testAttr = testEle->getAttributeNodeNS(0, X("defaultString"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("defaultInt"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
//ns attr
testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/2000/xmlns/"), X("prefix"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/2001/XMLSchema-instance"), X("noNamespaceSchemaLocation"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
return passed;
}
bool TypeInfo::testInBuiltTypesOnElements() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
//the eleTest element.
DOMElement *testEle = findElement(X("eleTest"));
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_BOOLEAN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_FLOAT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DOUBLE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DURATION, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATETIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_TIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEARMONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEAR, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTHDAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_HEXBINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_BASE64BINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_QNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NORMALIZEDSTRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_TOKEN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_LANGUAGE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), XMLUni::fgNmTokenString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), XMLUni::fgNmTokensString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NCNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONPOSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_LONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_INT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_SHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_BYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONNEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_ULONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_UINT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_USHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_UBYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_POSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
return passed;
}
bool TypeInfo::testSimpleDerived() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
//element simpleDerTest
DOMElement *testEle = (DOMElement *)docEle->getFirstChild()->getNextSibling()->getNextSibling()
->getNextSibling()->getNextSibling()->getNextSibling();
DOMAttr *testAtt = testEle->getAttributeNodeNS(0, X("decimalDerived"));
DOMTYPEINFOTEST(testAtt->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
testAtt = testEle->getAttributeNodeNS(0, X("stringDerived"));
DOMTYPEINFOTEST(testAtt->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
return passed;
}
bool TypeInfo::testComplexTypes() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
//element complexTest
DOMElement *testEle = findElement(X("complexTest"));
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("complexTestType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("complexDerTestType"), X(""), __LINE__);
return passed;
}
bool TypeInfo::testUnions() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
DOMAttr *testAttr;
//element unionTest
DOMElement *testEle = findElement(X("unionTest"));
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
return passed;
}
bool TypeInfo::testAnonymous() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
DOMAttr *testAttr;
//element anonymousTest
DOMElement *testEle = findElement(X("anonymousTest"));
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonC1"), X(""), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("partNum"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("__AnonS7"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonS2"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonS4"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonS6"), X(""), __LINE__);
return passed;
}
bool TypeInfo::testXsiTypes() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
//element xsiTypeTest
DOMElement *testEle = findElement(X("xsiTypeTest"));
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("base"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level1"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level2"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("baseComplex"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level1Complex"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level2Complex"), X(""), __LINE__);
return passed;
}
bool TypeInfo::testAnys() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
DOMAttr *testAttr;
//element anyTestPartial
DOMElement *testEle = findElement(X("anyTestPartial"));
DOMElement *back = testEle;
testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/1999/xhtml"), X("attr2"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("anyTestPartialType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
//element anyTest
testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
back = testEle;
testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr1"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr2"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr3"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr4"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("anyTestType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
//anyTestAttr1
testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
back = testEle;
testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr5"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
//anyTestAttr2
testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
back = testEle;
testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr5"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
//anyTestMissing
testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
back = testEle;
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("anyTestType"), X(""), __LINE__);
return passed;
}
bool TypeInfo::testInvaild() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
DOMAttr *testAttr;
DOMTYPEINFOTEST(((DOMElement *)docEle)->getSchemaTypeInfo(), X("rootType"), X(""), __LINE__);
//element invalidTest
DOMElement *testEle = findElement(X("invalidTest"));
testAttr = testEle->getAttributeNodeNS(X(""), X("simple"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("invalid"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("baseComplex"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
// this is a "number" of type "base" but it has a xsi:type="stringDerivedType"
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("baseComplex"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("uType"), X(""), __LINE__);
//an undeclared element does not have anon value. Test this here
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
DOMElement *testEle2 = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle2->getSchemaTypeInfo(), 0, 0, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("attrOnlyType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("attrOnlyType"), X(""), __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("prohibitedAttrType"), X(""), __LINE__);
return passed;
}
bool TypeInfo::compareDOMTypeInfo(const DOMTypeInfo *info, const XMLCh* type, const XMLCh* uri) {
return XMLString::equals(info->getTypeName(), type) && XMLString::equals(info->getTypeNamespace(), uri);
}
bool TypeInfo::testDTD() {
bool passed = true;
DOMElement *testEle = doc->getDocumentElement();
DOMAttr *testAttr;
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X(""), X(""), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("cdata"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("CDATA"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("enum"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ENUMERATION"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("id"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ID"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("idRef"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("IDREF"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("idRefs"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("IDREFS"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("nmToken"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKEN"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokenDefault"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKEN"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokenDefault2"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKEN"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokens"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKENS"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("entity"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ENTITY"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("entities"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ENTITIES"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("notation"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NOTATION"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("noDecl"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("CDATA"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
testAttr = testEle->getAttributeNode(X("xmlns:foo"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("CDATA"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
return passed;
}
bool TypeInfo::combinedTest() {
bool passed = true;
DOMNode *docEle = doc->getDocumentElement();
UNUSED(docEle); // silence warning
DOMAttr *testAttr;
DOMElement *testEle = doc->getDocumentElement();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("rootType"), X(""), __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("attBoth"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("attSchema"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testAttr = testEle->getAttributeNodeNS(X(""), X("attDTD"));
DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
return passed;
}
DOMElement* TypeInfo::findElement(const XMLCh *name) const {
DOMNode *toTest = doc->getDocumentElement()->getFirstChild();
while(!XMLString::equals(toTest->getNodeName(), name)) {
toTest = toTest->getNextSibling();
}
return (DOMElement *)toTest;
}
int main(int /*argc*/, char ** /*argv*/)
{
bool passed = true;
TypeInfo ti;
try {
//first the combined DTD/Schema scanner
ti.parser = new XercesDOMParser;
ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
ti.parser->setCreateSchemaInfo(true);
ti.parser->setDoNamespaces(true);
ti.parser->setDoSchema(true);
ti.parser->parse("data/TypeInfo.xml");
ti.doc = ti.parser->getDocument();
}
catch (...) {
XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfo.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
delete ti.parser;
return false;
}
// test only if we got a doc
if (ti.doc) {
passed &= ti.testInBuiltTypesOnAttributes(true);
passed &= ti.testInBuiltTypesOnElements();
passed &= ti.testSimpleDerived();
passed &= ti.testComplexTypes();
passed &= ti.testUnions();
passed &= ti.testAnonymous();
passed &= ti.testXsiTypes();
passed &= ti.testAnys();
passed &= ti.testInvaild();
}
else
XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
delete ti.parser;
//lets do the same for the just schema scanner
try {
ti.parser = new XercesDOMParser;
ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
ti.parser->setCreateSchemaInfo(true);
ti.parser->setDoNamespaces(true);
ti.parser->setDoSchema(true);
ti.parser->useScanner(X("SGXMLScanner"));
ti.parser->parse("data/TypeInfoNoDTD.xml");
ti.doc = ti.parser->getDocument();
}
catch (...) {
XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoNoDTD.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
delete ti.parser;
return false;
}
// test only if we got a doc
if (ti.doc) {
passed &= ti.testInBuiltTypesOnAttributes(false);
passed &= ti.testInBuiltTypesOnElements();
passed &= ti.testSimpleDerived();
passed &= ti.testComplexTypes();
passed &= ti.testUnions();
passed &= ti.testAnonymous();
passed &= ti.testXsiTypes();
passed &= ti.testAnys();
passed &= ti.testInvaild();
}
else
XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
delete ti.parser;
//now default for DTD
try {
ti.parser = new XercesDOMParser;
ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
ti.parser->setCreateSchemaInfo(true);
ti.parser->parse("data/TypeInfoJustDTD.xml");
ti.doc = ti.parser->getDocument();
}
catch (...) {
XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoJustDTD.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
delete ti.parser;
return false;
}
// test only if we got a doc
if (ti.doc) {
passed &= ti.testDTD();
}
else
XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
delete ti.parser;
//and specific scanner
try {
ti.parser = new XercesDOMParser;
ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
ti.parser->setCreateSchemaInfo(true);
ti.parser->useScanner(X("DGXMLScanner"));
ti.parser->parse("data/TypeInfoJustDTD.xml");
ti.doc = ti.parser->getDocument();
}
catch (...) {
XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoJustDTD.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
delete ti.parser;
return false;
}
// test only if we got a doc
if (ti.doc) {
passed &= ti.testDTD();
}
else
XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
delete ti.parser;
try {
ti.parser = new XercesDOMParser;
ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
ti.parser->setCreateSchemaInfo(true);
ti.parser->setDoNamespaces(true);
ti.parser->setDoSchema(true);
ti.parser->parse("data/combined.xml");
ti.doc = ti.parser->getDocument();
}
catch (...) {
XERCES_STD_QUALIFIER cerr << "parsing data/combined.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
delete ti.parser;
return false;
}
// test only if we got a doc
if (ti.doc) {
passed &= ti.combinedTest();
}
else
XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
delete ti.parser;
if (!passed) {
XERCES_STD_QUALIFIER cerr << "test failed" << XERCES_STD_QUALIFIER endl;
return 4;
}
XERCES_STD_QUALIFIER cerr << "Test Run Successfully" << XERCES_STD_QUALIFIER endl;
return 0;
}
+59
View File
@@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
// define null for compatibility with original Java source code.
#define null 0
#include <xercesc/dom/DOM.hpp>
XERCES_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_BEGIN
class XercesDOMParser;
XERCES_CPP_NAMESPACE_END
class TypeInfo {
public:
TypeInfo();
~TypeInfo();
bool testInBuiltTypesOnElements();
bool testInBuiltTypesOnAttributes(bool DTDPresent);
bool testSimpleDerived();
bool testComplexTypes();
bool testUnions();
bool testAnonymous();
bool testXsiTypes();
bool testInvaild();
bool testAnys();
bool testDTD();
bool combinedTest();
bool compareDOMTypeInfo(const DOMTypeInfo *info, const XMLCh* type, const XMLCh* uri);
XercesDOMParser *parser;
DOMDocument *doc;
private:
DOMElement* findElement(const XMLCh *name) const ;
};
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault="unqualified" targetNamespace="http://www.secondSchema" xmlns:ss="http://www.secondSchema">
<xs:element name="realTag1" type="xs:string" />
<xs:element name="realTag2" type="xs:string" />
<xs:element name="realTag3" type="xs:string" />
<xs:attribute name="attr1" type="xs:string" />
<xs:attribute name="attr2" type="xs:integer" />
<xs:attribute name="attr3" type="ss:unionType" />
<xs:attribute name="attr4" type="ss:unionType" />
<xs:simpleType name="unionType" >
<xs:union memberTypes="xs:integer xs:string" />
</xs:simpleType>
</xs:schema>
+22
View File
@@ -0,0 +1,22 @@
<!NOTATION png SYSTEM 'http://xml.apache.org' >
<!ENTITY APACHE SYSTEM 'xml.apache.org' NDATA png>
<!ELEMENT attributeTest EMPTY >
<!ATTLIST attributeTest
xmlns:foo CDATA #REQUIRED
cdata CDATA #REQUIRED
enum (a | b) #REQUIRED
id ID #REQUIRED
idRef IDREF #REQUIRED
idRefs IDREFS #REQUIRED
nmToken NMTOKEN #REQUIRED
nmTokenDefault NMTOKEN "lala"
nmTokenDefault2 NMTOKEN "lala2"
nmTokens NMTOKENS #REQUIRED
entity ENTITY #REQUIRED
entities ENTITIES #REQUIRED
notation NOTATION (png) #REQUIRED
>
+170
View File
@@ -0,0 +1,170 @@
<!DOCTYPE root SYSTEM "TypeInfo.dtd" >
<root xsi:noNamespaceSchemaLocation="TypeInfo.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ss="http://www.secondSchema" >
<attrTest
anySimpleType="asdas"
string="string"
boolean="true"
decimal="2.0"
float="2.1"
double="2.1"
duration="P1Y2M3DT10H30M"
dateTime="2000-10-30T11:12:00"
time="11:12:00"
date="2000-10-30"
gYearMonth="1999-01"
gYear="1999"
gMonthDay="--01-08"
gDay="---21"
gMonth="--12--"
hexBinary="0FB7"
base64Binary="abcd"
anyURI="http://www.example.com/"
QName="xsla"
normalizedString="example"
token="example"
language="en"
NMTOKEN="example"
NMTOKENS="example bar"
Name="example"
NCName="example"
integer="1"
nonPositiveInteger="-1"
negativeInteger="-1"
long="1"
int="1"
short="1"
byte="1"
nonNegativeInteger="1"
unsignedLong="1"
unsignedInt="1"
unsignedShort="1"
unsignedByte="1"
positiveInteger="1"
ID="abc"
IDREF="abc"
IDREFS="abc"
ENTITY="APACHE"
ENTITIES="APACHE"
defaultString="test"
xmlns:prefix="http://lala"
xsi:noNamespaceSchemaLocation="hello"
/>
<eleTest >
<level1string >string</level1string>
<level1boolean >true</level1boolean>
<level1decimal >2.0</level1decimal>
<level1float >2.1</level1float>
<level1double >2.1</level1double>
<level1duration >P1Y2M3DT10H30M</level1duration>
<level1dateTime >2000-10-30T11:12:00</level1dateTime>
<level1time >11:12:00</level1time>
<level1date >2000-10-30</level1date>
<level1gYearMonth >1999-01</level1gYearMonth>
<level1gYear >1999</level1gYear>
<level1gMonthDay >--01-08</level1gMonthDay>
<level1gDay >---21</level1gDay>
<level1gMonth >--12--</level1gMonth>
<level1hexBinary >0FB7</level1hexBinary>
<level1base64Binary >abcd</level1base64Binary>
<level1anyURI >http://www.example.com/</level1anyURI>
<level1QName >xsla</level1QName>
<level1normalizedString >example</level1normalizedString>
<level1token >example</level1token>
<level1language >en</level1language>
<level1NMTOKEN >example</level1NMTOKEN>
<level1NMTOKENS >example bar</level1NMTOKENS>
<level1Name >example</level1Name>
<level1NCName >example</level1NCName>
<level1integer >1</level1integer>
<level1nonPositiveInteger >-1</level1nonPositiveInteger>
<level1negativeInteger >-1</level1negativeInteger>
<level1long >1</level1long>
<level1int >1</level1int>
<level1short >1</level1short>
<level1byte >1</level1byte>
<level1nonNegativeInteger >1</level1nonNegativeInteger>
<level1unsignedLong >1</level1unsignedLong>
<level1unsignedInt >1</level1unsignedInt>
<level1unsignedShort >1</level1unsignedShort>
<level1unsignedByte >1</level1unsignedByte>
<level1positiveInteger >1</level1positiveInteger>
<level1anyType />
</eleTest>
<simpleDerTest decimalDerived="50" stringDerived="hello" >
<decimalDerived >20</decimalDerived>
<stringDerived >hello</stringDerived>
</simpleDerTest>
<complexTest a="abcd" b="hello" c="50" >
<a >abcd</a>
<b >hello</b>
<c >50</c>
</complexTest>
<complexDerTest a="abcd" b="hello" c="50" >
<a >abcd</a>
<b >hello</b>
<c >50</c>
<d >abcdefg</d>
</complexDerTest>
<unionTest >
<testEle >50</testEle>
<testEle >hello</testEle>
<testEle >200</testEle>
<testEle >abcdefg</testEle>
<testEle2 testAttr="50" testAttr2="hello" />
<testEle2 testAttr="hello" testAttr2="50" />
<testEle2 testAttr="200" testAttr2="abcdefg" />
<testEle2 testAttr="abcdefg" testAttr2="200" />
</unionTest>
<anonymousTest partNum="50">
<quantity>50</quantity>
<size>25</size>
<anonElement>11</anonElement>
</anonymousTest>
<xsiTypeTest>
<number>99</number>
<number xsi:type="level1" >74</number>
<number xsi:type="level2" >49</number>
<complexXsi >
<a >a</a>
</complexXsi>
<complexXsi xsi:type="level1Complex" >
<a >a</a>
<b >b</b>
</complexXsi>
<complexXsi xsi:type="level2Complex" >
<a >a</a>
<b >b</b>
<c >c</c>
</complexXsi>
</xsiTypeTest>
<anyTestPartial xhtml:attr2="some value" >
<xhtml:fakeTag1 />
<xhtml:fakeTag2 />
<ss:realTag1 >la</ss:realTag1>
</anyTestPartial>
<anyTest ss:attr1="string" ss:attr2="2" ss:attr3="string" ss:attr4="2">
<ss:realTag2 >la</ss:realTag2>
<ss:realTag3 >la</ss:realTag3>
<ss:notRealTag >la</ss:notRealTag>
</anyTest>
<anyTestAttr1 ss:attr5="2" />
<anyTestAttr2 ss:attr5="2" />
<anyTestMissing />
<invalidTest simple="abcd" invalid="asdas" >
<simple >abcd</simple>
<complex >
<a >asa</a>
<invalid />
</complex>
<number xsi:type="stringDerivedType" >74</number>
<complexXsi xsi:type="simpleDerTestType" >
<a >a</a>
<b >b</b>
</complexXsi>
<unionTest >hello1</unionTest>
<empty ><a /><a /></empty>
<invalidAttrTest attr="lala" />
<missingAttrTest />
<prohibitedAttrTest attr="lala" />
</invalidTest>
</root>
+352
View File
@@ -0,0 +1,352 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault="unqualified" xmlns:foo="http://anothernamespace.com" >
<xs:import namespace="http://www.secondSchema" schemaLocation="SecondSchema.xsd" />
<xs:element name="root" type="rootType" />
<xs:complexType name="rootType" >
<xs:sequence>
<xs:element name="attrTest" type="attrTestType" />
<xs:element name="eleTest" type="eleTestType" />
<xs:element name="simpleDerTest" type="simpleDerTestType" />
<xs:element name="complexTest" type="complexTestType" />
<xs:element name="complexDerTest" type="complexDerTestType" />
<xs:element name="unionTest" type="unionTest" />
<xs:element name="anonymousTest" >
<xs:complexType>
<xs:sequence>
<xs:element name="quantity">
<xs:simpleType>
<xs:restriction base="xs:positiveInteger">
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name='size'>
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base='xs:integer'/>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base='xs:string'/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>
<xs:element ref="anonElement" />
</xs:sequence>
<xs:attribute name="partNum" >
<xs:simpleType>
<xs:restriction base="xs:positiveInteger">
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="xsiTypeTest" type="xsiTypeTestType" />
<xs:element name="anyTestPartial" type="anyTestPartialType" />
<xs:element name="anyTest" type="anyTestType" />
<xs:element name="anyTestAttr1" type="anyTestAttr1Type" />
<xs:element name="anyTestAttr2" type="anyTestAttr2Type" />
<xs:element name="anyTestMissing" type="anyTestType" />
<xs:element name="invalidTest" type="invalidTestType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="anyTestPartialType" >
<xs:sequence >
<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="skip" />
<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="lax" />
<xs:any namespace="http://www.secondSchema" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="http://www.w3.org/1999/xhtml" processContents="skip" />
</xs:complexType>
<xs:complexType name="anyTestType" >
<xs:sequence >
<xs:any namespace="http://www.secondSchema" processContents="lax"/>
<xs:any namespace="http://www.secondSchema" processContents="strict"/>
<xs:any namespace="http://www.secondSchema" processContents="strict"/>
</xs:sequence>
<xs:anyAttribute namespace="http://www.secondSchema" processContents="lax" />
</xs:complexType>
<xs:complexType name="anyTestAttr1Type" >
<xs:anyAttribute namespace="http://www.secondSchema" processContents="strict" />
</xs:complexType>
<xs:complexType name="anyTestAttr2Type" >
<xs:anyAttribute namespace="http://www.secondSchema" processContents="lax" />
</xs:complexType>
<xs:complexType name="invalidTestType" >
<xs:sequence >
<xs:element name="simple" type="stringDerivedType" />
<xs:element name="complex" type="baseComplex" />
<xs:element name="number" type="base" />
<xs:element name="complexXsi" type="baseComplex" />
<xs:element name="unionTest" type="uType" />
<xs:element name="invalidAttrTest" type="attrOnlyType" />
<xs:element name="missingAttrTest" type="attrOnlyType" />
<xs:element name="prohibitedAttrTest" type="prohibitedAttrType" />
</xs:sequence>
<xs:attribute name="simple" type="stringDerivedType" />
</xs:complexType>
<xs:complexType name="prohibitedAttrType" >
<xs:attribute name="attr" type="stringDerivedType" use="prohibited" />
</xs:complexType>
<xs:complexType name="attrOnlyType" >
<xs:attribute name="attr" type="stringDerivedType" use="required" />
</xs:complexType>
<xs:simpleType name="uType" >
<xs:union memberTypes="stringDerivedType" />
</xs:simpleType>
<xs:complexType name="xsiTypeTestType" >
<xs:sequence>
<xs:element name="number" type="base" maxOccurs="3"/>
<xs:element name="complexXsi" type="baseComplex" maxOccurs="3"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="baseComplex" >
<xs:sequence>
<xs:element name="a" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="level1Complex" >
<xs:complexContent >
<xs:extension base="baseComplex" >
<xs:sequence>
<xs:element name="b" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="level2Complex" >
<xs:complexContent >
<xs:extension base="level1Complex" >
<xs:sequence>
<xs:element name="c" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="base" >
<xs:restriction base="xs:decimal" >
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="level1" >
<xs:restriction base="base" >
<xs:maxExclusive value="75"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="level2" >
<xs:restriction base="level1" >
<xs:maxExclusive value="50"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="anonElement" >
<xs:simpleType >
<xs:restriction base="xs:decimal" >
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:complexType name="eleTestType" >
<xs:sequence >
<xs:element name="level1string" type="xs:string" />
<xs:element name="level1boolean" type="xs:boolean" />
<xs:element name="level1decimal" type="xs:decimal" />
<xs:element name="level1float" type="xs:float" />
<xs:element name="level1double" type="xs:double" />
<xs:element name="level1duration" type="xs:duration" />
<xs:element name="level1dateTime" type="xs:dateTime" />
<xs:element name="level1time" type="xs:time" />
<xs:element name="level1date" type="xs:date" />
<xs:element name="level1gYearMonth" type="xs:gYearMonth" />
<xs:element name="level1gYear" type="xs:gYear" />
<xs:element name="level1gMonthDay" type="xs:gMonthDay" />
<xs:element name="level1gDay" type="xs:gDay" />
<xs:element name="level1gMonth" type="xs:gMonth" />
<xs:element name="level1hexBinary" type="xs:hexBinary" />
<xs:element name="level1base64Binary" type="xs:base64Binary" />
<xs:element name="level1anyURI" type="xs:anyURI" />
<xs:element name="level1QName" type="xs:QName" />
<xs:element name="level1normalizedString" type="xs:normalizedString" />
<xs:element name="level1token" type="xs:token" />
<xs:element name="level1language" type="xs:language" />
<xs:element name="level1NMTOKEN" type="xs:NMTOKEN" />
<xs:element name="level1NMTOKENS" type="xs:NMTOKENS" />
<xs:element name="level1Name" type="xs:Name" />
<xs:element name="level1NCName" type="xs:NCName" />
<xs:element name="level1integer" type="xs:integer" />
<xs:element name="level1nonPositiveInteger" type="xs:nonPositiveInteger" />
<xs:element name="level1negativeInteger" type="xs:negativeInteger" />
<xs:element name="level1long" type="xs:long" />
<xs:element name="level1int" type="xs:int" />
<xs:element name="level1short" type="xs:short" />
<xs:element name="level1byte" type="xs:byte" />
<xs:element name="level1nonNegativeInteger" type="xs:nonNegativeInteger" />
<xs:element name="level1unsignedLong" type="xs:unsignedLong" />
<xs:element name="level1unsignedInt" type="xs:unsignedInt" />
<xs:element name="level1unsignedShort" type="xs:unsignedShort" />
<xs:element name="level1unsignedByte" type="xs:unsignedByte" />
<xs:element name="level1positiveInteger" type="xs:positiveInteger" />
<xs:element name="level1anyType" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="attrTestType" >
<xs:attribute name="anySimpleType" type="xs:anySimpleType" />
<xs:attribute name="string" type="xs:string" />
<xs:attribute name="boolean" type="xs:boolean" />
<xs:attribute name="decimal" type="xs:decimal" />
<xs:attribute name="float" type="xs:float" />
<xs:attribute name="double" type="xs:double" />
<xs:attribute name="duration" type="xs:duration" />
<xs:attribute name="dateTime" type="xs:dateTime" />
<xs:attribute name="time" type="xs:time" />
<xs:attribute name="date" type="xs:date" />
<xs:attribute name="gYearMonth" type="xs:gYearMonth" />
<xs:attribute name="gYear" type="xs:gYear" />
<xs:attribute name="gMonthDay" type="xs:gMonthDay" />
<xs:attribute name="gDay" type="xs:gDay" />
<xs:attribute name="gMonth" type="xs:gMonth" />
<xs:attribute name="hexBinary" type="xs:hexBinary" />
<xs:attribute name="base64Binary" type="xs:base64Binary" />
<xs:attribute name="anyURI" type="xs:anyURI" />
<xs:attribute name="QName" type="xs:QName" />
<xs:attribute name="normalizedString" type="xs:normalizedString" />
<xs:attribute name="token" type="xs:token" />
<xs:attribute name="language" type="xs:language" />
<xs:attribute name="NMTOKEN" type="xs:NMTOKEN" />
<xs:attribute name="NMTOKENS" type="xs:NMTOKENS" />
<xs:attribute name="Name" type="xs:Name" />
<xs:attribute name="NCName" type="xs:NCName" />
<xs:attribute name="ID" type="xs:ID" />
<xs:attribute name="IDREF" type="xs:IDREF" />
<xs:attribute name="IDREFS" type="xs:IDREFS" />
<xs:attribute name="ENTITY" type="xs:ENTITY" />
<xs:attribute name="ENTITIES" type="xs:ENTITIES" />
<xs:attribute name="integer" type="xs:integer" />
<xs:attribute name="nonPositiveInteger" type="xs:nonPositiveInteger" />
<xs:attribute name="negativeInteger" type="xs:negativeInteger" />
<xs:attribute name="long" type="xs:long" />
<xs:attribute name="int" type="xs:int" />
<xs:attribute name="short" type="xs:short" />
<xs:attribute name="byte" type="xs:byte" />
<xs:attribute name="nonNegativeInteger" type="xs:nonNegativeInteger" />
<xs:attribute name="unsignedLong" type="xs:unsignedLong" />
<xs:attribute name="unsignedInt" type="xs:unsignedInt" />
<xs:attribute name="unsignedShort" type="xs:unsignedShort" />
<xs:attribute name="unsignedByte" type="xs:unsignedByte" />
<xs:attribute name="positiveInteger" type="xs:positiveInteger" />
<xs:attribute name="defaultString" type="xs:string" default="hello" />
<xs:attribute name="defaultInt" type="xs:integer" default="12" />
</xs:complexType>
<xs:complexType name="simpleDerTestType" >
<xs:sequence>
<xs:element name="decimalDerived" type="decimalDerivedType" />
<xs:element name="stringDerived" type="stringDerivedType" />
</xs:sequence>
<xs:attribute name="decimalDerived" type="decimalDerivedType" />
<xs:attribute name="stringDerived" type="stringDerivedType" />
</xs:complexType>
<xs:simpleType name="stringDerivedType" >
<xs:restriction base="xs:string" >
<xs:pattern value="hello"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="decimalDerivedType" >
<xs:restriction base="xs:decimal" >
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="complexTestType" >
<xs:sequence>
<xs:element name="a" type="xs:string"/>
<xs:element name="b" type="stringDerivedType"/>
<xs:element name="c" type="decimalDerivedType"/>
</xs:sequence>
<xs:attribute name="a" type="xs:string" />
<xs:attribute name="b" type="stringDerivedType" />
<xs:attribute name="c" type="decimalDerivedType" />
</xs:complexType>
<xs:complexType name="complexDerTestType" >
<xs:complexContent >
<xs:extension base="complexTestType" >
<xs:sequence>
<xs:element name="d" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="unionTestType" >
<xs:union memberTypes="decimalDerivedType stringDerivedType xs:decimal xs:string" />
</xs:simpleType>
<xs:complexType name="unionTest" >
<xs:sequence >
<xs:element name="testEle" maxOccurs="4" type="unionTestType" />
<xs:element name="testEle2" maxOccurs="4" >
<xs:complexType >
<xs:attribute name="testAttr" type="unionTestType" />
<xs:attribute name="testAttr2" type="unionTestType" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="unionTest2" >
<xs:sequence >
<xs:element name="testEle" maxOccurs="4" >
<xs:complexType >
<xs:simpleContent >
<xs:extension base="unionTestType" >
<xs:attribute name="testAttr" type="unionTestType" />
</xs:extension >
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="testtype2" >
<xs:sequence>
<xs:element name="poo" type="xs:string"/>
</xs:sequence>
<xs:attribute name="a" type="xs:IDREF" />
<xs:attribute name="b" type="xs:ID" />
<xs:attribute name="c" type="xs:string" />
</xs:complexType>
</xs:schema>
+16
View File
@@ -0,0 +1,16 @@
<!DOCTYPE attributeTest SYSTEM "TypeInfo.dtd" >
<attributeTest
xmlns:foo = "lala"
cdata = "cdata"
enum = "a"
id = "someID"
idRef = "someID"
idRefs = "someID"
nmToken = "abc"
nmTokenDefault2 = "test"
nmTokens = "abc"
entity = "APACHE"
entities = "APACHE"
notation = "png"
noDecl = "lalal"
/>
+167
View File
@@ -0,0 +1,167 @@
<root xsi:noNamespaceSchemaLocation="TypeInfoNoDTD.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ss="http://www.secondSchema" >
<attrTest
anySimpleType="asdas"
string="string"
boolean="true"
decimal="2.0"
float="2.1"
double="2.1"
duration="P1Y2M3DT10H30M"
dateTime="2000-10-30T11:12:00"
time="11:12:00"
date="2000-10-30"
gYearMonth="1999-01"
gYear="1999"
gMonthDay="--01-08"
gDay="---21"
gMonth="--12--"
hexBinary="0FB7"
base64Binary="abcd"
anyURI="http://www.example.com/"
QName="xsla"
normalizedString="example"
token="example"
language="en"
NMTOKEN="example"
NMTOKENS="example bar"
Name="example"
NCName="example"
integer="1"
nonPositiveInteger="-1"
negativeInteger="-1"
long="1"
int="1"
short="1"
byte="1"
nonNegativeInteger="1"
unsignedLong="1"
unsignedInt="1"
unsignedShort="1"
unsignedByte="1"
positiveInteger="1"
ID="abc"
IDREF="abc"
IDREFS="abc"
defaultString="test"
xmlns:prefix="http://lala"
xsi:noNamespaceSchemaLocation="hello"
/>
<eleTest >
<level1string >string</level1string>
<level1boolean >true</level1boolean>
<level1decimal >2.0</level1decimal>
<level1float >2.1</level1float>
<level1double >2.1</level1double>
<level1duration >P1Y2M3DT10H30M</level1duration>
<level1dateTime >2000-10-30T11:12:00</level1dateTime>
<level1time >11:12:00</level1time>
<level1date >2000-10-30</level1date>
<level1gYearMonth >1999-01</level1gYearMonth>
<level1gYear >1999</level1gYear>
<level1gMonthDay >--01-08</level1gMonthDay>
<level1gDay >---21</level1gDay>
<level1gMonth >--12--</level1gMonth>
<level1hexBinary >0FB7</level1hexBinary>
<level1base64Binary >abcd</level1base64Binary>
<level1anyURI >http://www.example.com/</level1anyURI>
<level1QName >xsla</level1QName>
<level1normalizedString >example</level1normalizedString>
<level1token >example</level1token>
<level1language >en</level1language>
<level1NMTOKEN >example</level1NMTOKEN>
<level1NMTOKENS >example bar</level1NMTOKENS>
<level1Name >example</level1Name>
<level1NCName >example</level1NCName>
<level1integer >1</level1integer>
<level1nonPositiveInteger >-1</level1nonPositiveInteger>
<level1negativeInteger >-1</level1negativeInteger>
<level1long >1</level1long>
<level1int >1</level1int>
<level1short >1</level1short>
<level1byte >1</level1byte>
<level1nonNegativeInteger >1</level1nonNegativeInteger>
<level1unsignedLong >1</level1unsignedLong>
<level1unsignedInt >1</level1unsignedInt>
<level1unsignedShort >1</level1unsignedShort>
<level1unsignedByte >1</level1unsignedByte>
<level1positiveInteger >1</level1positiveInteger>
<level1anyType />
</eleTest>
<simpleDerTest decimalDerived="50" stringDerived="hello" >
<decimalDerived >20</decimalDerived>
<stringDerived >hello</stringDerived>
</simpleDerTest>
<complexTest a="abcd" b="hello" c="50" >
<a >abcd</a>
<b >hello</b>
<c >50</c>
</complexTest>
<complexDerTest a="abcd" b="hello" c="50" >
<a >abcd</a>
<b >hello</b>
<c >50</c>
<d >abcdefg</d>
</complexDerTest>
<unionTest >
<testEle >50</testEle>
<testEle >hello</testEle>
<testEle >200</testEle>
<testEle >abcdefg</testEle>
<testEle2 testAttr="50" testAttr2="hello" />
<testEle2 testAttr="hello" testAttr2="50" />
<testEle2 testAttr="200" testAttr2="abcdefg" />
<testEle2 testAttr="abcdefg" testAttr2="200" />
</unionTest>
<anonymousTest partNum="50">
<quantity>50</quantity>
<size>25</size>
<anonElement>11</anonElement>
</anonymousTest>
<xsiTypeTest>
<number>99</number>
<number xsi:type="level1" >74</number>
<number xsi:type="level2" >49</number>
<complexXsi >
<a >a</a>
</complexXsi>
<complexXsi xsi:type="level1Complex" >
<a >a</a>
<b >b</b>
</complexXsi>
<complexXsi xsi:type="level2Complex" >
<a >a</a>
<b >b</b>
<c >c</c>
</complexXsi>
</xsiTypeTest>
<anyTestPartial xhtml:attr2="some value" >
<xhtml:fakeTag1 />
<xhtml:fakeTag2 />
<ss:realTag1 >la</ss:realTag1>
</anyTestPartial>
<anyTest ss:attr1="string" ss:attr2="2" ss:attr3="string" ss:attr4="2">
<ss:realTag2 >la</ss:realTag2>
<ss:realTag3 >la</ss:realTag3>
<ss:notRealTag >la</ss:notRealTag>
</anyTest>
<anyTestAttr1 ss:attr5="2" />
<anyTestAttr2 ss:attr5="2" />
<anyTestMissing />
<invalidTest simple="abcd" invalid="asdas" >
<simple >abcd</simple>
<complex >
<a >asa</a>
<invalid />
</complex>
<number xsi:type="stringDerivedType" >74</number>
<complexXsi xsi:type="simpleDerTestType" >
<a >a</a>
<b >b</b>
</complexXsi>
<unionTest >hello1</unionTest>
<empty ><a /><a /></empty>
<invalidAttrTest attr="lala" />
<missingAttrTest />
<prohibitedAttrTest attr="lala" />
</invalidTest>
</root>
+350
View File
@@ -0,0 +1,350 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault="unqualified" xmlns:foo="http://anothernamespace.com" >
<xs:import namespace="http://www.secondSchema" schemaLocation="SecondSchema.xsd" />
<xs:element name="root" type="rootType" />
<xs:complexType name="rootType" >
<xs:sequence>
<xs:element name="attrTest" type="attrTestType" />
<xs:element name="eleTest" type="eleTestType" />
<xs:element name="simpleDerTest" type="simpleDerTestType" />
<xs:element name="complexTest" type="complexTestType" />
<xs:element name="complexDerTest" type="complexDerTestType" />
<xs:element name="unionTest" type="unionTest" />
<xs:element name="anonymousTest" >
<xs:complexType>
<xs:sequence>
<xs:element name="quantity">
<xs:simpleType>
<xs:restriction base="xs:positiveInteger">
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name='size'>
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base='xs:integer'/>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base='xs:string'/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>
<xs:element ref="anonElement" />
</xs:sequence>
<xs:attribute name="partNum" >
<xs:simpleType>
<xs:restriction base="xs:positiveInteger">
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="xsiTypeTest" type="xsiTypeTestType" />
<xs:element name="anyTestPartial" type="anyTestPartialType" />
<xs:element name="anyTest" type="anyTestType" />
<xs:element name="anyTestAttr1" type="anyTestAttr1Type" />
<xs:element name="anyTestAttr2" type="anyTestAttr2Type" />
<xs:element name="anyTestMissing" type="anyTestType" />
<xs:element name="invalidTest" type="invalidTestType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="anyTestPartialType" >
<xs:sequence >
<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="skip" />
<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="lax" />
<xs:any namespace="http://www.secondSchema" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="http://www.w3.org/1999/xhtml" processContents="skip" />
</xs:complexType>
<xs:complexType name="anyTestType" >
<xs:sequence >
<xs:any namespace="http://www.secondSchema" processContents="lax"/>
<xs:any namespace="http://www.secondSchema" processContents="strict"/>
<xs:any namespace="http://www.secondSchema" processContents="strict"/>
</xs:sequence>
<xs:anyAttribute namespace="http://www.secondSchema" processContents="lax" />
</xs:complexType>
<xs:complexType name="anyTestAttr1Type" >
<xs:anyAttribute namespace="http://www.secondSchema" processContents="strict" />
</xs:complexType>
<xs:complexType name="anyTestAttr2Type" >
<xs:anyAttribute namespace="http://www.secondSchema" processContents="lax" />
</xs:complexType>
<xs:complexType name="invalidTestType" >
<xs:sequence >
<xs:element name="simple" type="stringDerivedType" />
<xs:element name="complex" type="baseComplex" />
<xs:element name="number" type="base" />
<xs:element name="complexXsi" type="baseComplex" />
<xs:element name="unionTest" type="uType" />
<xs:element name="invalidAttrTest" type="attrOnlyType" />
<xs:element name="missingAttrTest" type="attrOnlyType" />
<xs:element name="prohibitedAttrTest" type="prohibitedAttrType" />
</xs:sequence>
<xs:attribute name="simple" type="stringDerivedType" />
</xs:complexType>
<xs:complexType name="prohibitedAttrType" >
<xs:attribute name="attr" type="stringDerivedType" use="prohibited" />
</xs:complexType>
<xs:complexType name="attrOnlyType" >
<xs:attribute name="attr" type="stringDerivedType" use="required" />
</xs:complexType>
<xs:simpleType name="uType" >
<xs:union memberTypes="stringDerivedType" />
</xs:simpleType>
<xs:complexType name="xsiTypeTestType" >
<xs:sequence>
<xs:element name="number" type="base" maxOccurs="3"/>
<xs:element name="complexXsi" type="baseComplex" maxOccurs="3"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="baseComplex" >
<xs:sequence>
<xs:element name="a" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="level1Complex" >
<xs:complexContent >
<xs:extension base="baseComplex" >
<xs:sequence>
<xs:element name="b" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="level2Complex" >
<xs:complexContent >
<xs:extension base="level1Complex" >
<xs:sequence>
<xs:element name="c" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="base" >
<xs:restriction base="xs:decimal" >
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="level1" >
<xs:restriction base="base" >
<xs:maxExclusive value="75"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="level2" >
<xs:restriction base="level1" >
<xs:maxExclusive value="50"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="anonElement" >
<xs:simpleType >
<xs:restriction base="xs:decimal" >
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:complexType name="eleTestType" >
<xs:sequence >
<xs:element name="level1string" type="xs:string" />
<xs:element name="level1boolean" type="xs:boolean" />
<xs:element name="level1decimal" type="xs:decimal" />
<xs:element name="level1float" type="xs:float" />
<xs:element name="level1double" type="xs:double" />
<xs:element name="level1duration" type="xs:duration" />
<xs:element name="level1dateTime" type="xs:dateTime" />
<xs:element name="level1time" type="xs:time" />
<xs:element name="level1date" type="xs:date" />
<xs:element name="level1gYearMonth" type="xs:gYearMonth" />
<xs:element name="level1gYear" type="xs:gYear" />
<xs:element name="level1gMonthDay" type="xs:gMonthDay" />
<xs:element name="level1gDay" type="xs:gDay" />
<xs:element name="level1gMonth" type="xs:gMonth" />
<xs:element name="level1hexBinary" type="xs:hexBinary" />
<xs:element name="level1base64Binary" type="xs:base64Binary" />
<xs:element name="level1anyURI" type="xs:anyURI" />
<xs:element name="level1QName" type="xs:QName" />
<xs:element name="level1normalizedString" type="xs:normalizedString" />
<xs:element name="level1token" type="xs:token" />
<xs:element name="level1language" type="xs:language" />
<xs:element name="level1NMTOKEN" type="xs:NMTOKEN" />
<xs:element name="level1NMTOKENS" type="xs:NMTOKENS" />
<xs:element name="level1Name" type="xs:Name" />
<xs:element name="level1NCName" type="xs:NCName" />
<xs:element name="level1integer" type="xs:integer" />
<xs:element name="level1nonPositiveInteger" type="xs:nonPositiveInteger" />
<xs:element name="level1negativeInteger" type="xs:negativeInteger" />
<xs:element name="level1long" type="xs:long" />
<xs:element name="level1int" type="xs:int" />
<xs:element name="level1short" type="xs:short" />
<xs:element name="level1byte" type="xs:byte" />
<xs:element name="level1nonNegativeInteger" type="xs:nonNegativeInteger" />
<xs:element name="level1unsignedLong" type="xs:unsignedLong" />
<xs:element name="level1unsignedInt" type="xs:unsignedInt" />
<xs:element name="level1unsignedShort" type="xs:unsignedShort" />
<xs:element name="level1unsignedByte" type="xs:unsignedByte" />
<xs:element name="level1positiveInteger" type="xs:positiveInteger" />
<xs:element name="level1anyType" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="attrTestType" >
<xs:attribute name="anySimpleType" type="xs:anySimpleType" />
<xs:attribute name="string" type="xs:string" />
<xs:attribute name="boolean" type="xs:boolean" />
<xs:attribute name="decimal" type="xs:decimal" />
<xs:attribute name="float" type="xs:float" />
<xs:attribute name="double" type="xs:double" />
<xs:attribute name="duration" type="xs:duration" />
<xs:attribute name="dateTime" type="xs:dateTime" />
<xs:attribute name="time" type="xs:time" />
<xs:attribute name="date" type="xs:date" />
<xs:attribute name="gYearMonth" type="xs:gYearMonth" />
<xs:attribute name="gYear" type="xs:gYear" />
<xs:attribute name="gMonthDay" type="xs:gMonthDay" />
<xs:attribute name="gDay" type="xs:gDay" />
<xs:attribute name="gMonth" type="xs:gMonth" />
<xs:attribute name="hexBinary" type="xs:hexBinary" />
<xs:attribute name="base64Binary" type="xs:base64Binary" />
<xs:attribute name="anyURI" type="xs:anyURI" />
<xs:attribute name="QName" type="xs:QName" />
<xs:attribute name="normalizedString" type="xs:normalizedString" />
<xs:attribute name="token" type="xs:token" />
<xs:attribute name="language" type="xs:language" />
<xs:attribute name="NMTOKEN" type="xs:NMTOKEN" />
<xs:attribute name="NMTOKENS" type="xs:NMTOKENS" />
<xs:attribute name="Name" type="xs:Name" />
<xs:attribute name="NCName" type="xs:NCName" />
<xs:attribute name="ID" type="xs:ID" />
<xs:attribute name="IDREF" type="xs:IDREF" />
<xs:attribute name="IDREFS" type="xs:IDREFS" />
<xs:attribute name="integer" type="xs:integer" />
<xs:attribute name="nonPositiveInteger" type="xs:nonPositiveInteger" />
<xs:attribute name="negativeInteger" type="xs:negativeInteger" />
<xs:attribute name="long" type="xs:long" />
<xs:attribute name="int" type="xs:int" />
<xs:attribute name="short" type="xs:short" />
<xs:attribute name="byte" type="xs:byte" />
<xs:attribute name="nonNegativeInteger" type="xs:nonNegativeInteger" />
<xs:attribute name="unsignedLong" type="xs:unsignedLong" />
<xs:attribute name="unsignedInt" type="xs:unsignedInt" />
<xs:attribute name="unsignedShort" type="xs:unsignedShort" />
<xs:attribute name="unsignedByte" type="xs:unsignedByte" />
<xs:attribute name="positiveInteger" type="xs:positiveInteger" />
<xs:attribute name="defaultString" type="xs:string" default="hello" />
<xs:attribute name="defaultInt" type="xs:integer" default="12" />
</xs:complexType>
<xs:complexType name="simpleDerTestType" >
<xs:sequence>
<xs:element name="decimalDerived" type="decimalDerivedType" />
<xs:element name="stringDerived" type="stringDerivedType" />
</xs:sequence>
<xs:attribute name="decimalDerived" type="decimalDerivedType" />
<xs:attribute name="stringDerived" type="stringDerivedType" />
</xs:complexType>
<xs:simpleType name="stringDerivedType" >
<xs:restriction base="xs:string" >
<xs:pattern value="hello"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="decimalDerivedType" >
<xs:restriction base="xs:decimal" >
<xs:maxExclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="complexTestType" >
<xs:sequence>
<xs:element name="a" type="xs:string"/>
<xs:element name="b" type="stringDerivedType"/>
<xs:element name="c" type="decimalDerivedType"/>
</xs:sequence>
<xs:attribute name="a" type="xs:string" />
<xs:attribute name="b" type="stringDerivedType" />
<xs:attribute name="c" type="decimalDerivedType" />
</xs:complexType>
<xs:complexType name="complexDerTestType" >
<xs:complexContent >
<xs:extension base="complexTestType" >
<xs:sequence>
<xs:element name="d" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="unionTestType" >
<xs:union memberTypes="decimalDerivedType stringDerivedType xs:decimal xs:string" />
</xs:simpleType>
<xs:complexType name="unionTest" >
<xs:sequence >
<xs:element name="testEle" maxOccurs="4" type="unionTestType" />
<xs:element name="testEle2" maxOccurs="4" >
<xs:complexType >
<xs:attribute name="testAttr" type="unionTestType" />
<xs:attribute name="testAttr2" type="unionTestType" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="unionTest2" >
<xs:sequence >
<xs:element name="testEle" maxOccurs="4" >
<xs:complexType >
<xs:simpleContent >
<xs:extension base="unionTestType" >
<xs:attribute name="testAttr" type="unionTestType" />
</xs:extension >
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="testtype2" >
<xs:sequence>
<xs:element name="poo" type="xs:string"/>
</xs:sequence>
<xs:attribute name="a" type="xs:IDREF" />
<xs:attribute name="b" type="xs:ID" />
<xs:attribute name="c" type="xs:string" />
</xs:complexType>
</xs:schema>
+12
View File
@@ -0,0 +1,12 @@
<!ELEMENT root (level1, level1a) >
<!ATTLIST root
xsi:noNamespaceSchemaLocation CDATA #REQUIRED
xmlns:xsi CDATA #REQUIRED
attBoth CDATA #REQUIRED
attDTD CDATA #REQUIRED
>
<!ELEMENT level1 (#PCDATA) >
<!ELEMENT level1a (#PCDATA) >
+7
View File
@@ -0,0 +1,7 @@
<!DOCTYPE root SYSTEM "combined.dtd" >
<root xsi:noNamespaceSchemaLocation="combined.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attBoth="lala"
attSchema="lala" attDTD="lala"
>
<level1 >content</level1>
<level1a >content</level1a>
</root>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault="unqualified" >
<xs:element name="root" type="rootType" />
<xs:complexType name="rootType" >
<xs:sequence >
<xs:element name="level1" type="xs:string" />
</xs:sequence>
<xs:attribute name="attBoth" type="xs:string" />
<xs:attribute name="attSchema" type="xs:string" />
</xs:complexType>
</xs:schema>
+443
View File
@@ -0,0 +1,443 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 test program is used, in conjunction with a set of test data files,
// to verify support for different character encodings in XML.
//
//---------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/framework/XMLBuffer.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/sax/SAXException.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <stdio.h>
XERCES_CPP_NAMESPACE_USE
static int gTestsFailed = 0;
static int gTestsRun = 0;
static XercesDOMParser* parser = 0;
//-----------------------------------------------------------------------
//
// ErrorHandler. The DOM Parser will report any parsing errors by means
// of call-backs to the methods of this class.
// This is just necessary boilerplate, as far as this
// program is concerned.
//
//-----------------------------------------------------------------------
class ParseErrorHandler: public ErrorHandler
{
public:
void warning(const SAXParseException& e);
void error(const SAXParseException& e);
void fatalError(const SAXParseException& e);
void resetErrors() {};
};
void ParseErrorHandler::error(const SAXParseException& e)
{
char* systemId = XMLString::transcode(e.getSystemId());
char* message = XMLString::transcode(e.getMessage());
fprintf(stderr, "\nError at file \"%s\", line %d, char %d: %s\n",
systemId, e.getLineNumber(),
e.getColumnNumber(), message);
XMLString::release(&systemId);
XMLString::release(&message);
throw e;
};
void ParseErrorHandler::fatalError(const SAXParseException& e)
{
char* systemId = XMLString::transcode(e.getSystemId());
char* message = XMLString::transcode(e.getMessage());
fprintf(stderr, "\nFatal Error at file \"%s\", line %d, char %d: %s\n",
systemId, e.getLineNumber(),
e.getColumnNumber(), message);
XMLString::release(&systemId);
XMLString::release(&message);
throw e;
};
void ParseErrorHandler::warning(const SAXParseException& e)
{
char* systemId = XMLString::transcode(e.getSystemId());
char* message = XMLString::transcode(e.getMessage());
fprintf(stderr, "\nWarning at file \"%s\", line %d, char %d: %s\n",
systemId, e.getLineNumber(),
e.getColumnNumber(), message);
XMLString::release(&systemId);
XMLString::release(&message);
throw e;
};
//------------------------------------------------------------------------
//
// parseFile - a simpler to use function for just parsing an XML file
// and getting the DOM Document back.
//
//------------------------------------------------------------------------
static DOMDocument* parseFile(char *fileName)
{
ParseErrorHandler eh;
if (!parser)
parser = new XercesDOMParser;
parser->setValidationScheme(AbstractDOMParser::Val_Never);
parser->setErrorHandler(&eh);
try
{
parser->parse(fileName);
}
catch (const OutOfMemoryException&)
{
fprintf(stderr, "OutOfMemoryException during parsing: %s\n", fileName);
return 0;
}
catch (const XMLException& e )
{
fprintf(stderr, "Exception Occurred \"%s\". \n",
XMLString::transcode(e.getMessage()));
fprintf(stderr, "File being parsed is \"%s\".\n", fileName);
return 0; // A null document.
}
catch (...)
{
fprintf(stderr, "Unexpected Exception thrown during parse of file \"%s\".\n",
fileName);
return 0;
}
return parser->getDocument();
}
//------------------------------------------------------------------------
//
// writeUData - Write out a udata xml element for a XMLCh* contents.
//
//------------------------------------------------------------------------
static void writeUData(const XMLCh* s)
{
unsigned int i;
printf("<udata>\n");
size_t len = XMLString::stringLen(s);
for (i=0; i<len; i++)
{
if (i % 16 == 0)
printf("\n");
XMLCh c = s[i];
printf("%4x ", c);
}
printf("\n</udata>\n");
};
//------------------------------------------------------------------------
//
// eatWhiteSpace - XMLCh*s are kind of short on utility functions :-(
//
//------------------------------------------------------------------------
static void eatWhiteSpace(XMLCh* s, unsigned int &i)
{
size_t len = XMLString::stringLen(s);
while (i < len)
{
XMLCh c = s[i];
if (!(c == 0x20 || // These are the official XML space characters,
c == 0x09 || // expressed as Unicode constants.
c == 0x0A))
break;
i++;
}
}
//------------------------------------------------------------------------
//
// convertHexValue if the XMLCh* contains a hex number at position i,
// convert it and return it, and update i to index the
// first char not in the string.
// return 0 if string[i] didn't have a hex digit.
// 0 return is ambiguous, but it doesn't matter for XML,
// where 0 is not a valid character.
//
//------------------------------------------------------------------------
static int convertHexValue(XMLCh* s, unsigned int &i)
{
int value = 0;
// For reference, the digits 0-9 are Unicode 0x30-39
// the letters A-F are Unicode 0x41-0x46
// the letters a-f are Unicode 0x61-66
// We can't use character literals - we might be
// building on an EBCDIC machine.
size_t len = XMLString::stringLen(s);
while (i < len)
{
XMLCh c = s[i];
if (c >= 0x61 && c <= 0x66) // Uppercase a-f to A-F.
c -= 0x20;
if (c < 0x30 || c >0x46) // Stop if not a hex digit
break;
if (c > 0x39 && c <0x41)
break;
value = value << 4; // Append this digit to accumulating value
if (c <= 0x39)
value += c-0x30;
else
value += 0xA + c - 0x41;
i++;
}
return value;
}
//------------------------------------------------------------------------
//
// processTestFile Given the file name of an encoding test xml file,
// run it.
//
//------------------------------------------------------------------------
static bool processTestFile(const XMLCh* fileName)
{
//
// Send the input file through the parse, create a DOM document for it.
//
char cFileName[4000];
XMLString::transcode(fileName, cFileName, 3999);
DOMDocument* testDoc = parseFile(cFileName);
if (testDoc == 0)
return false; // parse errors in the source xml.
//
// Pull the "data" element out of the document.
//
XMLCh tempStr[4000];
XMLString::transcode("data", tempStr, 3999);
DOMNodeList* nl = testDoc->getElementsByTagName(tempStr);
if (nl->getLength() != 1) {
fprintf(stderr, "Test file \"%s\" must have exactly one \"data\" element.\n", cFileName);
return false;
};
DOMNode* tmpNode = nl->item(0);
DOMElement* data = (DOMElement*) tmpNode;
//
// Build up a string containing the character data contents of the data element.
//
DOMNode* child;
XMLBuffer elData;
for (child=data->getFirstChild(); child != 0; child= child->getNextSibling())
{
if (child->getNodeType() == DOMNode::COMMENT_NODE)
continue;
if (! (child->getNodeType() == DOMNode::TEXT_NODE ||
child->getNodeType() == DOMNode::CDATA_SECTION_NODE ||
child->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE))
{
fprintf(stderr, "Test file \"%s\": data element contains unexpected children.",
cFileName);
return false;
}
elData.append(((DOMCharacterData *)child)->getData());
};
//
// Pull the "udata" element out of the document
//
XMLString::transcode("udata", tempStr, 3999);
nl = testDoc->getElementsByTagName(tempStr);
if (nl->getLength() != 1) {
fprintf(stderr, "Test file \"%s\" must have exactly one \"udata\" element.\n", cFileName);
return false;
};
DOMNode* tmpNode1 = nl->item(0);
DOMElement* udata = (DOMElement*) tmpNode1;
//
// Build up a string containing the character data contents of the udata element.
// This will consist of a whole bunch hex numbers, still in string from
//
XMLBuffer rawUData;
for (child=udata->getFirstChild(); child != 0; child= child->getNextSibling())
{
if (child->getNodeType() == DOMNode::COMMENT_NODE)
continue;
if (! (child->getNodeType() == DOMNode::TEXT_NODE ||
child->getNodeType() == DOMNode::CDATA_SECTION_NODE ||
child->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE))
{
fprintf(stderr, "Test file \"%s\": udata element contains unexpected children.",
cFileName);
return false;
}
rawUData.append(((DOMCharacterData *)child)->getData());
};
//
// Convert the raw (hex numbers) form of the udata to the corresponding string.
//
XMLBuffer uData;
unsigned int rawIndex = 0;
while (rawIndex < rawUData.getLen())
{
eatWhiteSpace(rawUData.getRawBuffer(), rawIndex);
XMLCh c = convertHexValue(rawUData.getRawBuffer(), rawIndex);
if (c > 0)
uData.append(c);
else
if (rawIndex < rawUData.getLen())
{
fprintf(stderr, "Test file \"%s\": Bad hex number in udata element. "
"Data character number %d\n", cFileName, uData.getLen());
return false;
}
}
//
// Compare the two strings.
//
unsigned int i;
for (i=0; i< elData.getLen(); i++)
{
XMLCh* elDataRaw = elData.getRawBuffer();
XMLCh* uDataRaw = uData.getRawBuffer();
if (i >= uData.getLen())
{
fprintf(stderr, "Test file \"%s\": udata element shorter than data at char number %d\n",
cFileName, i);
writeUData(elDataRaw);
return false;
}
if (uDataRaw[i] != elDataRaw[i])
{
fprintf(stderr, "Test file \"%s\": comparison failure at character number %d\n",
cFileName, i);
writeUData(elDataRaw);
return false;
};
}
if (elData.getLen() != uData.getLen())
{
fprintf(stderr, "Test file \"%s\": udata element longer than data at char number %d\n",
cFileName, i);
writeUData(elData.getRawBuffer());
return false;
}
return true;
}
int main(int argc, char ** argv) {
//
// Initialize the Xerces-c environment
//
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
fprintf(stderr, "Error during initialization of xerces-c: %s\n",
XMLString::transcode(toCatch.getMessage()));
return 1;
}
//
// Parse the command line, which should specify exactly one file, which is an
// xml file containing the list of test files to be processed.
//
if (argc != 2) {
printf("usage: %s file_name \n"
" where file name is the xml file specifying the list of test files.", argv[0]);
return 1;
}
DOMDocument* fileListDoc = parseFile(argv[1]);
if (fileListDoc == 0) return 1;
//
// Iterate over the list of files, running each as a test.
//
XMLCh tempStr[4000];
XMLString::transcode("testFile", tempStr, 3999);
DOMNodeList* list = fileListDoc->getElementsByTagName(tempStr);
XMLSize_t i;
XMLSize_t numFiles = list->getLength();
for (i=0; i<numFiles; i++)
{
++gTestsRun;
DOMNode* tmpNode3 = list->item(i);
XMLString::transcode("name", tempStr, 3999);
const XMLCh* fileName = ((DOMElement*) tmpNode3)->getAttribute(tempStr);
if (processTestFile(fileName) == false)
++gTestsFailed;
};
//
// We are done. Print out a summary of the results
//
printf("Encoding Tests Results Summary: \n"
" %d encoding tests run.\n"
" %d tests passed,\n"
" %d tests failed\n", gTestsRun, gTestsRun-gTestsFailed, gTestsFailed);
delete parser;
parser = 0;
return 0;
};
+426
View File
@@ -0,0 +1,426 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: InitTermTest.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// This program tests the XMLPlatformUtils::Initialize/Terminate() pair
// by calling the pair a number of times.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/sax/SAXException.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/parsers/SAXParser.hpp>
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/dom/DOMException.hpp>
#include "InitTermTest.hpp"
#include <string.h>
#include <stdlib.h>
#if defined(XERCES_NEW_IOSTREAMS)
#include <fstream>
#else
#include <fstream.h>
#endif
#include <limits.h>
// ---------------------------------------------------------------------------
// Local Enum to switch theState
// ---------------------------------------------------------------------------
enum Teststate {
Once,
Multiple,
UnEven,
Limit,
ExceedLimit
};
// ---------------------------------------------------------------------------
// Declare functions
// ---------------------------------------------------------------------------
int TestInit4DOM(const char* xmlFile, bool gDoNamespaces, bool gDoSchema, bool gSchemaFullChecking, Teststate theState);
int TestInit4SAX(const char* xmlFile, bool gDoNamespaces, bool gDoSchema, bool gSchemaFullChecking, Teststate theState);
int TestInit4SAX2(const char* xmlFile, bool gDoNamespaces, bool gDoSchema, bool gSchemaFullChecking, Teststate theState);
// ---------------------------------------------------------------------------
// Define macro
// ---------------------------------------------------------------------------
#define TESTINITPRE \
long times = 1; \
switch (theState) { \
case Multiple: \
case UnEven: \
times = 100; \
break; \
case Limit: \
case ExceedLimit: \
times = LONG_MAX; \
break; \
case Once: \
default: \
times = 1; \
} \
long i = 0; \
for (i = 0; i < times; i++) { \
try \
{ \
XMLPlatformUtils::Initialize(); \
} \
\
catch (const XMLException& toCatch) \
{ \
XERCES_STD_QUALIFIER cerr << "Error during initialization! :\n" \
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; \
return 1; \
} \
} \
\
if (theState == ExceedLimit) { \
try \
{ \
XMLPlatformUtils::Initialize(); \
} \
\
catch (const XMLException& toCatch) \
{ \
XERCES_STD_QUALIFIER cerr << "Error during initialization! :\n" \
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; \
return 1; \
} \
}
#define TESTINITPOST \
InitTermTestErrorHandler errorHandler; \
parser->setErrorHandler(&errorHandler); \
bool errorOccurred = false; \
\
errorHandler.resetErrors(); \
\
try \
{ \
parser->parse(xmlFile); \
} \
catch (const OutOfMemoryException&) \
{ \
XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl; \
errorOccurred = true; \
} \
catch (const XMLException& toCatch) \
{ \
XERCES_STD_QUALIFIER cerr << "\nError during parsing: '" << xmlFile << "'\n" \
<< "Exception message is: \n" \
<< StrX(toCatch.getMessage()) << "\n" << XERCES_STD_QUALIFIER endl; \
errorOccurred = true; \
} \
catch (const DOMException& toCatch) \
{ \
XERCES_STD_QUALIFIER cerr << "\nDOM Error during parsing: '" << xmlFile \
<< "\nDOMException code is: \n" \
<< toCatch.code << "\n" << XERCES_STD_QUALIFIER endl; \
errorOccurred = true; \
} \
catch (...) \
{ \
XERCES_STD_QUALIFIER cerr << "\nUnexpected exception during parsing: '" \
<< xmlFile << "'\n"; \
errorOccurred = true; \
} \
\
if (errorHandler.getSawErrors()) \
{ \
XERCES_STD_QUALIFIER cout << "\nErrors occurred, no output available\n" << XERCES_STD_QUALIFIER endl;\
errorOccurred = true; \
} \
\
delete parser; \
\
for (i = 0; i < times; i++) { \
XMLPlatformUtils::Terminate(); \
} \
\
if (theState == ExceedLimit || theState == UnEven) { \
XMLPlatformUtils::Terminate(); \
} \
\
if (errorOccurred) \
return 4; \
else \
return 0;
// ---------------------------------------------------------------------------
// DOM Parser
// ---------------------------------------------------------------------------
int TestInit4DOM(const char* xmlFile, bool gDoNamespaces, bool gDoSchema, bool gSchemaFullChecking, Teststate theState)
{
TESTINITPRE;
XercesDOMParser* parser = new XercesDOMParser;
parser->setDoNamespaces(gDoNamespaces);
parser->setDoSchema(gDoSchema);
parser->setValidationSchemaFullChecking(gSchemaFullChecking);
TESTINITPOST;
}
// ---------------------------------------------------------------------------
// SAX Parser
// ---------------------------------------------------------------------------
int TestInit4SAX(const char* xmlFile, bool gDoNamespaces, bool gDoSchema, bool gSchemaFullChecking, Teststate theState)
{
TESTINITPRE;
SAXParser* parser = new SAXParser;
parser->setDoNamespaces(gDoNamespaces);
parser->setDoSchema(gDoSchema);
parser->setValidationSchemaFullChecking(gSchemaFullChecking);
TESTINITPOST;
}
// ---------------------------------------------------------------------------
// SAX2 XML Reader
// ---------------------------------------------------------------------------
int TestInit4SAX2(const char* xmlFile, bool gDoNamespaces, bool gDoSchema, bool gSchemaFullChecking, Teststate theState)
{
TESTINITPRE;
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
XMLCh* doNamespaceFeature = XMLString::transcode("http://xml.org/sax/features/namespaces");
parser->setFeature(doNamespaceFeature, gDoNamespaces);
XMLCh* doSchemaFeature = XMLString::transcode("http://apache.org/xml/features/validation/schema");
parser->setFeature(doSchemaFeature, gDoSchema);
XMLCh* fullSchemaCheckFeature = XMLString::transcode("http://apache.org/xml/features/validation/schema-full-checking");
parser->setFeature(fullSchemaCheckFeature, gSchemaFullChecking);
XMLString::release(&doNamespaceFeature);
XMLString::release(&doSchemaFeature);
XMLString::release(&fullSchemaCheckFeature);
TESTINITPOST;
}
// ---------------------------------------------------------------------------
//
// Usage()
//
// ---------------------------------------------------------------------------
void usage()
{
XERCES_STD_QUALIFIER cout << "\nUsage:\n"
" InitTermTest [options] <XML file>\n\n"
"This program tests the XMLPlatformUtils::Initialize()/Terminate()\n"
"pair by calling it a number of times.\n"
"Options:\n"
" -n Enable namespace processing. Default is off.\n"
" -s Enable schema processing. Default is off.\n"
" -f Enable full schema constraint checking. Defaults to off.\n"
" -? Show this help.\n"
<< XERCES_STD_QUALIFIER endl;
}
// ---------------------------------------------------------------------------
// Main
// ---------------------------------------------------------------------------
int main(int argC, char* argV[]) {
// ---------------------------------------------------------------------------
// Local data
//
// gDoNamespaces
// Indicates whether namespace processing should be done.
//
// gDoSchema
// Indicates whether schema processing should be done.
//
// gSchemaFullChecking
// Indicates whether full schema constraint checking should be done.
//
// ---------------------------------------------------------------------------
bool gDoNamespaces = false;
bool gDoSchema = false;
bool gSchemaFullChecking = false;
// Check command line and extract arguments.
if (argC < 2)
{
usage();
return 1;
}
// See if non validating dom parser configuration is requested.
int parmInd;
for (parmInd = 1; parmInd < argC; parmInd++)
{
// Break out on first parm not starting with a dash
if (argV[parmInd][0] != '-')
break;
// Watch for special case help request
if (!strcmp(argV[parmInd], "-?"))
{
usage();
return 2;
}
else if (!strcmp(argV[parmInd], "-n")
|| !strcmp(argV[parmInd], "-N"))
{
gDoNamespaces = true;
}
else if (!strcmp(argV[parmInd], "-s")
|| !strcmp(argV[parmInd], "-S"))
{
gDoSchema = true;
}
else if (!strcmp(argV[parmInd], "-f")
|| !strcmp(argV[parmInd], "-F"))
{
gSchemaFullChecking = true;
}
else
{
XERCES_STD_QUALIFIER cerr << "Unknown option '" << argV[parmInd]
<< "', ignoring it.\n" << XERCES_STD_QUALIFIER endl;
}
}
//
// And now we have to have only one parameter left and it must be
// the file name.
//
if (parmInd + 1 != argC)
{
usage();
return 1;
}
char* xmlFile = argV[parmInd];
bool error = false;
//
// Calling Init/Term pair a number of times
//
unsigned int i = 0;
for (i=0; i < 100; i++) {
if (error) {
XERCES_STD_QUALIFIER cout << "Test Failed" << XERCES_STD_QUALIFIER endl;
return 4;
}
if (TestInit4DOM(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Once))
error = true;
if (TestInit4SAX(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Once))
error = true;
if (TestInit4SAX2(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Once))
error = true;
}
if (error || TestInit4DOM(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Multiple))
error = true;
if (error || TestInit4SAX(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Multiple))
error = true;
if (error || TestInit4SAX2(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Multiple))
error = true;
/*
* The following Limit test is a stress test that can run a long time
* Commented out for regular sanity test
*/
/*
if (error || TestInit4DOM(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Limit))
error = true;
if (error || TestInit4SAX(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Limit))
error = true;
if (error || TestInit4SAX2(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, Limit))
error = true;
if (error || TestInit4DOM(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, ExceedLimit))
error = true;
if (error || TestInit4SAX(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, ExceedLimit))
error = true;
if (error || TestInit4SAX2(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, ExceedLimit))
error = true;
*/
if (error || TestInit4DOM(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, UnEven))
error = true;
if (error || TestInit4SAX(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, UnEven))
error = true;
if (error || TestInit4SAX2(xmlFile, gDoNamespaces, gDoSchema, gSchemaFullChecking, UnEven))
error = true;
if (error) {
XERCES_STD_QUALIFIER cout << "Test Failed" << XERCES_STD_QUALIFIER endl;
return 4;
}
XERCES_STD_QUALIFIER cout << "Test Run Successfully" << XERCES_STD_QUALIFIER endl;
return 0;
}
// ---------------------------------------------------------------------------
// InitTermTestErrorHandler
// ---------------------------------------------------------------------------
InitTermTestErrorHandler::InitTermTestErrorHandler() :
fSawErrors(false)
{
}
InitTermTestErrorHandler::~InitTermTestErrorHandler()
{
}
void InitTermTestErrorHandler::error(const SAXParseException& e)
{
fSawErrors = true;
XERCES_STD_QUALIFIER cerr << "\nError at file " << StrX(e.getSystemId())
<< ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
}
void InitTermTestErrorHandler::fatalError(const SAXParseException& e)
{
fSawErrors = true;
XERCES_STD_QUALIFIER cerr << "\nFatal Error at file " << StrX(e.getSystemId())
<< ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
}
void InitTermTestErrorHandler::warning(const SAXParseException& e)
{
XERCES_STD_QUALIFIER cerr << "\nWarning at file " << StrX(e.getSystemId())
<< ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
}
void InitTermTestErrorHandler::resetErrors()
{
fSawErrors = false;
}
+138
View File
@@ -0,0 +1,138 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: InitTermTest.hpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/sax/ErrorHandler.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
XERCES_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_BEGIN
class SAXParseException;
XERCES_CPP_NAMESPACE_END
// ---------------------------------------------------------------------------
// Simple error handler deriviative to install on parser
// ---------------------------------------------------------------------------
class InitTermTestErrorHandler : public ErrorHandler
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
InitTermTestErrorHandler();
~InitTermTestErrorHandler();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getSawErrors() const;
// -----------------------------------------------------------------------
// Implementation of the SAX ErrorHandler interface
// -----------------------------------------------------------------------
void warning(const SAXParseException& e);
void error(const SAXParseException& e);
void fatalError(const SAXParseException& e);
void resetErrors();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
InitTermTestErrorHandler(const InitTermTestErrorHandler&);
void operator=(const InitTermTestErrorHandler&);
// -----------------------------------------------------------------------
// Private data members
//
// fSawErrors
// This is set if we get any errors, and is queryable via a getter
// method. Its used by the main code to suppress output if there are
// errors.
// -----------------------------------------------------------------------
bool fSawErrors;
};
// ---------------------------------------------------------------------------
// This is a simple class that lets us do easy (though not terribly efficient)
// trancoding of XMLCh data to local code page for display.
// ---------------------------------------------------------------------------
class StrX
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
StrX(const XMLCh* const toTranscode)
{
// Call the private transcoding method
fLocalForm = XMLString::transcode(toTranscode);
}
~StrX()
{
XMLString::release(&fLocalForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const char* localForm() const
{
return fLocalForm;
}
private :
// -----------------------------------------------------------------------
// Private data members
//
// fLocalForm
// This is the local code page form of the string.
// -----------------------------------------------------------------------
char* fLocalForm;
};
inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
{
target << toDump.localForm();
return target;
}
inline bool InitTermTestErrorHandler::getSawErrors() const
{
return fSawErrors;
}
+439
View File
@@ -0,0 +1,439 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: MemoryMonitor.cpp 674434 2008-07-07 09:39:20Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "MemoryMonitor.hpp"
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#include <fstream>
#else
#include <iostream.h>
#include <fstream.h>
#endif
#include <assert.h>
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/dom/DOM.hpp>
MemoryManager* MemoryMonitor::getExceptionMemoryManager()
{
return this;
}
void* MemoryMonitor::allocate(XMLSize_t size)
{
void *key = ::operator new(size);
fHashTable->put(key, (unsigned int)size);
return key;
}
void MemoryMonitor::deallocate(void* p)
{
// if fHashTable doesn't contain p, then this memory manager
// didn't allocate that memory--a segfault waiting to happen...
assert(p == 0 || fHashTable->containsKey(p) != 0);
if (p != 0)
{
fHashTable->removeKey(p);
::operator delete(p);
}
}
unsigned int MemoryMonitor::getTotalMemory()
{
unsigned int total = 0;
ValueHashTableOfEnumerator<unsigned int> *memEnum =
new ValueHashTableOfEnumerator<unsigned int>(fHashTable);
while(memEnum->hasMoreElements()) {
total += memEnum->nextElement();
}
delete memEnum;
return total;
}
static void usage()
{
XERCES_STD_QUALIFIER cout << "\nUsage:\n"
" MemHandlerTest [options] <XML file | List file>\n\n"
"This program invokes the XercesDOMParser, DOMLSParser, SAXParser ,\n"
"and the SAX2XMLReader, and ensures that MemoryManagers set on these\n"
"domBuilders are called to delete just as many bytes as they allocate.\n"
"This is done for each XML file, and each file is processed\n"
"as many times as indicated.\n"
"Options:\n"
" -l Indicate the input file is a List File that has a list of xml files.\n"
" Default to off (Input file is an XML file).\n"
" -v=xxx Validation scheme [always | never | auto*].\n"
" -n Enable namespace processing. Defaults to off.\n"
" -s Enable schema processing. Defaults to off.\n"
" -f Enable full schema constraint checking. Defaults to off.\n"
" -r=n Run file through domBuilders n times.\n"
" -? Show this help.\n\n"
" * = Default if not provided explicitly.\n"
<< XERCES_STD_QUALIFIER endl;
}
class DOMLSParserHandler : public DOMErrorHandler
{
public:
DOMLSParserHandler() {};
~DOMLSParserHandler() {};
bool handleError(const DOMError &error)
{
char *message = 0;
XERCES_STD_QUALIFIER cerr << "Error occurred in DOMBuilder! Message: " <<
(message = XMLString::transcode(error.getMessage())) << " of severity " << error.getSeverity() << "." << XERCES_STD_QUALIFIER endl;
XMLString::release(&message);
return true;
}
};
class SAXErrorHandler : public ErrorHandler
{
public:
SAXErrorHandler() {};
~SAXErrorHandler() {};
void warning(const SAXParseException &exc )
{
char *message = 0;
XERCES_STD_QUALIFIER cerr << "SAX warning received! Text: " <<
(message = XMLString::transcode(exc.getMessage())) << "." << XERCES_STD_QUALIFIER endl;
XMLString::release(&message);
}
void error(const SAXParseException &exc )
{
char *message = 0;
XERCES_STD_QUALIFIER cerr << "SAX error received! Text: " <<
(message = XMLString::transcode(exc.getMessage())) << "." << XERCES_STD_QUALIFIER endl;
XMLString::release(&message);
}
void fatalError(const SAXParseException &exc )
{
char *message = 0;
XERCES_STD_QUALIFIER cerr << "SAX fatalError received! Text: " <<
(message = XMLString::transcode(exc.getMessage())) << "." << XERCES_STD_QUALIFIER endl;
XMLString::release(&message);
}
// no state so no body
void resetErrors() {};
};
/**
* This utility takes similar parameters as DOMCount,
* with similar meanings. The only difference is that it runs
* the file(s) in question through a DOMParser, a DOMBuilder, a SAXParser and
* a SAX2XMLReader, setting options as appropriate. It does this
* sequentially, n times per file with a single domBuilder
* object, and reports what it finds in terms of memory
* allocations/deallocations.
*/
int main (int argC, char *argV[])
{
MemoryMonitor *staticMemMonitor = new MemoryMonitor();
// Initialize the XML4C system
try
{
XMLPlatformUtils::Initialize(XMLUni::fgXercescDefaultLocale, 0, 0, staticMemMonitor);
}
catch (const XMLException& toCatch)
{
char *msg = XMLString::transcode(toCatch.getMessage());
XERCES_STD_QUALIFIER cerr << "Error during initialization! :\n"
<< msg << XERCES_STD_QUALIFIER endl;
XMLString::release(&msg);
return 1;
}
// Check command line and extract arguments.
if (argC < 2)
{
usage();
return 1;
}
const char* xmlFile = 0;
AbstractDOMParser::ValSchemes domBuilderValScheme = AbstractDOMParser::Val_Auto;
bool doNamespaces = false;
bool doSchema = false;
bool schemaFullChecking = false;
bool doList = false;
int numReps =1;
int argInd;
for (argInd = 1; argInd < argC; argInd++)
{
// Break out on first parm not starting with a dash
if (argV[argInd][0] != '-')
break;
// Watch for special case help request
if (!strcmp(argV[argInd], "-?"))
{
usage();
return 2;
}
else if (!strncmp(argV[argInd], "-v=", 3)
|| !strncmp(argV[argInd], "-V=", 3))
{
const char* const parm = &argV[argInd][3];
if (!strcmp(parm, "never"))
domBuilderValScheme = AbstractDOMParser::Val_Never;
else if (!strcmp(parm, "auto"))
domBuilderValScheme = AbstractDOMParser::Val_Auto;
else if (!strcmp(parm, "always"))
domBuilderValScheme = AbstractDOMParser::Val_Always;
else
{
XERCES_STD_QUALIFIER cerr << "Unknown -v= value: " << parm << XERCES_STD_QUALIFIER endl;
return 2;
}
}
else if (!strcmp(argV[argInd], "-n")
|| !strcmp(argV[argInd], "-N"))
{
doNamespaces = true;
}
else if (!strcmp(argV[argInd], "-s")
|| !strcmp(argV[argInd], "-S"))
{
doSchema = true;
}
else if (!strcmp(argV[argInd], "-f")
|| !strcmp(argV[argInd], "-F"))
{
schemaFullChecking = true;
}
else if (!strcmp(argV[argInd], "-l")
|| !strcmp(argV[argInd], "-L"))
{
doList = true;
}
else if (!strncmp(argV[argInd], "-r=", 3)
|| !strncmp(argV[argInd], "-R=", 3))
{
const char* const numStr = &argV[argInd][3];
XMLCh* numXStr = XMLString::transcode(numStr);
numReps = XMLString::parseInt(numXStr);
XMLString::release(&numXStr);
}
else
{
XERCES_STD_QUALIFIER cerr << "Unknown option '" << argV[argInd]
<< "', ignoring it\n" << XERCES_STD_QUALIFIER endl;
}
}
//
// There should be only one and only one parameter left, and that
// should be the file name.
//
if (argInd != argC - 1)
{
usage();
return 1;
}
// Instantiate the DOM domBuilder with its memory manager.
MemoryMonitor *domBuilderMemMonitor = new MemoryMonitor();
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS);
DOMLSParser *domBuilder = ((DOMImplementationLS*)impl)->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0, domBuilderMemMonitor);
DOMLSParserHandler domBuilderHandler;
domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, &domBuilderHandler);
// Instantiate the SAX2 parser with its memory manager.
MemoryMonitor *sax2MemMonitor = new MemoryMonitor();
SAX2XMLReader *sax2parser = XMLReaderFactory::createXMLReader(sax2MemMonitor);
SAXErrorHandler saxErrorHandler;
sax2parser->setErrorHandler(&saxErrorHandler);
// Instantiate the SAX 1 parser with its memory manager.
MemoryMonitor *sax1MemMonitor = new MemoryMonitor();
SAXParser *saxParser = new (sax1MemMonitor) SAXParser(0, sax1MemMonitor);
saxParser->setErrorHandler(&saxErrorHandler);
// set features
domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, doNamespaces);
sax2parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, doNamespaces);
saxParser->setDoNamespaces(doNamespaces);
domBuilder->getDomConfig()->setParameter(XMLUni::fgXercesSchema, doSchema);
sax2parser->setFeature(XMLUni::fgXercesSchema, doSchema);
saxParser->setDoSchema(doSchema);
domBuilder->getDomConfig()->setParameter(XMLUni::fgXercesSchemaFullChecking, schemaFullChecking);
sax2parser->setFeature(XMLUni::fgXercesSchemaFullChecking, schemaFullChecking);
saxParser->setValidationSchemaFullChecking(schemaFullChecking);
if (domBuilderValScheme == AbstractDOMParser::Val_Auto)
{
domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMValidateIfSchema, true);
sax2parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
sax2parser->setFeature(XMLUni::fgXercesDynamic, true);
saxParser->setValidationScheme(SAXParser::Val_Auto);
}
else if (domBuilderValScheme == AbstractDOMParser::Val_Never)
{
domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMValidate, false);
sax2parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
saxParser->setValidationScheme(SAXParser::Val_Never);
}
else if (domBuilderValScheme == AbstractDOMParser::Val_Always)
{
domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMValidate, true);
sax2parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
sax2parser->setFeature(XMLUni::fgXercesDynamic, false);
saxParser->setValidationScheme(SAXParser::Val_Always);
}
// enable datatype normalization - default is off
domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMDatatypeNormalization, true);
XERCES_STD_QUALIFIER ifstream fin;
bool more = true;
// the input is a list file
if (doList)
fin.open(argV[argInd]);
if (fin.fail()) {
XERCES_STD_QUALIFIER cerr <<"Cannot open the list file: " << argV[argInd] << XERCES_STD_QUALIFIER endl;
return 2;
}
while (more)
{
char fURI[1000];
//initialize the array to zeros
memset(fURI,0,sizeof(fURI));
if (doList) {
if (! fin.eof() ) {
fin.getline (fURI, sizeof(fURI));
if (!*fURI)
continue;
else {
xmlFile = fURI;
XERCES_STD_QUALIFIER cerr << "==Parsing== " << xmlFile << XERCES_STD_QUALIFIER endl;
}
}
else
break;
}
else {
xmlFile = argV[argInd];
more = false;
}
// parse numReps times (in case we need it for some reason)
for (int i=0; i<numReps; i++)
{
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc = 0;
try
{
// reset document pool
domBuilder->resetDocumentPool();
doc = domBuilder->parseURI(xmlFile);
if(doc && doc->getDocumentElement())
{
XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList *list=NULL;
if(doNamespaces)
list=doc->getElementsByTagNameNS(doc->getDocumentElement()->getNamespaceURI(), doc->getDocumentElement()->getLocalName());
else
list=doc->getElementsByTagName(doc->getDocumentElement()->getNodeName());
if(list==NULL)
XERCES_STD_QUALIFIER cout << "getElementsByTagName didn't return a valid DOMNodeList." << XERCES_STD_QUALIFIER endl;
else if(list->item(0)!=doc->getDocumentElement())
XERCES_STD_QUALIFIER cout << "getElementsByTagName didn't find the root element." << XERCES_STD_QUALIFIER endl;
}
sax2parser->parse(xmlFile);
saxParser->parse(xmlFile);
}
catch (const OutOfMemoryException&)
{
XERCES_STD_QUALIFIER cerr << "OutOfMemoryException during parsing: '" << xmlFile << "'\n" << XERCES_STD_QUALIFIER endl;;
continue;
}
catch (const XMLException& toCatch)
{
char *msg = XMLString::transcode(toCatch.getMessage());
XERCES_STD_QUALIFIER cerr << "\nError during parsing: '" << xmlFile << "'\n"
<< "Exception message is: \n"
<< msg << "\n" << XERCES_STD_QUALIFIER endl;
XMLString::release(&msg);
continue;
}
catch (const DOMException& toCatch)
{
const unsigned int maxChars = 2047;
XMLCh errText[maxChars + 1];
XERCES_STD_QUALIFIER cerr << "\nDOM Error during parsing: '" << xmlFile << "'\n"
<< "DOMException code is: " << toCatch.code << XERCES_STD_QUALIFIER endl;
if (DOMImplementation::loadDOMExceptionMsg(toCatch.code, errText, maxChars))
{
char * msg = XMLString::transcode(errText);
XERCES_STD_QUALIFIER cerr << "Message is: " << msg << XERCES_STD_QUALIFIER endl;
continue;
}
}
catch (...)
{
XERCES_STD_QUALIFIER cerr << "\nUnexpected exception during parsing: '" << xmlFile << "'\n";
continue;
}
}
}
//
// Delete the domBuilder itself. Must be done prior to calling Terminate, below.
//
domBuilder->release();
delete sax2parser;
delete saxParser;
XERCES_STD_QUALIFIER cout << "At destruction, domBuilderMemMonitor has " << domBuilderMemMonitor->getTotalMemory() << " bytes." << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER cout << "At destruction, sax2MemMonitor has " << sax2MemMonitor->getTotalMemory() << " bytes." << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER cout << "At destruction, sax1MemMonitor has " << sax1MemMonitor->getTotalMemory() << " bytes." << XERCES_STD_QUALIFIER endl;
delete domBuilderMemMonitor;
delete sax2MemMonitor;
delete sax1MemMonitor;
XMLPlatformUtils::Terminate();
XERCES_STD_QUALIFIER cout << "At destruction, staticMemMonitor has " << staticMemMonitor->getTotalMemory() << " bytes." << XERCES_STD_QUALIFIER endl;
delete staticMemMonitor;
return 0;
}
+113
View File
@@ -0,0 +1,113 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: MemoryMonitor.hpp 679340 2008-07-24 10:28:29Z borisk $
*/
#include <xercesc/framework/MemoryManager.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOMLSParser.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
#include <xercesc/dom/DOMError.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMImplementationRegistry.hpp>
#include <xercesc/parsers/AbstractDOMParser.hpp>
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/parsers/SAXParser.hpp>
#include "SimpleValueHashTableOf.hpp"
XERCES_CPP_NAMESPACE_USE
/**
* Configurable memory manager
*
* <p>This class is a memory manager implementation that keeps track of all
* allocations/deallocations to ensure that all memory that it allocated is
* deallocated.
* </p>
*/
class MemoryMonitor : public MemoryManager
{
public:
/** @name Constructor */
//@{
/**
* Default constructor
*/
MemoryMonitor()
{
fHashTable = new SimpleValueHashTableOf<unsigned int>(1013);
}
//@}
/** @name Destructor */
//@{
/**
* Default destructor
*/
virtual ~MemoryMonitor()
{
delete fHashTable;
}
//@}
virtual MemoryManager* getExceptionMemoryManager();
/** @name The virtual methods in MemoryManager */
//@{
/**
* This method allocates requested memory.
*
* @param size The requested memory size
*
* @return A pointer to the allocated memory
*/
virtual void* allocate(XMLSize_t size);
/**
* This method deallocates memory
*
* @param p The pointer to the allocated memory to be deleted
*/
virtual void deallocate(void* p);
//@}
// Print out amount of currently allocated memory
unsigned int getTotalMemory();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
MemoryMonitor(const MemoryMonitor &);
MemoryMonitor& operator=(const MemoryMonitor &);
SimpleValueHashTableOf<unsigned int>* fHashTable;
};
+544
View File
@@ -0,0 +1,544 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: SimpleValueHashTableOf.hpp 679340 2008-07-24 10:28:29Z borisk $
*/
//
// This is just a version of the ValueHashTableOf implementation from
// xercesc/util; we need a new one here because this cannot use the
// pluggable memory management facilities.
//
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
#include <xercesc/util/NullPointerException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/XMLExceptMsgs.hpp>
#include <xercesc/util/XMLEnumerator.hpp>
#include <xercesc/util/Hashers.hpp>
XERCES_CPP_NAMESPACE_USE
// Forward declare the enumerator so it can be our friend.
//
template <class TVal, class THasher = PtrHasher>
class ValueHashTableOfEnumerator;
//
// This should really be a nested class, but some of the compilers we
// have to support cannot deal with that!
//
template <class TVal>
struct ValueHashTableBucketElem
{
ValueHashTableBucketElem(void* key, const TVal& value, ValueHashTableBucketElem<TVal>* next)
: fData(value), fNext(next), fKey(key)
{
}
TVal fData;
ValueHashTableBucketElem<TVal>* fNext;
void* fKey;
};
template <class TVal, class THasher = PtrHasher>
class SimpleValueHashTableOf
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
SimpleValueHashTableOf(const XMLSize_t modulus);
SimpleValueHashTableOf(const XMLSize_t modulus, const THasher& hasher);
~SimpleValueHashTableOf();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
bool isEmpty() const;
bool containsKey(const void* const key) const;
void removeKey(const void* const key);
void removeAll();
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
TVal& get(const void* const key);
const TVal& get(const void* const key) const;
// -----------------------------------------------------------------------
// Putters
// -----------------------------------------------------------------------
void put(void* key, const TVal& valueToAdopt);
private :
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class ValueHashTableOfEnumerator<TVal, THasher>;
private:
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
ValueHashTableBucketElem<TVal>* findBucketElem(const void* const key, XMLSize_t& hashVal);
const ValueHashTableBucketElem<TVal>* findBucketElem(const void* const key, XMLSize_t& hashVal) const;
void removeBucketElem(const void* const key, XMLSize_t& hashVal);
void initialize(const XMLSize_t modulus);
// -----------------------------------------------------------------------
// Data members
//
// fBucketList
// This is the array that contains the heads of all of the list
// buckets, one for each possible hash value.
//
// fHashModulus
// The modulus used for this hash table, to hash the keys. This is
// also the number of elements in the bucket list.
//
// fHash
// The hasher for the key data type.
// -----------------------------------------------------------------------
ValueHashTableBucketElem<TVal>** fBucketList;
XMLSize_t fHashModulus;
THasher fHasher;
};
//
// An enumerator for a value array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TVal, class THasher>
class ValueHashTableOfEnumerator : public XMLEnumerator<TVal>
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueHashTableOfEnumerator(SimpleValueHashTableOf<TVal, THasher>* const toEnum, const bool adopt = false);
virtual ~ValueHashTableOfEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TVal& nextElement();
void Reset();
private :
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
void findNext();
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurElem
// This is the current bucket bucket element that we are on.
//
// fCurHash
// The is the current hash buck that we are working on. Once we hit
// the end of the bucket that fCurElem is in, then we have to start
// working this one up to the next non-empty bucket.
//
// fToEnum
// The value array being enumerated.
// -----------------------------------------------------------------------
bool fAdopted;
ValueHashTableBucketElem<TVal>* fCurElem;
XMLSize_t fCurHash;
SimpleValueHashTableOf<TVal, THasher>* fToEnum;
};
// ---------------------------------------------------------------------------
// ValueHashTableOf: Constructors and Destructor
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
SimpleValueHashTableOf<TVal, THasher>::SimpleValueHashTableOf(const XMLSize_t modulus
, const THasher& hasher)
: fBucketList(0), fHashModulus(modulus), fHasher (hasher)
{
initialize(modulus);
}
template <class TVal, class THasher>
SimpleValueHashTableOf<TVal, THasher>::SimpleValueHashTableOf(const XMLSize_t modulus)
: fBucketList(0), fHashModulus(modulus)
{
initialize(modulus);
}
template <class TVal, class THasher>
void SimpleValueHashTableOf<TVal, THasher>::initialize(const XMLSize_t modulus)
{
if (modulus == 0)
ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus);
// Allocate the bucket list and zero them
fBucketList = new ValueHashTableBucketElem<TVal>*[fHashModulus];
for (XMLSize_t index = 0; index < fHashModulus; index++)
fBucketList[index] = 0;
}
template <class TVal, class THasher>
SimpleValueHashTableOf<TVal, THasher>::~SimpleValueHashTableOf()
{
removeAll();
// Then delete the bucket list & hasher
delete [] fBucketList;
}
// ---------------------------------------------------------------------------
// SimpleValueHashTableOf: Element management
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
bool SimpleValueHashTableOf<TVal, THasher>::isEmpty() const
{
// Just check the bucket list for non-empty elements
for (XMLSize_t buckInd = 0; buckInd < fHashModulus; buckInd++)
{
if (fBucketList[buckInd] != 0)
return false;
}
return true;
}
template <class TVal, class THasher>
bool SimpleValueHashTableOf<TVal, THasher>::
containsKey(const void* const key) const
{
XMLSize_t hashVal;
const ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal);
return (findIt != 0);
}
template <class TVal, class THasher>
void SimpleValueHashTableOf<TVal, THasher>::
removeKey(const void* const key)
{
XMLSize_t hashVal;
removeBucketElem(key, hashVal);
}
template <class TVal, class THasher>
void SimpleValueHashTableOf<TVal, THasher>::removeAll()
{
// Clean up the buckets first
for (XMLSize_t buckInd = 0; buckInd < fHashModulus; buckInd++)
{
// Get the bucket list head for this entry
ValueHashTableBucketElem<TVal>* curElem = fBucketList[buckInd];
ValueHashTableBucketElem<TVal>* nextElem;
while (curElem)
{
// Save the next element before we hose this one
nextElem = curElem->fNext;
// delete the current element and move forward
delete curElem;
curElem = nextElem;
}
// Clean out this entry
fBucketList[buckInd] = 0;
}
}
// ---------------------------------------------------------------------------
// SimpleValueHashTableOf: Getters
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
TVal& SimpleValueHashTableOf<TVal, THasher>::get(const void* const key)
{
XMLSize_t hashVal;
ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal);
if (!findIt)
ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
return findIt->fData;
}
template <class TVal, class THasher>
const TVal& SimpleValueHashTableOf<TVal, THasher>::
get(const void* const key) const
{
XMLSize_t hashVal;
const ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal);
if (!findIt)
ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
return findIt->fData;
}
// ---------------------------------------------------------------------------
// SimpleValueHashTableOf: Putters
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
void SimpleValueHashTableOf<TVal, THasher>::put(void* key, const TVal& valueToAdopt)
{
// First see if the key exists already
XMLSize_t hashVal;
ValueHashTableBucketElem<TVal>* newBucket = findBucketElem(key, hashVal);
//
// If so,then update its value. If not, then we need to add it to
// the right bucket
//
if (newBucket)
{
newBucket->fData = valueToAdopt;
newBucket->fKey = key;
}
else
{
newBucket = new ValueHashTableBucketElem<TVal>(key, valueToAdopt, fBucketList[hashVal]);
fBucketList[hashVal] = newBucket;
}
}
// ---------------------------------------------------------------------------
// SimpleValueHashTableOf: Private methods
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
ValueHashTableBucketElem<TVal>* SimpleValueHashTableOf<TVal, THasher>::
findBucketElem(const void* const key, XMLSize_t& hashVal)
{
// Hash the key
hashVal = fHasher.getHashVal(key, fHashModulus);
if (hashVal > fHashModulus)
ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
// Search that bucket for the key
ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
while (curElem)
{
if (fHasher.equals(key, curElem->fKey))
return curElem;
curElem = curElem->fNext;
}
return 0;
}
template <class TVal, class THasher>
const ValueHashTableBucketElem<TVal>* SimpleValueHashTableOf<TVal, THasher>::
findBucketElem(const void* const key, XMLSize_t& hashVal) const
{
// Hash the key
hashVal = fHasher.getHashVal(key, fHashModulus);
if (hashVal > fHashModulus)
ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
// Search that bucket for the key
const ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
while (curElem)
{
if (fHasher.equals(key, curElem->fKey))
return curElem;
curElem = curElem->fNext;
}
return 0;
}
template <class TVal, class THasher>
void SimpleValueHashTableOf<TVal, THasher>::
removeBucketElem(const void* const key, XMLSize_t& hashVal)
{
// Hash the key
hashVal = fHasher.getHashVal(key, fHashModulus);
if (hashVal > fHashModulus)
ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
//
// Search the given bucket for this key. Keep up with the previous
// element so we can patch around it.
//
ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
ValueHashTableBucketElem<TVal>* lastElem = 0;
while (curElem)
{
if (fHasher.equals(key, curElem->fKey))
{
if (!lastElem)
{
// It was the first in the bucket
fBucketList[hashVal] = curElem->fNext;
}
else
{
// Patch around the current element
lastElem->fNext = curElem->fNext;
}
// Delete the current element
delete curElem;
return;
}
// Move both pointers upwards
lastElem = curElem;
curElem = curElem->fNext;
}
// We never found that key
ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
}
// ---------------------------------------------------------------------------
// ValueHashTableOfEnumerator: Constructors and Destructor
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
ValueHashTableOfEnumerator<TVal, THasher>::
ValueHashTableOfEnumerator(SimpleValueHashTableOf<TVal, THasher>* const toEnum, const bool adopt)
: fAdopted(adopt), fCurElem(0), fCurHash((XMLSize_t)-1), fToEnum(toEnum)
{
if (!toEnum)
ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero);
//
// Find the next available bucket element in the hash table. If it
// comes back zero, that just means the table is empty.
//
// Note that the -1 in the current hash tells it to start from the
// beginning.
//
findNext();
}
template <class TVal, class THasher>
ValueHashTableOfEnumerator<TVal, THasher>::~ValueHashTableOfEnumerator()
{
if (fAdopted)
delete fToEnum;
}
// ---------------------------------------------------------------------------
// ValueHashTableOfEnumerator: Enum interface
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
bool ValueHashTableOfEnumerator<TVal, THasher>::hasMoreElements() const
{
//
// If our current has is at the max and there are no more elements
// in the current bucket, then no more elements.
//
if (!fCurElem && (fCurHash == fToEnum->fHashModulus))
return false;
return true;
}
template <class TVal, class THasher>
TVal& ValueHashTableOfEnumerator<TVal, THasher>::nextElement()
{
// Make sure we have an element to return
if (!hasMoreElements())
ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements);
//
// Save the current element, then move up to the next one for the
// next time around.
//
ValueHashTableBucketElem<TVal>* saveElem = fCurElem;
findNext();
return saveElem->fData;
}
template <class TVal, class THasher>
void ValueHashTableOfEnumerator<TVal, THasher>::Reset()
{
fCurHash = (XMLSize_t)-1;
fCurElem = 0;
findNext();
}
// ---------------------------------------------------------------------------
// ValueHashTableOfEnumerator: Private helper methods
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
void ValueHashTableOfEnumerator<TVal, THasher>::findNext()
{
//
// If there is a current element, move to its next element. If this
// hits the end of the bucket, the next block will handle the rest.
//
if (fCurElem)
fCurElem = fCurElem->fNext;
//
// If the current element is null, then we have to move up to the
// next hash value. If that is the hash modulus, then we cannot
// go further.
//
if (!fCurElem)
{
fCurHash++;
if (fCurHash == fToEnum->fHashModulus)
return;
// Else find the next non-empty bucket
while (true)
{
if (fToEnum->fBucketList[fCurHash])
break;
// Bump to the next hash value. If we max out return
fCurHash++;
if (fCurHash == fToEnum->fHashModulus)
return;
}
fCurElem = fToEnum->fBucketList[fCurHash];
}
}
+165
View File
@@ -0,0 +1,165 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: NetAccessorTest.cpp 470088 2006-11-01 20:35:12Z amassari $
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLURL.hpp>
#include <xercesc/util/XMLNetAccessor.hpp>
#include <xercesc/util/BinInputStream.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
XERCES_CPP_NAMESPACE_USE
inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& os, const XMLCh* xmlStr)
{
char* transcoded = XMLString::transcode(xmlStr);
os << transcoded;
XMLString::release(&transcoded);
return os;
}
void
exercise(BinInputStream& stream)
{
static float percents[] = { 1.0, 0.5, 0.25, 0.1, 0.15, 0.113, 0.333, 0.0015, 0.0013 };
int numPercents = sizeof(percents) / sizeof(float);
const unsigned int bufferMax = 4096;
XMLByte buffer[bufferMax];
int iteration = 0;
unsigned int bytesRead = 0;
do {
// Calculate a percentage of our maximum buffer size, going through
// them round-robin
float percent = percents[iteration % numPercents];
unsigned int bufCnt = (unsigned int)(bufferMax * percent);
// Check to make sure we didn't go out of bounds
if (bufCnt <= 0)
bufCnt = 1;
if (bufCnt > bufferMax)
bufCnt = bufferMax;
// Read bytes into our buffer
bytesRead = stream.readBytes(buffer, bufCnt);
//XERCES_STD_QUALIFIER cerr << "Read " << bytesRead << " bytes into a " << bufCnt << " byte buffer\n";
if (bytesRead > 0)
{
// Write the data to standard out
XERCES_STD_QUALIFIER cout.write((char*)buffer, bytesRead);
}
++iteration;
} while (bytesRead > 0);
}
// ---------------------------------------------------------------------------
// Program entry point
// ---------------------------------------------------------------------------
int
main(int argc, char** argv)
{
// Init the XML platform
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER cout << "Error during platform init! Message:\n"
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return 1;
}
// Look for our one and only parameter
if (argc != 2)
{
XERCES_STD_QUALIFIER cerr << "Usage: NetAccessorTest url\n"
"\n"
"This test reads data from the given url and writes the result\n"
"to standard output.\n"
"\n"
"A variety of buffer sizes is are used during the test.\n"
"\n"
;
exit(1);
}
// Get the URL
char* url = argv[1];
// Do the test
try
{
XMLURL xmlURL(url);
// Get the netaccessor
XMLNetAccessor* na = XMLPlatformUtils::fgNetAccessor;
if (na == 0)
{
XERCES_STD_QUALIFIER cerr << "No netaccessor is available. Aborting.\n";
exit(2);
}
// Build a binary input stream
BinInputStream* is = na->makeNew(xmlURL);
if (is == 0)
{
XERCES_STD_QUALIFIER cerr << "No binary input stream created. Aborting.\n";
exit(3);
}
// Exercise the inputstream
exercise(*is);
// Delete the is
delete is;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER cout << "Exception during test:\n "
<< toCatch.getMessage()
<< XERCES_STD_QUALIFIER endl;
}
// And call the termination method
XMLPlatformUtils::Terminate();
return 0;
}
+215
View File
@@ -0,0 +1,215 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: ParserTest.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLURL.hpp>
#include <xercesc/internal/XMLScanner.hpp>
#include <xercesc/validators/DTD/DTDValidator.hpp>
#include "ParserTest.hpp"
// ---------------------------------------------------------------------------
// Program entry point
// ---------------------------------------------------------------------------
int main(int argC, char** argV)
{
// Init the XML platform
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER cout << "Error during platform init! Message:\n"
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
return 1;
}
//
// Create our test parser object. This object implements the internal
// event APIs and is plugged into the scanner.
//
TestParser parserTest;
// Figure out the parameters
bool doValidation = false;
bool doNamespaces = false;
bool keepGoing = false;
XMLCh* urlPath = 0;
for (int index = 1; index < argC; index++)
{
if (!XMLString::compareIString(argV[index], "/Debug"))
parserTest.setOutputType(OutputType_Debug);
else if (!XMLString::compareIString(argV[index], "/Validate"))
doValidation = true;
else if (!XMLString::compareIString(argV[index], "/Namespaces"))
{
doNamespaces = true;
parserTest.setDoNamespaces(true);
}
else if (!XMLString::compareIString(argV[index], "/XML"))
parserTest.setOutputType(OutputType_XML);
else if (!XMLString::compareIString(argV[index], "/IntDTD"))
parserTest.setShowIntDTD(true);
else if (!XMLString::compareIString(argV[index], "/ShowWarnings"))
parserTest.setShowWarnings(true);
else if (!XMLString::compareIString(argV[index], "/ShowErrLoc"))
parserTest.setShowErrLoc(true);
else if (!XMLString::compareIString(argV[index], "/JCCanon"))
parserTest.setOutputType(OutputType_JCCanon);
else if (!XMLString::compareIString(argV[index], "/SunCanon"))
parserTest.setOutputType(OutputType_SunCanon);
else if (!XMLString::compareIString(argV[index], "/KeepGoing"))
keepGoing = true;
else if (!XMLString::compareNIString(argV[index], "/URL=", 5))
urlPath = XMLString::transcode(&argV[index][5]);
else
XERCES_STD_QUALIFIER cout << "Unknown parameter: " << argV[index] << XERCES_STD_QUALIFIER endl;
}
// We have to have a URL to work on
if (!urlPath)
{
XERCES_STD_QUALIFIER cout << "A URL must be provided, /URL=xxxx" << XERCES_STD_QUALIFIER endl;
return 1;
}
//
// Create a validator of the correct type so that we can install it
// on the scanner.
//
// <TBD> Later, when Schema validators exist, we'll have a parameter
// to select one or the other
//
XMLValidator* validator = 0;
DTDValidator* dtdVal = new DTDValidator(&parserTest);
validator = dtdVal;
// And now create the scanner and give it all the handlers
XMLScanner scanner
(
&parserTest
, &parserTest
, 0
, &parserTest
, validator
);
// Set the scanner flags that we were told to
scanner.setDoValidation(doValidation);
scanner.setDoNamespaces(doNamespaces);
scanner.setExitOnFirstFatal(!keepGoing);
// Tell the parser about the scanner
parserTest.setScanner(&scanner);
try
{
scanner.scanDocument(urlPath);
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER cout << "Exception during scan:\n "
<< StrX(toCatch.getMessage())
<< XERCES_STD_QUALIFIER endl;
}
// And call the termination method
XMLPlatformUtils::Terminate();
return 0;
}
// ---------------------------------------------------------------------------
// StrX: Private helper methods
// ---------------------------------------------------------------------------
void StrX::transcode(const XMLCh* const toTranscode, const unsigned int len)
{
// Short circuit if its a null pointer
if (!toTranscode || (!toTranscode[0]))
{
fLocalForm = new char[1];
fLocalForm[0] = 0;
return;
}
// See if our XMLCh and wchar_t as the same on this platform
const bool isSameSize = (sizeof(XMLCh) == sizeof(wchar_t));
//
// Get the actual number of chars. If the passed len is zero, its null
// terminated. Else we have to use the len.
//
wchar_t realLen = (wchar_t)len;
if (!realLen)
{
//
// We cannot just assume we can use wcslen() because we don't know
// if our XMLCh is the same as wchar_t on this platform.
//
const XMLCh* tmpPtr = toTranscode;
while (*(tmpPtr++))
realLen++;
}
//
// If either the passed length was non-zero or our char sizes are not
// same, we have to use a temp buffer. Since this is common in these
// samples, we just do it anyway.
//
wchar_t* tmpSource = new wchar_t[realLen + 1];
if (isSameSize)
{
memcpy(tmpSource, toTranscode, realLen * sizeof(wchar_t));
}
else
{
for (unsigned int index = 0; index < realLen; index++)
tmpSource[index] = (wchar_t)toTranscode[index];
}
tmpSource[realLen] = 0;
// See now many chars we need to transcode this guy
const unsigned int targetLen = ::wcstombs(0, tmpSource, 0);
// Allocate out storage member
fLocalForm = new char[targetLen + 1];
//
// And transcode our temp source buffer to the local buffer. Cap it
// off since the converter won't do it (because the null is beyond
// where the target will fill up.)
//
::wcstombs(fLocalForm, tmpSource, targetLen);
fLocalForm[targetLen] = 0;
// Don't forget to delete our temp buffer
delete [] tmpSource;
}
+103
View File
@@ -0,0 +1,103 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: ParserTest.hpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// Some types used by this program
// ---------------------------------------------------------------------------
enum OutputTypes
{
OutputType_None
, OutputType_Debug
, OutputType_JCCanon
, OutputType_SunCanon
, OutputType_XML
};
// ---------------------------------------------------------------------------
// Includes that everyone uses inside this program
// ---------------------------------------------------------------------------
#include "ParserTest_Parser.hpp"
#include <stdlib.h>
#include <xercesc/util/PlatformUtils.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
// ---------------------------------------------------------------------------
// This is a simple class that lets us do easy (though not terribly efficient)
// trancoding of XMLCh data to local code page for display.
// ---------------------------------------------------------------------------
class StrX
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
StrX(const XMLCh* const toTranscode, const unsigned int len = 0) :
fLocalForm(0)
{
// Call the private transcoding method
transcode(toTranscode, len);
}
~StrX()
{
XMLString::release(&fLocalForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const char* localForm() const
{
return fLocalForm;
}
private :
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void transcode (const XMLCh* const toTranscode, const unsigned int len);
// -----------------------------------------------------------------------
// Private data members
//
// fLocalForm
// This is the local code page form of the string.
// -----------------------------------------------------------------------
char* fLocalForm;
};
inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
{
target << toDump.localForm();
return target;
}
File diff suppressed because it is too large Load Diff
+339
View File
@@ -0,0 +1,339 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: ParserTest_Parser.hpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/framework/XMLDocumentHandler.hpp>
#include <xercesc/framework/XMLErrorReporter.hpp>
#include <xercesc/validators/DTD/DocTypeHandler.hpp>
XERCES_CPP_NAMESPACE_USE
class TestParser :
public XMLDocumentHandler, public XMLErrorReporter, public DocTypeHandler
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
TestParser();
~TestParser();
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setDoNamespaces(const bool state);
void setScanner(XMLScanner* const state);
void setOutputType(const OutputTypes outType);
void setShowErrLoc(const bool state);
void setShowIntDTD(const bool state);
void setShowWarnings(const bool state);
// -----------------------------------------------------------------------
// The XMLDocumentHandler interface
// -----------------------------------------------------------------------
virtual void docCharacters
(
const XMLCh* const chars
, const unsigned int length
, const bool cdataSection
);
virtual void docComment
(
const XMLCh* const comment
);
virtual void docPI
(
const XMLCh* const target
, const XMLCh* const data
);
virtual void endDocument();
virtual void endElement
(
const XMLElementDecl& elemDecl
, const unsigned int uriId
, const bool isRoot
);
virtual void endEntityReference
(
const XMLEntityDecl& entDecl
);
virtual void ignorableWhitespace
(
const XMLCh* const chars
, const unsigned int length
, const bool cdataSection
);
virtual void resetDocument();
virtual void startDocument();
virtual void startElement
(
const XMLElementDecl& elemDecl
, const unsigned int elemURIId
, const XMLCh* const elemPrefix
, const RefVectorOf<XMLAttr>& attrList
, const unsigned int attrCount
, const bool isEmpty
, const bool isRoot
);
virtual void startEntityReference
(
const XMLEntityDecl& entDecl
);
virtual void XMLDecl
(
const XMLCh* const versionStr
, const XMLCh* const encodingStr
, const XMLCh* const standaloneStr
, const XMLCh* const autoEncStr
);
// -----------------------------------------------------------------------
// Implementation of the XMLErrorReporter interface
// -----------------------------------------------------------------------
virtual void error
(
const unsigned int errCode
, const XMLCh* const msgDomain
, const XMLErrorReporter::ErrTypes type
, const XMLCh* const text
, const XMLCh* const systemId
, const XMLCh* const publicId
, const unsigned int lineNum
, const unsigned int colNum
);
virtual void resetErrors();
// -----------------------------------------------------------------------
// The document type handler virtual handler interface
// -----------------------------------------------------------------------
virtual void attDef
(
const DTDElementDecl& elemDecl
, const DTDAttDef& attDef
, const bool ignoring
);
virtual void doctypeComment
(
const XMLCh* const comment
);
virtual void doctypeDecl
(
const DTDElementDecl& elemDecl
, const XMLCh* const publicId
, const XMLCh* const systemId
, const bool hasIntSubset
);
virtual void doctypePI
(
const XMLCh* const target
, const XMLCh* const data
);
virtual void doctypeWhitespace
(
const XMLCh* const chars
, const unsigned int length
);
virtual void elementDecl
(
const DTDElementDecl& decl
, const bool isIgnored
);
virtual void endAttList
(
const DTDElementDecl& elemDecl
);
virtual void endIntSubset();
virtual void endExtSubset();
virtual void entityDecl
(
const DTDEntityDecl& entityDecl
, const bool isPEDecl
, const bool isIgnored
);
virtual void resetDocType();
virtual void notationDecl
(
const XMLNotationDecl& notDecl
, const bool isIgnored
);
virtual void startAttList
(
const DTDElementDecl& elemDecl
);
virtual void startIntSubset();
virtual void startExtSubset();
virtual void TextDecl
(
const XMLCh* const versionStr
, const XMLCh* const encodingStr
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
TestParser(const TestParser&);
void operator=(const TestParser&);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void showChar(const char toShow, const bool doCan);
void showChars
(
const XMLCh* const chars
, const unsigned int length
);
void showIds(const XMLCh* const publicId, const XMLCh* const systemId);
void showString(const XMLCh* const toShow);
// -----------------------------------------------------------------------
// Data members
//
// fDoNamespaces
// Indicates whether the user wanted us to be namespace aware or
// not.
//
// fInsideRoot
// This is set once the first start element event is seen, and cleared
// when the root element ends. Its used to support the canonical
// format used by the Bosak tests. Basically it allows us to supress
// the whitespace outside the internal subset but before the root
// element.
//
// fInExtSubSet
// Indicates when we are in the external subset, so that we don't
// display that part.
//
// fIntDTDOutput
// Indicates whether the data from the internal DTD subset is
// output or not (only used if fXMLOutput is true.)
//
// fNestingLevel
// This is used to handle tabbing over nested elements. Each start
// element bumps it up, and each end element bumps it down.
//
// fOutputType
// This flag controls the primary style of output used. It can
// be set to do James Clark type canonical output, Sun style
// canonical output, debug output, regular XML output, or none.
//
// fScanner
// The scanner we created to do the scanning.
//
// fShowErrLoc
// This flag turns on the special display mode that is used for
// negative test testing. It puts out a special, condensed display
// of error info that can be compared in subsequent runs to check
// for changes. If its turned on, it forces the output type to
// 'none'.
//
// fShowWarnings
// Indicates whether warning messages should be displayed or not.
//
// fSurrogate
// Indicates that we got a surrogate char, so we have to wait for
// the next char before we can output it. Its zero when not.
// -----------------------------------------------------------------------
bool fDoNamespaces;
bool fInExtSubset;
bool fInsideRoot;
bool fIntDTDOutput;
unsigned int fNestingLevel;
OutputTypes fOutputType;
XMLScanner* fScanner;
bool fShowErrLoc;
bool fShowWarnings;
XMLCh fSurrogate;
};
// ---------------------------------------------------------------------------
// TestParser: Setter Methods
// ---------------------------------------------------------------------------
inline void TestParser::setDoNamespaces(const bool state)
{
fDoNamespaces = state;
}
inline void TestParser::setScanner(XMLScanner* const ourScanner)
{
fScanner = ourScanner;
}
inline void TestParser::setOutputType(const OutputTypes outType)
{
fOutputType = outType;
}
inline void TestParser::setShowIntDTD(const bool state)
{
fIntDTDOutput = state;
}
inline void TestParser::setShowWarnings(const bool state)
{
fShowWarnings = state;
}
inline void TestParser::setShowErrLoc(const bool state)
{
fShowErrLoc = state;
}
+1368
View File
File diff suppressed because it is too large Load Diff
+34
View File
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests.hpp 470088 2006-11-01 20:35:12Z amassari $
*/
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
XERCES_CPP_NAMESPACE_USE
+223
View File
@@ -0,0 +1,223 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTestsMain.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/PlatformUtils.hpp>
// ---------------------------------------------------------------------------
// Externs for our testing methods. There is just one per file so a header
// for each one is a little overkill, so we just do it the old fashioned way.
// ---------------------------------------------------------------------------
extern bool testTranscoders();
extern bool testCountedPointer();
extern bool testBitSet();
extern bool testRefArray();
extern bool testRefHashTable();
extern bool testRefStack();
extern bool testRefVector();
extern bool testString();
extern bool testURL();
extern bool testValueArray();
extern bool testValueStack();
extern bool testValueVector();
int main()
{
// Do the platform initialization
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L"Parser Init Failed!\n INFO: ("
<< toCatch.getSrcFile() << L"." << toCatch.getSrcLine()
<< L") -" << toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return 0xFFFF;
}
XERCES_STD_QUALIFIER wcout << L"\nXML4C2 Core Utilities Unit Tester\n" << XERCES_STD_QUALIFIER endl;
// This value will return the number of failed tests
int retVal = 0;
try
{
// -------------------------------------------------------------------
// Test the basic transcoding services
// -------------------------------------------------------------------
if (!testTranscoders())
{
XERCES_STD_QUALIFIER wcout << L"Transcoder tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the String class
// -------------------------------------------------------------------
if (!testString())
{
XERCES_STD_QUALIFIER wcout << L"String tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the CountedPointerTo template class
// -------------------------------------------------------------------
if (!testCountedPointer())
{
XERCES_STD_QUALIFIER wcout << L"CountedPointerTo tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the URL class
// -------------------------------------------------------------------
if (!testURL())
{
XERCES_STD_QUALIFIER wcout << L"URL tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the ValueVectorOf template class
// -------------------------------------------------------------------
if (!testValueVector())
{
XERCES_STD_QUALIFIER wcout << L"ValueVectorOf tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the ValueArrayOf template class
// -------------------------------------------------------------------
if (!testValueArray())
{
XERCES_STD_QUALIFIER wcout << L"ValueArrayOf tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the ValueStackOf template class
// -------------------------------------------------------------------
if (!testValueStack())
{
XERCES_STD_QUALIFIER wcout << L"ValueStackOf tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the RefArrayOf template class
// -------------------------------------------------------------------
if (!testRefArray())
{
XERCES_STD_QUALIFIER wcout << L"RefArrayOf tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the RefStackOf template class
// -------------------------------------------------------------------
if (!testRefStack())
{
XERCES_STD_QUALIFIER wcout << L"RefStackOf tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the RefVectorOf template class
// -------------------------------------------------------------------
if (!testRefVector())
{
XERCES_STD_QUALIFIER wcout << L"RefVectorOf tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the RefHashtableOf template class
// -------------------------------------------------------------------
if (!testRefHashTable())
{
XERCES_STD_QUALIFIER wcout << L"RefHashTableOf tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
// -------------------------------------------------------------------
// Test the BitSet class
// -------------------------------------------------------------------
if (!testBitSet())
{
XERCES_STD_QUALIFIER wcout << L"BitSet tests failed" << XERCES_STD_QUALIFIER endl;
retVal++;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L"Exception During Test!\n INFO: ("
<< toCatch.getSrcFile() << L"."
<< toCatch.getSrcLine() << L") -"
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return 0xFFFF;
}
// If we failed any tests, display a message
XERCES_STD_QUALIFIER wcout << L"--------------------------------\n";
if (retVal == 0)
XERCES_STD_QUALIFIER wcout << L"<<PASSED>>: All tests passed\n";
else
XERCES_STD_QUALIFIER wcout << L"<<FAILED>>: Some tests failed\n";
XERCES_STD_QUALIFIER wcout << L"--------------------------------\n" << XERCES_STD_QUALIFIER endl;
return retVal;
}
+252
View File
@@ -0,0 +1,252 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_BitSet.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 Includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/BitSet.hpp>
// ---------------------------------------------------------------------------
// Local testing methods
// ---------------------------------------------------------------------------
static bool basicTests()
{
//
// Create a bitset with 32 bits. We just happen to know that this is
// the unit of expansion, so it should come back with exactly that
// number of bits of size.
//
BitSet setTest(32);
if (setTest.size() != 32)
{
XERCES_STD_QUALIFIER wcout << L" Ctor did not create set of correct size"
<< XERCES_STD_QUALIFIER endl;
return false;
}
//
// Check the value of all of the bits and make sure that they all come
// back zero.
//
const unsigned int count = setTest.size();
unsigned int index;
for (index = 0; index < count; index++)
{
if (setTest.get(index))
{
XERCES_STD_QUALIFIER wcout << L" A bit's initial value was not zero"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Make sure that allAreCleared() agrees
if (!setTest.allAreCleared())
{
XERCES_STD_QUALIFIER wcout << L" allAreCleared() disagrees with individual bit gets"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Set and clear each bit and make sure that they come back right
for (index = 0; index < count; index++)
{
setTest.set(index);
if (!setTest.get(index))
{
XERCES_STD_QUALIFIER wcout << L" Bit was set but get returned false"
<< XERCES_STD_QUALIFIER endl;
return false;
}
setTest.clear(index);
if (setTest.get(index))
{
XERCES_STD_QUALIFIER wcout << L" Bit was cleared but get returned true"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// And once more make sure they are all zero
for (index = 0; index < count; index++)
{
if (setTest.get(index))
{
XERCES_STD_QUALIFIER wcout << L" A bit remained set after clearing"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
//
// Set some bits, then copy construct another bitset from this one. Then
// see if they come out equal.
//
setTest.set(1);
setTest.set(16);
setTest.set(20);
setTest.set(24);
BitSet setTest2(setTest);
if (!setTest.equals(setTest2))
{
XERCES_STD_QUALIFIER wcout << L" Copy ctor did not create equal sets"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Clear all bits of the copy and make sure they are all cleared
setTest2.clearAll();
for (index = 0; index < count; index++)
{
if (setTest2.get(index))
{
XERCES_STD_QUALIFIER wcout << L" clearAll() did not clear all bits"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Set a bit beyond the current size
setTest2.set(32);
// Make sure it expanded
if (setTest2.size() != 64)
{
XERCES_STD_QUALIFIER wcout << L" Set of bit beyond size did not expand"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Set all the bits
for (index = 0; index < count; index++)
setTest.set(index);
// Make sure that allAreSet() sees them all set
if (!setTest.allAreSet())
{
XERCES_STD_QUALIFIER wcout << L" After setting all bits, allAreSet() returned false"
<< XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
static bool bitopsTests()
{
// Create a bit set to test
BitSet setTest(48);
// Set some bits
setTest.set(1);
setTest.set(10);
setTest.set(16);
setTest.set(21);
setTest.set(33);
setTest.set(41);
// Create another set to do ops on
BitSet setTest2(48);
// Or with the new set
setTest2.orWith(setTest);
// They should be equal now
if (!setTest.equals(setTest2))
{
XERCES_STD_QUALIFIER wcout << L" OR of set with empty set did not create equal sets"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Xor with original which should get back an empty set
setTest2.xorWith(setTest);
if (!setTest2.allAreCleared())
{
XERCES_STD_QUALIFIER wcout << L" XOR against original set did not get back original"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// And them, which should have no effect
setTest2.andWith(setTest);
if (!setTest2.allAreCleared())
{
XERCES_STD_QUALIFIER wcout << L" AND against empty set changed bits" << XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testBitSet()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing BitSet class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
XERCES_STD_QUALIFIER wcout << L"Testing basic BitSet methods" << XERCES_STD_QUALIFIER endl;
if (!basicTests())
{
XERCES_STD_QUALIFIER wcout << L"Bitset basic test methods failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"Bitset basic tests passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER wcout << L"Testing BitSet logical bit ops methods" << XERCES_STD_QUALIFIER endl;
if (!bitopsTests())
{
XERCES_STD_QUALIFIER wcout << L"Bitset logical bit ops failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"Bitset logical bit ops passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+95
View File
@@ -0,0 +1,95 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_CountedPointer.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 Includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/CountedPointer.hpp>
// ---------------------------------------------------------------------------
// A local class used for testing
// ---------------------------------------------------------------------------
class TestClass
{
public :
static unsigned int gCounter;
TestClass()
{
gCounter++;
}
~TestClass()
{
gCounter--;
}
void addRef()
{
refCount++;
}
void removeRef()
{
refCount--;
if (refCount == 0)
delete this;
}
private :
unsigned int refCount;
};
unsigned int TestClass::gCounter = 0;
// ---------------------------------------------------------------------------
// Force a full instantiation to test syntax
// ---------------------------------------------------------------------------
template class CountedPointerTo<TestClass>;
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testCountedPointer()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing CountedPointerTo class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+220
View File
@@ -0,0 +1,220 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_RefArray.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/RefArrayOf.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
// ---------------------------------------------------------------------------
// Force a full instantiation of our array and its enumerator, just to
// insure that all methods get instantiated and compiled.
// ---------------------------------------------------------------------------
template RefArrayOf<int>;
template RefArrayEnumerator<int>;
// ---------------------------------------------------------------------------
// Local functions
// ---------------------------------------------------------------------------
static bool constructorTests()
{
// Some values to test with
double testVals[16];
unsigned int index;
for (index = 0; index < 16; index++)
testVals[index] = index;
// Do a basic constructor with just the count of elements
RefArrayOf<double> testArray1(255);
// Make sure that it has the right initial size
if (testArray1.length() != 255)
{
XERCES_STD_QUALIFIER wcout << L" The ctor created wrong length() value"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Copy construct another array from it and test the length
RefArrayOf<double> testArray2(testArray1);
if (testArray2.length() != 255)
{
XERCES_STD_QUALIFIER wcout << L" The copy ctor created wrong length() value"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Test the equality of the two arrays
if (testArray1 != testArray2)
{
XERCES_STD_QUALIFIER wcout << L" The copy ctor created unequal arrays"
<< XERCES_STD_QUALIFIER endl;
return false;
}
//
// Do another one where we provide the initial values.
//
double* initValues[16];
for (index = 0; index < 16; index++)
initValues[index ] = &testVals[index];
RefArrayOf<double> testArray3(initValues, 16);
if (testArray3.length() != 16)
{
XERCES_STD_QUALIFIER wcout << L" The init values ctor created wrong length() value"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Make sure the initial values are correct
for (index = 0; index < 16; index++)
{
if (*testArray3[index] != (double)index)
{
XERCES_STD_QUALIFIER wcout << L" The init values ctor did not init contents correctly"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
//
// Create another array of a different size and assign one of the
// existing ones to it and make sure that they are equal.
//
RefArrayOf<double> testArray4(15);
testArray4 = testArray3;
if (testArray4 != testArray3)
{
XERCES_STD_QUALIFIER wcout << L" Assignment did not create equal arrays"
<< XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
static bool accessTests()
{
// Some values to test with
unsigned int testVals[16];
unsigned int index;
for (index = 0; index < 16; index++)
testVals[index] = index;
RefArrayOf<unsigned int> testArray1(16);
// Fill in the array
for (index = 0; index < 16; index++)
testArray1[index] = &testVals[index];
// Read them back again
for (index = 0; index < 16; index++)
{
if (testArray1[index] != &testVals[index])
{
XERCES_STD_QUALIFIER wcout << L" Failed to read back values just set"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Make sure we get the expected array index error
bool caughtIt = false;
try
{
testArray1[16];
}
catch(const ArrayIndexOutOfBoundsException&)
{
caughtIt = true;
}
if (!caughtIt)
{
XERCES_STD_QUALIFIER wcout << L" Failed to catch index error" << XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testRefArray()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing RefArrayOf template class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
// Call other local methods to do specific tests
XERCES_STD_QUALIFIER wcout << L"Testing RefArrayOf contructors" << XERCES_STD_QUALIFIER endl;
if (!constructorTests())
{
XERCES_STD_QUALIFIER wcout << L"RefArrayOf constructor tests failed"
<< XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"RefArrayOf constructor tests passed"
<< XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER wcout << L"Testing RefArrayOf element access" << XERCES_STD_QUALIFIER endl;
if (!accessTests())
{
XERCES_STD_QUALIFIER wcout << L"RefArrayOf element access tests failed"
<< XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"RefArrayOf element access tests passed"
<< XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+115
View File
@@ -0,0 +1,115 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_RefHashTable.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/RefHashTableOf.hpp>
// ---------------------------------------------------------------------------
// A simple class to test the ref hash table with
// ---------------------------------------------------------------------------
class TestElem
{
public :
TestElem( const XMLCh* const key
, const unsigned int value1
, const double value2) :
fKey(XMLString::replicate(key))
, fValue1(value1)
, fValue2(value2)
{
}
~TestElem()
{
XMLString::release(&fKey);
}
const XMLCh* getKey() const
{
return fKey;
}
private :
XMLCh* fKey;
unsigned int fValue1;
double fValue2;
};
// ---------------------------------------------------------------------------
// Force a full instantiation of our hashtable, and its enumerator, just to
// insure that all methods get instantiated and compiled.
// ---------------------------------------------------------------------------
template RefHashTableOf<TestElem>;
template RefHashTableOfEnumerator<TestElem>;
// ---------------------------------------------------------------------------
// Local testing methods
// ---------------------------------------------------------------------------
static bool basicTests()
{
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testRefHashTable()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing RefHashTableOf class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
XERCES_STD_QUALIFIER wcout << L"Testing basic RefHashtable methods" << XERCES_STD_QUALIFIER endl;
if (!basicTests())
{
XERCES_STD_QUALIFIER wcout << L"RefHashtable basic test methods failed"
<< XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"RefHashtable basic tests passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+85
View File
@@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_RefStack.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/RefStackOf.hpp>
// ---------------------------------------------------------------------------
// Force a full instantiation of our stack and its enumerator, just to
// insure that all methods get instantiated and compiled.
// ---------------------------------------------------------------------------
template RefStackOf<int>;
template RefStackEnumerator<int>;
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
static bool basicTests()
{
RefStackOf<double> testStack(500);
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testRefStack()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing RefStackOf template class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
// Call other local methods to do specific tests
XERCES_STD_QUALIFIER wcout << L"Testing RefStackOf basics" << XERCES_STD_QUALIFIER endl;
if (!basicTests())
{
XERCES_STD_QUALIFIER wcout << L"RefStackOf basic tests failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"RefArrayOf constructor tests passed"
<< XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+363
View File
@@ -0,0 +1,363 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_RefVector.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 Includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
// ---------------------------------------------------------------------------
// Force a full instantiation of the vector and its enumerator just to insure
// that all methods get instantiated and compiled.
// ---------------------------------------------------------------------------
template RefVectorOf<int>;
template RefVectorEnumerator<int>;
// ---------------------------------------------------------------------------
// Templatized testing code. These allow the exact same tests to be run
// for any number of instantiation types over the by value vectors.
// ---------------------------------------------------------------------------
template <class T> bool commonRefTests()
{
const unsigned int testMax = 3;
bool caughtIt;
//
// Create a vector of testMax of the instantiation type. Tell it that
// we adopt elements.
//
RefVectorOf<T> testVec(testMax, true);
// Make sure the initial capacity is what we set
if (testVec.curCapacity() != testMax)
{
XERCES_STD_QUALIFIER wcout << L" Init capacity was incorrect" << XERCES_STD_QUALIFIER endl;
return false;
}
// Make sure the initial size is zero
if (testVec.size() != 0)
{
XERCES_STD_QUALIFIER wcout << L" Init size was not correct" << XERCES_STD_QUALIFIER endl;
return false;
}
// Add a value and check the count is 1
testVec.addElement(new T);
if (testVec.size() != 1)
{
XERCES_STD_QUALIFIER wcout << L" Adding one element caused bad size" << XERCES_STD_QUALIFIER endl;
return false;
}
// Add another value and check the count is 2
testVec.addElement(new T);
if (testVec.size() != 2)
{
XERCES_STD_QUALIFIER wcout << L" Adding another element caused bad size"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Add two more, which should cause an expansion of the vector
testVec.addElement(new T);
testVec.addElement(new T);
if (testVec.curCapacity() == testMax)
{
XERCES_STD_QUALIFIER wcout << L" Adding another element failed to cause an expansion"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Check that we get an array bounds exception after an expansion
caughtIt = false;
try
{
testVec.elementAt(4);
}
catch(const ArrayIndexOutOfBoundsException&)
{
caughtIt = true;
}
if (!caughtIt)
{
XERCES_STD_QUALIFIER wcout << L" Failed to catch array bounds error at element 4"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Remove an item and see if the count went down by one
testVec.removeElementAt(0);
if (testVec.size() != 3)
{
XERCES_STD_QUALIFIER wcout << L" Removing an element did not adjust size correctly"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Remove the rest of them and make sure we hit zero
testVec.removeElementAt(0);
testVec.removeElementAt(0);
testVec.removeElementAt(0);
if (testVec.size() != 0)
{
XERCES_STD_QUALIFIER wcout << L" Removing all elements did not zero the size"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Check that we get an array bounds exception now still
caughtIt = false;
try
{
testVec.elementAt(0);
}
catch(const ArrayIndexOutOfBoundsException&)
{
caughtIt = true;
}
if (!caughtIt)
{
XERCES_STD_QUALIFIER wcout << L" Failed to catch array bounds error at element 0"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Add a few more elements back in, via insertion
testVec.insertElementAt(new T, 0);
testVec.insertElementAt(new T, 0);
testVec.insertElementAt(new T, 0);
if (testVec.size() != 3)
{
XERCES_STD_QUALIFIER wcout << L" Inserting elements caused bad size" << XERCES_STD_QUALIFIER endl;
return false;
}
// Now do a remove all elements
testVec.removeAllElements();
if (testVec.size() != 0)
{
XERCES_STD_QUALIFIER wcout << L" removeAllElements caused bad size" << XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
template <class T> bool extendedRefTests()
{
const unsigned int testMax = 8;
// Create a test vector and put in ascending test values
RefVectorOf<T> testVec(testMax, true);
testVec.addElement(new T(0));
testVec.addElement(new T(1));
testVec.addElement(new T(2));
testVec.addElement(new T(3));
testVec.addElement(new T(4));
testVec.addElement(new T(5));
testVec.addElement(new T(6));
testVec.addElement(new T(7));
// Now check that they went in that way
unsigned int index;
for (index = 0; index < testMax; index++)
{
if (*testVec.elementAt(index) != T(index))
{
XERCES_STD_QUALIFIER wcout << L" addElement put elements in wrong order"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Remove the zero'th element and test again
testVec.removeElementAt(0);
for (index = 0; index < testMax-1; index++)
{
if (*testVec.elementAt(index) != T(index+1))
{
XERCES_STD_QUALIFIER wcout << L" removeElement at head removed wrong element"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Test edge case by removing last element and test again
testVec.removeElementAt(6);
for (index = 0; index < testMax-2; index++)
{
if (*testVec.elementAt(index) != T(index+1))
{
XERCES_STD_QUALIFIER wcout << L" removeElement at end removed wrong element"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
return true;
}
// ---------------------------------------------------------------------------
// Local functions
// ---------------------------------------------------------------------------
static bool doBasicTests()
{
bool retVal = true;
//
// Do the common reference vector tests for ints, bools and strings.
//
XERCES_STD_QUALIFIER wcout << L"Testing RefVectorOf<int>, common tests" << XERCES_STD_QUALIFIER endl;
if (!commonRefTests<int>())
{
XERCES_STD_QUALIFIER wcout << L"RefVectorOf<int> failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"RefVectorOf<int> passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER wcout << L"Testing RefVectorOf<bool>, common tests" << XERCES_STD_QUALIFIER endl;
if (!commonRefTests<bool>())
{
XERCES_STD_QUALIFIER wcout << L"RefVectorOf<bool> failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"RefVectorOf<bool> passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
//
// And now do the second round of extended tests. These require that
// the instantiation type be of a fundamental value, because its going
// to test element ordering issues.
//
XERCES_STD_QUALIFIER wcout << L"Testing RefVectorOf<int>, extended tests" << XERCES_STD_QUALIFIER endl;
if (!extendedRefTests<int>())
{
XERCES_STD_QUALIFIER wcout << L"Extended RefVectorOf<int> failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"Extended RefVectorOf<int> passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
return retVal;
}
static bool enumTests()
{
// Create a vector and fill it in with some known values
RefVectorOf<unsigned int> testVec(32, true);
unsigned int index;
for (index = 0; index < 32; index++)
testVec.addElement(new unsigned int(index));
// Create an enumeration for it
RefVectorEnumerator<unsigned int> enumTest(&testVec);
index = 0;
while (enumTest.hasMoreElements())
{
if (enumTest.nextElement() != index++)
{
XERCES_STD_QUALIFIER wcout << L" Enumerator sequence was incorrect" << XERCES_STD_QUALIFIER endl;
return false;
}
}
if (index != 32)
{
XERCES_STD_QUALIFIER wcout << L" Enumerator did not enum enough elements"
<< XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testRefVector()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing RefVectorOf template class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
// Do the basic suite of tests
if (!doBasicTests())
retVal = false;
// Test the enumerator
XERCES_STD_QUALIFIER wcout << L"Testing RefVectorEnumerator" << XERCES_STD_QUALIFIER endl;
if (!enumTests())
{
XERCES_STD_QUALIFIER wcout << L"RefVectorEnumeration failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"RefVectorEnumeration passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+60
View File
@@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_String.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
#include <xercesc/util/ValueArrayOf.hpp>
#include <string.h>
// ---------------------------------------------------------------------------
// Local test functions
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testString()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing String class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+52
View File
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_Transcoders.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/XMLASCIITranscoder.hpp>
#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/TransService.hpp>
// ---------------------------------------------------------------------------
// Local test methods
// ---------------------------------------------------------------------------
// The transcoding system was changed, and there is no time at the moment
// to update the tests, so they were temporarily removed.
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testTranscoders()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing transcoder classes\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
return true;
}
+376
View File
@@ -0,0 +1,376 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_URL.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 includes
// ---------------------------------------------------------------------------
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/XMLURL.hpp>
#include "CoreTests.hpp"
// ---------------------------------------------------------------------------
// Local testing functions
// ---------------------------------------------------------------------------
//
// This test just sets up a list of variations on URLs and parses them. The
// URL list includes the expected text for each of the parts that should be
// parsed out of the URL.
//
struct BasicTestEntry
{
const XMLCh* orgURL;
const XMLCh* fullText;
XMLURL::Protocols protocol;
unsigned int portNum;
const XMLCh* fragment;
const XMLCh* host;
const XMLCh* path;
const XMLCh* password;
const XMLCh* query;
const XMLCh* user;
};
static bool checkAField(const XMLCh* const test
, const XMLCh* const expected
, const XMLCh* const fieldName)
{
if (!test && !expected)
return true;
if (!test && expected)
{
XERCES_STD_QUALIFIER wcout << L"Expected value for the " << fieldName
<< " field was not present" << XERCES_STD_QUALIFIER endl;
return false;
}
else if (test && !expected)
{
XERCES_STD_QUALIFIER wcout << L"The value '" << test << L"' for the " << fieldName
<< L" was not expected" << XERCES_STD_QUALIFIER endl;
return false;
}
else if (XMLString::compareString(test, expected))
{
XERCES_STD_QUALIFIER wcout << L"Expected: " << expected << L", but got: " << test
<< XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
static bool checkBasicResult(const XMLURL& testURL
, const BasicTestEntry& testInfo)
{
//
// Check each part to insure that its what its supposed to be. Since
// any of them can be a null pointer, we have a little helper function
// that spits out the actual testing code for each one.
//
if (!checkAField(testURL.getURLText(), testInfo.fullText, L"Full Text"))
return false;
if (!checkAField(testURL.getFragment(), testInfo.fragment, L"Fragment"))
return false;
if (!checkAField(testURL.getHost(), testInfo.host, L"Host"))
return false;
if (testURL.getPortNum() != testInfo.portNum)
{
XERCES_STD_QUALIFIER wcout << L"Expected port number: " << testInfo.portNum
<< L" but got: " << testURL.getPortNum() << XERCES_STD_QUALIFIER endl;
return false;
}
if (!checkAField(testURL.getPath(), testInfo.path, L"Path"))
return false;
if (!checkAField(testURL.getPassword(), testInfo.password, L"Password"))
return false;
if (!checkAField(testURL.getQuery(), testInfo.query, L"Query"))
return false;
if (!checkAField(testURL.getUser(), testInfo.user, L"User"))
return false;
return true;
}
static bool basicURLTest()
{
static BasicTestEntry testList[] =
{
{
L"file://user:password@host/path1/path2/file.txt?query#fragment"
, L"file://user:password@host/path1/path2/file.txt?query#fragment"
, XMLURL::File
, 0
, L"fragment"
, L"host"
, L"/path1/path2/file.txt"
, L"password"
, L"query"
, L"user"
}
, {
L"file:///path2/file.txt?query#fragment"
, L"file:///path2/file.txt?query#fragment"
, XMLURL::File
, 0
, L"fragment"
, 0
, L"/path2/file.txt"
, 0
, L"query"
, 0
}
, {
L"#fragment"
, L"#fragment"
, XMLURL::Unknown
, 0
, L"fragment"
, 0
, 0
, 0
, 0
, 0
}
, {
L"file://user@host/path1/path2/file.txt#fragment"
, L"file://user@host/path1/path2/file.txt#fragment"
, XMLURL::File
, 0
, L"fragment"
, L"host"
, L"/path1/path2/file.txt"
, 0
, 0
, L"user"
}
, {
L" file://user@host/path1/path2/file.txt#fragment"
, L"file://user@host/path1/path2/file.txt#fragment"
, XMLURL::File
, 0
, L"fragment"
, L"host"
, L"/path1/path2/file.txt"
, 0
, 0
, L"user"
}
, {
L"http://host:90/path1/path2/file.txt"
, L"http://host:90/path1/path2/file.txt"
, XMLURL::HTTP
, 90
, 0
, L"host"
, L"/path1/path2/file.txt"
, 0
, 0
, 0
}
, {
L"http://host/path1/path2/file.txt"
, L"http://host/path1/path2/file.txt"
, XMLURL::HTTP
, 80
, 0
, L"host"
, L"/path1/path2/file.txt"
, 0
, 0
, 0
}
, {
L"ftp://"
, L"ftp://"
, XMLURL::FTP
, 21
, 0
, 0
, 0
, 0
, 0
, 0
}
, {
L"ftp://user@"
, L"ftp://user@"
, XMLURL::FTP
, 21
, 0
, 0
, 0
, 0
, 0
, L"user"
}
};
const unsigned int testCount = sizeof(testList) / sizeof(testList[0]);
bool retVal = true;
//
// Do a run where we construct the URL over and over for each
// test.
//
unsigned int index;
for (index = 0; index < testCount; index++)
{
// Force full destruction each time
{
XMLURL testURL(testList[index].orgURL);
// Call the comparison function
if (!checkBasicResult(testURL, testList[index]))
retVal = false;
}
}
//
// Do a run where we use a single URL object and just reset it over
// and over again.
//
XMLURL testURL;
for (index = 0; index < testCount; index++)
{
testURL.setURL(testList[index].orgURL);
// Call the comparison function
if (!checkBasicResult(testURL, testList[index]))
retVal = false;
}
return retVal;
}
//
// This test makes sure that parsing one URL relative to another works
// correctly. The tests used here come from one of the internet RFCs on
// generic URI syntax. A single base URL is created, then a number of
// relative URLs are parsed against it and the results compared to the
// expected result.
//
static bool relativeURLTest()
{
static struct TestEntry
{
const XMLCh* relative;
const XMLCh* result;
} testList[] =
{
{ L"g" , L"http://a/b/c/g" }
, { L"./g" , L"http://a/b/c/g" }
, { L"g/" , L"http://a/b/c/g/" }
, { L"/g" , L"http://a/g" }
, { L"?y" , L"http://a/b/c/?y" }
, { L"g?y" , L"http://a/b/c/g?y" }
, { L"#s" , L"http://a/b/c/d;p#s" }
, { L"g#s" , L"http://a/b/c/g#s" }
, { L"g?y#s" , L"http://a/b/c/g?y#s" }
, { L";x" , L"http://a/b/c/;x" }
, { L"g;x" , L"http://a/b/c/g;x" }
, { L"g;x?y#s", L"http://a/b/c/g;x?y#s" }
, { L"." , L"http://a/b/c/" }
, { L"./" , L"http://a/b/c/" }
, { L".." , L"http://a/b/" }
, { L"../" , L"http://a/b/" }
, { L"../g" , L"http://a/b/g" }
, { L"../.." , L"http://a/" }
, { L"../../" , L"http://a/" }
, { L"../../g", L"http://a/g" }
};
const unsigned int testCount = sizeof(testList) / sizeof(testList[0]);
// This is the base URL against which the tests are run
XMLURL baseURL(L"http://a/b/c/d;p?q");
bool retVal = true;
for (unsigned int index = 0; index < testCount; index++)
{
XMLURL testURL(baseURL, testList[index].relative);
if (XMLString::compareString(testURL.getURLText(), testList[index].result))
{
XERCES_STD_QUALIFIER wcout << L"Expected URL: " << testList[index].result
<< L" but got: " << testURL.getURLText() << XERCES_STD_QUALIFIER endl;
retVal = false;
}
}
return retVal;
};
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testURL()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing URL class \n"
<< L"----------------------------------"
<< XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
// Call other local methods to do specific tests
XERCES_STD_QUALIFIER wcout << L"Testing basic URL parsing" << XERCES_STD_QUALIFIER endl;
if (!basicURLTest())
{
XERCES_STD_QUALIFIER wcout << L"Basic URL parsing tests failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"Basic URL parsing tests passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER wcout << L"Testing relative URL parsing" << XERCES_STD_QUALIFIER endl;
if (!relativeURLTest())
{
XERCES_STD_QUALIFIER wcout << L"Relative URL parsing tests failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"Relative URL parsing tests passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+206
View File
@@ -0,0 +1,206 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_ValueArray.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/ValueArrayOf.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
// ---------------------------------------------------------------------------
// Force a full instantiation of our array and its enumerator, just to
// insure that all methods get instantiated and compiled.
// ---------------------------------------------------------------------------
template ValueArrayOf<int>;
template ValueArrayEnumerator<int>;
// ---------------------------------------------------------------------------
// Local functions
// ---------------------------------------------------------------------------
static bool constructorTests()
{
// Do a basic constructor with just the count of elements
ValueArrayOf<double> testArray1(255);
// Make sure that it has the right initial size
if (testArray1.length() != 255)
{
XERCES_STD_QUALIFIER wcout << L" The ctor created wrong length() value"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Copy construct another array from it and test the length
ValueArrayOf<double> testArray2(testArray1);
if (testArray2.length() != 255)
{
XERCES_STD_QUALIFIER wcout << L" The copy ctor created wrong length() value"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Test the equality of the two arrays
if (testArray1 != testArray2)
{
XERCES_STD_QUALIFIER wcout << L" The copy ctor created unequal arrays"
<< XERCES_STD_QUALIFIER endl;
return false;
}
//
// Do another one where we provide the initial values.
//
double initValues[] = { 1.1, 2.2, 3.3, 4.4 };
ValueArrayOf<double> testArray3(initValues, 4);
if (testArray3.length() != 4)
{
XERCES_STD_QUALIFIER wcout << L" The init values ctor created wrong length() value"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Make sure the initial values are correct
if ((testArray3[0] != 1.1)
|| (testArray3[1] != 2.2)
|| (testArray3[2] != 3.3)
|| (testArray3[3] != 4.4))
{
XERCES_STD_QUALIFIER wcout << L" The init values ctor did not init contents correctly"
<< XERCES_STD_QUALIFIER endl;
return false;
}
//
// Create another array of a different size and assign one of the
// existing ones to it and make sure that they are equal.
//
ValueArrayOf<double> testArray4(15);
testArray4 = testArray3;
if (testArray4 != testArray3)
{
XERCES_STD_QUALIFIER wcout << L" Assignment did not create equal arrays"
<< XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
static bool accessTests()
{
ValueArrayOf<unsigned int> testArray1(16);
// Fill in the array
unsigned int index;
for (index = 0; index < 16; index++)
testArray1[index] = index;
// Read them back again
for (index = 0; index < 16; index++)
{
if (testArray1[index] != index)
{
XERCES_STD_QUALIFIER wcout << L" Failed to read back values just set"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Make sure we get the expected array index error
bool caughtIt = false;
try
{
index = testArray1[16];
}
catch(const ArrayIndexOutOfBoundsException&)
{
caughtIt = true;
}
if (!caughtIt)
{
XERCES_STD_QUALIFIER wcout << L" Failed to catch index error" << XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testValueArray()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing ValueArrayOf template class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
// Call other local methods to do specific tests
XERCES_STD_QUALIFIER wcout << L"Testing ValueArrayOf contructors" << XERCES_STD_QUALIFIER endl;
if (!constructorTests())
{
XERCES_STD_QUALIFIER wcout << L"ValueArrayOf constructor tests failed"
<< XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"ValueArrayOf constructor tests passed"
<< XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER wcout << L"Testing ValueArrayOf element access" << XERCES_STD_QUALIFIER endl;
if (!accessTests())
{
XERCES_STD_QUALIFIER wcout << L"ValueArrayOf element access tests failed"
<< XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"ValueArrayOf element access tests passed"
<< XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+84
View File
@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_ValueStack.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/ValueStackOf.hpp>
// ---------------------------------------------------------------------------
// Force a full instantiation of our stack and its enumerator, just to
// insure that all methods get instantiated and compiled.
// ---------------------------------------------------------------------------
template ValueStackOf<int>;
template ValueStackEnumerator<int>;
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
static bool basicTests()
{
ValueStackOf<double> testStack(500);
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testValueStack()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing ValueStackOf template class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
// Call other local methods to do specific tests
XERCES_STD_QUALIFIER wcout << L"Testing ValueStackOf basics" << XERCES_STD_QUALIFIER endl;
if (!basicTests())
{
XERCES_STD_QUALIFIER wcout << L"ValueStackOf basic tests failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"ValueArrayOf constructor tests passed"
<< XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+367
View File
@@ -0,0 +1,367 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: CoreTests_ValueVector.cpp 470088 2006-11-01 20:35:12Z amassari $
*/
// ---------------------------------------------------------------------------
// XML4C2 includes
// ---------------------------------------------------------------------------
#include "CoreTests.hpp"
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
// ---------------------------------------------------------------------------
// Force a full instantiation of our vector and its enumerator, just to
// insure that all methods get instantiated and compiled.
// ---------------------------------------------------------------------------
template ValueVectorOf<int>;
template ValueVectorEnumerator<int>;
// ---------------------------------------------------------------------------
// Templatized testing code. These allow the exact same tests to be run
// for any number of instantiation types over the by value vectors.
// ---------------------------------------------------------------------------
template <class T> bool commonValueTests()
{
const unsigned int testMax = 3;
bool caughtIt;
// Create a vector of testMax of the instantiation type
ValueVectorOf<T> testVec(testMax);
// Make sure the initial capacity is what we set
if (testVec.curCapacity() != testMax)
{
XERCES_STD_QUALIFIER wcout << L" Init capacity was bad" << XERCES_STD_QUALIFIER endl;
return false;
}
// Make sure the initial size is zero
if (testVec.size() != 0)
{
XERCES_STD_QUALIFIER wcout << L" Init size was bad" << XERCES_STD_QUALIFIER endl;
return false;
}
// Test value for adding
T testElem;
// Add a value and check the count is 1
testVec.addElement(testElem);
if (testVec.size() != 1)
{
XERCES_STD_QUALIFIER wcout << L" Adding one element caused bad size" << XERCES_STD_QUALIFIER endl;
return false;
}
// Add another value and check the count is 2
testVec.addElement(testElem);
if (testVec.size() != 2)
{
XERCES_STD_QUALIFIER wcout << L" Adding another element caused bad size" << XERCES_STD_QUALIFIER endl;
return false;
}
// Test that the two of them are the same
if (testVec.elementAt(0) != testVec.elementAt(1))
{
XERCES_STD_QUALIFIER wcout << L" First two elements did not match" << XERCES_STD_QUALIFIER endl;
return false;
}
// Add two more, which should cause an expansion of the vector
testVec.addElement(testElem);
testVec.addElement(testElem);
if (testVec.curCapacity() == testMax)
{
XERCES_STD_QUALIFIER wcout << L" Adding another element failed to cause an expansion"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Check that we get an array bounds exception after an expansion
caughtIt = false;
try
{
testVec.elementAt(4);
}
catch(const ArrayIndexOutOfBoundsException&)
{
caughtIt = true;
}
if (!caughtIt)
{
XERCES_STD_QUALIFIER wcout << L" Failed to catch array bounds error at element 4"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Remove an item and see if the count went down by one
testVec.removeElementAt(0);
if (testVec.size() != 3)
{
XERCES_STD_QUALIFIER wcout << L" Removing an element did not adjust size correctly"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Remove the rest of them and make sure we hit zero
testVec.removeElementAt(0);
testVec.removeElementAt(0);
testVec.removeElementAt(0);
if (testVec.size() != 0)
{
XERCES_STD_QUALIFIER wcout << L" Removing all elements did not zero the size"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Check that we get an array bounds exception now still
caughtIt = false;
try
{
testVec.elementAt(0);
}
catch(const ArrayIndexOutOfBoundsException&)
{
caughtIt = true;
}
if (!caughtIt)
{
XERCES_STD_QUALIFIER wcout << L" Failed to catch array bounds error at element 0"
<< XERCES_STD_QUALIFIER endl;
return false;
}
// Add a few more elements back in, via insertion
testVec.insertElementAt(testElem, 0);
testVec.insertElementAt(testElem, 0);
testVec.insertElementAt(testElem, 0);
if (testVec.size() != 3)
{
XERCES_STD_QUALIFIER wcout << L" Inserting elements caused bad size" << XERCES_STD_QUALIFIER endl;
return false;
}
// Now do a remove all elements
testVec.removeAllElements();
if (testVec.size() != 0)
{
XERCES_STD_QUALIFIER wcout << L" removeAllElements caused bad size" << XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
template <class T> bool extendedValueTests()
{
const unsigned int testMax = 8;
// Create a test vector and put in ascending test values
ValueVectorOf<T> testVec(testMax);
testVec.addElement(T(0));
testVec.addElement(T(1));
testVec.addElement(T(2));
testVec.addElement(T(3));
testVec.addElement(T(4));
testVec.addElement(T(5));
testVec.addElement(T(6));
testVec.addElement(T(7));
// Now check that they went in that way
unsigned int index;
for (index = 0; index < testMax; index++)
{
if (testVec.elementAt(index) != T(index))
{
XERCES_STD_QUALIFIER wcout << L" addElement put elements in wrong order"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Remove the zero'th element and test again
testVec.removeElementAt(0);
for (index = 0; index < testMax-1; index++)
{
if (testVec.elementAt(index) != T(index+1))
{
XERCES_STD_QUALIFIER wcout << L" removeElement at head removed wrong element"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
// Test edge case by removing last element and test again
testVec.removeElementAt(6);
for (index = 0; index < testMax-2; index++)
{
if (testVec.elementAt(index) != T(index+1))
{
XERCES_STD_QUALIFIER wcout << L" removeElement at end removed wrong element"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
return true;
}
// ---------------------------------------------------------------------------
// Local functions
// ---------------------------------------------------------------------------
static bool doBasicTests()
{
bool retVal = true;
//
// Do the common value vector tests for ints, bools and strings.
//
XERCES_STD_QUALIFIER wcout << L"Testing ValueVectorOf<int>, common tests" << XERCES_STD_QUALIFIER endl;
if (!commonValueTests<int>())
{
XERCES_STD_QUALIFIER wcout << L"ValueVectorOf<int> failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"ValueVectorOf<int> passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER wcout << L"Testing ValueVectorOf<bool>, common tests" << XERCES_STD_QUALIFIER endl;
if (!commonValueTests<bool>())
{
XERCES_STD_QUALIFIER wcout << L"ValueVectorOf<bool> failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"ValueVectorOf<bool> passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
//
// And now do the second round of extended tests. These require that
// the instantiation type be of a fundamental value, because its going
// to test element ordering issues.
//
XERCES_STD_QUALIFIER wcout << L"Testing ValueVectorOf<int>, extended tests" << XERCES_STD_QUALIFIER endl;
if (!extendedValueTests<int>())
{
XERCES_STD_QUALIFIER wcout << L"Extended ValueVectorOf<int> failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"Extended ValueVectorOf<int> passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
return retVal;
}
static bool enumTests()
{
// Create a vector and fill it in with some known values
ValueVectorOf<unsigned int> testVec(32);
unsigned int index;
for (index = 0; index < 32; index++)
testVec.addElement(index);
// Create an enumeration for it
ValueVectorEnumerator<unsigned int> enumTest(&testVec);
index = 0;
while (enumTest.hasMoreElements())
{
if (enumTest.nextElement() != index++)
{
XERCES_STD_QUALIFIER wcout << L" Enumerator sequence was incorrect"
<< XERCES_STD_QUALIFIER endl;
return false;
}
}
if (index != 32)
{
XERCES_STD_QUALIFIER wcout << L" Enumerator did not enum enough elements"
<< XERCES_STD_QUALIFIER endl;
return false;
}
return true;
}
// ---------------------------------------------------------------------------
// Test entry point
// ---------------------------------------------------------------------------
bool testValueVector()
{
XERCES_STD_QUALIFIER wcout << L"----------------------------------\n"
<< L"Testing ValueVectorOf template class\n"
<< L"----------------------------------" << XERCES_STD_QUALIFIER endl;
bool retVal = true;
try
{
// Do the basic suite of tests, which is templatized
if (!doBasicTests())
retVal = false;
// Test the enumerator
XERCES_STD_QUALIFIER wcout << L"Testing ValueVectorEnumerator" << XERCES_STD_QUALIFIER endl;
if (!enumTests())
{
XERCES_STD_QUALIFIER wcout << L"ValueVectorEnumeration failed" << XERCES_STD_QUALIFIER endl;
retVal = false;
}
else
{
XERCES_STD_QUALIFIER wcout << L"ValueVectorEnumeration passed" << XERCES_STD_QUALIFIER endl;
}
XERCES_STD_QUALIFIER wcout << XERCES_STD_QUALIFIER endl;
}
catch(const XMLException& toCatch)
{
XERCES_STD_QUALIFIER wcout << L" ERROR: Unexpected exception!\n Msg: "
<< toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
return false;
}
return retVal;
}
+195
View File
@@ -0,0 +1,195 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: XSTSHarness.cpp 677563 2008-07-17 11:51:39Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "XSTSHarness.hpp"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/XMLReaderFactory.hpp>
#if defined(XERCES_NEW_IOSTREAMS)
#include <fstream>
#else
#include <fstream.h>
#endif
#include <xercesc/util/OutOfMemoryException.hpp>
// ---------------------------------------------------------------------------
// Local helper methods
// ---------------------------------------------------------------------------
void usage()
{
XERCES_STD_QUALIFIER cout << "\nUsage:\n"
" XSTSHarness <XSTS testSet>\n\n"
"This program runs the tests listed in the XMLSchema Test Suite:\n"
"download the suite from http://www.w3.org/XML/2004/xml-schema-test-suite\n"
"and uncompress it. Then run this executable against each .testSet\n"
"file found in the suite.\n\n"
<< XERCES_STD_QUALIFIER endl;
}
// ---------------------------------------------------------------------------
// Program entry point
// ---------------------------------------------------------------------------
int main(int argC, char* argV[])
{
// Check command line and extract arguments.
if (argC < 2)
{
usage();
return 1;
}
int argInd;
for (argInd = 1; argInd < argC; argInd++)
{
// Break out on first parm not starting with a dash
if (argV[argInd][0] != '-')
break;
// Watch for special case help request
if (!strcmp(argV[argInd], "-?"))
{
usage();
return 2;
}
// TODO: add option to generate the XML summarizing the result
else if (!strncmp(argV[argInd], "-v=", 3)
|| !strncmp(argV[argInd], "-V=", 3))
{
}
else
{
XERCES_STD_QUALIFIER cout << "Unknown option '" << argV[argInd]
<< "', ignoring it\n" << XERCES_STD_QUALIFIER endl;
}
}
//
// There should be only one and only one parameter left, and that
// should be the file name.
//
if (argInd != argC - 1)
{
usage();
return 1;
}
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
XERCES_STD_QUALIFIER cout << "Error during initialization! Message:\n"
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
return 1;
}
//
// Create a SAX parser object. Then, according to what we were told on
// the command line, set it to validate or not.
//
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
const char* xmlFile = argV[argInd];
//
// Create our SAX handler object and install it on the parser, as the
// document and error handler.
//
XMLCh* uniFile = XMLString::transcode(xmlFile);
XMLCh* uri = new XMLCh[XMLString::stringLen(xmlFile) + 9];
XMLString::fixURI(uniFile, uri);
XSTSHarnessHandlers* handler=new XSTSHarnessHandlers(uri);
XMLString::release(&uniFile);
delete [] uri;
parser->setContentHandler(handler);
parser->setErrorHandler(handler);
//
// Get the starting time and kick off the parse of the indicated
// file. Catch any exceptions that might propogate out of it.
//
bool errorOccurred=false;
const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
try
{
parser->parse(xmlFile);
}
catch (const OutOfMemoryException&)
{
XERCES_STD_QUALIFIER cout << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl;
errorOccurred = true;
}
catch (const XMLException& e)
{
XERCES_STD_QUALIFIER cout << "\nError during parsing: '" << xmlFile << "'\n"
<< "Exception message is: \n"
<< StrX(e.getMessage()) << "\n" << XERCES_STD_QUALIFIER endl;
errorOccurred = true;
}
catch (...)
{
XERCES_STD_QUALIFIER cout << "\nUnexpected exception during parsing: '" << xmlFile << "'\n";
errorOccurred = true;
}
const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
unsigned long duration = endMillis - startMillis;
if (handler->getSawErrors())
errorOccurred = true;
XERCES_STD_QUALIFIER cout << "Total tests: " << handler->getTotalTests() << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER cout << "Failed tests: " << handler->getFailedTests() << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER cout << "Success rate: " << ((double)(handler->getTotalTests()-handler->getFailedTests()))/(double)handler->getTotalTests()*100 << "%" << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER cout << "Duration: ";
if(duration > 60000)
{
XERCES_STD_QUALIFIER cout << duration/60000 << ":";
duration=duration % 60000;
}
if(duration/1000 < 10)
XERCES_STD_QUALIFIER cout << "0";
XERCES_STD_QUALIFIER cout << duration/1000 << "." << duration % 1000 << XERCES_STD_QUALIFIER endl;
//
// Delete the parser itself. Must be done prior to calling Terminate, below.
//
delete parser;
delete handler;
// And call the termination method
XMLPlatformUtils::Terminate();
if (errorOccurred)
return 4;
else
return 0;
}
+83
View File
@@ -0,0 +1,83 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: XSTSHarness.hpp 671315 2008-06-24 19:39:53Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes for all the program files to see
// ---------------------------------------------------------------------------
#include <xercesc/util/PlatformUtils.hpp>
#include <stdlib.h>
#include <string.h>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
#include "XSTSHarnessHandlers.hpp"
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/SAX2XMLReader.hpp>
// ---------------------------------------------------------------------------
// This is a simple class that lets us do easy (though not terribly efficient)
// trancoding of XMLCh data to local code page for display.
// ---------------------------------------------------------------------------
class StrX
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
StrX(const XMLCh* const toTranscode)
{
// Call the private transcoding method
fLocalForm = XMLString::transcode(toTranscode);
}
~StrX()
{
XMLString::release(&fLocalForm);
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const char* localForm() const
{
return fLocalForm;
}
private :
// -----------------------------------------------------------------------
// Private data members
//
// fLocalForm
// This is the local code page form of the string.
// -----------------------------------------------------------------------
char* fLocalForm;
};
inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
{
target << toDump.localForm();
return target;
}
+424
View File
@@ -0,0 +1,424 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: XSTSHarnessHandlers.cpp 677563 2008-07-17 11:51:39Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "XSTSHarness.hpp"
#include <xercesc/sax2/Attributes.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/sax/SAXException.hpp>
#include <xercesc/validators/common/Grammar.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/util/BinInputStream.hpp>
// ---------------------------------------------------------------------------
// XSTSHarnessHandlers: Constructors and Destructor
// ---------------------------------------------------------------------------
XSTSHarnessHandlers::XSTSHarnessHandlers(const XMLCh* baseURL) :
fSawErrors(false),
fBaseURL(baseURL),
fFailures(0),
fTests(0)
{
fParser = XMLReaderFactory::createXMLReader();
fParser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
fParser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, true);
fParser->setFeature(XMLUni::fgSAX2CoreValidation, true);
fParser->setFeature(XMLUni::fgXercesSchema, true);
fParser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
fParser->setFeature(XMLUni::fgXercesDynamic, false);
fParser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);
fParser->setFeature(XMLUni::fgXercesIdentityConstraintChecking, true);
fParser->setErrorHandler(&fErrorHandler);
}
XSTSHarnessHandlers::~XSTSHarnessHandlers()
{
delete fParser;
}
static XMLCh urlW3C[]={ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash,
chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash,
chLatin_X, chLatin_M, chLatin_L, chForwardSlash,
chLatin_S, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chNull };
static XMLCh szTestSuite[]={ chLatin_T, chLatin_e, chLatin_s, chLatin_t, chLatin_S, chLatin_u, chLatin_i, chLatin_t, chLatin_e, chNull };
static XMLCh szTestGroup[]={ chLatin_t, chLatin_e, chLatin_s, chLatin_t, chLatin_G, chLatin_r, chLatin_o, chLatin_u, chLatin_p, chNull };
static XMLCh szSchemaTest[]={ chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chLatin_T, chLatin_e, chLatin_s, chLatin_t, chNull };
static XMLCh szInstanceTest[]={ chLatin_i, chLatin_n, chLatin_s, chLatin_t, chLatin_a, chLatin_n, chLatin_c, chLatin_e, chLatin_T, chLatin_e, chLatin_s, chLatin_t, chNull };
static XMLCh szDocumentationReference[]={ chLatin_d, chLatin_o, chLatin_c, chLatin_u, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n,
chLatin_R, chLatin_e, chLatin_f, chLatin_e, chLatin_r, chLatin_e, chLatin_n, chLatin_c, chLatin_e, chNull };
static XMLCh szSchemaDocument[]={ chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chLatin_D, chLatin_o, chLatin_c, chLatin_u, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chNull };
static XMLCh szInstanceDocument[]={ chLatin_i, chLatin_n, chLatin_s, chLatin_t, chLatin_a, chLatin_n, chLatin_c, chLatin_e, chLatin_D, chLatin_o, chLatin_c, chLatin_u, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chNull };
static XMLCh szExpected[]={ chLatin_e, chLatin_x, chLatin_p, chLatin_e, chLatin_c, chLatin_t, chLatin_e, chLatin_d, chNull };
static XMLCh szValidity[]={ chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d, chLatin_i, chLatin_t, chLatin_y, chNull };
static XMLCh szXLINK[]={ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash,
chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash,
chDigit_1, chDigit_9, chDigit_9, chDigit_9, chForwardSlash,
chLatin_x, chLatin_l, chLatin_i, chLatin_n, chLatin_k, chNull };
static XMLCh szHREF[]={ chLatin_h, chLatin_r, chLatin_e, chLatin_f, chNull };
static XMLCh szNAME[]={ chLatin_n, chLatin_a, chLatin_m, chLatin_e, chNull };
static XMLCh szVALID[]={ chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d, chNull };
static XMLCh szINVALID[]={ chLatin_i, chLatin_n, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d, chNull };
static XMLCh szTestSuite2[]={ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash,
chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash,
chLatin_X, chLatin_M, chLatin_L, chForwardSlash,
chDigit_2, chDigit_0, chDigit_0, chDigit_4, chForwardSlash,
chLatin_x, chLatin_m, chLatin_l, chDash, chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chDash,
chLatin_t, chLatin_e, chLatin_s, chLatin_t, chDash, chLatin_s, chLatin_u, chLatin_i, chLatin_t, chLatin_e, chForwardSlash, chNull };
static XMLCh szTestSetRef[]={ chLatin_t, chLatin_e, chLatin_s, chLatin_t, chLatin_S, chLatin_e, chLatin_t, chLatin_R, chLatin_e, chLatin_f, chNull };
static XMLCh dummy[]={ chLatin_f, chLatin_i, chLatin_l, chLatin_e, chColon, chForwardSlash, chForwardSlash,
chLatin_d, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chForwardSlash, chNull };
// ---------------------------------------------------------------------------
// XSTSHarnessHandlers: Implementation of the SAX DocumentHandler interface
// ---------------------------------------------------------------------------
void XSTSHarnessHandlers::startElement(const XMLCh* const uri
, const XMLCh* const localname
, const XMLCh* const /* qname */
, const Attributes& attrs)
{
if(XMLString::equals(uri, szTestSuite) || XMLString::equals(uri, szTestSuite2))
{
if(XMLString::equals(localname, szTestSetRef))
{
XMLURL testSet, backupBase(fBaseURL);
testSet.setURL(fBaseURL, attrs.getValue(szXLINK, szHREF));
fBaseURL=testSet;
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
try
{
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
parser->setContentHandler(this);
parser->setErrorHandler(this);
parser->parse(testSet.getURLText());
}
catch (...)
{
}
delete parser;
fBaseURL=backupBase;
}
else if(XMLString::equals(localname, szTestGroup))
{
fCurrentTest.fExpectedResult=unknown;
fCurrentTest.fSpecReference.setURL(urlW3C);
fCurrentTest.fTestName[0]=0;
fCurrentTest.fXMLName.setURL(dummy);
fCurrentTest.fXSDNames.removeAllElements();
StrX x(attrs.getValue(szNAME));
const char* groupName=x.localForm();
if(XMLString::equals(groupName,"isDefault072") || // this fails because of an access violation
XMLString::equals(groupName,"addB194") ||
XMLString::equals(groupName,"particlesZ033_c") ||
XMLString::equals(groupName,"particlesZ033_d") ||
XMLString::equals(groupName,"particlesZ033_e") ||
XMLString::equals(groupName,"particlesZ033_f") ||
XMLString::equals(groupName,"particlesZ033_g") ||
XMLString::equals(groupName,"particlesZ035_a") ||
XMLString::equals(groupName,"particlesZ036_b1") ||
XMLString::equals(groupName,"particlesZ036_b2") ||
XMLString::equals(groupName,"particlesZ036_c") ||
XMLString::equals(groupName,"wildG032") )
fCurrentTest.fSkipped=true;
else
fCurrentTest.fSkipped=false;
fParser->resetCachedGrammarPool();
}
else if(XMLString::equals(localname, szDocumentationReference))
{
const XMLCh* ref=attrs.getValue(szXLINK, szHREF);
if(ref && *ref)
fCurrentTest.fSpecReference.setURL(ref);
else
fCurrentTest.fSpecReference.setURL(dummy);
}
else if(XMLString::equals(localname, szSchemaTest) ||
XMLString::equals(localname, szInstanceTest))
{
XMLString::copyString(fCurrentTest.fTestName, attrs.getValue(szNAME));
}
else if(XMLString::equals(localname, szSchemaDocument))
{
fCurrentTest.fXSDNames.addElement(new XMLURL(fBaseURL, attrs.getValue(szXLINK, szHREF)));
}
else if(XMLString::equals(localname, szInstanceDocument))
{
fCurrentTest.fXMLName.setURL(fBaseURL, attrs.getValue(szXLINK, szHREF));
}
else if(XMLString::equals(localname, szExpected))
{
const XMLCh* validity=attrs.getValue(szValidity);
if(XMLString::equals(validity, szVALID))
fCurrentTest.fExpectedResult=valid;
else if(XMLString::equals(validity, szINVALID))
fCurrentTest.fExpectedResult=invalid;
else
fCurrentTest.fExpectedResult=unknown;
}
}
}
void XSTSHarnessHandlers::endElement(const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const /*qname*/)
{
if(XMLString::equals(uri, szTestSuite) || XMLString::equals(uri, szTestSuite2))
{
if(XMLString::equals(localname, szSchemaTest))
{
if(fCurrentTest.fSkipped)
{
fTests++;
fFailures++;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " skipped" << XERCES_STD_QUALIFIER endl;
return;
}
bool success=true, fatalFailure=false;
try
{
fErrorHandler.resetErrors();
for(unsigned int i=0;i<fCurrentTest.fXSDNames.size();i++)
{
Grammar* grammar=fParser->loadGrammar(fCurrentTest.fXSDNames.elementAt(i)->getURLText(), Grammar::SchemaGrammarType, true);
success=(success && (grammar!=NULL));
}
}
catch (const OutOfMemoryException&)
{
fatalFailure=true;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " ran out of memory" << XERCES_STD_QUALIFIER endl;
success=false;
}
catch(const XMLException& exc)
{
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " threw " << StrX(exc.getMessage()) << XERCES_STD_QUALIFIER endl;
success=false;
}
catch (...)
{
fatalFailure=true;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " crashed" << XERCES_STD_QUALIFIER endl;
success=false;
exit(1);
}
fTests++;
if(fatalFailure)
{
// skip the rest of the group, as we had problems with the schema itself
fCurrentTest.fSkipped=true;
fFailures++;
for(unsigned int i=0;i<fCurrentTest.fXSDNames.size();i++)
printFile(*fCurrentTest.fXSDNames.elementAt(i));
}
else
{
if(success && !fErrorHandler.getSawErrors())
{
if(fCurrentTest.fExpectedResult!=valid)
{
// skip the rest of the group, as we had problems with the schema itself
fCurrentTest.fSkipped=true;
fFailures++;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " succeeded but was expected to fail" << XERCES_STD_QUALIFIER endl;
for(unsigned int i=0;i<fCurrentTest.fXSDNames.size();i++)
printFile(*fCurrentTest.fXSDNames.elementAt(i));
}
}
else
{
if(fCurrentTest.fExpectedResult!=invalid)
{
// skip the rest of the group, as we had problems with the schema itself
fCurrentTest.fSkipped=true;
fFailures++;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " failed but was expected to pass" << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER cout << "Reported error: " << StrX(fErrorHandler.getErrorText()) << XERCES_STD_QUALIFIER endl;
for(unsigned int i=0;i<fCurrentTest.fXSDNames.size();i++)
printFile(*fCurrentTest.fXSDNames.elementAt(i));
}
}
}
}
else if(XMLString::equals(localname, szInstanceTest))
{
if(fCurrentTest.fSkipped)
{
fTests++;
fFailures++;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " skipped" << XERCES_STD_QUALIFIER endl;
return;
}
bool success=true, fatalFailure=false;
try
{
fErrorHandler.resetErrors();
fParser->parse(fCurrentTest.fXMLName.getURLText());
}
catch (const OutOfMemoryException&)
{
fatalFailure=true;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " ran out of memory" << XERCES_STD_QUALIFIER endl;
success=false;
}
catch(const XMLException& exc)
{
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " threw " << StrX(exc.getMessage()) << XERCES_STD_QUALIFIER endl;
success=false;
}
catch (...)
{
fatalFailure=true;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " crashed" << XERCES_STD_QUALIFIER endl;
success=false;
exit(1);
}
fTests++;
if(fatalFailure)
{
fFailures++;
for(unsigned int i=0;i<fCurrentTest.fXSDNames.size();i++)
printFile(*fCurrentTest.fXSDNames.elementAt(i));
printFile(fCurrentTest.fXMLName);
}
else
{
if(success && !fErrorHandler.getSawErrors())
{
if(fCurrentTest.fExpectedResult!=valid)
{
fFailures++;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " succeeded but was expected to fail" << XERCES_STD_QUALIFIER endl;
for(unsigned int i=0;i<fCurrentTest.fXSDNames.size();i++)
printFile(*fCurrentTest.fXSDNames.elementAt(i));
printFile(fCurrentTest.fXMLName);
}
}
else
{
if(fCurrentTest.fExpectedResult!=invalid)
{
fFailures++;
XERCES_STD_QUALIFIER cout << "Test " << StrX(fCurrentTest.fTestName) << " failed but was expected to pass" << XERCES_STD_QUALIFIER endl;
XERCES_STD_QUALIFIER cout << "Reported error: " << StrX(fErrorHandler.getErrorText()) << XERCES_STD_QUALIFIER endl;
for(unsigned int i=0;i<fCurrentTest.fXSDNames.size();i++)
printFile(*fCurrentTest.fXSDNames.elementAt(i));
printFile(fCurrentTest.fXMLName);
}
}
}
}
}
}
// ---------------------------------------------------------------------------
// XSTSHarnessHandlers: Overrides of the SAX ErrorHandler interface
// ---------------------------------------------------------------------------
void XSTSHarnessHandlers::error(const SAXParseException& e)
{
fSawErrors = true;
XERCES_STD_QUALIFIER cout << "\nError at file " << StrX(e.getSystemId())
<< ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
}
void XSTSHarnessHandlers::fatalError(const SAXParseException& e)
{
fSawErrors = true;
XERCES_STD_QUALIFIER cout << "\nFatal Error at file " << StrX(e.getSystemId())
<< ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
}
void XSTSHarnessHandlers::warning(const SAXParseException& e)
{
XERCES_STD_QUALIFIER cout << "\nWarning at file " << StrX(e.getSystemId())
<< ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
}
void XSTSHarnessHandlers::resetErrors()
{
fSawErrors = false;
}
// ---------------------------------------------------------------------------
// XSTSHarnessHandlers: Helpers
// ---------------------------------------------------------------------------
void XSTSHarnessHandlers::printFile(XMLURL& url)
{
if(XMLString::equals(url.getURLText(), dummy))
return;
BinInputStream* stream=url.makeNewStream();
if(stream==NULL)
{
XERCES_STD_QUALIFIER cout << "File " << StrX(url.getURLText()) << " is missing" << XERCES_STD_QUALIFIER endl;
return;
}
XERCES_STD_QUALIFIER cout << "Content of file " << StrX(url.getURLText()) << XERCES_STD_QUALIFIER endl;
XMLByte buffer[256];
XMLSize_t nRead;
while((nRead=stream->readBytes(buffer, 255)) >0)
{
buffer[nRead]=0;
// sending data containing \n\r to cout generates \n\n\r, so strip any \r
XMLSize_t idx=0;
while(true)
{
int cr=XMLString::indexOf((const char*)buffer, '\r', idx);
if(cr==-1)
break;
memmove(&buffer[cr], &buffer[cr+1], XMLString::stringLen((const char*)&buffer[cr+1])+1);
idx=cr;
if(buffer[idx]==0)
break;
}
XERCES_STD_QUALIFIER cout << (const char*)buffer;
}
XERCES_STD_QUALIFIER cout << XERCES_STD_QUALIFIER endl;
delete stream;
}
void XSTSErrorHandler::error(const SAXParseException& exc)
{
fSawErrors=true;
fErrorText.append(exc.getMessage());
fErrorText.append(chLF);
}
void XSTSErrorHandler::fatalError(const SAXParseException& exc)
{
fSawErrors=true;
fErrorText.append(exc.getMessage());
fErrorText.append(chLF);
}
+149
View File
@@ -0,0 +1,149 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: XSTSHarnessHandlers.hpp 677563 2008-07-17 11:51:39Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/Attributes.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/util/XMLURL.hpp>
#include <xercesc/util/RefVectorOf.hpp>
XERCES_CPP_NAMESPACE_USE
class XSTSErrorHandler : public ErrorHandler
{
public:
XSTSErrorHandler() : fSawErrors(false) {}
bool getSawErrors() const
{
return fSawErrors;
}
const XMLCh* getErrorText()
{
return fErrorText.getRawBuffer();
}
// -----------------------------------------------------------------------
// Handlers for the SAX ErrorHandler interface
// -----------------------------------------------------------------------
void warning(const SAXParseException& exc) {}
void error(const SAXParseException& exc);
void fatalError(const SAXParseException& exc);
void resetErrors() { fSawErrors=false; fErrorText.reset(); }
private:
// -----------------------------------------------------------------------
// Private data members
//
// fSawErrors
// This is set by the error handlers, and is queryable later to
// see if any errors occured.
// -----------------------------------------------------------------------
bool fSawErrors;
XMLBuffer fErrorText;
};
typedef enum
{
unknown,
invalid,
valid
} ValidityOutcome;
class XSTSTest
{
public:
XSTSTest() :
fXSDNames(1)
{
fTestName[0]=0;
fExpectedResult=unknown;
fSkipped=false;
}
XMLCh fTestName[256];
RefVectorOf<XMLURL> fXSDNames;
XMLURL fXMLName;
ValidityOutcome fExpectedResult;
XMLURL fSpecReference;
bool fSkipped;
};
class XSTSHarnessHandlers : public DefaultHandler
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XSTSHarnessHandlers(const XMLCh* baseURL);
~XSTSHarnessHandlers();
unsigned int getTotalTests() const
{
return fTests;
}
unsigned int getFailedTests() const
{
return fFailures;
}
bool getSawErrors() const
{
return fSawErrors;
}
// -----------------------------------------------------------------------
// Handlers for the SAX ContentHandler interface
// -----------------------------------------------------------------------
void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs);
void endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname);
// -----------------------------------------------------------------------
// Handlers for the SAX ErrorHandler interface
// -----------------------------------------------------------------------
void warning(const SAXParseException& exc);
void error(const SAXParseException& exc);
void fatalError(const SAXParseException& exc);
void resetErrors();
protected:
void printFile(XMLURL& url);
private:
// -----------------------------------------------------------------------
// Private data members
//
// fSawErrors
// This is set by the error handlers, and is queryable later to
// see if any errors occured.
// -----------------------------------------------------------------------
bool fSawErrors;
XSTSTest fCurrentTest;
XMLURL fBaseURL;
unsigned int fFailures, fTests;
SAX2XMLReader* fParser;
XSTSErrorHandler fErrorHandler;
};
+594
View File
@@ -0,0 +1,594 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
NOTE (JT): This schema differs from the official version adopted by the WG in that
1) these attribute declarations in the xs:schema element:
xmlns:ts="http://www.w3.org/2003/XMLSchema/TestSuite/PLACEHOLDER"
targetNamespace="http://www.w3.org/2003/XMLSchema/TestSuite/PLACEHOLDER"
are replaced by lines to enable the use of a local copy of this schema.
2) The import declarations for XLink and XML namespace are given schemaLocation attributes.
-->
<xs:schema
xmlns:ts="TestSuite"
targetNamespace="TestSuite"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<!--
<xs:import namespace="http://www.w3.org/1999/xlink"/>
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
-->
<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="file:///C:/3rd-party/XlnGui/Catalogs/Large/www.xbrl.org/2003/xlink-2003-12-31.xsd"/>
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="file:///C:/3rd-party/XlnGui/Catalogs/Small/www.w3.org/2001/03/xml.xsd"/>
<xs:annotation>
<xs:documentation>
This is the schema for the W3C XML Schema Test Suite collection
(TS), as approved by the W3C XML Schema Working Group on May 12,
2003. It defines the namespace:
http://www.w3.org/2003/XMLSchema/TestSuite/PLACEHOLDER
The TS consists of a set of test suites, each of which is identified
according to the version of W3C XML Schema it is designed to
test. Previous versions of test suites are archived and are also
available, identifiable by the version of the test suite itself.
This schema defines three separate but related document types for
the TS:
1) The testSuite element is the root element of a document
which defines a test suite as described above (e.g. the
2003-10-25 version of the test suite for version 1 of the
Recommendation).
The principal purpose of a testSuite document is the provision
of a set of links to documents defining the tests which
constitute the test suite.
Files containing testSuite documents have the filename suffix
".suite".
2) The testSet element is the root element of a document which
describes a set of tests. Each testSuite consists primarily
of a set of links to testSet documents. The scope of the
testSet is typically determined by the contributor of the
tests which make up the testSet: it is the unit in which
tests are contributed to the collection.
Files containing testSet documents have the filename suffix
".testSet".
3) The testSuiteResults element is the root element of a
document describing the results of testing a processor
against a testSuite.
Files containing testSuiteResults documents have the filename
suffix ".results".
</xs:documentation>
</xs:annotation>
<xs:element name="testSuite">
<xs:annotation>
<xs:documentation>
The root element of a document describing all tests for a
particular version of W3C XML Schema, for the version of the TS
defined by the document.
The element has three attributes, each of which is required:
name - the name of this test suite.
releaseDate - the date on which this test suite was
released. This value serves to identify the
version of the test suite.
schemaVersion - the version of W3C XML Schema for which the
tests are designed.
Two elements may optionally be present:
annotation - at most one instance of general documentation.
testSetRef - a set of references to the sets of tests which
make up this test suite.
The test sets referenced are uniquely named.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ts:annotation" minOccurs="0"/>
<xs:element ref="ts:testSetRef" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:Name"/>
<xs:attribute name="releaseDate" use="required" type="xs:date"/>
<xs:attribute name="schemaVersion" use="required" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:element name="testSetRef" type="ts:ref"/>
<xs:element name="testSet">
<xs:annotation>
<xs:documentation>
The root element of a document describing a set of tests,
normally from a single contributor. A contributor may supply
any number of testSet files.
The element has two attributes, each of which is required:
contributor - the name of the contributor of this testSet.
name - the name of this testSet, which must be unique within
the enclosing testSuite.
Two elements may optionally be present:
annotation - at most one instance of general documentation.
testGroup - a set of testGroup elements, each of which defines a
group of closely related tests.
The testGroup elements must be uniquely named.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ts:annotation" minOccurs="0"/>
<xs:element ref="ts:testGroup" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="contributor" use="required" type="xs:string"/>
<xs:attribute name="name" use="required" type="xs:Name"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<xs:unique name="uniqueGroupName">
<xs:annotation>
<xs:documentation>
Each test group within a test set must have a unique name.
</xs:documentation>
</xs:annotation>
<xs:selector xpath="ts:testGroup"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="testGroup">
<xs:annotation>
<xs:documentation>
This element groups a collection of closely related tests. In the
case where a schema is present, this element groups the schema with a
set of instance documents which should be validated against the
schema.
It has one attribute, which is required:
name - an identifier for the testGroup which is unique within
the enclosing testSet.
Four elements may optionally be present:
annotation - at most one instance of general documentation.
documentationReference - any number of references to external
documentation upon which the test
is based, e.g. links to relevant
sections of the Recommendation,
to the Errata, etc.
schemaTest - any number of elements, each of which holds
information on a single schema document.
When more than one schema document is present,
a single schema is constructed from the set
(or from other schemas via import).
Schema documents may be omitted, for the purpose
of testing a processor's validation of an instance
containing only the built-in datatypes defined in
the Recommendation.
instanceTest - any number of elements, each of which holds
information on a single instance document to
be validated against the included schema.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ts:annotation" minOccurs="0"/>
<xs:element ref="ts:documentationReference" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ts:schemaTest" minOccurs="0"/>
<xs:element ref="ts:instanceTest" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:Name"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<xs:unique name="uniqueTestName">
<xs:annotation>
<xs:documentation>
Each test within a test group must have a unique name.
</xs:documentation>
</xs:annotation>
<xs:selector xpath="ts:schemaTest|ts:instanceTest"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="schemaTest">
<xs:annotation>
<xs:documentation>
This element groups together information about the schema for
a particular test condition.
It has one attribute, which is required:
name - the name of the schema, which must be unique within
the enclosing testGroup (i.e. it must differ from the
name(s) of any associated instanceTest elements).
One element is required:
schemaDocument - at least one link to a file containing a
schema document. The schema for the test is
constructed from the set (or from other
schemas via import).
Three elements may optionally be present:
expected - the expected validation outcome for the schema
contained in the schema document(s).
current - the current status of this test in the TS (an
indication of the test's accuracy in testing the
feature it is intended to test).
prior - the history of any changes in the status of this test.
The elements "expected" and "current" may be absent when tests
are contributed, but will always be present for tests included in
the TS.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ts:schemaDocument" maxOccurs="unbounded"/>
<xs:element ref="ts:expected" minOccurs="0"/>
<xs:element ref="ts:current" minOccurs="0"/>
<xs:element ref="ts:prior" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:Name"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:element name="instanceTest">
<xs:annotation>
<xs:documentation>
This element groups together information about an instance
document which should be validated against the schema referenced
in the enclosing testGroup.
It has one attribute, which is required:
name - the name of the instance document, which must be unique
within the enclosing testGroup (i.e. it must differ
from the name of any associated schemaTest elements).
One element is required:
instanceDocument - a link to a file containing the instance
document.
Three elements may optionally be present:
expected - the expected validation outcome for the instance
document.
current - the current status of this test in the TS (an
indication of the test's accuracy in testing the
feature it is intended to test).
prior - the history of any changes in the status of this test.
The elements "expected" and "current" may be absent when tests
are contributed, but will always be present for tests included in
the TS.
Note: per section 5.2 "Assessing Schema-Validity" of the
Recommendation "XML Schema Part 1: Structures", validation may
be started in a variety of ways. For the purposes of the TS,
only the third method shall be used:
"The processor starts from Schema-Validity Assessment (Element)
(3.3.4) with no stipulated declaration or definition".
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ts:instanceDocument"/>
<xs:element ref="ts:expected" minOccurs="0"/>
<xs:element ref="ts:current" minOccurs="0"/>
<xs:element ref="ts:prior" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:Name"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:element name="schemaDocument" type="ts:ref"/>
<xs:element name="instanceDocument" type="ts:ref"/>
<xs:element name="current" type="ts:statusEntry">
<xs:annotation>
<xs:documentation>
The current status of a test in the TS.
This element has two attributes, both of which are required:
status - the status of the test. One of "accepted", "stable",
"disputed-test" or "disputed-spec" (see the TS website
for an explanation of these values).
date - the date on which the value in the status attribute
was attained.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="prior" type="ts:statusEntry">
<xs:annotation>
<xs:documentation>
A former status of a test in the TS.
This element has two attributes, both of which are required:
status - the former status of the test. One of "accepted",
"stable", "disputed-test" or "disputed-spec" (see
the TS website for an explanation of these values).
date - the date on which the value in the status attribute
was attained.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="statusEntry">
<xs:attribute name="status" use="required" type="ts:status"/>
<xs:attribute name="date" use="required" type="xs:date"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<xs:simpleType name="status">
<xs:restriction base="xs:token">
<xs:enumeration value="accepted"/>
<xs:enumeration value="stable"/>
<xs:enumeration value="disputed-test"/>
<xs:enumeration value="disputed-spec"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="expected">
<xs:annotation>
<xs:documentation>
The expected validation outcome of a test in the TS.
This element has one attribute, which is required:
validity - the expected validity of the test. One of "valid",
"invalid" or "notKnown".
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="validity" use="required" type="ts:validityOutcome"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:simpleType name="validityOutcome">
<xs:restriction base="xs:token">
<xs:enumeration value="valid"/>
<xs:enumeration value="invalid"/>
<xs:enumeration value="notKnown"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="testSuiteResults">
<xs:annotation>
<xs:documentation>
This is the root element of a document containing a test result
report. The report takes the form of a set of test results
returned by a processor/validator when run against the TS.
It has three required attributes:
suite - the name of the test suite to which these results
correspond. This should be the value of the name
attribute of the testSuite element at the root of
the test suite document describing the tests to which
these results correspond.
processor - some identifying information for the processor/
validator which produced the reported results. The
value of this attribute is left to the discretion
of the reporter.
submitDate - the date on which these results were submitted
to the TS Task Force.
The element also has one optional attribute:
publicationPermission - the degree to which the result reporter
authorizes the W3C to disseminate the
reported results. One of "W3C members"
or "public" (see the TS website for an
explanation of these values). If this
attribute is absent, no permission to
publish is granted.
This element has two optional elements:
annotation - at most one instance of more detailed
(ts:documentation) or structured (ts:appinfo)
information or commentary regarding the enclosed
test results.
testResult - any number of reports of the results of individual
tests. Any results may be omitted, particularly
those for tests of features for which the processor
claims no support.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ts:annotation" minOccurs="0"/>
<xs:element ref="ts:testResult" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="suite" use="required" type="xs:Name"/>
<xs:attribute name="processor" use="required" type="xs:string"/>
<xs:attribute name="submitDate" use="required" type="xs:date"/>
<xs:attribute name="publicationPermission">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="W3C members"/>
<xs:enumeration value="public"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:element name="testResult">
<xs:annotation>
<xs:documentation>
The result of an individual instance test or a schema test.
This element has four required attributes:
validity - the validition outcome of the test. One of "valid",
"invalid" or "notKnown".
set - the value of the "name" attribute of the test set to
which the test belongs.
group - the value of the "name" attribute of the test group
to which the test belongs.
test - the value of the "name" attribute of the schema test
or instance test, the validation outcome of which this
result reports.
NOTE: The "set", "group" and "test" attributes are used to
uniquely identify the test within the TS for which this
result reports the validation outcome. Each matches the
"name" attribute of the respective element in the test suite.
This element has one optional attribute:
normalizedLoad - a relative load value, intended as an indicator
of the resource requirements of an individual
test. Values may be based on processing time,
memory usage or a combination of the two.
Values should be in the vicinity of 1.0.
The element has one optional element:
annotation - at most one instance of more detailed
(ts:documentation) or structured (ts:appinfo)
information or commentary regarding the individual
test result. Reporters are encouraged to use
annotation/appinfo to report more detailed outcome
information, such as error and warning messages.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="ts:annotation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="validity" use="required" type="ts:validityOutcome"/>
<xs:attribute name="set" use="required" type="xs:Name"/>
<xs:attribute name="group" use="required" type="xs:Name"/>
<xs:attribute name="test" use="required" type="xs:Name"/>
<xs:attribute name="normalizedLoad" type="xs:decimal"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:complexType name="ref">
<xs:attribute ref="xlink:type" default="locator"/>
<xs:attribute ref="xlink:href"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<xs:element name="documentationReference" type="ts:ref">
<xs:annotation>
<xs:documentation>
A link to documentation relevant to a test, such as a link to the
Recommendation, an erratum, an archived email discussion, etc.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="annotation">
<xs:annotation>
<xs:documentation>
This is an exact copy of the annotation element defined in the Schema
Recommendation. It is duplicated here in order to replicate the
functionality of the xs:annotation element and because the Schema for
Schemas cannot be imported.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element ref="ts:appinfo"/>
<xs:element ref="ts:documentation"/>
</xs:choice>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:element name="appinfo">
<xs:complexType mixed="true">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:any processContents="lax"/>
</xs:sequence>
<xs:attribute name="source" type="xs:anyURI"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:element name="documentation">
<xs:complexType mixed="true">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:any processContents="lax"/>
</xs:sequence>
<xs:attribute name="source" type="xs:anyURI"/>
<xs:attribute ref="xml:lang"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
</xs:schema>
+10
View File
@@ -0,0 +1,10 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="season">
<xs:complexType>
<xs:sequence minOccurs="3" maxOccurs="100">
<xs:element name="spring" minOccurs="10" maxOccurs="99"/>
<xs:element name="summer" minOccurs="10" maxOccurs="99"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<season xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<spring>cool</spring>
<summer>warm</summer>
</season>
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<season xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<spring>cool</spring>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
<summer>warm</summer>
</season>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="unique.xsd">
<child attr="1">1</child>
<child attr="2">2</child>
<child>4</child>
</root>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="rootType">
<xs:sequence>
<xs:element name="child" maxOccurs="5">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="attr" type="xs:int"/>
<xs:attribute name="attr2" type="xs:int"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="root" type="rootType">
<xs:unique name="uniqueKey">
<xs:selector xpath=".//child"/>
<xs:field xpath="@attr"/>
<xs:field xpath="@attr2"/>
</xs:unique>
</xs:element>
</xs:schema>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="flibble">
<xs:simpleType>
<xs:union memberTypes="TextString Null"/>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="TextString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="31"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Null">
<xs:restriction base="xs:string">
<xs:length value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Test.xsd">
<flibble>curiouser &amp; curiouser&amp;curiouser</flibble>
</root>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<Bucket xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://my.big.org" xsi:schemaLocation="http://my.big.org ./restrictionTest.xsd">
<a2>
<O2>
<s1>first text string</s1>
<s2>next string</s2>
</O2>
</a2>
<!--
<b2>
<O2>
<s1>first text string</s1>
<s2>next string</s2>
</O2>
<O2>
<s1>another string</s1>
<s2>yetanother string</s2>
</O2>
</b2>
-->
</Bucket>
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://my.big.org" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:my="http://my.big.org">
<!-- ============================================================= -->
<!-- ============================================================= -->
<element name="AbstractObject" type="anyType" abstract="true"/>
<!-- ============================================================= -->
<element name="O1" type="my:O1_Type" substitutionGroup="my:AbstractObject"/>
<!-- =========================================================== -->
<complexType name="O1_Type">
<complexContent>
<restriction base="anyType">
<sequence>
<element name="s1" type="string"/>
</sequence>
</restriction>
</complexContent>
</complexType>
<!-- =========================================================== -->
<element name="O2" type="my:O2_Type" substitutionGroup="my:O1"/>
<!-- =========================================================== -->
<complexType name="O2_Type">
<complexContent>
<extension base="my:O1_Type">
<sequence>
<element name="s2" type="string"/>
</sequence>
</extension>
</complexContent>
</complexType>
<!-- =========================================================== -->
<!-- =========================================================== -->
<element name="a1" type="my:A1_Type"/>
<!-- =========================================================== -->
<complexType name="A1_Type">
<sequence maxOccurs="unbounded">
<element ref="my:O1"/>
</sequence>
</complexType>
<!-- =========================================================== -->
<element name="a2" type="my:A2_Type" substitutionGroup="my:a1"/>
<!-- =========================================================== -->
<complexType name="A2_Type">
<complexContent>
<restriction base="my:A1_Type">
<sequence maxOccurs="unbounded">
<element ref="my:O2"/>
</sequence>
</restriction>
</complexContent>
</complexType>
<!-- =========================================================== -->
<!-- =========================================================== -->
<element name="b1" type="my:B1_Type"/>
<!-- =========================================================== -->
<complexType name="B1_Type">
<sequence>
<element ref="my:O1" maxOccurs="unbounded"/>
</sequence>
</complexType>
<!-- =========================================================== -->
<!--
<element name="b2" type="my:B2_Type" substitutionGroup="my:b1"/>
-->
<!-- =========================================================== -->
<!-- This hasn't been fixed yet
<complexType name="B2_Type">
<complexContent>
<restriction base="my:B1_Type">
<sequence>
<choice maxOccurs="unbounded">
<element ref="my:O2"/>
</choice>
</sequence>
</restriction>
</complexContent>
</complexType>
-->
<!-- =========================================================== -->
<element name="Bucket">
<complexType>
<sequence maxOccurs="unbounded">
<choice>
<element ref="my:a1"/>
<element ref="my:b1"/>
</choice>
</sequence>
</complexType>
</element>
<!-- =========================== -->
</schema>
@@ -0,0 +1,4 @@
<Songs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<Song title="Hotel California"/>
<Song title="Hotel California"/>
</Songs>
+20
View File
@@ -0,0 +1,20 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="Songs">
<xs:complexType>
<xs:sequence>
<xs:element name="Song" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="title" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="Song">
<xs:selector xpath="Song"/>
<xs:field xpath="@title"/>
</xs:unique>
</xs:element>
</xs:schema>
+4
View File
@@ -0,0 +1,4 @@
<Songs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<Song title="Hotel California"/>
<Song title="Desperado"/>
</Songs>
@@ -0,0 +1,2 @@
<?xml version="1.0"?>
<Element-0 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="pattern1.xsd">-9</Element-0>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="SimpleType-0">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[-+][0-9]*"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Element-0" type="SimpleType-0"/>
</xsd:schema>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<multipleChoice>0</multipleChoice>
<multipleChoice>1</multipleChoice>
<multipleChoice>1.0000</multipleChoice>
<multipleChoice>.1</multipleChoice>
<multipleChoice>.135</multipleChoice>
<multipleChoice>0.9</multipleChoice>
<multipleChoice>0.</multipleChoice>
</root>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="multipleChoice">
<xsd:simpleType>
<xsd:restriction base="xsd:float">
<xsd:minInclusive value="0.0"/>
<xsd:maxInclusive value="1.0"/>
<xsd:pattern value="[0-9]"/>
<xsd:pattern value="[0-9][.]([0-9]+)?"/>
<xsd:pattern value="([0-9])?[.][0-9]+"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="multipleChoice" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd"
xmlns="test">0 0 0</root>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:t="test"
targetNamespace="test"
elementFormDefault="qualified">
<simpleType name="ListOfInts">
<list itemType="int"/>
</simpleType>
<simpleType name="int3">
<restriction base="t:ListOfInts">
<minLength value="3"/>
<maxLength value="3"/>
</restriction>
</simpleType>
<element name="root" type="t:int3" default="0 0 0"/>
</schema>
+49
View File
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:hl7-org:v3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:complexType name="ANY" abstract="true"></xsd:complexType>
<xsd:complexType name="CD">
<xsd:complexContent>
<xsd:extension base="ANY">
<xsd:sequence>
<xsd:element name="qualifier" type="CR" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="code" use="optional"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="CE">
<xsd:complexContent>
<xsd:restriction base="CD">
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name="code" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="CV">
<xsd:complexContent>
<xsd:restriction base="CE">
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name="code" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="CR">
<xsd:complexContent>
<xsd:extension base="ANY">
<xsd:sequence>
<xsd:element name="name" type="CV" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="inverted" use="optional" default="false"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="root" type="CV"/>
</xsd:schema>
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<p1:Messages xmlns:p1="SplitAndMerge" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="SplitAndMerge MainSchema.xsd">
<p1:Message1>
<msg>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
<DOC>DOC</DOC>
</msg>
</p1:Message1>
</p1:Messages>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="SplitAndMerge" xmlns="SplitAndMerge" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import schemaLocation="Schema1.xsd"/>
<xsd:element name="Messages">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Message1" form="qualified">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="msg" xmlns=""/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="msg">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="DOC" type="xsd:string" maxOccurs="unbounded" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<lib:library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dyomedea.com/ns/library need-import-t.xsd"
xmlns:lib="http://dyomedea.com/ns/library">
<lib:importTest>
<name>String</name>
</lib:importTest>
</lib:library>
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<xs:schema xmlns:lib="http://dyomedea.com/ns/library" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://dyomedea.com/ns/library" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import schemaLocation="very-simple-2-ns-ppl-nons-t.xsd"/>
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="importTest" type="importType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="importType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<st:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quovadx.com/schema_test schema_test.xsd"
xmlns:st="http://www.quovadx.com/schema_test">
<gst0>1</gst0>
<gst1>2</gst1>
<gst2>3</gst2>
<gst3>4</gst3>
<gst4>5</gst4>
<gst5>6</gst5>
<gst6>7</gst6>
<gst7>8</gst7>
<gst8>9</gst8>
</st:root>
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.quovadx.com/schema_test"
xmlns:st="http://www.quovadx.com/schema_test"
finalDefault="list union"
>
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="gst0" type="st:gst_explicit_none"></xs:element>
<xs:element name="gst1" type="st:gst_none"></xs:element>
<xs:element name="gst2" type="st:gst_r"></xs:element>
<xs:element name="gst3" type="st:gst_u"></xs:element>
<xs:element name="gst4" type="st:gst_rl"></xs:element>
<xs:element name="gst5" type="st:gst_ru"></xs:element>
<xs:element name="gst6" type="st:gst_lu"></xs:element>
<xs:element name="gst7" type="st:gst_rlu"></xs:element>
<xs:element name="gst8" type="st:gst_all"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="gst_explicit_none" final=""><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_none"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_r" final="restriction"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_l" final="list"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_u" final="union"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_rl" final="restriction list"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_ru" final="restriction union"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_lu" final="list union"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_rlu" final="restriction list union"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
<xs:simpleType name="gst_all" final="#all"><xs:union memberTypes="xs:int"></xs:union></xs:simpleType>
</xs:schema>
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="A">
<xs:sequence>
<xs:element name="elem" type="B" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="foo"/>
</xs:complexType>
<xs:complexType name="B">
<xs:sequence>
<xs:element name="elem" type="C" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="C">
<xs:complexContent>
<xs:restriction base="D">
<xs:attribute name="foo"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="D">
<xs:complexContent>
<xs:restriction base="A">
<xs:attribute name="foo"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
<simpleType name="list">
<list itemType="string"/>
</simpleType>
<complexType name="type">
<sequence>
<element name="efoo" type="string"/>
</sequence>
<attribute name="abar">
<simpleType name="list">
<list itemType="string"/>
</simpleType>
</attribute>
</complexType>
<element name="root" type="string"/>
</schema>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:a="a"
targetNamespace="a">
<xs:simpleType name="AA">
<xs:restriction base="xs:string">
<xs:enumeration value="B"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:a="a"
xmlns:b="b"
targetNamespace="b">
<xs:import namespace="a" schemaLocation="a.xsd"/>
<!-- If you change a:A to b:A, the error is detected. -->
<xs:simpleType name="B">
<xs:restriction base="a:A">
<xs:enumeration value="B"/>
</xs:restriction>
</xs:simpleType>
<!-- If you change xs:string to b:B you will get the wrong diagnostics.
If you change xs:string to a:A you will get the correct diagnostics.
-->
<xs:element name="root" type="xs:string"/>
</xs:schema>
+11
View File
@@ -0,0 +1,11 @@
<t:root xmlns:t="test"
xmlns:o="foo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<upa><o:a>a</o:a></upa>
<upa><a>a</a></upa>
<derived><a>a</a></derived>
</t:root>
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
<complexType name="upa">
<choice>
<any namespace="##other" processContents="skip"/>
<any namespace="##local" processContents="skip"/>
</choice>
</complexType>
<complexType name="base">
<sequence>
<any namespace="##other" processContents="skip"/>
</sequence>
</complexType>
<complexType name="derived">
<complexContent>
<restriction base="t:base">
<sequence>
<any namespace="##local" processContents="skip"/>
</sequence>
</restriction>
</complexContent>
</complexType>
<complexType name="type">
<sequence>
<element name="upa" type="t:upa" maxOccurs="unbounded"/>
<element name="derived" type="t:derived" maxOccurs="unbounded"/>
</sequence>
</complexType>
<element name="root" type="t:type"/>
</schema>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://gargamel" elementFormDefault="qualified" >
<xsd:complexType name="gargamelType">
<xsd:sequence>
<xsd:element name="Data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Object" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<s:Alert xmlns:s="http://smerf" xmlns:g="http://gargamel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation='http://smerf smerf.xsd' >
<g:Data>
<g:Object>
pawel
</g:Object>
</g:Data>
</s:Alert>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:g="http://gargamel" targetNamespace="http://smerf" elementFormDefault="qualified">
<import namespace="http://gargamel" schemaLocation="gargamel.xsd" />
<element name="Alert" > <!-- type="g:gargamelType"> -->
<complexType>
<complexContent>
<extension base="g:gargamelType" />
</complexContent>
</complexType>
</element>
</schema>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:b="base"
targetNamespace="base">
<xsd:complexType name="foo">
<xsd:sequence>
<xsd:element name="a" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="base">
<xsd:sequence>
<xsd:element name="Value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:b="base"
xmlns:d="derived"
targetNamespace="derived">
<xsd:import namespace="base" schemaLocation="base.xsd"/>
<xsd:complexType name="derived">
<xsd:complexContent>
<xsd:restriction base="b:base">
<xsd:sequence>
<xsd:element name="Value" type="xsd:string"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="bar">
<xsd:sequence>
<xsd:element name="Value" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
+20
View File
@@ -0,0 +1,20 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="Songs">
<xs:complexType>
<xs:sequence>
<xs:element name="Song" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="title" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="Song">
<xs:selector xpath="*:Song"/>
<xs:field xpath="@title"/>
</xs:unique>
</xs:element>
</xs:schema>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<t:Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:t="test"
xsi:schemaLocation="test test.xsd">
<t:Book>Weekly Want Ads</t:Book>
<t:Book>McLeans</t:Book>
<t:Book>Software Developers Monthly</t:Book>
<t:Book>McLeans</t:Book>
<t:Book>Weekly Want Ads</t:Book>
<t:Book>Software Developers Monthly</t:Book>
<t:Book>O</t:Book>
</t:Library>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:t="test"
targetNamespace="test">
<element name="Book" type="string"/>
<element name="Library">
<complexType>
<sequence>
<element ref="t:Book" minOccurs="3" maxOccurs="3"/>
<element ref="t:Book" minOccurs="4" maxOccurs="4"/>
</sequence>
</complexType>
</element>
</schema>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<!-- =========================================================================
Test Type : Schema Valid ( <element> )
Description: A valid instance document used to test a valid schema with
example of <element>s with substitutionGroup=.
========================================================================== -->
<svi:Library xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xmlns:svi ="http://www.schemaTest.org/m3_3v"
xsi:schemaLocation="http://www.schemaTest.org/m3_3v
test2.xsd">
<svi:Periodical>Weekly Want Ads</svi:Periodical>
<svi:Periodical>Weekly Want Ads</svi:Periodical>
<svi:Magazine>McLeans</svi:Magazine>
<svi:Newsletter>Software Developers Monthly</svi:Newsletter>
<svi:Magazine>McLeans</svi:Magazine>
<svi:Periodical>Weekly Want Ads</svi:Periodical>
<svi:Newsletter>Software Developers Monthly</svi:Newsletter>
<svi:Book>O</svi:Book>
<svi:Newsletter>Software Developers Monthly</svi:Newsletter>
</svi:Library>
+48
View File
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<!-- =========================================================================
Test Type : Schema Valid ( <element> )
Description: Tests valid substitutionGroup= for <element>s with valid derived
<simpleType> definitions.
========================================================================== -->
<schema xmlns ="http://www.w3.org/2001/XMLSchema"
xmlns:sv ="http://www.schemaTest.org/m3_3v"
targetNamespace="http://www.schemaTest.org/m3_3v">
<element name="Magazine" type="sv:strMin5" substitutionGroup="sv:Book"/>
<element name="Book" type="string"/>
<element name="Periodical" type="sv:strMin10" substitutionGroup="sv:Magazine"/>
<element name="Newsletter" substitutionGroup="sv:Magazine">
<simpleType>
<restriction base="sv:strMin5">
<minLength value="15"/>
</restriction>
</simpleType>
</element>
<simpleType name="strMin5">
<restriction base="string">
<minLength value="5"/>
</restriction>
</simpleType>
<simpleType name="strMin10">
<restriction base="sv:strMin5">
<minLength value="10"/>
</restriction>
</simpleType>
<element name="Library">
<complexType>
<sequence>
<element ref="sv:Periodical"/>
<element ref="sv:Magazine" minOccurs="3" maxOccurs="3"/>
<element ref="sv:Book" minOccurs="4" maxOccurs="4"/>
<element ref="sv:Newsletter"/>
</sequence>
</complexType>
</element>
</schema>
+9
View File
@@ -0,0 +1,9 @@
<t:root xmlns:t="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<foo>foo</foo>
<t:bar>t:bar</t:bar>
<bar>bar</bar>
</t:root>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
<complexType name="type">
<sequence>
<element name="foo" type="string"/>
<any namespace="##targetNamespace" processContents="skip"/>
<element name="bar" type="string"/>
</sequence>
</complexType>
<element name="root" type="t:type"/>
</schema>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<father xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="m3_10v39.xsd"
last_name="Smith" position="professor" degree="PhD">
<home_address>1252 College Blvd., fargo, ND 58105</home_address>
<car year="1985">Buick</car>
<pet age="2">dog</pet>
<child1 boy_girl="girl" age="12"/>
<child2 boy_girl="boy" age="9"/>
<car year="1">Buick</car>
<pet age="five">lamb</pet>
</father>
<!--
Test Type : Schema VALID ( element wildcard <any> )
Description: This is a valid instance document used to test a valid schema.
-->
+77
View File
@@ -0,0 +1,77 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--
Test Type : Schema VALID ( element wildcard <any> )
Description: Tests <any> with minOccurs=, maxOccurs=, namespace="##local",
processContents="skip" within <group><sequence>.
No targetNamespace defined.
-->
<xs:simpleType name="boy_girl_type">
<xs:restriction base="xs:string">
<xs:enumeration value="boy"/>
<xs:enumeration value="girl"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="childType">
<xs:attribute name="boy_girl" type="boy_girl_type"/>
<xs:attribute name="age" type="xs:nonNegativeInteger"/>
</xs:complexType>
<xs:group name="group2">
<xs:sequence>
<xs:element name="child1" type="childType"/>
<xs:element name="child2" type="childType"/>
<xs:any namespace="##local" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="attrgrp1">
<xs:attribute name="position" type="xs:Name"/>
<xs:attribute name="degree" type="xs:string"/>
</xs:attributeGroup>
<xs:element name="pet">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:NCName">
<xs:attribute name="age" type="xs:positiveInteger"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="year">
<xs:restriction base="xs:positiveInteger">
<xs:minInclusive value="1900"/>
<xs:maxExclusive value="2100"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="car">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:NCName">
<xs:attribute name="year" type="year"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:group name="group1">
<xs:sequence>
<xs:element name="home_address" type="xs:string"/>
<xs:any minOccurs="2" maxOccurs="2" namespace="##targetNamespace"/>
<xs:group ref="group2"/>
</xs:sequence>
</xs:group>
<xs:complexType name="fatherType">
<xs:group ref="group1"/>
<xs:attribute name="last_name" type="xs:Name"/>
<xs:attributeGroup ref="attrgrp1"/>
</xs:complexType>
<xs:element name="father" type="fatherType"/>
</xs:schema>

Some files were not shown because too many files have changed in this diff Show More