This commit was manufactured by cvs2svn to create branch
'LotusXSL4C_1_0_0'.
diff --git a/Projects/Win32/VC6/PlatformSupport/PlatformSupport.dsp b/Projects/Win32/VC6/PlatformSupport/PlatformSupport.dsp
new file mode 100644
index 0000000..f6959f4
--- /dev/null
+++ b/Projects/Win32/VC6/PlatformSupport/PlatformSupport.dsp
@@ -0,0 +1,458 @@
+# Microsoft Developer Studio Project File - Name="PlatformSupport" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=PlatformSupport - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "PlatformSupport.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "PlatformSupport.mak" CFG="PlatformSupport - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "PlatformSupport - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "PlatformSupport - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "PlatformSupport - Win32 Release with symbols" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "PlatformSupport - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\..\..\Build\Win32\VC6\Release"
+# PROP Intermediate_Dir "..\..\..\..\Build\Win32\VC6\Release\PlatformSupport"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_PLATFORMSUPPORT_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W4 /GR /GX /O2 /Ob2 /I "..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_PLATFORMSUPPORT_BUILD_DLL" /FD /I /xml4c/include" /I /xml4c/include" " " " " " " /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 ..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo /dll /pdb:none /machine:I386
+# SUBTRACT LINK32 /debug
+
+!ELSEIF "$(CFG)" == "PlatformSupport - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\..\..\..\Build\Win32\VC6\Debug"
+# PROP Intermediate_Dir "..\..\..\..\Build\Win32\VC6\Debug\PlatformSupport"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PlatformSupport_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I "..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_WINDOWS" /D "_USRDLL" /D "XALAN_PLATFORMSUPPORT_BUILD_DLL" /D "WIN32" /D "_DEBUG" /D "_MBCS" /YX /FD /I /xml4c/include" /I /lotusxsl4c/stl" /I /lotusxsl4c/src/include" /I /xml4c/include" /GZ " " " " " " /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1D.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\..\Build\Win32\VC6\Debug/PlatformSupportD.dll" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "PlatformSupport - Win32 Release with symbols"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "PlatformSupport___Win32_Release_with_symbols"
+# PROP BASE Intermediate_Dir "PlatformSupport___Win32_Release_with_symbols"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\..\..\Build\Win32\VC6\Release.symbols"
+# PROP Intermediate_Dir "..\..\..\..\Build\Win32\VC6\Release.symbols\PlatformSupport"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W4 /GR /GX /O2 /Ob2 /I "..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_PLATFORMSUPPORT_BUILD_DLL" /D "XALAN_XERCES" /FD /I /xml4c/include" /I /xml4c/include" " " " " " " /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W4 /GR /GX /Zi /O2 /Ob2 /I "..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_PLATFORMSUPPORT_BUILD_DLL" /D "XALAN_XERCES" /FD /I /xml4c/include" /I /xml4c/include" " " " " " " /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 ..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo /dll /pdb:none /machine:I386
+# SUBTRACT BASE LINK32 /debug
+# ADD LINK32 ..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\..\Build\Win32\VC6\Release.symbols/PlatformSupportS.dll"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "PlatformSupport - Win32 Release"
+# Name "PlatformSupport - Win32 Debug"
+# Name "PlatformSupport - Win32 Release with symbols"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\AttributeListImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\AttributesImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\DOMStringHelper.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\DOMStringPrintWriter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\DoubleSupport.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\ExecutionContext.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\FormatterListener.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\NamedNodeMapAttributeList.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\NullPrintWriter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\PlatformSupportInit.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\PrefixResolver.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\PrintWriter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\Resettable.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\StdBinInputStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\StringTokenizer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\URISupport.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\Writer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanBitmap.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDecimalFormat.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDecimalFormatSymbols.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDOMStringCache.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDOMStringHashTable.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDOMStringPool.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanFileOutputStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanNullOutputStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanNumberFormat.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanOutputStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanOutputStreamPrintWriter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanReferenceCountedObject.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanStdOutputStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanToXercesTranscoderWrapper.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanTranscodingServices.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanUTF16Transcoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanXMLChar.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XSLException.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\ArenaAllocator.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\ArenaBlock.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\AttributeListImpl.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\AttributesImpl.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\AttributeVectorEntry.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\AttributeVectorEntryExtended.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\DirectoryEnumerator.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\DOMStringHelper.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\DOMStringPrintWriter.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\DoubleSupport.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\ExecutionContext.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\FormatterListener.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\NamedNodeMapAttributeList.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\NullPrintWriter.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\PlatformSupportDefinitions.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\PlatformSupportInit.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\PrefixResolver.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\PrintWriter.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\Resettable.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\ReusableArenaAllocator.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\ReusableArenaBlock.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\StdBinInputStream.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\StringTokenizer.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\URISupport.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\Writer.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanAllocator.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanBitmap.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDecimalFormat.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDecimalFormatSymbols.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDOMStringCache.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDOMStringHashTable.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanDOMStringPool.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanFileOutputStream.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanNullOutputStream.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanNumberFormat.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanOutputStream.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanOutputStreamPrintWriter.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanReferenceCountedObject.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanStdOutputStream.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanToXercesTranscoderWrapper.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanTranscodingServices.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanUnicode.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanUTF16Transcoder.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XalanXMLChar.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\PlatformSupport\XSLException.hpp
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/Tests/Compare/compare.dsp b/Tests/Compare/compare.dsp
new file mode 100644
index 0000000..2065f7c
--- /dev/null
+++ b/Tests/Compare/compare.dsp
@@ -0,0 +1,149 @@
+# Microsoft Developer Studio Project File - Name="compare" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=compare - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "compare.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "compare.mak" CFG="compare - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "compare - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "compare - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "compare - Win32 Release with symbols" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "compare - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\Build\Win32\VC6\Release"
+# PROP Intermediate_Dir "..\..\Build\Win32\VC6\Release\compare"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W4 /GR /GX /O2 /Ob2 /I "..\..\..\..\xml-xerces\c\src" /I "..\..\src\\" /I "..\harness\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib ..\..\Build\Win32\VC6\Release\*.lib /nologo /stack:0x1f4000 /subsystem:console /pdb:none /machine:I386
+
+!ELSEIF "$(CFG)" == "compare - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\..\Build\Win32\VC6\Debug"
+# PROP Intermediate_Dir "..\..\Build\Win32\VC6\Debug\compare"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W4 /GR /GX /Od /I "..\..\..\..\xml-xerces\c\src" /I "..\..\src\\" /I "..\harness\\" /D "_WINDOWS" /D "_CONSOLE" /D "WIN32" /D "_DEBUG" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1D.lib ..\..\Build\Win32\VC6\Debug\*.lib /nologo /stack:0x1f4000 /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "compare - Win32 Release with symbols"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "compare___Win32_Release_with_symbols"
+# PROP BASE Intermediate_Dir "compare___Win32_Release_with_symbols"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\Build\Win32\VC6\Release.symbols"
+# PROP Intermediate_Dir "..\..\Build\Win32\VC6\Release.symbols\compare"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\..\xml-xerces\c\src" /I "..\..\src\\" /I "..\harness\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W4 /GR /GX /Zi /O2 /Ob2 /I "..\..\..\..\xml-xerces\c\src" /I "..\..\src\\" /I "..\harness\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 ..\..\Build\Win32\VC6\Release\Harness.lib ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib ..\..\Build\Win32\VC6\Release\*.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\..\Build\Win32\VC6\Release/perft.exe"
+# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib ..\..\Build\Win32\VC6\Release.symbols\*.lib /nologo /stack:0x1f4000 /subsystem:console /debug /machine:I386 /fixed:no
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "compare - Win32 Release"
+# Name "compare - Win32 Debug"
+# Name "compare - Win32 Release with symbols"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\compare.cpp
+
+!IF "$(CFG)" == "compare - Win32 Release"
+
+# ADD CPP /MD /Zi
+
+!ELSEIF "$(CFG)" == "compare - Win32 Debug"
+
+# PROP Intermediate_Dir "..\..\Build\Win32\VC6\Debug\compare"
+# ADD CPP /MDd /Zi
+
+!ELSEIF "$(CFG)" == "compare - Win32 Release with symbols"
+
+# ADD BASE CPP /MD /Zi
+# ADD CPP /MD /Zi
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/Tests/Tests.dsw b/Tests/Tests.dsw
new file mode 100644
index 0000000..4719fc2
--- /dev/null
+++ b/Tests/Tests.dsw
@@ -0,0 +1,170 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "Harness"=".\Harness\Harness.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "Memory"=".\Memory\Memory.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Harness
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "Params"=".\Params\Params.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Harness
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "PerfT"=".\PerfT\PerfT.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Harness
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "ThreadTest"=".\Threads\ThreadTest.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "Transformer"=".\Transformer\Transformer.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "compare"=".\Compare\compare.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Harness
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "dom2dom"=".\Dom2Dom\Dom2Dom.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "extensions"=".\Extensions\extensions.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Harness
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "inputsource"=".\InputSource\inputsource.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Harness
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "perf"=".\Performance\perf.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Harness
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/Tests/Threads/ThreadTest.cpp b/Tests/Threads/ThreadTest.cpp
new file mode 100644
index 0000000..e4ad5a3
--- /dev/null
+++ b/Tests/Threads/ThreadTest.cpp
@@ -0,0 +1,402 @@
+// Base header file. Must be first.
+#include <Include/PlatformDefinitions.hpp>
+
+
+
+#include <cassert>
+#include <ctime>
+
+
+
+#if defined(XALAN_OLD_STREAM_HEADERS)
+#include <iostream.h>
+#else
+#include <iostream>
+#endif
+
+
+
+#include <util/PlatformUtils.hpp>
+#include <util/Mutexes.hpp>
+
+
+
+#include <Include/XalanAutoPtr.hpp>
+
+
+
+#include <XalanTransformer/XalanTransformer.hpp>
+
+
+
+#if defined(WIN32)
+//This is here for the threads.
+#include <process.h>
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#elif defined(XALAN_POSIX2_AVAILABLE)
+#include <pthread.h>
+#include <unistd.h>
+#else
+#error Unsupported platform!
+#endif
+
+
+
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::cerr;
+ using std::cout;
+ using std::endl;
+#endif
+
+
+
+// This is here for memory leak testing.
+#if defined(_DEBUG)
+#include <crtdbg.h>
+#endif
+
+
+
+class SynchronizedCounter
+{
+public:
+
+ SynchronizedCounter();
+
+ ~SynchronizedCounter();
+
+ void
+ increment();
+
+ void
+ decrement();
+
+ unsigned long
+ getCounter() const;
+
+private:
+
+ mutable XMLMutex m_mutex;
+
+ unsigned long m_counter;
+};
+
+
+
+SynchronizedCounter::SynchronizedCounter() :
+ m_mutex(),
+ m_counter(0)
+{
+}
+
+
+
+SynchronizedCounter::~SynchronizedCounter()
+{
+}
+
+
+
+void
+SynchronizedCounter::increment()
+{
+ XMLMutexLock theLock(&m_mutex);
+
+ if (m_counter < ULONG_MAX)
+ {
+ ++m_counter;
+ }
+}
+
+
+
+void
+SynchronizedCounter::decrement()
+{
+ XMLMutexLock theLock(&m_mutex);
+
+ if (m_counter > 0)
+ {
+ --m_counter;
+ }
+}
+
+
+
+unsigned long
+SynchronizedCounter::getCounter() const
+{
+ return m_counter;
+}
+
+
+
+struct
+ThreadInfo
+{
+ ThreadInfo(
+ unsigned int theThreadNumber = 0,
+ SynchronizedCounter* theCounter = 0) :
+ m_threadNumber(theThreadNumber),
+ m_counter(theCounter)
+ {
+ }
+
+ unsigned int m_threadNumber;
+
+ SynchronizedCounter* m_counter;
+};
+
+
+
+// Used to hold compiled stylesheet and pre-parsed source...
+const XalanCompiledStylesheet* glbCompiledStylesheet = 0;
+const XalanParsedSource* glbParsedSource = 0;
+
+
+
+#if defined(WIN32)
+
+extern "C" void theThreadRoutine(void* param);
+
+void
+#elif defined(XALAN_POSIX2_AVAILABLE)
+
+extern "C" void* theThreadRoutine(void* param);
+
+void*
+#else
+#error Unsupported platform!
+#endif
+theThreadRoutine(void* param)
+{
+// This routine uses compiled stylesheet (glbStylesheetRoot), which is set using the
+// theProcessor.setStylesheetRoot method. The transform is done using the theProcessor's
+// process() method.
+
+#if defined(XALAN_OLD_STYLE_CASTS)
+ const ThreadInfo* const theInfo = (const ThreadInfo*)param;
+#else
+ const ThreadInfo* const theInfo = reinterpret_cast<const ThreadInfo*>(param);
+#endif
+
+ assert(theInfo != 0);
+
+ theInfo->m_counter->increment();
+
+ try
+ {
+ // Our input file. The assumption is that the executable will be run
+ // from same directory as the input files.
+
+ // Generate the output file name.
+ const XalanDOMString theOutputFile(
+ XalanDOMString("birds") +
+ UnsignedLongToDOMString(theInfo->m_threadNumber) +
+ XalanDOMString(".out"));
+
+ // Create a transformer...
+ XalanTransformer theTransformer;
+
+ // Do the transform...
+ theTransformer.transform(*glbParsedSource, glbCompiledStylesheet, XSLTResultTarget(theOutputFile));
+ }
+ catch(...)
+ {
+ cerr << "Exception caught in thread " << theInfo->m_threadNumber;
+ }
+
+ // Decrement the counter because we're done...
+ theInfo->m_counter->decrement();
+
+#if defined(XALAN_POSIX2_AVAILABLE)
+ return 0;
+#endif
+}
+
+
+
+inline void
+doSleep(unsigned int theMilliseconds)
+{
+#if defined(WIN32)
+ Sleep(theMilliseconds);
+#elif defined(XALAN_POSIX2_AVAILABLE)
+ usleep(theMilliseconds * 10);
+#else
+#error Unsupported platform!
+#endif
+}
+
+
+
+void
+doThreads(long theThreadCount)
+{
+ cout << endl << "Starting " << theThreadCount << " threads." << endl;
+
+ XalanArrayAutoPtr<ThreadInfo> theThreadInfo(new ThreadInfo[theThreadCount]);
+
+ try
+ {
+ cout << endl << "Clock before starting threads: " << clock() << endl;
+
+ SynchronizedCounter theCounter;
+
+ long i = 0;
+
+ while (i < theThreadCount)
+ {
+ theThreadInfo[i].m_threadNumber = i;
+ theThreadInfo[i].m_counter = &theCounter;
+
+#if defined(WIN32)
+
+ const unsigned long theThreadID =
+ _beginthread(theThreadRoutine, 4096, reinterpret_cast<LPVOID>(&theThreadInfo[i]));
+
+ if (theThreadID == unsigned(-1))
+ {
+ cerr << endl << "Unable to create thread number " << i + 1 << "." << endl;
+ }
+
+#elif defined(XALAN_POSIX2_AVAILABLE)
+
+ pthread_t theThread;
+
+ const int theResult = pthread_create(&theThread, 0, theThreadRoutine, (void*)&theThreadInfo[i]);
+
+ if (theResult != 0)
+ {
+ cerr << endl << "Unable to create thread number " << i + 1 << "." << endl;
+ }
+ else
+ {
+#if defined(OS390)
+ pthread_detach(&theThread);
+#else
+ pthread_detach(theThread);
+#endif
+ }
+#else
+#error Unsupported platform!
+#endif
+
+ ++i;
+ }
+
+ clock_t theClock = 0;
+
+ if (i == 0)
+ {
+ cerr << endl << "No threads were created!" << endl;
+ }
+ else
+ {
+ unsigned int theCheckCount = 0;
+
+ do
+ {
+ doSleep(2000);
+
+ // Check a couple of times, just in case, since
+ // getCounter() is not synchronized...
+ if (theCounter.getCounter() == 0)
+ {
+ if (theCheckCount == 0)
+ {
+ theClock = clock();
+ }
+
+ ++theCheckCount;
+ }
+ }
+ while(theCheckCount < 2);
+ }
+
+ cout << endl << "Clock after threads: " << theClock << endl;
+ }
+ catch(...)
+ {
+ cerr << "Exception caught!!!"
+ << endl
+ << endl;
+ }
+}
+
+
+int
+main(
+ int argc,
+ const char* argv[])
+{
+#if !defined(NDEBUG) && defined(_MSC_VER)
+ _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
+
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+#endif
+
+ if (argc > 2)
+ {
+ cerr << "Usage: ThreadTest"
+ << endl
+ << endl;
+ }
+ else
+ {
+ int threadCount = 60;
+
+ if (argc == 2)
+ {
+ threadCount = atoi(argv[1]);
+ }
+
+ try
+ {
+ // Initialize Xerces...
+ XMLPlatformUtils::Initialize();
+
+ // Initialize Xalan...
+ XalanTransformer::initialize();
+
+ {
+ // Create a XalanTransformer. We won't actually use this to transform --
+ // it's just acting likely a factory for the compiled stylesheet and
+ // pre-parsed source.
+ XalanTransformer theXalanTransformer;
+
+ const char* const theXSLFileName = "birds.xsl";
+
+ theXalanTransformer.compileStylesheet(theXSLFileName, glbCompiledStylesheet);
+ assert(glbCompiledStylesheet != 0);
+
+ // Compile the XML source document as well. All threads will use
+ // this binary representation of the source tree.
+ const char* const theXMLFileName = "birds.xml";
+
+ theXalanTransformer.parseSource(theXMLFileName, glbParsedSource);
+ assert(glbParsedSource != 0);
+
+ doThreads(threadCount);
+ }
+
+ // Terminate Xalan...
+ XalanTransformer::terminate();
+
+ // Terminate Xerces...
+ XMLPlatformUtils::Terminate();
+ }
+ catch(...)
+ {
+ cerr << "Exception caught!!!"
+ << endl
+ << endl;
+ }
+
+ }
+
+ return 0;
+}
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..fb94606
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,664 @@
+#
+# The Apache Software License, Version 1.1
+#
+# Copyright (c) 1999 The Apache Software Foundation. All rights
+# reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#
+# 3. The end-user documentation included with the redistribution,
+# if any, must include the following acknowledgment:
+# "This product includes software developed by the
+# Apache Software Foundation (http://www.apache.org/)."
+# Alternately, this acknowledgment may appear in the software itself,
+# if and wherever such third-party acknowledgments normally appear.
+#
+# 4. The names "Xalan", "Xerces" and "Apache Software Foundation" must
+# not be used to endorse or promote products derived from this
+# software without prior written permission. For written
+# permission, please contact apache\@apache.org.
+#
+# 5. Products derived from this software may not be called "Apache",
+# nor may "Apache" appear in their name, without prior written
+# permission of the Apache Software Foundation.
+#
+# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+# ====================================================================
+#
+# This software consists of voluntary contributions made by many
+# individuals on behalf of the Apache Software Foundation, and was
+# originally based on software copyright (c) 1999, International
+# Business Machines, Inc., http://www.ibm.com . For more information
+# on the Apache Software Foundation, please see
+# <http://www.apache.org/>.
+#
+###################################################################
+# IMPORTANT NOTE #
+###################################################################
+# Before you try to run the Makefile, make sure you have two #
+# environment variables set. #
+# #
+# export XALANCROOT=<the directory where you installed XALAN-C> #
+# export XERCESCROOT=<the directory where you installed XERCES-C> #
+# #
+###################################################################
+
+DEPFILE=depends
+
+#MACROS defining commands
+MKDIR=mkdir
+
+ifndef XALANCROOT
+noxalanroot:
+ @echo XALANCROOT must be defined
+endif
+
+ifndef XERCESCROOT
+noxercesroot:
+ @echo XERCESCROOT must be defined
+endif
+
+ifdef XALAN_USE_ICU
+ifndef ICUROOT
+ICUROOT=/usr/local
+endif
+ifndef ICUI18NROOT
+ICUI18NROOT=${ICUROOT}
+endif
+endif
+
+XALANDOM_DIR = XalanDOM
+DOMSUPPORT_DIR = DOMSupport
+INCLUDE_DIR = Include
+ICUBRIDGE_DIR = ICUBridge
+PLATFORMSUPPORT_DIR = PlatformSupport
+XALANSOURCETREE_DIR = XalanSourceTree
+TESTXPATH_DIR = TestXPath
+TESTXSLT_DIR = TestXSLT
+XMLSUPPORT_DIR = XMLSupport
+XPATH_DIR = XPath
+XSLT_DIR = XSLT
+XALANEXTENSIONS_DIR = XalanExtensions
+XERCESPARSERLIAISON_DIR = XercesParserLiaison
+XALANTRANSFORMER_DIR = XalanTransformer
+ALL_OBJECTS_DIR = ${XALANCROOT}/obj
+LIB_DIR = ${XALANCROOT}/lib
+SAMPLES_DIR = ${XALANCROOT}/samples
+TESTS_DIR = ${XALANCROOT}/Tests
+
+PROJECT_NAME = xalan-c
+LIBNAME = lib${PROJECT_NAME}
+THISLIB = ${LIB_DIR}/${LIBNAME}
+VER = 1_2
+
+PRODUCTNAME=xalan
+PRODUCTVERSION=${VER}
+BINTARGETDIR=${XALANCROOT}/bin
+
+ALL_VPATH_CPP = \
+$(XALANDOM_DIR):$(DOMSUPPORT_DIR):$(PLATFORMSUPPORT_DIR):$(XALANSOURCETREE_DIR):$(TESTXPATH_DIR):$(TESTXSLT_DIR):\
+$(XMLSUPPORT_DIR):$(XPATH_DIR):$(XSLT_DIR):$(XALANEXTENSIONS_DIR):$(XALANTRANSFORMER_DIR):$(XERCESPARSERLIAISON_DIR)
+
+# Using ICUBridge
+ifdef XALAN_USE_ICU
+ALL_VPATH_CPP+=:$(ICUBRIDGE_DIR)
+endif
+
+#all these setting come from the arguments passed in to runConfigure.
+PLATFORM =@platform@
+CC = @cc@
+CXX = @cxx@
+CXXFLAGS = @cxxflags@
+PREFIX = @prefix@
+
+#=============== LINUX SPECIFIC OPTIONS =========================
+
+ifeq ($(PLATFORM), LINUX)
+
+ SUPPORTED = TRUE
+ PLATFORM_COMPILE_OPTIONS = -fpic -Wall -instances=static -D${PLATFORM} -D_REENTRANT
+ ALLLIBS = ${LIBS} -L/usr/lib
+ SHLIBSUFFIX=.so
+
+ # We need the ICU library if we are using the ICUBridge
+ ifdef XALAN_USE_ICU
+ LD_RPATH_PRE= -Wl,-rpath,
+ PLATFORM_LIB_LINK_OPTIONS=$(LD_RPATH_PRE)${ICUROOT}/lib
+ endif
+
+ EXTRA_LINK_OPTIONS=-lc
+ CC1 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+ MAKE_SHARED = ${CXX} $(CXXFLAGS) -D${PLATFORM} -shared -fpic
+ LINK = g++ -D${PLATFORM} -fpic
+
+endif
+
+#=============== HPUX SPECIFIC OPTIONS =========================
+
+ifeq ($(PLATFORM), HPUX)
+
+ SUPPORTED = TRUE
+ PLATFORM_COMPILE_OPTIONS = +Z -D${PLATFORM} -D_THREAD_SAFE
+ ALLLIBS = ${LIBS}
+ SHLIBSUFFIX=.sl
+ CC1 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+ CC2 = $(CXX) $(PLATFORM_COMPILE_OPTIONS)
+ MAKE_SHARED = $(CXX) -b +Z
+ LINK = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS) -Wl,+s
+
+endif
+
+#=============== SOLARIS SPECIFIC OPTIONS =========================
+
+ifeq ($(PLATFORM), SOLARIS)
+
+ SUPPORTED = TRUE
+
+ ifeq (${CXX}, g++)
+
+ PLATFORM_COMPILE_OPTIONS = -fPIC -instances=static -D${PLATFORM} -D_REENTRANT
+ ALLLIBS = ${LIBS} -L/usr/lib -L/usr/local/lib -lc
+
+ ifdef XALAN_USE_ICU
+ LD_RPATH_PRE= -Wl,-rpath,
+ endif
+
+ EXTRA_LINK_OPTIONS=-lc
+ CC1 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+ MAKE_SHARED = ${CXX} $(CXXFLAGS) -D${PLATFORM} -shared -fPIC
+ LINK = g++ -D${PLATFORM} -fPIC
+
+ ALLLIBS = ${LIBS} -L/usr/lib -L/usr/local/lib -lc
+
+ PLATFORM_LIB_LINK_OPTIONS=$(LD_RPATH_PRE)${ICUROOT}/lib $(LD_RPATH_PRE)${ICUI18NROOT}/lib
+
+ else
+
+ PLATFORM_COMPILE_OPTIONS = -KPIC -mt -xs -ptr$(ALL_OBJECTS_DIR) -features=rtti -D${PLATFORM} -D_REENTRANT
+
+ CC1 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS) -I${STLPORTROOT}/stlport
+ MAKE_SHARED = ${CXX} -D${PLATFORM} -G -ptr$(ALL_OBJECTS_DIR) ${LDFLAGS}
+ MAKE_SHARED_C = ${CC} -D${PLATFORM} -G ${LDFLAGS}
+ LINK = ${CXX} -D${PLATFORM} -ptr$(ALL_OBJECTS_DIR) ${LDFLAGS}
+
+ ALLLIBS = -mt ${LIBS} -L/usr/local/SUNWspro/lib -L/usr/ccs/lib \
+ -lc -lgen
+ endif
+
+ SHLIBSUFFIX=.so
+
+endif
+
+#=============== AIX SPECIFIC OPTIONS =========================
+ifeq ($(PLATFORM), AIX)
+
+ SUPPORTED = TRUE
+
+ ifeq (${CXX}, g++)
+
+ PLATFORM_COMPILE_OPTIONS = -fPIC -instances=static -D${PLATFORM} -D_REENTRANT
+ ALLLIBS = ${LIBS} -L/usr/lib -L/usr/local/lib -lc
+
+ ifdef XALAN_USE_ICU
+ LD_RPATH_PRE= -Wl,-rpath,
+ PLATFORM_LIB_LINK_OPTIONS=$(LD_RPATH_PRE)${ICUROOT}/lib $(LD_RPATH_PRE)${ICUI18NROOT}/lib
+ endif
+
+ EXTRA_LINK_OPTIONS=-lc
+ CC1 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+ MAKE_SHARED = ${CXX} $(CXXFLAGS) -D${PLATFORM} -shared -fPIC
+ LINK = g++ -D${PLATFORM} -fPIC
+
+ ALLLIBS = ${LIBS} -L/usr/lib -L/usr/local/lib -lc
+
+ else
+
+ ifndef STLPORTROOT
+ nostlportroot:
+ @echo STLPORTROOT must be defined
+ endif
+
+ PLATFORM_COMPILE_OPTIONS = -D${PLATFORM} -D_THREAD_SAFE -I${STLPORTROOT}/stlport
+ ALLLIBS = ${LIBS} -L/usr/lib
+ CC1 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+ CC2 = $(CXX) $(PLATFORM_COMPILE_OPTIONS)
+ MAKE_SHARED = makeC++SharedLib_r -p 5000
+ LINK = $(CXX) -qnotempinc $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+
+ endif
+
+ SHLIBSUFFIX=.a
+
+endif
+
+#=============== OS390 SPECIFIC OPTIONS =========================
+
+ifeq ($(PLATFORM), OS390)
+
+ ifndef STLPORTROOT
+ nostlportroot:
+ @echo STLPORTROOT must be defined
+ endif
+
+ SUPPORTED = TRUE
+ PLATFORM_COMPILE_OPTIONS =-Wc,dll -W0,"langlvl(extended),float(ieee)" -D${PLATFORM} -D_OPEN_THREADS -D_XOPEN_SOURCE_EXTENDED -I ${STLPORTROOT}/stlport
+ PLATFORM_COMPILE_OPTIONS2 =-Wc,dll -W0,"langlvl(extended),notempinc,float(ieee)" -D${PLATFORM} -D_OPEN_THREADS -D_XOPEN_SOURCE_EXTENDED -I ${STLPORTROOT}/stlport
+ ALLLIBS =
+ SHLIBSUFFIX=.dll
+ OS390SIDEDECK=.x
+
+ CC1 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+ CC2 = $(CXX) $(PLATFORM_COMPILE_OPTIONS2)
+ CC3 = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS2)
+ MAKE_SHARED = ${CXX} $(CXXFLAGS) -D${PLATFORM} -Wl,dll
+ LINK = $(CXX) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+
+endif
+
+#============ TRU64 SPECIFIC OPTIONS ============================
+
+ifeq ($(PLATFORM), TRU64)
+
+ SUPPORTED = TRUE
+ PLATFORM_COMPILE_OPTIONS = -D${PLATFORM} -ptr ${ALL_OBJECTS_DIR}/.cxx_repository -ieee -pthread
+ ALLLIBS = ${LIBS} -L/usr/lib -lc -lrt -lm
+ SHLIBSUFFIX = .so
+ CC1 = ${CXX} ${CXXFLAGS} $(PLATFORM_COMPILE_OPTIONS)
+ MAKE_SHARED = ${CXX} ${CXXFLAGS} -shared -D${PLATFORM} -ptr ${ALL_OBJECTS_DIR}/.cxx_repository -nocxxstd
+ LINK = ${CXX} $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+
+endif
+
+#============ MacOSX SPECIFIC OPTIONS ============================
+
+ifeq ($(PLATFORM), MACOSX)
+
+ SUPPORTED = TRUE
+ PLATFORM_COMPILE_OPTIONS = -Wall -D${PLATFORM} -D_REENTRANT -DXALAN_USE_XERCES_LOCAL_CODEPAGE_TRANSCODERS
+ ALLLIBS = ${LIBS} -L/usr/lib -L/usr/local/lib
+ SHLIBSUFFIX=.dylib
+ CC1 = ${CXX} $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+ MAKE_SHARED = ${CXX} $(CXXFLAGS) -D${PLATFORM} -dynamiclib
+ LINK = ${CXX} $(CXXFLAGS) ${PLATFORM_COMPILE_OPTIONS}
+
+endif
+
+ifndef SUPPORTED
+ nogood:
+ @echo Linux, Solaris, AIX, Compaq Tru64, OS/390, MacOSX, and HP-UX are the only platforms supported.
+endif
+
+# We need the Xerces library
+ifeq ($(PLATFORM), OS390)
+ ALLLIBS += $(XERCESCROOT)/lib/libxerces-c1_5_1.x
+else
+ ALLLIBS += -L$(XERCESCROOT)/lib -lxerces-c1_5
+endif
+
+# We need the ICU library if we are using the ICUBridge
+ifdef XALAN_USE_ICU
+ ifeq ($(PLATFORM), OS390)
+ ALLLIBS += ${ICUROOT}/lib/libicuuc.x ${ICUROOT}/lib/libicui18n.x
+ else
+ ALLLIBS += -L${ICUROOT}/lib -licuuc
+ ALLLIBS += -L${ICUI18NROOT}/lib -licui18n
+ endif
+endif
+
+
+# We have to use the includes from the source distribution, since we use
+# headers that others normally wouldn't
+ifdef XALAN_USE_ICU
+# We need the ICU library if we are using the ICUBridge
+ XSL_INCL = -I${ICUROOT}/include/ -I. -I$(XERCESCROOT)/src/ -I$(XERCESCROOT)/include/
+ XSL_BUILD_OPTIONS += -DXALAN_USE_ICU
+else
+ XSL_INCL = -I. -I$(XERCESCROOT)/src/ -I$(XERCESCROOT)/include/
+endif
+
+
+vpath %.cpp \
+$(ALL_VPATH_CPP)
+${ALL_OBJECTS_DIR}/%.o:%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+
+${ALL_OBJECTS_DIR}/%.o:%.hpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $(patsubst .hpp,.cpp,$<)
+
+
+ALLSOURCE = \
+ $(wildcard $(XALANDOM_DIR)/*.cpp) \
+ $(wildcard $(DOMSUPPORT_DIR)/*.cpp) \
+ $(wildcard $(PLATFORMSUPPORT_DIR)/*.cpp) \
+ $(wildcard $(XALANSOURCETREE_DIR)/*.cpp) \
+ $(wildcard $(XMLSUPPORT_DIR)/*.cpp) \
+ $(wildcard $(XPATH_DIR)/*.cpp) \
+ $(wildcard $(XSLT_DIR)/*.cpp) \
+ $(wildcard $(XALANEXTENSIONS_DIR)/*.cpp) \
+ $(wildcard $(XERCESINIT_DIR)/*.cpp) \
+ $(wildcard $(XERCESPARSERLIAISON_DIR)/*.cpp) \
+ $(wildcard $(XALANTRANSFORMER_DIR)/*.cpp) \
+
+
+# Using ICUBridge
+ifdef XALAN_USE_ICU
+ALLSOURCE += \
+ $(wildcard $(ICUBRIDGE_DIR)/*.cpp)
+endif
+
+ALL_OBJECTS = $(addprefix $(ALL_OBJECTS_DIR)/,$(addsuffix .o,$(basename $(notdir $(ALLSOURCE)))))
+
+all: lib testXSLT testXPath
+
+prepare:
+ @echo Preparing the directory structure for a build ...
+ -${MKDIR} -p ${ALL_OBJECTS_DIR}
+ -${MKDIR} -p ${LIB_DIR}
+ -${MKDIR} -p $(BINTARGETDIR)
+
+# Create header dependencies file -- this must be run before any objects are
+# built
+depend:
+ $(MAKE) -f makedepends DEPFILE=$(DEPFILE)
+
+-include $(DEPFILE)
+
+compile: $(ALL_OBJECTS)
+
+ifeq ($(PLATFORM), AIX)
+templates: ${ALL_OBJECTS_DIR}/XalanTemplate.o
+
+${ALL_OBJECTS_DIR}/XalanTemplate.o:$(XSLT_DIR)/XalanTemplate.cpp
+ $(CC2) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) -o $@ $<
+else
+ifeq ($(PLATFORM), OS390)
+templates: ${ALL_OBJECTS_DIR}/XalanTemplate.o
+${ALL_OBJECTS_DIR}/XalanTemplate.o:$(XSLT_DIR)/XalanTemplate.cpp
+ $(CC2) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) -o $@ $<
+endif
+endif
+
+testXSLT: lib $(BINTARGETDIR)/testXSLT
+
+ifeq ($(PLATFORM), OS390)
+$(BINTARGETDIR)/testXSLT: ${ALL_OBJECTS_DIR}/process.o
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $^ -o $@
+${ALL_OBJECTS_DIR}/process.o: $(TESTXSLT_DIR)/process.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+$(BINTARGETDIR)/testXSLT: ${ALL_OBJECTS_DIR}/process.o
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $^ -o $@
+${ALL_OBJECTS_DIR}/process.o: $(TESTXSLT_DIR)/process.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+testXPath: lib $(BINTARGETDIR)/testXPath
+
+ifeq ($(PLATFORM), OS390)
+$(BINTARGETDIR)/testXPath: ${ALL_OBJECTS_DIR}/TestXPath.o ${ALL_OBJECTS_DIR}/NodeNameTreeWalker.o
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/TestXPath.o: $(TESTXPATH_DIR)/TestXPath.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+${ALL_OBJECTS_DIR}/NodeNameTreeWalker.o: $(TESTXPATH_DIR)/NodeNameTreeWalker.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+$(BINTARGETDIR)/testXPath: ${ALL_OBJECTS_DIR}/TestXPath.o ${ALL_OBJECTS_DIR}/NodeNameTreeWalker.o
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(TESTXPATH_DIR)/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+samples : Samples
+
+tests : ThreadTest
+
+Samples: lib CompileStylesheet DocumentBuilder ExternalFunction SimpleTransform SimpleXPathAPI StreamTransform TraceListen UseStylesheetParam XalanTransform XalanTransformerCallback XPathWrapper
+
+ApacheModuleXSLT: lib ${LIB_DIR}/mod_xslt$(SHLIBSUFFIX)
+
+${LIB_DIR}/mod_xslt$(SHLIBSUFFIX) : ${ALL_OBJECTS_DIR}/mod_xslt.o
+ifeq ($(PLATFORM), OS390)
+ $(MAKE_SHARED) $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/ApacheModuleXSLT/%.c
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) -I/usr/include/apache/ $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ $(MAKE_SHARED) $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/ApacheModuleXSLT/%.c
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) -I/usr/include/apache/ $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+CompileStylesheet: lib $(BINTARGETDIR)/CompileStylesheet
+
+$(BINTARGETDIR)/CompileStylesheet: ${ALL_OBJECTS_DIR}/CompileStylesheet.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/CompileStylesheet/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/CompileStylesheet/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+DocumentBuilder: lib $(BINTARGETDIR)/DocumentBuilder
+
+$(BINTARGETDIR)/DocumentBuilder: ${ALL_OBJECTS_DIR}/DocumentBuilder.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/DocumentBuilder/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/DocumentBuilder/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+ExternalFunction: lib $(BINTARGETDIR)/ExternalFunction
+
+$(BINTARGETDIR)/ExternalFunction: ${ALL_OBJECTS_DIR}/ExternalFunction.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/ExternalFunction/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/ExternalFunction/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+SimpleTransform: lib $(BINTARGETDIR)/SimpleTransform
+
+$(BINTARGETDIR)/SimpleTransform: ${ALL_OBJECTS_DIR}/SimpleTransform.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/SimpleTransform/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/SimpleTransform/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+SimpleXPathAPI: lib $(BINTARGETDIR)/SimpleXPathAPI
+
+$(BINTARGETDIR)/SimpleXPathAPI: ${ALL_OBJECTS_DIR}/SimpleXPathAPI.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/SimpleXPathAPI/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/SimpleXPathAPI/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+StreamTransform: lib $(BINTARGETDIR)/StreamTransform
+
+$(BINTARGETDIR)/StreamTransform: ${ALL_OBJECTS_DIR}/StreamTransform.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/StreamTransform/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/StreamTransform/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+TraceListen: lib $(BINTARGETDIR)/TraceListen
+
+$(BINTARGETDIR)/TraceListen: ${ALL_OBJECTS_DIR}/TraceListen.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/TraceListen/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/TraceListen/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+UseStylesheetParam: lib $(BINTARGETDIR)/UseStylesheetParam
+
+$(BINTARGETDIR)/UseStylesheetParam: ${ALL_OBJECTS_DIR}/UseStylesheetParam.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/UseStylesheetParam/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/UseStylesheetParam/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+XalanTransform: lib $(BINTARGETDIR)/XalanTransform
+
+$(BINTARGETDIR)/XalanTransform: ${ALL_OBJECTS_DIR}/XalanTransform.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/XalanTransform/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/XalanTransform/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+XalanTransformerCallback: lib $(BINTARGETDIR)/XalanTransformerCallback
+
+$(BINTARGETDIR)/XalanTransformerCallback: ${ALL_OBJECTS_DIR}/XalanTransformerCallback.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/XalanTransformerCallback/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/XalanTransformerCallback/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+XPathWrapper: lib $(BINTARGETDIR)/XPathWrapper
+
+$(BINTARGETDIR)/XPathWrapper: ${ALL_OBJECTS_DIR}/XPathWrapper.o ${ALL_OBJECTS_DIR}/TestDriver.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/XPathWrapper/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(SAMPLES_DIR)/XPathWrapper/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+Tests: lib ThreadTest
+
+ThreadTest: lib $(BINTARGETDIR)/ThreadTest
+
+$(BINTARGETDIR)/ThreadTest: ${ALL_OBJECTS_DIR}/ThreadTest.o
+ifeq ($(PLATFORM), OS390)
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} $(LIB_DIR)/lib$(PROJECT_NAME)$(VER).x $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(TESTS_DIR)/Threads/%.cpp
+ $(CC3) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+else
+ ${LINK} $(XSL_BUILD_OPTIONS) ${PLATFORM_LIB_LINK_OPTIONS} ${LIBRARY_SEARCH_PATHS} \
+ ${EXTRA_LINK_OPTIONS} -L$(LIB_DIR) -l$(PROJECT_NAME)$(VER) $(ALLLIBS) $(CXXFLAGS) $^ -o $@
+${ALL_OBJECTS_DIR}/%.o:$(TESTS_DIR)/Threads/%.cpp
+ $(CC1) $(XSL_BUILD_OPTIONS) -c $(XSL_INCL) $(EXTRA_COMPILE_OPTIONS) -o $@ $<
+endif
+
+lib: prepare compile $(THISLIB)$(VER)$(SHLIBSUFFIX)
+
+$(THISLIB)$(VER)$(SHLIBSUFFIX): $(ALL_OBJECTS)
+ $(MAKE_SHARED) $(PLATFORM_LIBRARIES) $(EXTRA_LINK_OPTIONS) $(ALLLIBS) $^ -o $@
+ifeq ($(PLATFORM), OS390)
+ cp -p *.x ${LIB_DIR}
+endif
+
+clean:
+ rm -rf $(ALL_OBJECTS_DIR)/*
+ifeq ($(PLATFORM), TRU64)
+ rm -rf $(ALL_OBJECTS_DIR)/.cxx_repository
+endif
+ rm -f $(THISLIB)$(VER)$(SHLIBSUFFIX)
+ rm -f $(BINTARGETDIR)/testXSLT
+ rm -f $(BINTARGETDIR)/testXPath
+ rm -f ${LIB_DIR}/mod_xslt$(SHLIBSUFFIX)
+ rm -f $(BINTARGETDIR)/CompileStylesheet
+ rm -f $(BINTARGETDIR)/ExternalFunction
+ rm -f $(BINTARGETDIR)/SimpleTransform
+ rm -f $(BINTARGETDIR)/StreamTransform
+ rm -f $(BINTARGETDIR)/TraceListen
+ rm -f $(BINTARGETDIR)/UseStylesheetParam
+ rm -f $(BINTARGETDIR)/XalanTransform
+ rm -f $(BINTARGETDIR)/XPathWrapper
+
diff --git a/src/TestXSLT/process.cpp b/src/TestXSLT/process.cpp
new file mode 100644
index 0000000..46dde32
--- /dev/null
+++ b/src/TestXSLT/process.cpp
@@ -0,0 +1,1370 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+#include <Include/PlatformDefinitions.hpp>
+
+
+
+#include <cstdio>
+#include <cstring>
+
+
+
+#if defined(XALAN_OLD_STREAM_HEADERS)
+#include <iostream.h>
+#else
+#include <iostream>
+#endif
+
+
+
+#if !defined(NDEBUG) && defined(_MSC_VER)
+#include <crtdbg.h>
+#endif
+
+
+
+#include <util/PlatformUtils.hpp>
+#include <sax/SAXException.hpp>
+
+
+
+#include <XalanDOM/XalanDOMException.hpp>
+
+
+
+#include <PlatformSupport/DOMStringHelper.hpp>
+#include <PlatformSupport/DOMStringPrintWriter.hpp>
+#include <PlatformSupport/XalanOutputStreamPrintWriter.hpp>
+#include <PlatformSupport/XalanFileOutputStream.hpp>
+#include <PlatformSupport/XalanStdOutputStream.hpp>
+
+
+
+#include <Include/XalanAutoPtr.hpp>
+
+
+
+#include <DOMSupport/DOMSupportDefault.hpp>
+
+
+
+#include <XPath/XObjectFactoryDefault.hpp>
+#include <XPath/XPathEnvSupportDefault.hpp>
+#include <XPath/XPath.hpp>
+#include <XPath/XPathExecutionContextDefault.hpp>
+#include <XPath/XPathFactoryBlock.hpp>
+#include <XPath/XPathFactoryDefault.hpp>
+#include <XPath/XPathProcessorImpl.hpp>
+
+
+
+#include <XalanExtensions/XalanExtensions.hpp>
+
+
+
+#include <XercesParserLiaison/XercesParserLiaison.hpp>
+#include <XercesParserLiaison/XercesDOMSupport.hpp>
+
+
+
+#include <XMLSupport/FormatterToDOM.hpp>
+#include <XMLSupport/FormatterToHTML.hpp>
+#include <XMLSupport/FormatterToNull.hpp>
+#include <XMLSupport/FormatterToText.hpp>
+#include <XMLSupport/FormatterToXML.hpp>
+#include <XMLSupport/FormatterTreeWalker.hpp>
+
+
+
+#include <XalanSourceTree/FormatterToSourceTree.hpp>
+#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
+#include <XalanSourceTree/XalanSourceTreeDocument.hpp>
+#include <XalanSourceTree/XalanSourceTreeInit.hpp>
+#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
+
+
+
+#include <XSLT/XSLTEngineImpl.hpp>
+#include <XSLT/XSLTInit.hpp>
+#include <XSLT/XSLTInputSource.hpp>
+#include <XSLT/XSLTResultTarget.hpp>
+#include <XSLT/StylesheetRoot.hpp>
+#include <XSLT/StylesheetConstructionContextDefault.hpp>
+#include <XSLT/StylesheetExecutionContextDefault.hpp>
+#include <XSLT/TraceListenerDefault.hpp>
+#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
+
+
+
+//#define XALAN_USE_ICU
+#if defined(XALAN_USE_ICU)
+#include <ICUBridge/ICUBridge.hpp>
+#include <ICUBridge/FunctionICUFormatNumber.hpp>
+#include <ICUBridge/ICUBridgeCollationCompareFunctor.hpp>
+#endif
+
+
+
+//#define XALAN_VQ_SPECIAL_TRACE
+#if defined(XALAN_VQ_SPECIAL_TRACE)
+#include "C:/Program Files/Rational/Quantify/pure.h"
+#endif
+
+
+
+#if !defined (XALAN_NO_NAMESPACES)
+using std::cerr;
+using std::cin;
+using std::cout;
+using std::endl;
+using std::hex;
+using std::pair;
+using std::vector;
+#endif
+
+
+
+/**
+ * Print argument options.
+ */
+void
+printArgOptions()
+{
+ cerr << endl
+ << "TestXSLT options: "
+ << endl
+ << endl
+ << "Options are not case-sensitive."
+ << endl
+ << endl
+ << " [-? Shows this message.]"
+ << endl
+ << endl
+ << " [-h Shows this message.]"
+ << endl
+ << endl
+ << " [-IN inputXMLURL (If not specified, stdin is used.)]"
+ << endl
+ << endl
+ << " [-XSL XSLTransformationURL]"
+ << endl
+ << " [-OUT outputFileName]"
+ << endl
+ << " [-V (Show version information only.)]"
+ << endl
+ << " [-QC (Quiet pattern conflicts warnings.)]"
+ << endl
+ << " [-Q (Use quiet mode.)]"
+ << endl
+ << " [-INDENT n (Controls how many spaces to indent. {default is 0})]"
+ << endl
+ << " [-VALIDATE (Controls whether validation occurs. Validation is off by default.)]"
+ << endl
+ << endl
+ << " [-TT (Trace the templates as they are being called.)]"
+ << endl
+ << " [-TG (Trace each generation event.)]"
+ << endl
+ << " [-TS (Trace each selection event.)]"
+ << endl
+ << " [-TTC (Trace the template children as they are being processed.)]"
+ << endl
+ << endl
+ << " [-XML (Use XML formatter and add XML header.)]"
+ << endl
+ << " [-TEXT (Use Text formatter.)]"
+ << endl
+ << " [-HTML (Use HTML formatter.)]"
+ << endl
+ << " [-DOM (Use DOM formatter. Formats to DOM, then formats XML for output.)]"
+ << endl
+ << " [-XST (Use source tree formatter. Formats to Xalan source tree, then formats XML for output.)]"
+ << endl
+ << endl
+ << " [-PARAM name expression (Sets a stylesheet parameter.)]"
+ << endl
+ << endl
+ << " [-XD (Use Xerces DOM instead of Xalan source tree.)]"
+ << endl
+ << endl
+ << " [-DE (Disable built-in extension functions.)]"
+ << endl
+ << " [-EN (Specify the namespace URI for Xalan extension functions. The default is 'http://xml.apache.org/xalan')]"
+ << endl
+ << endl
+ << "The following options are valid only with -HTML or -XML."
+ << endl
+ << endl
+ << " [-STRIPCDATA (Strip CDATA sections of their brackets, but don't escape.)"
+ << endl
+ << " [-ESCAPECDATA (Strip CDATA sections of their brackets, but escape.)"
+ << endl
+ << endl
+ << "The following option is valid only with -HTML."
+ << endl
+ << endl
+ << " [-NOINDENT (Turns off HTML indenting..]"
+ << endl
+ << endl
+ << "The following option is valid only with -XML."
+ << endl
+ << endl
+ << " [-NH (Don't write XML header.)]"
+ << endl;
+}
+
+
+
+typedef vector<pair<const char*, const char*> > StringPairVectorType;
+
+
+
+struct CmdLineParams
+{
+ StringPairVectorType params;
+
+ bool escapeCData;
+ bool setQuietConflictWarnings;
+ bool setQuietMode;
+ bool stripCData;
+ bool versionOnly;
+ bool traceTemplates;
+ bool traceGenerationEvent;
+ bool traceSelectionEvent;
+ bool traceTemplateChildren;
+ bool shouldWriteXMLHeader;
+ bool doValidation;
+ bool noIndent;
+ bool formatToNull;
+ bool formatToSourceTree;
+ bool useDOM;
+ bool disableExtensions;
+
+ int indentAmount;
+ int outputType;
+
+ const char* outFileName;
+ const char* xslFileName;
+ const char* inFileName;
+ const char* extentionsNamespace;
+
+ CmdLineParams() :
+ params(),
+ escapeCData(false),
+ setQuietConflictWarnings(false),
+ setQuietMode(false),
+ stripCData(false),
+ versionOnly(false),
+ traceTemplates(false),
+ traceGenerationEvent(false),
+ traceSelectionEvent(false),
+ traceTemplateChildren(false),
+ shouldWriteXMLHeader(true),
+ doValidation(false),
+ noIndent(false),
+ formatToNull(false),
+ formatToSourceTree(false),
+ useDOM(false),
+ disableExtensions(false),
+ indentAmount(-1),
+ outputType(-1),
+ outFileName(0),
+ xslFileName(0),
+ inFileName(0),
+ extentionsNamespace(0)
+ {
+ }
+};
+
+
+
+void
+warnPreviousOutputMethod(int outputMethod)
+{
+ cerr << endl << "Warning: Ignoring previous output method switch ";
+
+ switch(outputMethod)
+ {
+ case FormatterListener::OUTPUT_METHOD_XML:
+ cerr << "-XML.";
+ break;
+
+ case FormatterListener::OUTPUT_METHOD_TEXT:
+ cerr << "-TEXT.";
+ break;
+
+ case FormatterListener::OUTPUT_METHOD_HTML:
+ cerr << "-HTML.";
+ break;
+
+ case FormatterListener::OUTPUT_METHOD_DOM:
+ cerr << "-DOM.";
+ break;
+ }
+
+ cerr << endl << endl;
+}
+
+
+
+#if defined(OS390)
+#include <strings.h>
+
+int
+compareNoCase(
+ const char* str1,
+ const char* str2)
+{
+ return strcasecmp(str1, str2);
+}
+
+#else
+
+int
+compareNoCase(
+ const char* str1,
+ const char* str2)
+{
+ return stricmp(str1, str2);
+}
+
+#endif
+
+
+
+bool
+getArgs(
+ int argc,
+ const char* argv[],
+ CmdLineParams& p)
+{
+ bool fSuccess = true;
+
+ for (int i = 1; i < argc && fSuccess == true; ++i)
+ {
+ if (!compareNoCase("-h", argv[i]) || !compareNoCase("-?", argv[i]))
+ {
+ fSuccess = false;
+ }
+ else if (!compareNoCase("-IN", argv[i]))
+ {
+ ++i;
+
+ if(i < argc && argv[i][0] != '-')
+ {
+ p.inFileName = argv[i];
+ }
+ else
+ {
+ fSuccess = false;
+ }
+ }
+ else if (!compareNoCase("-XSL", argv[i]))
+ {
+ ++i;
+
+ if(i < argc && argv[i][0] != '-')
+ {
+ p.xslFileName = argv[i];
+ }
+ else
+ {
+ fSuccess = false;
+ }
+ }
+ else if (!compareNoCase("-OUT", argv[i]))
+ {
+ ++i;
+
+ if(i < argc && argv[i][0] != '-')
+ {
+ p.outFileName = argv[i];
+ }
+ else
+ {
+ fSuccess = false;
+ }
+ }
+ else if (!compareNoCase("-NOINDENT", argv[i]))
+ {
+ p.noIndent = true;
+ }
+ else if (!compareNoCase("-INDENT", argv[i]))
+ {
+ ++i;
+
+ if(i < argc && argv[i][0] != '-')
+ {
+ p.indentAmount = atoi(argv[i]);
+ }
+ else
+ {
+ fSuccess = false;
+ }
+ }
+ else if(!compareNoCase("-VALIDATE", argv[i]))
+ {
+ p.doValidation = true;
+ }
+ else if (!compareNoCase("-PARAM", argv[i]))
+ {
+ ++i;
+
+ if(i < argc && argv[i][0] != '-')
+ {
+ const char* const name = argv[i];
+
+ ++i;
+
+ // Don't check for '-' here, since that might
+ // be a valid character in a parameter value.
+ if(i < argc)
+ {
+ typedef StringPairVectorType::value_type value_type;
+
+ p.params.push_back(value_type(name, argv[i]));
+ }
+ else
+ {
+ fSuccess = false;
+ }
+ }
+ else
+ {
+ fSuccess = false;
+ }
+ }
+ else if(!compareNoCase("-V", argv[i]))
+ {
+ p.versionOnly = true;
+ }
+ else if(!compareNoCase("-QC", argv[i]))
+ {
+ p.setQuietConflictWarnings = true;
+ }
+ else if(!compareNoCase("-Q", argv[i]))
+ {
+ p.setQuietMode = true;
+ }
+ else if(!compareNoCase("-XML", argv[i]))
+ {
+ if (p.outputType != -1)
+ {
+ warnPreviousOutputMethod(p.outputType);
+ }
+
+ p.outputType = FormatterListener::OUTPUT_METHOD_XML;
+ }
+ else if(!compareNoCase("-TEXT", argv[i]))
+ {
+ if (p.outputType != -1)
+ {
+ warnPreviousOutputMethod(p.outputType);
+ }
+
+ p.outputType = FormatterListener::OUTPUT_METHOD_TEXT;
+ }
+ else if(!compareNoCase("-HTML", argv[i]))
+ {
+ if (p.outputType != -1)
+ {
+ warnPreviousOutputMethod(p.outputType);
+ }
+
+ p.outputType = FormatterListener::OUTPUT_METHOD_HTML;
+ }
+ else if(!compareNoCase("-DOM", argv[i]))
+ {
+ if (p.outputType != -1)
+ {
+ warnPreviousOutputMethod(p.outputType);
+ }
+
+ p.outputType = FormatterListener::OUTPUT_METHOD_DOM;
+ }
+ else if(!compareNoCase("-XST", argv[i]))
+ {
+ if (p.outputType != -1)
+ {
+ warnPreviousOutputMethod(p.outputType);
+ }
+
+ p.outputType = FormatterListener::OUTPUT_METHOD_DOM;
+
+ p.formatToSourceTree = true;
+ }
+ else if(!compareNoCase("-NULL", argv[i]))
+ {
+ p.formatToNull = true;
+ }
+ else if(!compareNoCase("-STRIPCDATA", argv[i]))
+ {
+ p.stripCData = true;
+ }
+ else if(!compareNoCase("-ESCAPECDATA", argv[i]))
+ {
+ p.escapeCData = true;
+ }
+ else if (!compareNoCase("-NH", argv[i]))
+ {
+ p.shouldWriteXMLHeader = false;
+ }
+ else if(!compareNoCase("-TT", argv[i]))
+ {
+ p.traceTemplates = true;
+ }
+ else if(!compareNoCase("-TG", argv[i]))
+ {
+ p.traceGenerationEvent = true;
+ }
+ else if(!compareNoCase("-TS", argv[i]))
+ {
+ p.traceSelectionEvent = true;
+ }
+ else if(!compareNoCase("-TTC", argv[i]))
+ {
+ p.traceTemplateChildren = true;
+ }
+ else if (!compareNoCase("-XD", argv[i]))
+ {
+ p.useDOM = true;
+ }
+ else if (!compareNoCase("-DE", argv[i]))
+ {
+ p.disableExtensions = true;
+ }
+ else if (!compareNoCase("-EN", argv[i]))
+ {
+ ++i;
+
+ if(i < argc)
+ {
+ p.extentionsNamespace = argv[i];
+
+ if (strlen(p.extentionsNamespace) == 0)
+ {
+ fSuccess = false;
+ }
+ }
+ else
+ {
+ fSuccess = false;
+ }
+ }
+ else
+ {
+ cerr << endl << "Warning: Ignoring unknown option \"" << argv[i] << "\"." << endl << endl;
+ }
+ }
+
+ return fSuccess;
+}
+
+
+
+FormatterListener*
+createFormatter(
+ int outputType,
+ bool shouldWriteXMLHeader,
+ bool stripCData,
+ bool escapeCData,
+ bool noIndent,
+ bool formatToNull,
+ bool formatToSourceTree,
+ PrintWriter& resultWriter,
+ int indentAmount,
+ const XalanDOMString& mimeEncoding,
+ const StylesheetRoot* stylesheet,
+ XMLParserLiaison& parserLiaison,
+ XalanSourceTreeParserLiaison& sourceTreeParserLiaison,
+ const PrefixResolver& prefixResolver,
+ const XalanDocument*& theResultDocument)
+{
+ FormatterListener* formatter = 0;
+
+ if (formatToNull == true)
+ {
+ formatter = new FormatterToNull;
+ }
+ else if(FormatterListener::OUTPUT_METHOD_XML == outputType)
+ {
+ XalanDOMString version;
+ bool outputIndent = false;
+ XalanDOMString mediatype;
+ XalanDOMString doctypeSystem;
+ XalanDOMString doctypePublic;
+ XalanDOMString standalone;
+
+ if (stylesheet != 0)
+ {
+ version = stylesheet->m_version;
+
+ mediatype = stylesheet->m_mediatype;
+ doctypeSystem = stylesheet->getOutputDoctypeSystem();
+ doctypePublic = stylesheet->getOutputDoctypePublic();
+ standalone = stylesheet->m_standalone;
+ }
+
+ FormatterToXML* const fToXML =
+ new FormatterToXML(
+ resultWriter,
+ version,
+ outputIndent,
+ indentAmount,
+ mimeEncoding,
+ mediatype,
+ doctypeSystem,
+ doctypePublic,
+ true, // xmlDecl
+ standalone);
+
+ fToXML->setShouldWriteXMLHeader(shouldWriteXMLHeader);
+ fToXML->setStripCData(stripCData);
+ fToXML->setEscapeCData(escapeCData);
+
+ formatter = fToXML;
+ }
+ else if(FormatterListener::OUTPUT_METHOD_TEXT == outputType)
+ {
+ formatter = new FormatterToText(resultWriter, mimeEncoding);
+ }
+ else if(FormatterListener::OUTPUT_METHOD_HTML == outputType)
+ {
+ XalanDOMString version;
+ bool outputIndent = !noIndent;
+ XalanDOMString mediatype;
+ XalanDOMString doctypeSystem;
+ XalanDOMString doctypePublic;
+ XalanDOMString standalone;
+
+ if (stylesheet != 0)
+ {
+ version = stylesheet->m_version;
+
+ if (noIndent == false)
+ {
+ outputIndent = stylesheet->getOutputIndent();
+ }
+
+ mediatype = stylesheet->m_mediatype;
+ doctypeSystem = stylesheet->getOutputDoctypeSystem();
+ doctypePublic = stylesheet->getOutputDoctypePublic();
+ standalone = stylesheet->m_standalone;
+ }
+
+ FormatterToHTML* const fToHTML =
+ new FormatterToHTML(
+ resultWriter,
+ mimeEncoding,
+ mediatype,
+ doctypeSystem,
+ doctypePublic,
+ outputIndent,
+ indentAmount,
+ version,
+ standalone,
+ false); // xmlDecl
+
+ fToHTML->setStripCData(stripCData);
+ fToHTML->setPrefixResolver(&prefixResolver);
+
+ formatter = fToHTML;
+ }
+ else if(FormatterListener::OUTPUT_METHOD_DOM == outputType)
+ {
+ if (formatToSourceTree == true)
+ {
+ XalanSourceTreeDocument* theDocument =
+ sourceTreeParserLiaison.createXalanSourceTreeDocument();
+ assert(theDocument != 0);
+
+ theResultDocument = theDocument;
+
+ FormatterToSourceTree* const fToSourceTree =
+ new FormatterToSourceTree(theDocument);
+
+ fToSourceTree->setPrefixResolver(&prefixResolver);
+
+ formatter = fToSourceTree;
+ }
+ else
+ {
+ XalanDocument* const theDocument =
+ parserLiaison.createDOMFactory();
+ assert(theDocument != 0);
+
+ theResultDocument = theDocument;
+
+ FormatterToDOM* const fToDOM =
+ new FormatterToDOM(theDocument, 0);
+
+ fToDOM->setPrefixResolver(&prefixResolver);
+
+ formatter = fToDOM;
+ }
+ }
+
+ return formatter;
+}
+
+
+
+XalanOutputStream*
+createOutputStream(const CmdLineParams& params)
+{
+ if (params.outFileName == 0)
+ {
+ return new XalanStdOutputStream(cout);
+ }
+ else
+ {
+ return new XalanFileOutputStream(TranscodeFromLocalCodePage(params.outFileName));
+ }
+}
+
+
+
+TraceListener*
+createTraceListener(
+ const CmdLineParams& params,
+ PrintWriter& diagnosticsWriter)
+{
+ if (params.traceTemplates == true ||
+ params.traceTemplateChildren == true ||
+ params.traceGenerationEvent == true ||
+ params.traceSelectionEvent == true)
+ {
+ return new TraceListenerDefault(
+ diagnosticsWriter,
+ params.traceTemplates,
+ params.traceTemplateChildren,
+ params.traceGenerationEvent,
+ params.traceSelectionEvent);
+ }
+ else
+ {
+ return 0;
+ }
+
+}
+
+
+
+DOMSupport&
+getDOMSupport(
+ XalanSourceTreeDOMSupport& theXalanSourceTreeDOMSupport,
+ XercesDOMSupport& theXercesDOMSupport,
+ const CmdLineParams& params)
+{
+ if (params.useDOM == false)
+ {
+ return theXalanSourceTreeDOMSupport;
+ }
+ else
+ {
+ return theXercesDOMSupport;
+ }
+}
+
+
+
+XMLParserLiaison&
+getParserLiaison(
+ XalanSourceTreeParserLiaison& theXalanSourceTreeParserLiaison,
+ XercesParserLiaison& theXercesParserLiaison,
+ const CmdLineParams& params)
+{
+ if (params.useDOM == false)
+ {
+ return theXalanSourceTreeParserLiaison;
+ }
+ else
+ {
+ return theXercesParserLiaison;
+ }
+}
+
+
+
+void
+installExtensions(
+ const CmdLineParams& params,
+ XSLTProcessorEnvSupportDefault& theXSLProcessorSupport)
+{
+ XalanDOMString theXalanNamespace;
+
+ if (params.extentionsNamespace != 0)
+ {
+ theXalanNamespace = XalanDOMString(params.extentionsNamespace);
+ assert(length(theXalanNamespace) > 0);
+ }
+ else
+ {
+ theXalanNamespace = XALAN_STATIC_UCODE_STRING("http://xml.apache.org/xalan");
+ }
+
+ theXSLProcessorSupport.installExternalFunctionLocal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("difference")),
+ FunctionDifference());
+
+ theXSLProcessorSupport.installExternalFunctionLocal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("distinct")),
+ FunctionDistinct());
+
+ theXSLProcessorSupport.installExternalFunctionLocal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("evaluate")),
+ FunctionEvaluate());
+
+ theXSLProcessorSupport.installExternalFunctionLocal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("hasSameNodes")),
+ FunctionHasSameNodes());
+
+ theXSLProcessorSupport.installExternalFunctionLocal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("intersection")),
+ FunctionIntersection());
+
+ theXSLProcessorSupport.installExternalFunctionLocal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("nodeset")),
+ FunctionNodeSet());
+}
+
+
+
+int
+xsltMain(const CmdLineParams& params)
+{
+ // Initialize the XSLT subsystem. This must stay in scope until
+ // we're done with the subsystem, since its destructor shuts down
+ // the subsystem.
+ XSLTInit theInit;
+
+#if defined(XALAN_USE_ICU)
+ // Create an installer to install the substitute format-number() function.
+ FunctionICUFormatNumber::FunctionICUFormatNumberInstaller theInstaller;
+#endif
+
+ const XalanDOMString mimeEncoding(XALAN_STATIC_UCODE_STRING("UTF-8"));
+ const XalanDOMString encoding(XALAN_STATIC_UCODE_STRING("UTF-8"));
+
+ /**
+ * The default diagnostic writer...
+ */
+ XalanStdOutputStream theStdErr(cerr);
+ XalanOutputStreamPrintWriter diagnosticsWriter(theStdErr);
+
+ // Make sure that error reporting, which includes any TraceListener output
+ // does not throw exceptions when transcoding, since that could result in
+ // an exception being thrown will another exception is active. In particular,
+ // characters that the TraceListener writes might not be representable in the
+ // local code page.
+ theStdErr.setThrowTranscodeException(false);
+
+ // Initialize the XalanSourceTree subsystem. This must stay in scope until
+ // we're done with the subsystem, since its destructor shuts down the
+ // subsystem.
+ XalanSourceTreeInit theXalanSourceTreeInit;
+
+ XalanSourceTreeDOMSupport theXalanSourceTreeDOMSupport;
+ XalanSourceTreeParserLiaison theXalanSourceTreeParserLiaison(theXalanSourceTreeDOMSupport);
+
+ // Hookup the parser liaison instance to the support instance.
+ theXalanSourceTreeDOMSupport.setParserLiaison(&theXalanSourceTreeParserLiaison);
+
+
+ XercesDOMSupport theXercesDOMSupport;
+ XercesParserLiaison theXercesParserLiaison(theXercesDOMSupport);
+
+ DOMSupport& theDOMSupport = getDOMSupport(
+ theXalanSourceTreeDOMSupport,
+ theXercesDOMSupport,
+ params);
+
+ XMLParserLiaison& xmlParserLiaison = getParserLiaison(
+ theXalanSourceTreeParserLiaison,
+ theXercesParserLiaison,
+ params);
+
+ XSLTProcessorEnvSupportDefault theXSLProcessorSupport;
+
+ if (params.disableExtensions == false)
+ {
+ installExtensions(params, theXSLProcessorSupport);
+ }
+
+ XObjectFactoryDefault theXObjectFactory;
+
+ XPathFactoryDefault theXPathFactory;
+
+ const XalanAutoPtr<TraceListener> theTraceListener(
+ createTraceListener(
+ params,
+ diagnosticsWriter));
+
+ XSLTEngineImpl processor(
+ xmlParserLiaison,
+ theXSLProcessorSupport,
+ theDOMSupport,
+ theXObjectFactory,
+ theXPathFactory);
+
+ theXSLProcessorSupport.setProcessor(&processor);
+
+ if (theTraceListener.get() != 0)
+ {
+ processor.setTraceSelects(params.traceSelectionEvent);
+ processor.addTraceListener(theTraceListener.get());
+ }
+
+ // Use a different factory type for the stylesheet. This is an optimization, since
+ // stylesheet XPath instances are built all at once and are deleted all at once when
+ // the stylesheet is destroyed.
+ XPathFactoryBlock theStylesheetXPathFactory;
+
+ StylesheetConstructionContextDefault theConstructionContext(
+ processor,
+ theStylesheetXPathFactory);
+
+ /*
+ * Set specified processor flags
+ */
+ processor.setQuietConflictWarnings(params.setQuietConflictWarnings);
+
+ if (params.params.size() > 0)
+ {
+ StringPairVectorType::const_iterator it = params.params.begin();
+
+ for ( ; it != params.params.end(); ++it)
+ {
+ assert((*it).first != 0 && (*it).second != 0);
+
+ processor.setStylesheetParam(
+ XalanDOMString((*it).first),
+ XalanDOMString((*it).second));
+ }
+ }
+
+ /*
+ * Set specified parser flags
+ */
+ if (params.indentAmount != 0)
+ {
+ xmlParserLiaison.setIndent(params.indentAmount);
+ }
+
+ xmlParserLiaison.setUseValidation(params.doValidation);
+
+ if (!params.setQuietMode)
+ {
+ processor.setDiagnosticsOutput(&diagnosticsWriter);
+ }
+
+ XalanDOMString xslFileName;
+
+ if(params.xslFileName != 0)
+ {
+ xslFileName = params.xslFileName;
+ }
+
+ const StylesheetRoot* stylesheet = 0;
+
+ if (!isEmpty(xslFileName))
+ {
+ stylesheet = processor.processStylesheet(xslFileName, theConstructionContext);
+ }
+
+ XalanAutoPtr<XalanOutputStream> outputFileStream(createOutputStream(params));
+ assert(outputFileStream.get() != 0);
+
+ XalanOutputStreamPrintWriter resultWriter(*outputFileStream.get());
+
+ const XalanDocument* theResultDocument = 0;
+
+ const XalanAutoPtr<FormatterListener> formatter(
+ createFormatter(
+ params.outputType,
+ params.shouldWriteXMLHeader,
+ params.stripCData,
+ params.escapeCData,
+ params.noIndent,
+ params.formatToNull,
+ params.formatToSourceTree,
+ resultWriter,
+ xmlParserLiaison.getIndent(),
+ mimeEncoding,
+ stylesheet,
+ xmlParserLiaison,
+ theXalanSourceTreeParserLiaison,
+ processor,
+ theResultDocument));
+
+ XSLTResultTarget rTreeTarget;
+
+ if(formatter.get() == 0)
+ {
+ rTreeTarget.setCharacterStream(&resultWriter);
+ }
+ else
+ {
+ rTreeTarget.setFormatterListener(formatter.get());
+ }
+
+ // Do the transformation...
+ XSLTInputSource theInputSource;
+
+ if (params.inFileName != 0)
+ {
+ theInputSource.setSystemId(c_wstr(XalanDOMString(params.inFileName)));
+ }
+ else
+ {
+ theInputSource.setStream(&cin);
+
+ cerr << "Reading input document from stdin..." << endl;
+ }
+
+ StylesheetExecutionContextDefault theExecutionContext(processor,
+ theXSLProcessorSupport,
+ theDOMSupport,
+ theXObjectFactory);
+
+#if defined(XALAN_USE_ICU)
+ ICUBridgeCollationCompareFunctor theICUFunctor;
+
+ theExecutionContext.installCollationCompareFunctor(&theICUFunctor);
+#endif
+
+ if (params.useDOM == false)
+ {
+ theXalanSourceTreeParserLiaison.setExecutionContext(theExecutionContext);
+ }
+ else
+ {
+ theXercesParserLiaison.setExecutionContext(theExecutionContext);
+ }
+
+ if (stylesheet == 0)
+ {
+ // No stylesheet, so our only hope is that the xml file has
+ // PI with the stylesheet...
+
+ // Dummy input source...
+ XSLTInputSource theStylesheetSource;
+
+ processor.process(
+ theInputSource,
+ theStylesheetSource,
+ rTreeTarget,
+ theConstructionContext,
+ theExecutionContext);
+ }
+ else
+ {
+ theExecutionContext.setStylesheetRoot(stylesheet);
+
+ processor.process(
+ theInputSource,
+ rTreeTarget,
+ theExecutionContext);
+ }
+
+ if (params.outputType == FormatterListener::OUTPUT_METHOD_DOM)
+ {
+ // Output is to DOM, so we have to format to XML to
+ // produce output...
+ assert(rTreeTarget.getFormatterListener() != 0 &&
+ rTreeTarget.getFormatterListener()->getOutputFormat() ==
+ FormatterListener::OUTPUT_METHOD_DOM);
+
+ if (theResultDocument == 0)
+ {
+ cerr << endl << "Error: No document to format!!!" << endl;
+ }
+ else
+ {
+ // Create a FormaterToXML with the required output
+ // options...
+ const XalanAutoPtr<FormatterListener> formatter(
+ createFormatter(
+ FormatterListener::OUTPUT_METHOD_XML,
+ params.shouldWriteXMLHeader,
+ params.stripCData,
+ params.escapeCData,
+ params.noIndent,
+ false,
+ false,
+ resultWriter,
+ xmlParserLiaison.getIndent(),
+ mimeEncoding,
+ stylesheet,
+ xmlParserLiaison,
+ theXalanSourceTreeParserLiaison,
+ processor,
+ theResultDocument));
+
+ // Create a FormatterTreeWalker with the the
+ // new formatter...
+ FormatterTreeWalker theTreeWalker(*formatter.get());
+
+ // Walk the document and produce the XML...
+ theTreeWalker.traverse(theResultDocument);
+ }
+ }
+
+ theExecutionContext.reset();
+
+ theConstructionContext.reset();
+ theStylesheetXPathFactory.reset();
+
+ processor.reset();
+
+ theXPathFactory.reset();
+ theXObjectFactory.reset();
+ theXSLProcessorSupport.reset();
+ theDOMSupport.reset();
+
+ xmlParserLiaison.reset();
+
+ return 0;
+}
+
+
+
+int
+main(
+ int argc,
+ const char* argv[])
+{
+#if !defined(XALAN_USE_ICU) && !defined(NDEBUG) && defined(_MSC_VER)
+ _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
+
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+#endif
+
+#if defined(XALAN_VQ_SPECIAL_TRACE)
+ QuantifyStopRecordingData();
+#endif
+
+ int theResult = 0;
+
+ CmdLineParams theParams;
+
+ /*
+ * Get command line arguments
+ */
+ if (getArgs(argc, argv, theParams) == false)
+ {
+ printArgOptions();
+ }
+ else if (theParams.versionOnly == true)
+ {
+ cout << endl
+ << "TestXSLT version 1.2.0 (Xalan C++ version 1.2.0)"
+ << endl;
+ }
+ else
+ {
+ XMLPlatformUtils::Initialize();
+
+ try
+ {
+ theResult = xsltMain(theParams);
+ }
+ catch (XSLException& e)
+ {
+ cout << "\nXSLException ";
+
+ cout << "Type is: " << e.getType() << endl;
+
+ cout << "Message is: " << e.getMessage() << " (";
+
+ const XalanDOMString& theURI = e.getURI();
+
+ if (length(theURI) != 0)
+ {
+ cout << theURI;
+ }
+ else
+ {
+ cout << "Unknown URI";
+ }
+
+ const int theLineNumber = e.getLineNumber();
+
+ if (theLineNumber != -1)
+ {
+ cout << ", line " << theLineNumber;
+ }
+ else
+ {
+ cout << ", unknown line";
+ }
+
+ const int theColumnNumber = e.getColumnNumber();
+
+ if (theColumnNumber != -1)
+ {
+ cout << ", column " << theColumnNumber;
+ }
+ else
+ {
+ cout << ", unknown column";
+ }
+
+ cout << ")" << endl;
+
+ theResult = -1;
+ }
+ catch (SAXException& e)
+ {
+ cout << "\nSAXException ";
+
+ cout << "Message is: " << e.getMessage() << endl;
+
+ theResult = -2;
+ }
+ catch (XMLException& e)
+ {
+ cout << "\nXMLException ";
+
+ cout << "Type is: " << e.getType() << endl;
+
+ cout << "Message is: " << e.getMessage() << endl;
+
+ theResult = -3;
+ }
+ catch(const XalanDOMException& e)
+ {
+ cout << endl
+ << "XalanDOMException caught. The code is "
+ << int(e.getExceptionCode())
+ << "."
+ << endl;
+
+ theResult = -4;
+ }
+ catch (...)
+ {
+ cout << "\nUnhandled Exception\n";
+
+ theResult = -5;
+ }
+
+#if !defined(NDEBUG)
+ const size_t theInstanceCount =
+ XalanNode::getInstanceCount();
+
+ if (theInstanceCount > 0)
+ {
+ cout << "There are "
+ << XalanNode::getInstanceCount()
+ << " XalanNode instances still alive!"
+ << endl
+ << endl
+ << "A dump of these instances follows..."
+ << endl
+ << endl;
+
+ typedef vector<XalanNode*> NodeVectorType;
+
+ NodeVectorType theNodes(theInstanceCount, NodeVectorType::value_type(0));
+
+ XalanNode::getLiveInstances(&*theNodes.begin());
+
+ for(unsigned int i = 0; i < theInstanceCount; ++i)
+ {
+ const XalanNode* const theInstance = theNodes[i];
+
+ if(theInstance == 0)
+ {
+ cout << "No instance information is available..."
+ << endl;
+ }
+ else
+ {
+ cout << "("
+ << hex
+ << theInstance
+ << ") Node name: \""
+ << theInstance->getNodeName()
+ << "\" Node value: \""
+ << theInstance->getNodeValue()
+ << "\""
+#if defined(XALAN_RTTI_AVAILABLE) && !defined(XALAN_NO_TYPEINFO)
+ << " Type: \""
+ << typeid(*theInstance).name()
+ << "\""
+#endif
+ << endl
+ << endl;
+ }
+ }
+ }
+#endif
+
+ XMLPlatformUtils::Terminate();
+ }
+
+ return theResult;
+}
diff --git a/src/XSLT/Stylesheet.cpp b/src/XSLT/Stylesheet.cpp
new file mode 100644
index 0000000..a6084ca
--- /dev/null
+++ b/src/XSLT/Stylesheet.cpp
@@ -0,0 +1,1866 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $ Id: $
+ *
+ */
+
+#include "Stylesheet.hpp"
+
+
+
+#include <algorithm>
+
+
+
+#include <sax/AttributeList.hpp>
+
+
+
+#include <Include/STLHelper.hpp>
+
+
+
+#include <XalanDOM/XalanDOMException.hpp>
+
+
+
+#include <DOMSupport/DOMServices.hpp>
+
+
+
+#include <XMLSupport/XMLParserLiaison.hpp>
+
+
+
+#include <XPath/ElementPrefixResolverProxy.hpp>
+#include <XPath/XObject.hpp>
+#include <XPath/XPath.hpp>
+#include <XPath/XalanQNameByReference.hpp>
+
+
+
+#include "Constants.hpp"
+#include "ElemAttributeSet.hpp"
+#include "ElemDecimalFormat.hpp"
+#include "ElemTemplate.hpp"
+#include "ElemTemplateElement.hpp"
+#include "ElemVariable.hpp"
+#include "ExtensionNSHandler.hpp"
+#include "KeyTable.hpp"
+#include "StylesheetConstructionContext.hpp"
+#include "StylesheetExecutionContext.hpp"
+#include "StylesheetRoot.hpp"
+
+
+
+const Stylesheet::NamespaceVectorType Stylesheet::s_emptyNamespace;
+
+
+
+const XalanDOMString Stylesheet::s_emptyString;
+
+const XalanQNameByReference Stylesheet::s_emptyQName;
+
+const XalanEmptyNamedNodeMap Stylesheet::s_fakeAttributes;
+
+
+
+Stylesheet::Stylesheet(
+ StylesheetRoot& root,
+ const XalanDOMString& baseIdentifier,
+ StylesheetConstructionContext& constructionContext) :
+ XalanDocument(),
+ PrefixResolver(),
+ m_stylesheetRoot(root),
+ m_baseIdent(baseIdentifier),
+ m_keyDeclarations(),
+ m_XSLTNamespaceURI(constructionContext.getXSLTNamespaceURI()),
+ m_whitespacePreservingElements(),
+ m_whitespaceStrippingElements(),
+ m_imports(),
+ m_importsSize(0),
+ m_namespaces(),
+ m_namespaceDecls(),
+ m_isWrapperless(false),
+ m_wrapperlessTemplate(0),
+ m_extensionNamespaces(),
+ m_firstTemplate(0),
+ m_includeStack(),
+ m_namedTemplates(),
+ m_topLevelVariables(),
+ m_XSLTVerDeclared(1.0L),
+ m_isRoot(&root == this ? true: false),
+ m_patternTable(),
+ m_patternTableEnd(m_patternTable.end()),
+ m_textPatternList(),
+ m_commentPatternList(),
+ m_rootPatternList(),
+ m_piPatternList(),
+ m_nodePatternList(),
+ m_anyPatternList(),
+ m_matchPattern2Container(),
+ m_patternCount(0),
+ m_attributeSets(),
+ m_attributeSetsSize(0),
+ m_surrogateChildren(*this),
+ m_elemDecimalFormats(),
+ m_prefixAliases(),
+ m_namespacesHandler()
+{
+ if (length(m_baseIdent) == 0)
+ {
+ m_includeStack.push_back(m_baseIdent);
+ }
+ else
+ {
+ try
+ {
+ const XalanDOMString urlString = constructionContext.getURLStringFromString(m_baseIdent);
+
+ if (length(urlString) != 0)
+ {
+ m_includeStack.push_back(urlString);
+
+ m_baseIdent = urlString;
+ }
+ }
+ catch(const XMLException&)
+ {
+ // Assume that any exception here relates to get the urlString from
+ // m_baseIdent. We'll assume that it's just a fake base identifier
+ // since the parser will throw the real error if the base identifier
+ // can't be resolved.
+ m_includeStack.push_back(baseIdentifier);
+ }
+ }
+}
+
+
+
+Stylesheet::~Stylesheet()
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ // Clean up all entries in the imports vector.
+ for_each(m_imports.begin(),
+ m_imports.end(),
+ DeleteFunctor<Stylesheet>());
+
+ // Clean up the atribute sets vector
+ for_each(m_attributeSets.begin(),
+ m_attributeSets.end(),
+ DeleteFunctor<ElemAttributeSet>());
+
+ // Clean up the top-level variables vector
+ for_each(m_topLevelVariables.begin(),
+ m_topLevelVariables.end(),
+ DeleteFunctor<ElemVariable>());
+
+ // Clean up the decimal formats vector
+ for_each(m_elemDecimalFormats.begin(),
+ m_elemDecimalFormats.end(),
+ DeleteFunctor<ElemDecimalFormat>());
+
+ // Clean up the extension namespaces vector
+ for_each(m_extensionNamespaces.begin(),
+ m_extensionNamespaces.end(),
+ MapValueDeleteFunctor<ExtensionNamespacesMapType>());
+
+ delete m_wrapperlessTemplate;
+
+ delete m_firstTemplate;
+}
+
+
+
+void
+Stylesheet::processKeyElement(
+ ElemTemplateElement* nsContext,
+ const AttributeList& atts,
+ StylesheetConstructionContext& constructionContext)
+{
+ const XalanDOMChar* nameAttr = 0;
+ XPath* matchAttr = 0;
+ XPath* useAttr = 0;
+
+ const unsigned int nAttrs = atts.getLength();
+
+ for(unsigned int i = 0; i < nAttrs; i++)
+ {
+ const XalanDOMChar* const aname = atts.getName(i);
+
+ if (equals(aname, Constants::ATTRNAME_NAME))
+ {
+ nameAttr = atts.getValue(i);
+ }
+ else if(equals(aname, Constants::ATTRNAME_MATCH))
+ {
+ matchAttr =
+ constructionContext.createMatchPattern(
+ 0,
+ XalanDOMString(atts.getValue(i)),
+ *nsContext);
+ }
+ else if(equals(aname, Constants::ATTRNAME_USE))
+ {
+ useAttr =
+ constructionContext.createXPath(
+ 0,
+ atts.getValue(i),
+ *nsContext);
+ }
+ else if (isAttrOK(aname, atts, i, constructionContext) == false)
+ {
+ constructionContext.error(
+ TranscodeFromLocalCodePage("xsl:key, unrecognized keyword '") +
+ aname +
+ TranscodeFromLocalCodePage("'!"));
+ }
+ }
+
+ if(0 == nameAttr)
+ constructionContext.error(TranscodeFromLocalCodePage("xsl:key requires a ") + Constants::ATTRNAME_NAME + " attribute!");
+
+ if(0 == matchAttr)
+ constructionContext.error(TranscodeFromLocalCodePage("xsl:key requires a ") + Constants::ATTRNAME_MATCH + " attribute!");
+
+ if(0 == useAttr)
+ constructionContext.error(TranscodeFromLocalCodePage("xsl:key requires a ") + Constants::ATTRNAME_USE + " attribute!");
+
+ m_keyDeclarations.push_back(KeyDeclaration(XalanDOMString(nameAttr), *matchAttr, *useAttr));
+}
+
+
+
+void
+Stylesheet::pushNamespaces(const AttributeList& atts)
+{
+ const unsigned int nAttrs = atts.getLength();
+
+ NamespaceVectorType namespaces;
+
+ for(unsigned int i = 0; i < nAttrs; i++)
+ {
+ const XalanDOMChar* const aname = atts.getName(i);
+ const XalanDOMChar* const value = atts.getValue(i);
+
+ const bool isPrefix = startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator);
+
+ if (equals(aname, DOMServices::s_XMLNamespace) || isPrefix)
+ {
+ const XalanDOMString p = isPrefix ? substring(aname, 6) : XalanDOMString();
+
+ namespaces.push_back(NameSpace(p, XalanDOMString(value)));
+ }
+ }
+
+ m_namespaces.push_back(namespaces);
+}
+
+
+
+class attrSetCompare
+{
+public:
+
+ attrSetCompare(const ElemAttributeSet& theAttrSet) :
+ m_attrSet(theAttrSet)
+ {
+ }
+
+ bool
+ operator()(const ElemAttributeSet* theRHS) const
+ {
+ assert(theRHS != 0);
+
+ return m_attrSet == *theRHS;
+ }
+
+private:
+
+ const ElemAttributeSet& m_attrSet;
+};
+
+
+
+void
+Stylesheet::postConstruction(StylesheetConstructionContext& constructionContext)
+{
+ {
+ m_importsSize = m_imports.size();
+
+ // Call postConstruction() on any imported stylesheets, the get any aliases
+ // in reverse order, to preserve import precedence. Also, get any key declarations.
+ const StylesheetVectorType::reverse_iterator theEnd = m_imports.rend();
+ StylesheetVectorType::reverse_iterator i = m_imports.rbegin();
+
+ while(i != theEnd)
+ {
+ (*i)->postConstruction(constructionContext);
+
+ m_namespacesHandler.copyNamespaceAliases((*i)->getNamespacesHandler());
+
+ // $$ ToDo: Should we clear the imported stylesheet's key
+ // declarations after we copy them?
+ m_keyDeclarations.insert(
+ m_keyDeclarations.end(),
+ (*i)->m_keyDeclarations.begin(),
+ (*i)->m_keyDeclarations.end());
+
+ ++i;
+ }
+ }
+
+ // Call postConstruction() on our own namespaces handler...
+ m_namespacesHandler.postConstruction();
+
+
+ {
+ for (ElemTemplateElement* node = m_firstTemplate;
+ node != 0;
+ node = node->getNextSiblingElem())
+ {
+ node->postConstruction(constructionContext, m_namespacesHandler);
+ }
+ }
+
+ {
+ for (ElemVariableVectorType::iterator it = m_topLevelVariables.begin();
+ it != m_topLevelVariables.end();
+ ++it)
+ {
+ (*it)->postConstruction(constructionContext, m_namespacesHandler);
+ }
+ }
+
+ {
+ for (ElemTemplateElement* node = m_wrapperlessTemplate;
+ node != 0;
+ node = node->getNextSiblingElem())
+ {
+ node->postConstruction(constructionContext, m_namespacesHandler);
+ }
+ }
+
+ {
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find_if;
+#endif
+ for (AttributeSetVectorType::size_type i = 0; i < m_attributeSets.size(); ++i)
+ {
+ ElemAttributeSet* const theCurrent = m_attributeSets[i];
+
+ assert(theCurrent != 0);
+
+ for(;;)
+ {
+ // Look for duplicate sets...
+ const AttributeSetVectorType::iterator theResult =
+ find_if(
+ m_attributeSets.begin() + (i + 1),
+ m_attributeSets.end(),
+ attrSetCompare(*theCurrent));
+
+ // Did we find it?
+ if(theResult == m_attributeSets.end())
+ {
+ break;
+ }
+ else
+ {
+ theCurrent->adopt(**theResult);
+
+ delete *theResult;
+
+ m_attributeSets.erase(theResult);
+ }
+ }
+
+ theCurrent->postConstruction(constructionContext, m_namespacesHandler);
+ }
+
+ // Now that we're done with removing duplicates, cache the size...
+ m_attributeSetsSize = m_attributeSets.size();
+ }
+
+ // OK, now we need to add everything template that matches "node()"
+ // to the end of the text, comment, and PI template lists.
+ PatternTableListType::iterator theBegin = m_nodePatternList.begin();
+ PatternTableListType::iterator theEnd = m_nodePatternList.end();
+
+ if (theBegin != theEnd)
+ {
+ m_textPatternList.insert(
+ m_textPatternList.end(),
+ theBegin,
+ theEnd);
+
+ m_commentPatternList.insert(
+ m_commentPatternList.end(),
+ theBegin,
+ theEnd);
+
+ m_piPatternList.insert(
+ m_piPatternList.end(),
+ theBegin,
+ theEnd);
+ }
+
+ m_nodePatternList.insert(
+ theEnd,
+ m_anyPatternList.begin(),
+ m_anyPatternList.end());
+
+ theBegin = m_nodePatternList.begin();
+ theEnd = m_nodePatternList.end();
+
+ if (theBegin != theEnd)
+ {
+ PatternTableMapType::iterator i =
+ m_patternTable.begin();
+
+ while(i != m_patternTable.end())
+ {
+ PatternTableListType& theTable = (*i).second;
+
+ theTable.insert(
+ theTable.end(),
+ theBegin,
+ theEnd);
+
+ ++i;
+ }
+ }
+
+ m_patternCount = m_matchPattern2Container.size();
+}
+
+
+
+bool
+Stylesheet::isAttrOK(
+ const XalanDOMChar* attrName,
+ const AttributeList& /* atts */,
+ int /* which */,
+ StylesheetConstructionContext& constructionContext) const
+{
+ // Namespace declarations are OK by definition
+ bool attrOK = equals(attrName, DOMServices::s_XMLNamespace) ||
+ startsWith(attrName, DOMServices::s_XMLNamespaceWithSeparator);
+
+ if(!attrOK)
+ {
+ // Others are OK if their prefix has been
+ // bound to a non-null Namespace URI other than XSLT's
+ const unsigned int indexOfNSSep = indexOf(attrName, XalanUnicode::charColon);
+
+ if(indexOfNSSep < length(attrName))
+ {
+ const XalanDOMString prefix = substring(attrName, 0, indexOfNSSep);
+ const XalanDOMString* ns = getNamespaceForPrefixFromStack(prefix);
+
+ attrOK = ns != 0 && !::isEmpty(*ns) && !equals(*ns, constructionContext.getXSLTNamespaceURI());
+ }
+ else
+ {
+ attrOK = false;
+ }
+ }
+
+ return attrOK;
+}
+
+
+
+const XalanDOMString*
+Stylesheet::getNamespaceFromStack(const XalanDOMChar* nodeName) const
+{
+ assert(nodeName != 0);
+
+ const unsigned int indexOfNSSep = indexOf(nodeName, XalanUnicode::charColon);
+
+ const XalanDOMString prefix =
+ indexOfNSSep < length(nodeName) ?
+ substring(nodeName, 0, indexOfNSSep) :
+ XalanDOMString();
+
+ return getNamespaceForPrefixFromStack(prefix);
+}
+
+
+
+bool
+Stylesheet::getYesOrNo(
+ const XalanDOMChar* aname,
+ const XalanDOMChar* val,
+ StylesheetConstructionContext& constructionContext) const
+{
+ if(equals(val, Constants::ATTRVAL_YES))
+ {
+ return true;
+ }
+ else if(equals(val, Constants::ATTRVAL_NO))
+ {
+ return false;
+ }
+ else
+ {
+ constructionContext.error(XalanDOMString(val) + " is unknown value for " + aname);
+
+ return false;
+ }
+}
+
+
+
+void
+Stylesheet::addTemplate(
+ ElemTemplate* theTemplate,
+ StylesheetConstructionContext& constructionContext)
+{
+ assert(theTemplate != 0);
+
+ unsigned int pos = 0;
+
+ if(0 == m_firstTemplate)
+ {
+ m_firstTemplate = theTemplate;
+ }
+ else
+ {
+ ElemTemplateElement* next = m_firstTemplate;
+
+ // Find the last one, then append the new one.
+ while(0 != next)
+ {
+ if(0 == next->getNextSiblingElem())
+ {
+ next->setNextSiblingElem(theTemplate);
+ theTemplate->setNextSiblingElem(0); // just to play it safe.
+ theTemplate->setPreviousSiblingElem(next);
+ break;
+ }
+
+ pos++;
+
+ next = next->getNextSiblingElem();
+ }
+ }
+
+ // If it's a named template, then we need to
+ // and it to the map of named templates.
+ const XalanQName& theName = theTemplate->getName();
+
+ if(theName.isEmpty() == false)
+ {
+ if (m_namedTemplates.find(theName) == m_namedTemplates.end())
+ {
+ m_namedTemplates[theName] = theTemplate;
+ }
+ else
+ {
+ // This is an error...
+ XalanDOMString theMessage(TranscodeFromLocalCodePage("The stylesheet already has a template with the name "));
+
+ const XalanDOMString& theNamespace = theName.getNamespace();
+
+ if (length(theNamespace) != 0)
+ {
+ theMessage += theNamespace;
+ theMessage += DOMServices::s_XMLNamespaceSeparatorString;
+ }
+
+ theMessage += theName.getLocalPart();
+
+ constructionContext.error(theMessage, 0, theTemplate);
+ }
+ }
+
+ // Now, process the match pattern associated with the
+ // template.
+ const XPath* const xp = theTemplate->getMatchPattern();
+
+ if(0 != xp)
+ {
+ /* Each string has a list of pattern tables associated with it; if the
+ * string is not in the map, then create a list of pattern tables with one
+ * entry for the string, otherwise add to the existing pattern table list
+ * for that string
+ */
+ typedef XPath::TargetElementStringsVectorType TargetElementStringsVectorType;
+
+ TargetElementStringsVectorType strings;
+
+ xp->getTargetElementStrings(strings);
+
+ TargetElementStringsVectorType::size_type nTargets =
+ strings.size();
+
+ if(nTargets != 0)
+ {
+ for(TargetElementStringsVectorType::size_type stringIndex = 0;
+ stringIndex < nTargets; stringIndex++)
+ {
+ const XalanDOMString& target = strings[stringIndex];
+
+ m_matchPattern2Container.push_back(
+ MatchPattern2(
+ *theTemplate,
+ pos,
+ target,
+ *xp,
+ xp->getExpression().getCurrentPattern()));
+
+ const MatchPattern2* const newMatchPat =
+ &m_matchPattern2Container.back();
+
+ // Always put things on the front of the list, so
+ // templates later in the stylesheet are always
+ // selected first.
+ if (equals(target, XPath::PSEUDONAME_TEXT) == true)
+ {
+ m_textPatternList.insert(
+ m_textPatternList.begin(),
+ newMatchPat);
+ }
+ else if (equals(target, XPath::PSEUDONAME_COMMENT) == true)
+ {
+ m_commentPatternList.insert(
+ m_commentPatternList.begin(),
+ newMatchPat);
+ }
+ else if (equals(target, XPath::PSEUDONAME_ROOT) == true)
+ {
+ m_rootPatternList.insert(
+ m_rootPatternList.begin(),
+ newMatchPat);
+ }
+ else if (equals(target, XPath::PSEUDONAME_PI) == true)
+ {
+ m_piPatternList.insert(
+ m_piPatternList.begin(),
+ newMatchPat);
+ }
+ else if (equals(target, XPath::PSEUDONAME_NODE) == true)
+ {
+ m_nodePatternList.insert(
+ m_nodePatternList.begin(),
+ newMatchPat);
+ }
+ else if (equals(target, XPath::PSEUDONAME_ANY) == true)
+ {
+ m_anyPatternList.insert(
+ m_anyPatternList.begin(),
+ newMatchPat);
+ }
+ else
+ {
+ // Put it in the map.
+ PatternTableListType& theTable =
+ m_patternTable[target];
+
+ theTable.insert(
+ theTable.begin(),
+ newMatchPat);
+ }
+ }
+ }
+ }
+}
+
+
+
+const ElemTemplate*
+Stylesheet::findNamedTemplate(const XalanQName& qname) const
+{
+ ElemTemplateMapType::const_iterator it = m_namedTemplates.find(qname);
+
+ if(it != m_namedTemplates.end())
+ {
+ return (*it).second;
+ }
+ else
+ {
+ const ElemTemplate* namedTemplate = 0;
+
+ // Look for the template in the imports
+ const StylesheetVectorType::size_type nImports = m_imports.size();
+
+ for(StylesheetVectorType::size_type i = 0; i < nImports; ++i)
+ {
+ const Stylesheet* const stylesheet = m_imports[i];
+
+ namedTemplate = stylesheet->findNamedTemplate(qname);
+
+ if(0 != namedTemplate)
+ break;
+ }
+
+ return namedTemplate;
+ }
+}
+
+
+
+void
+Stylesheet::addObjectIfNotFound(
+ const MatchPattern2* thePattern,
+ PatternTableVectorType& theVector)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ const PatternTableVectorType::const_iterator theResult =
+ find(
+ theVector.begin(),
+ theVector.end(),
+ thePattern);
+
+ // Did we find it?
+ if(theResult == theVector.end())
+ {
+ theVector.push_back(thePattern);
+ }
+}
+
+
+
+inline void
+Stylesheet::addObjectIfNotFound(
+ const MatchPattern2* thePattern,
+ const MatchPattern2* thePatternArray[],
+ unsigned int& thePatternArraySize)
+{
+ if (thePatternArraySize == 0)
+ {
+ thePatternArray[0] = thePattern;
+
+ ++thePatternArraySize;
+ }
+ else
+ {
+ unsigned int i = 0;
+
+ while(i < thePatternArraySize)
+ {
+ if (thePatternArray[i] != thePattern)
+ {
+ ++i;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (i == thePatternArraySize)
+ {
+ thePatternArray[thePatternArraySize++] = thePattern;
+ }
+ }
+}
+
+
+
+inline const Stylesheet::PatternTableListType*
+Stylesheet::locateMatchPatternList2(const XalanDOMString& theName) const
+{
+ assert(m_patternTableEnd == m_patternTable.end());
+
+ const PatternTableMapType::const_iterator i =
+ m_patternTable.find(theName);
+
+ if (i != m_patternTableEnd)
+ {
+ return &(*i).second;
+ }
+ else
+ {
+ return &m_nodePatternList;
+ }
+}
+
+
+
+inline const Stylesheet::PatternTableListType*
+Stylesheet::locateMatchPatternList2(const XalanNode& theNode) const
+{
+ switch(theNode.getNodeType())
+ {
+ case XalanNode::ELEMENT_NODE:
+ return locateMatchPatternList2(DOMServices::getLocalNameOfNode(theNode));
+ break;
+
+ case XalanNode::PROCESSING_INSTRUCTION_NODE:
+ return &m_piPatternList;
+ break;
+
+ case XalanNode::ATTRIBUTE_NODE:
+ return locateMatchPatternList2(DOMServices::getLocalNameOfNode(theNode));
+ break;
+
+ case XalanNode::CDATA_SECTION_NODE:
+ case XalanNode::TEXT_NODE:
+ return &m_textPatternList;
+ break;
+
+ case XalanNode::COMMENT_NODE:
+ return &m_commentPatternList;
+ break;
+
+ case XalanNode::DOCUMENT_NODE:
+ return &m_rootPatternList;
+ break;
+
+ case XalanNode::DOCUMENT_FRAGMENT_NODE:
+ return &m_anyPatternList;
+ break;
+ }
+
+ return locateMatchPatternList2(theNode.getNodeName());
+}
+
+
+
+const ElemTemplate*
+Stylesheet::findTemplate(
+ StylesheetExecutionContext& executionContext,
+ XalanNode* targetNode,
+ const XalanQName& mode,
+ bool onlyUseImports) const
+{
+ assert(targetNode != 0);
+ assert(m_patternCount == m_matchPattern2Container.size());
+
+ if(m_isWrapperless == true)
+ {
+ return m_wrapperlessTemplate;
+ }
+ else
+ {
+ const ElemTemplate* bestMatchedRule = 0;
+ const MatchPattern2* bestMatchedPattern = 0; // Syncs with bestMatchedRule
+ const double matchScoreNoneValue =
+ XPath::getMatchScoreValue(XPath::eMatchScoreNone);
+
+ double bestMatchPatPriority = matchScoreNoneValue;
+
+
+ unsigned int nConflicts = 0;
+
+ // Use a stack-based array when possible...
+ const MatchPattern2* conflictsArray[100];
+
+ XalanArrayAutoPtr<const MatchPattern2*> conflictsVector;
+
+ const MatchPattern2** conflicts = 0;
+
+ if(onlyUseImports == false)
+ {
+ // Points to the current list of match patterns. Note
+ // that this may point to more than one table.
+ const PatternTableListType* matchPatternList =
+ locateMatchPatternList2(*targetNode);
+ assert(matchPatternList != 0);
+
+ PatternTableListType::const_iterator theCurrentEntry =
+ matchPatternList->begin();
+
+ const PatternTableListType::const_iterator theTableEnd =
+ matchPatternList->end();
+
+ if (theCurrentEntry != theTableEnd)
+ {
+ const XalanDOMString* prevPat = 0;
+ const MatchPattern2* prevMatchPat = 0;
+ double prevMatchPatPriority = matchScoreNoneValue;
+
+ do
+ {
+ const MatchPattern2* matchPat = *theCurrentEntry;
+ double matchPatPriority = matchScoreNoneValue;
+ assert(matchPat != 0);
+
+ const ElemTemplate* const rule = matchPat->getTemplate();
+ assert(rule != 0);
+
+ // We'll be needing to match rules according to what
+ // mode we're in.
+ const XalanQName& ruleMode = rule->getMode();
+
+ // The logic here should be that if we are not in a mode AND
+ // the rule does not have a node, then go ahead.
+ // OR if we are in a mode, AND the rule has a node,
+ // AND the rules match, then go ahead.
+ const bool haveMode = !mode.isEmpty();
+ const bool haveRuleMode = !ruleMode.isEmpty();
+
+ if ((!haveMode && !haveRuleMode) ||
+ (haveMode && haveRuleMode && ruleMode.equals(mode)))
+ {
+ const XalanDOMString* patterns = matchPat->getPattern();
+ assert(patterns != 0);
+
+ if(!isEmpty(*patterns) &&
+ !(prevMatchPat != 0 &&
+ (prevPat != 0 && equals(*prevPat, *patterns)) &&
+ prevMatchPat->getTemplate()->getPriority() == matchPat->getTemplate()->getPriority()))
+ {
+ prevPat = patterns;
+ prevMatchPat = matchPat;
+ prevMatchPatPriority = matchPatPriority;
+ matchPatPriority = matchScoreNoneValue;
+
+ const XPath* const xpath = matchPat->getExpression();
+
+ XPath::eMatchScore score =
+ xpath->getMatchScore(targetNode, *this, executionContext);
+
+ if(XPath::eMatchScoreNone != score)
+ {
+ const double priorityVal = rule->getPriority();
+ const double priorityOfRule
+ = (matchScoreNoneValue != priorityVal)
+ ? priorityVal : XPath::getMatchScoreValue(score);
+
+ matchPatPriority = priorityOfRule;
+ const double priorityOfBestMatched =
+ (0 != bestMatchedPattern) ?
+ bestMatchPatPriority :
+ matchScoreNoneValue;
+
+ if(priorityOfRule > priorityOfBestMatched)
+ {
+ nConflicts = 0;
+
+ bestMatchedRule = rule;
+ bestMatchedPattern = matchPat;
+ bestMatchPatPriority = matchPatPriority;
+ }
+ else if(priorityOfRule == priorityOfBestMatched)
+ {
+ if (conflicts == 0)
+ {
+ if (m_patternCount > sizeof(conflictsArray) / sizeof(conflictsArray[0]))
+ {
+ conflictsVector.reset(new const MatchPattern2*[m_patternCount]);
+
+ conflicts = conflictsVector.get();
+ }
+ else
+ {
+ conflicts = conflictsArray;
+ }
+ }
+
+ assert(conflicts != 0);
+
+ // Add the best matched pattern so far.
+ addObjectIfNotFound(bestMatchedPattern, conflicts, nConflicts);
+
+ // Add the pattern that caused the conflict...
+ conflicts[nConflicts++] = matchPat;
+
+ bestMatchedRule = rule;
+ bestMatchedPattern = matchPat;
+ bestMatchPatPriority = matchPatPriority;
+ }
+ }
+ }
+ }
+
+ ++theCurrentEntry;
+
+ } while(theCurrentEntry != theTableEnd);
+ }
+ } // end if(useImports == false)
+
+ if(0 == bestMatchedRule)
+ {
+ assert(m_importsSize == m_imports.size());
+
+ for(unsigned int i = 0; i < m_importsSize; i++)
+ {
+ const Stylesheet* const stylesheet =
+ m_imports[i];
+
+ bestMatchedRule = stylesheet->findTemplate(executionContext,
+ targetNode,
+ mode,
+ false);
+ if(0 != bestMatchedRule)
+ break;
+ }
+ }
+
+ if(nConflicts > 0)
+ {
+ assert(conflicts != 0);
+
+ const bool quietConflictWarnings = executionContext.getQuietConflictWarnings();
+
+ XalanDOMString conflictsString;
+
+ if (quietConflictWarnings == false)
+ {
+ conflictsString = XALAN_STATIC_UCODE_STRING("Specificity conflicts found: ");
+ }
+
+ for(unsigned int i = 0; i < nConflicts; i++)
+ {
+ const MatchPattern2* const conflictPat = conflicts[i];
+
+ if(0 != i)
+ {
+ if(quietConflictWarnings == false)
+ {
+ conflictsString += XALAN_STATIC_UCODE_STRING(", ");
+ }
+ // Find the furthest one towards the bottom of the document.
+ if(conflictPat->getPositionInStylesheet() >
+ bestMatchedPattern->getPositionInStylesheet())
+ {
+ bestMatchedPattern = conflictPat;
+ }
+ }
+ else
+ {
+ bestMatchedPattern = conflictPat;
+ }
+
+ if(quietConflictWarnings == false)
+ {
+ conflictsString += XalanDOMString(XALAN_STATIC_UCODE_STRING("\"")) +
+ *conflictPat->getPattern() +
+ XalanDOMString(XALAN_STATIC_UCODE_STRING("\""));
+ }
+ }
+
+ bestMatchedRule = bestMatchedPattern->getTemplate();
+
+ if(quietConflictWarnings == false)
+ {
+ conflictsString += XALAN_STATIC_UCODE_STRING(" ");
+ conflictsString += XALAN_STATIC_UCODE_STRING("Last found in stylesheet will be used.");
+ executionContext.warn(conflictsString);
+ }
+ }
+
+ return bestMatchedRule;
+ }
+}
+
+
+
+void
+Stylesheet::addExtensionNamespace(
+ const XalanDOMString& uri,
+ ExtensionNSHandler* nsh)
+{
+ m_extensionNamespaces.insert(ExtensionNamespacesMapType::value_type(uri, nsh));
+
+ m_namespacesHandler.addExtensionNamespaceURI(uri);
+}
+
+
+
+void
+Stylesheet::pushTopLevelVariables(
+ StylesheetExecutionContext& executionContext,
+ const ParamVectorType& topLevelParams) const
+{
+ {
+ // First, push any imports...
+ const StylesheetVectorType::const_reverse_iterator rend = m_imports.rend();
+
+ for(StylesheetVectorType::const_reverse_iterator i = m_imports.rbegin(); i != rend; ++i)
+ {
+ const Stylesheet* const stylesheet = *i;
+ assert(stylesheet != 0);
+
+ stylesheet->pushTopLevelVariables(executionContext, topLevelParams);
+ }
+ }
+
+ const ParamVectorType::size_type nVars = m_topLevelVariables.size();
+
+ for(ParamVectorType::size_type i = 0; i < nVars; ++i)
+ {
+ ElemVariable* const var = m_topLevelVariables[i];
+
+ bool isParam =
+ Constants::ELEMNAME_PARAMVARIABLE == var->getXSLToken();
+
+ if(isParam == true)
+ {
+ isParam = false;
+
+ const ParamVectorType::size_type n = topLevelParams.size();
+
+ for(ParamVectorType::size_type k = 0; k < n; k++)
+ {
+ const ParamVectorType::value_type& arg = topLevelParams[k];
+
+ if(arg.getName().equals(var->getName()))
+ {
+ isParam = true;
+
+ if (arg.getXObject().null() == false)
+ {
+ executionContext.pushVariable(
+ arg.getName(),
+ arg.getXObject(),
+ 0);
+ }
+ else
+ {
+ executionContext.pushVariable(
+ arg.getName(),
+ 0,
+ arg.getExpression(),
+ executionContext.getRootDocument(),
+ *this);
+ }
+
+ break;
+ }
+ }
+ }
+
+ if (isParam == false)
+ {
+ executionContext.pushVariable(var->getName(),
+ var,
+ var->getParentNodeElem());
+ }
+ }
+}
+
+
+
+void
+Stylesheet::processNSAliasElement(
+ const XalanDOMChar* name,
+ const AttributeList& atts,
+ StylesheetConstructionContext& constructionContext)
+{
+ const unsigned int nAttrs = atts.getLength();
+
+ const XalanDOMString* stylesheetNamespace = &DOMServices::s_emptyString;
+ const XalanDOMString* resultNamespace = &DOMServices::s_emptyString;
+ const XalanDOMString dummy;
+
+ for(unsigned int i = 0; i < nAttrs; i++)
+ {
+ const XalanDOMChar* const aname = atts.getName(i);
+
+ if(equals(aname, Constants::ATTRNAME_STYLESHEET_PREFIX) == true)
+ {
+ const XalanDOMChar* const value = atts.getValue(i);
+
+ if (equals(value, Constants::ATTRVAL_DEFAULT_PREFIX) == true)
+ {
+ stylesheetNamespace = getNamespaceForPrefix(dummy);
+ }
+ else
+ {
+ stylesheetNamespace = getNamespaceForPrefix(XalanDOMString(value));
+ }
+ }
+ else if(equals(aname, Constants::ATTRNAME_RESULT_PREFIX))
+ {
+ const XalanDOMChar* const value = atts.getValue(i);
+
+ if (equals(value, Constants::ATTRVAL_DEFAULT_PREFIX) == true)
+ {
+ resultNamespace = getNamespaceForPrefix(dummy);
+ }
+ else
+ {
+ resultNamespace = getNamespaceForPrefix(XalanDOMString(value));
+ }
+ }
+ else if(!isAttrOK(aname, atts, i, constructionContext))
+ {
+ constructionContext.error(XalanDOMString(name) + " has an illegal attribute: " + aname);
+ }
+ }
+
+ // Build a table of aliases, the key is the stylesheet uri and the
+ // value is the result uri
+ if (length(*stylesheetNamespace) == 0 ||
+ length(*resultNamespace) == 0)
+ {
+ constructionContext.error("Missing namespace URI for specified prefix");
+ }
+ else
+ {
+#if 1
+ // $$$ ToDo: Enable other code. Perhaps an error?
+ m_prefixAliases[*stylesheetNamespace] = *resultNamespace;
+
+ m_namespacesHandler.setNamespaceAlias(*stylesheetNamespace, *resultNamespace);
+#else
+ const PrefixAliasesMapType::iterator i =
+ m_prefixAliases.find(*stylesheetNamespace);
+
+ if (i != m_prefixAliases.end())
+ {
+ // $$$ ToDo: This could also be an error?
+ (*i).second = *resultNamespace;
+ }
+ else
+ {
+ m_prefixAliases.insert(PrefixAliasesMapType::value_type(*stylesheetNamespace, *resultNamespace));
+ }
+#endif
+ }
+}
+
+
+
+XalanDOMString
+Stylesheet::getAliasNamespaceURI(const XalanDOMChar* uri) const
+{
+ assert(uri != 0);
+
+ return getAliasNamespaceURI(XalanDOMString(uri));
+}
+
+
+
+XalanDOMString
+Stylesheet::getAliasNamespaceURI(const XalanDOMString& uri) const
+{
+ const StringToStringMapType::const_iterator i =
+ m_prefixAliases.find(uri);
+
+ if (i != m_prefixAliases.end())
+ {
+ assert(length((*i).second) > 0);
+
+ return (*i).second;
+ }
+ else
+ {
+ XalanDOMString theResult;
+
+ const StylesheetVectorType::size_type nImports =
+ m_imports.size();
+
+ for(StylesheetVectorType::size_type i = 0; i < nImports; ++i)
+ {
+ theResult = m_imports[i]->getAliasNamespaceURI(uri);
+
+ if(length(theResult) != 0)
+ {
+ break;
+ }
+ }
+
+ return theResult;
+ }
+}
+
+
+
+const XalanDecimalFormatSymbols*
+Stylesheet::getDecimalFormatSymbols(const XalanDOMString& name) const
+{
+ const XalanDecimalFormatSymbols* dfs = 0;
+
+ const ElemDecimalFormatVectorType::size_type theSize =
+ m_elemDecimalFormats.size();
+
+ if(theSize > 0)
+ {
+ // Start from the top of the stack
+ for (int i = theSize - 1; i >= 0; --i)
+ {
+ assert(m_elemDecimalFormats[i] != 0);
+
+ if (equals(m_elemDecimalFormats[i]->getName(), name) == true)
+ {
+ dfs = &m_elemDecimalFormats[i]->getDecimalFormatSymbols();
+
+ break;
+ }
+ }
+ }
+
+ // If dfs is null at this point, it should
+ // mean there wasn't an xsl:decimal-format declared
+ // with the given name. So go up the import hierarchy
+ // and see if one of the imported stylesheets declared
+ // it.
+ if(dfs == 0)
+ {
+ for(StylesheetVectorType::size_type i = 0; i < m_importsSize; ++i)
+ {
+ dfs = m_imports[i]->getDecimalFormatSymbols(name);
+
+ if(dfs != 0)
+ {
+ break;
+ }
+ }
+ }
+
+ return dfs;
+}
+
+
+
+void
+Stylesheet::applyAttrSets(
+ const QNameVectorType& attributeSetsNames,
+ StylesheetExecutionContext& executionContext,
+ XalanNode* sourceNode) const
+{
+ const QNameVectorType::size_type nNames = attributeSetsNames.size();
+
+ if(0 != nNames)
+ {
+ assert(m_importsSize == m_imports.size());
+
+ // Process up the import chain...
+ for(StylesheetVectorType::size_type i = 0; i < m_importsSize; i++)
+ {
+ const Stylesheet* const stylesheet = m_imports[i];
+
+ stylesheet->applyAttrSets(
+ attributeSetsNames,
+ executionContext,
+ sourceNode);
+ }
+
+ for(QNameVectorType::size_type j = 0; j < nNames; j++)
+ {
+ const XalanQName& qname = attributeSetsNames[j];
+
+ assert(m_attributeSetsSize == m_attributeSets.size());
+
+ for(StylesheetVectorType::size_type k = 0; k < m_attributeSetsSize; k++)
+ {
+ const ElemAttributeSet* const attrSet = m_attributeSets[k];
+ assert(attrSet != 0);
+
+ if(qname.equals(attrSet->getQName()))
+ {
+ attrSet->execute(executionContext);
+ }
+ }
+ }
+ }
+}
+
+
+
+const XalanDOMString&
+Stylesheet::getNodeName() const
+{
+ return s_emptyString;
+}
+
+
+
+const XalanDOMString&
+Stylesheet::getNodeValue() const
+{
+ return s_emptyString;
+}
+
+
+
+Stylesheet::NodeType
+Stylesheet::getNodeType() const
+{
+ return XalanNode::DOCUMENT_NODE;
+}
+
+
+
+XalanNode*
+Stylesheet::getParentNode() const
+{
+ return 0;
+}
+
+
+
+const XalanNodeList*
+Stylesheet::getChildNodes() const
+{
+ return &m_surrogateChildren;
+}
+
+
+
+XalanNode*
+Stylesheet::getFirstChild() const
+{
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::getLastChild() const
+{
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::getPreviousSibling() const
+{
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::getNextSibling() const
+{
+ return 0;
+}
+
+
+
+const XalanNamedNodeMap*
+Stylesheet::getAttributes() const
+{
+ return &s_fakeAttributes;
+}
+
+
+
+XalanDocument*
+Stylesheet::getOwnerDocument() const
+{
+ return 0;
+}
+
+
+
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+XalanNode*
+#else
+Stylesheet*
+#endif
+Stylesheet::cloneNode(bool /* deep */) const
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::insertBefore(
+ XalanNode* /* newChild */,
+ XalanNode* /* refChild */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::replaceChild(
+ XalanNode* /* newChild */,
+ XalanNode* /* oldChild */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::removeChild(XalanNode* /* oldChild */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::appendChild(XalanNode* /* oldChild */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+bool
+Stylesheet::hasChildNodes() const
+{
+ // $$$ ToDo: Is this always true?
+ return true;
+}
+
+
+
+void
+Stylesheet::setNodeValue(const XalanDOMString& /* nodeValue */)
+{
+ throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
+}
+
+
+
+void
+Stylesheet::normalize()
+{
+}
+
+
+
+bool
+Stylesheet::supports(
+ const XalanDOMString& /* feature */,
+ const XalanDOMString& /* version */) const
+{
+ return false;
+}
+
+
+
+const XalanDOMString&
+Stylesheet::getNamespaceURI() const
+{
+ // $$ ToDo: Is this the same value as PrefixResolver::getURI()?
+ return s_emptyString;
+}
+
+
+
+const XalanDOMString&
+Stylesheet::getPrefix() const
+{
+ return s_emptyString;
+}
+
+
+
+const XalanDOMString&
+Stylesheet::getLocalName() const
+{
+ return s_emptyString;
+}
+
+
+
+void
+Stylesheet::setPrefix(const XalanDOMString& /* prefix */)
+{
+ throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
+}
+
+
+
+unsigned long
+Stylesheet::getIndex() const
+{
+ return 0;
+}
+
+
+
+XalanElement*
+Stylesheet::createElement(const XalanDOMString& /* tagName */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanDocumentFragment*
+Stylesheet::createDocumentFragment()
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanText*
+Stylesheet::createTextNode(const XalanDOMString& /* data */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanComment*
+Stylesheet::createComment(const XalanDOMString& /* data */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanCDATASection*
+Stylesheet::createCDATASection(const XalanDOMString& /* data */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanProcessingInstruction*
+Stylesheet::createProcessingInstruction(
+ const XalanDOMString& /* target */,
+ const XalanDOMString& /* data */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanAttr*
+Stylesheet::createAttribute(const XalanDOMString& /* name */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanEntityReference*
+Stylesheet::createEntityReference(const XalanDOMString& /* name */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanDocumentType*
+Stylesheet::getDoctype() const
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanDOMImplementation*
+Stylesheet::getImplementation() const
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanElement*
+Stylesheet::getDocumentElement() const
+{
+ // $$$ ToDo: Is this correct?
+
+ return m_wrapperlessTemplate != 0 ? m_wrapperlessTemplate : m_firstTemplate;
+}
+
+
+
+XalanNodeList*
+Stylesheet::getElementsByTagName(const XalanDOMString& /* name */) const
+{
+ return 0;
+}
+
+
+
+XalanNodeList*
+Stylesheet::getElementsByTagNameNS(
+ const XalanDOMString& /* namespaceURI */,
+ const XalanDOMString& /* localName */) const
+{
+ return 0;
+}
+
+
+
+XalanNode*
+Stylesheet::importNode(
+ XalanNode* /* importedNode */,
+ bool /* deep */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanElement*
+Stylesheet::createElementNS(
+ const XalanDOMString& /* namespaceURI */,
+ const XalanDOMString& /* qualifiedName */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanAttr*
+Stylesheet::createAttributeNS(
+ const XalanDOMString& /* namespaceURI */,
+ const XalanDOMString& /* qualifiedName */)
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+XalanElement*
+Stylesheet::getElementById(const XalanDOMString& /* elementId */) const
+{
+ //should not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+bool
+Stylesheet::isIndexed() const
+{
+ // This member functionshould not be called
+ assert(false);
+
+ return false;
+}
+
+
+
+unsigned long
+Stylesheet::getNumber() const
+{
+ // This member functionshould not be called
+ assert(false);
+
+ return 0;
+}
+
+
+
+const XalanDOMString*
+Stylesheet::getNamespaceForPrefix(const XalanDOMString& prefix) const
+{
+ return XalanQName::getNamespaceForPrefix(m_namespaceDecls, prefix);
+}
+
+
+
+const XalanDOMString&
+Stylesheet::getURI() const
+{
+ return m_baseIdent;
+}
diff --git a/src/XSLT/XSLTEngineImpl.cpp b/src/XSLT/XSLTEngineImpl.cpp
new file mode 100644
index 0000000..5ce03dd
--- /dev/null
+++ b/src/XSLT/XSLTEngineImpl.cpp
@@ -0,0 +1,3349 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+
+// Class header file.
+#include "XSLTEngineImpl.hpp"
+
+
+
+#include <sax/DocumentHandler.hpp>
+#include <sax/EntityResolver.hpp>
+#include <sax/Locator.hpp>
+#include <sax/SAXException.hpp>
+#include <util/PlatformUtils.hpp>
+#include <framework/URLInputSource.hpp>
+
+
+
+#include <Include/STLHelper.hpp>
+
+
+
+#include <XalanDOM/XalanDOMException.hpp>
+#include <XalanDOM/XalanNode.hpp>
+#include <XalanDOM/XalanAttr.hpp>
+#include <XalanDOM/XalanComment.hpp>
+#include <XalanDOM/XalanCDATASection.hpp>
+#include <XalanDOM/XalanNodeList.hpp>
+#include <XalanDOM/XalanNamedNodeMap.hpp>
+#include <XalanDOM/XalanProcessingInstruction.hpp>
+#include <XalanDOM/XalanText.hpp>
+
+
+
+#include <PlatformSupport/PrintWriter.hpp>
+#include <PlatformSupport/StringTokenizer.hpp>
+#include <PlatformSupport/XalanUnicode.hpp>
+
+
+
+#include <DOMSupport/DOMServices.hpp>
+#include <DOMSupport/DOMSupport.hpp>
+
+
+
+#include <XMLSupport/FormatterToDOM.hpp>
+#include <XMLSupport/FormatterToText.hpp>
+#include <XMLSupport/FormatterToXML.hpp>
+#include <XMLSupport/FormatterToHTML.hpp>
+#include <XMLSupport/FormatterTreeWalker.hpp>
+#include <XMLSupport/XMLParserLiaison.hpp>
+#include <XMLSupport/FormatterTreeWalker.hpp>
+
+
+
+#include <XPath/ElementPrefixResolverProxy.hpp>
+#include <XPath/XalanQNameByReference.hpp>
+#include <XPath/ResultTreeFrag.hpp>
+#include <XPath/XObject.hpp>
+#include <XPath/XObjectFactory.hpp>
+#include <XPath/XPathEnvSupport.hpp>
+#include <XPath/XPathEnvSupportDefault.hpp>
+#include <XPath/XPathExecutionContextDefault.hpp>
+#include <XPath/XPathFactory.hpp>
+#include <XPath/XPathProcessorImpl.hpp>
+#include <XPath/XResultTreeFrag.hpp>
+
+
+
+#include "Constants.hpp"
+#include "ElemWithParam.hpp"
+#include "FunctionCurrent.hpp"
+#include "FunctionDocument.hpp"
+#include "FunctionElementAvailable.hpp"
+#include "FunctionFunctionAvailable.hpp"
+#include "FunctionFormatNumber.hpp"
+#include "FunctionGenerateID.hpp"
+#include "FunctionKey.hpp"
+#include "FunctionSystemProperty.hpp"
+#include "FunctionUnparsedEntityURI.hpp"
+#include "GenerateEvent.hpp"
+#include "ProblemListener.hpp"
+#include "ProblemListenerDefault.hpp"
+#include "Stylesheet.hpp"
+#include "StylesheetConstructionContext.hpp"
+#include "StylesheetExecutionContext.hpp"
+#include "StylesheetHandler.hpp"
+#include "StylesheetRoot.hpp"
+#include "TraceListener.hpp"
+#include "XSLTInputSource.hpp"
+#include "XSLTProcessorException.hpp"
+#include "XSLTResultTarget.hpp"
+
+
+
+//#define XALAN_VQ_SPECIAL_TRACE
+#if defined(XALAN_VQ_SPECIAL_TRACE)
+#include "C:/Program Files/Rational/Quantify/pure.h"
+#endif
+
+
+
+const XalanDOMString XSLTEngineImpl::s_emptyString;
+
+
+
+//==========================================================
+// SECTION: Constructors
+//==========================================================
+
+XSLTEngineImpl::XSLTEngineImpl(
+ XMLParserLiaison& parserLiaison,
+ XPathEnvSupport& xpathEnvSupport,
+ DOMSupport& domSupport,
+ XObjectFactory& xobjectFactory,
+ XPathFactory& xpathFactory) :
+ XSLTProcessor(),
+ DocumentHandler(),
+ PrefixResolver(),
+ m_useDOMResultTreeFactory(false),
+ m_domResultTreeFactory(0),
+ m_resultNameSpacePrefix(),
+ m_resultNameSpaceURL(),
+ m_xpathFactory(xpathFactory),
+ m_xobjectFactory(xobjectFactory),
+ m_xpathProcessor(new XPathProcessorImpl),
+ m_cdataStack(),
+ m_stylesheetLocatorStack(),
+ m_defaultProblemListener(),
+ m_problemListener(&m_defaultProblemListener),
+ m_stylesheetRoot(0),
+ m_traceSelects(false),
+ m_quietConflictWarnings(false),
+ m_diagnosticsPrintWriter(0),
+ m_durationsTable(),
+ m_traceListeners(),
+ m_uniqueNSValue(0),
+ m_topLevelParams(),
+ m_parserLiaison(parserLiaison),
+ m_xpathEnvSupport(xpathEnvSupport),
+ m_domSupport(domSupport),
+ m_executionContext(0),
+ m_outputContextStack(),
+ m_resultNamespacesStack(),
+ m_dummyAttributesList()
+{
+ m_outputContextStack.pushContext();
+}
+
+
+
+void
+XSLTEngineImpl::reset()
+{
+ m_topLevelParams.clear();
+ m_durationsTable.clear();
+ m_stylesheetLocatorStack.clear();
+ m_cdataStack.clear();
+
+ if (m_domResultTreeFactory != 0)
+ {
+ m_parserLiaison.destroyDocument(m_domResultTreeFactory);
+ m_domResultTreeFactory = 0;
+ }
+
+ m_stylesheetRoot = 0;
+
+ m_outputContextStack.reset();
+
+ m_outputContextStack.pushContext();
+
+ m_xpathEnvSupport.reset();
+ m_xpathFactory.reset();
+ m_xobjectFactory.reset();
+ m_domSupport.reset();
+
+ m_resultNamespacesStack.clear();
+}
+
+
+
+XSLTEngineImpl::~XSLTEngineImpl()
+{
+ reset();
+}
+
+
+
+//==========================================================
+// SECTION: Main API Functions
+//==========================================================
+
+
+
+static const XalanDOMChar s_dummyString = 0;
+
+
+void
+XSLTEngineImpl::process(
+ const XSLTInputSource& inputSource,
+ const XSLTInputSource& stylesheetSource,
+ XSLTResultTarget& outputTarget,
+ StylesheetConstructionContext& constructionContext,
+ StylesheetExecutionContext& executionContext)
+{
+ XalanDOMString xslIdentifier;
+
+ if (0 == stylesheetSource.getSystemId())
+ {
+ xslIdentifier = XalanDOMString(XALAN_STATIC_UCODE_STRING("Input XSL"));
+ }
+ else
+ {
+ xslIdentifier = stylesheetSource.getSystemId();
+ }
+
+ bool totalTimeID = true;
+
+ pushTime(&totalTimeID);
+
+ XalanNode* sourceTree = getSourceTreeFromInput(inputSource);
+
+ m_stylesheetRoot = processStylesheet(stylesheetSource, constructionContext);
+
+ if(0 != sourceTree && m_stylesheetRoot == 0)
+ {
+ // Didn't get a stylesheet from the input source, so look for a
+ // stylesheet processing instruction...
+ XalanDOMString stylesheetURI;
+
+ // The PI must be a child of the document...
+ XalanNode* child = sourceTree->getFirstChild();
+
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::vector;
+#endif
+
+ vector<XalanDOMString> hrefs;
+
+ // $$$ ToDo: is this first one style valid?
+ const XalanDOMString stylesheetNodeName1(XALAN_STATIC_UCODE_STRING("xml-stylesheet"));
+ const XalanDOMString stylesheetNodeName2(XALAN_STATIC_UCODE_STRING("xml:stylesheet"));
+
+ // $$$ ToDo: This code is much like that in getStyleSheetURIFromDoc().
+ // Why is it repeated???
+ // $$$ ToDo: Move these embedded strings from inside these loops
+ // out here...
+ // $$$ ToDo: These loops are a mess of repeated use of the
+ // same data values.
+ while(child != 0)
+ {
+ if(XalanNode::PROCESSING_INSTRUCTION_NODE == child->getNodeType())
+ {
+ const XalanDOMString nodeName(child->getNodeName());
+
+ if(equals(nodeName, stylesheetNodeName1) ||
+ equals(nodeName, stylesheetNodeName2))
+ {
+ bool isOK = true;
+
+ StringTokenizer tokenizer(child->getNodeValue(), XALAN_STATIC_UCODE_STRING(" \t="));
+
+ while(tokenizer.hasMoreTokens())
+ {
+ if(equals(tokenizer.nextToken(), XALAN_STATIC_UCODE_STRING("type")))
+ {
+ XalanDOMString typeVal = tokenizer.nextToken();
+
+ typeVal = substring(typeVal, 1, length(typeVal) - 1);
+
+ if(!equals(typeVal, XALAN_STATIC_UCODE_STRING("text/xsl")))
+ {
+ isOK = false;
+ }
+ }
+ }
+
+ if(isOK)
+ {
+ StringTokenizer tokenizer(child->getNodeValue(), XALAN_STATIC_UCODE_STRING(" \t="));
+
+ while(tokenizer.hasMoreTokens())
+ {
+ const XalanDOMString theCurrentToken = tokenizer.nextToken();
+
+ if(equals(theCurrentToken, XALAN_STATIC_UCODE_STRING("href")))
+ {
+ stylesheetURI = tokenizer.nextToken();
+ stylesheetURI = substring(stylesheetURI, 1, length(stylesheetURI) - 1);
+ hrefs.push_back(stylesheetURI);
+ }
+ }
+ }
+ }
+ }
+
+ child = child->getNextSibling();
+ }
+
+ bool isRoot = true;
+ Stylesheet* prevStylesheet = 0;
+
+ if (hrefs.empty() == false)
+ {
+ const XalanDOMChar* const pxch = inputSource.getSystemId();
+
+ const XalanDOMString sysid(pxch == 0 ? &s_dummyString : pxch);
+
+ do
+ {
+ const XalanDOMString& ref = hrefs.back();
+
+ Stylesheet* stylesheet =
+ getStylesheetFromPIURL(
+ ref,
+ *sourceTree,
+ sysid,
+ isRoot,
+ constructionContext);
+
+ if(false == isRoot)
+ {
+ prevStylesheet->addImport(stylesheet, false);
+ }
+
+ prevStylesheet = stylesheet;
+ isRoot = false;
+ hrefs.pop_back();
+ } while(!hrefs.empty());
+ }
+ }
+
+ if(0 == m_stylesheetRoot)
+ {
+ error("Failed to process stylesheet!");
+ }
+ else if(0 != sourceTree)
+ {
+ executionContext.setStylesheetRoot(m_stylesheetRoot);
+
+ FormatterListener* const theFormatter =
+ outputTarget.getDocumentHandler();
+
+ if (theFormatter != 0)
+ {
+ theFormatter->setPrefixResolver(this);
+ }
+
+ m_stylesheetRoot->process(sourceTree, outputTarget, executionContext);
+
+ if(0 != m_diagnosticsPrintWriter)
+ {
+ displayDuration(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("Total time")), &totalTimeID);
+ }
+ }
+}
+
+
+
+void
+XSLTEngineImpl::process(
+ const XSLTInputSource& inputSource,
+ XSLTResultTarget& outputTarget,
+ StylesheetExecutionContext& executionContext)
+{
+ bool totalTimeID = true;
+
+ if(0 != m_diagnosticsPrintWriter)
+ {
+ pushTime(&totalTimeID);
+ }
+
+ XalanNode* const sourceTree = getSourceTreeFromInput(inputSource);
+
+ if(0 != sourceTree)
+ {
+ if (m_stylesheetRoot == 0)
+ {
+ error("No stylesheet is available to process!");
+ }
+
+ FormatterListener* const theFormatter =
+ outputTarget.getDocumentHandler();
+
+ if (theFormatter != 0)
+ {
+ theFormatter->setPrefixResolver(this);
+ }
+
+ m_stylesheetRoot->process(sourceTree, outputTarget, executionContext);
+ }
+
+ if(0 != m_diagnosticsPrintWriter)
+ {
+ displayDuration(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("Total time")), &totalTimeID);
+ }
+}
+
+
+
+StylesheetRoot*
+XSLTEngineImpl::processStylesheet(
+ const XalanDOMString& xsldocURLString,
+ StylesheetConstructionContext& constructionContext)
+{
+ const XSLTInputSource input(c_wstr(xsldocURLString));
+
+ return processStylesheet(input, constructionContext);
+}
+
+
+
+StylesheetRoot*
+XSLTEngineImpl::processStylesheet(
+ const XSLTInputSource& stylesheetSource,
+ StylesheetConstructionContext& constructionContext)
+{
+ StylesheetRoot* theStylesheet = 0;
+
+ const XalanDOMChar* const systemID = stylesheetSource.getSystemId();
+ XalanNode* const stylesheetNode = stylesheetSource.getNode();
+
+ if (systemID != 0 || stylesheetNode != 0 || stylesheetSource.getStream() != 0)
+ {
+ XalanDOMString xslIdentifier;
+
+ theStylesheet = constructionContext.create(stylesheetSource);
+
+ StylesheetHandler stylesheetProcessor(*theStylesheet, constructionContext);
+
+ if(stylesheetNode != 0)
+ {
+ xslIdentifier = XALAN_STATIC_UCODE_STRING("Input XSL");
+
+ FormatterTreeWalker tw(stylesheetProcessor);
+
+ tw.traverse(stylesheetSource.getNode());
+ }
+ else
+ {
+ if (systemID != 0)
+ {
+ xslIdentifier = systemID;
+ }
+
+ diag(XALAN_STATIC_UCODE_STRING("========= Parsing ") + xslIdentifier + XALAN_STATIC_UCODE_STRING(" =========="));
+
+ pushTime(&xslIdentifier);
+
+ m_parserLiaison.parseXMLStream(stylesheetSource,
+ stylesheetProcessor);
+
+ if(0 != m_diagnosticsPrintWriter)
+ displayDuration(XALAN_STATIC_UCODE_STRING("Parse of ") + xslIdentifier, &xslIdentifier);
+ }
+
+ theStylesheet->postConstruction(constructionContext);
+ }
+
+ return theStylesheet;
+}
+
+
+
+//==========================================================
+// SECTION: XML Parsing Functions
+//==========================================================
+
+XalanNode*
+XSLTEngineImpl::getSourceTreeFromInput(const XSLTInputSource& inputSource)
+{
+ XalanNode* sourceTree = inputSource.getNode();
+
+ if(0 == sourceTree)
+ {
+ const XalanDOMString xmlIdentifier = 0 != inputSource.getSystemId() ?
+ XalanDOMString(inputSource.getSystemId()) :
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("Input XML"));
+
+ // In case we have a fragment identifier, go ahead and
+ // try to parse the XML here.
+ diag(XALAN_STATIC_UCODE_STRING("========= Parsing ") +
+ xmlIdentifier +
+ XALAN_STATIC_UCODE_STRING(" =========="));
+
+ pushTime(&xmlIdentifier);
+
+#if defined(XALAN_VQ_SPECIAL_TRACE)
+ QuantifyStartRecordingData();
+#endif
+
+ XalanDocument* const theDocument =
+ m_parserLiaison.parseXMLStream(inputSource,
+ xmlIdentifier);
+ assert(theDocument != 0);
+
+#if defined(XALAN_VQ_SPECIAL_TRACE)
+ QuantifyStopRecordingData();
+#endif
+ if(0 != m_diagnosticsPrintWriter)
+ {
+ displayDuration(
+ XALAN_STATIC_UCODE_STRING("Parse of ") + xmlIdentifier,
+ &xmlIdentifier);
+ }
+
+ m_xpathEnvSupport.setSourceDocument(xmlIdentifier, theDocument);
+
+ sourceTree = theDocument;
+ }
+
+ return sourceTree;
+}
+
+
+
+const XalanDOMString*
+XSLTEngineImpl::getNamespaceForPrefix(const XalanDOMString& prefix) const
+{
+ return m_resultNamespacesStack.getNamespaceForPrefix(prefix);
+}
+
+
+
+const XalanDOMString&
+XSLTEngineImpl::getURI() const
+{
+ return s_emptyString;
+}
+
+
+
+XalanDocument*
+XSLTEngineImpl::parseXML(
+ const XalanDOMString& urlString,
+ DocumentHandler* docHandler,
+ XalanDocument* docToRegister)
+{
+
+ XalanDocument* doc =
+ m_xpathEnvSupport.getSourceDocument(urlString);
+
+ if(doc == 0)
+ {
+ EntityResolver* const theResolver =
+ m_parserLiaison.getEntityResolver();
+
+ if (theResolver == 0)
+ {
+ const XSLTInputSource inputSource(c_wstr(urlString));
+
+ doc = parseXML(inputSource, docHandler, docToRegister);
+ }
+ else
+ {
+ const XalanAutoPtr<InputSource> resolverInputSource =
+ theResolver->resolveEntity(0, c_wstr(urlString));
+
+ if (resolverInputSource.get() != 0)
+ {
+ doc = parseXML(*resolverInputSource.get(), docHandler, docToRegister);
+ }
+ else
+ {
+ const XSLTInputSource inputSource(c_wstr(urlString));
+
+ doc = parseXML(inputSource, docHandler, docToRegister);
+ }
+ }
+
+ if (doc != 0)
+ {
+ m_xpathEnvSupport.setSourceDocument(urlString, doc);
+ }
+ }
+
+ return doc;
+}
+
+
+
+XalanDocument*
+XSLTEngineImpl::parseXML(
+ const InputSource& inputSource,
+ DocumentHandler* docHandler,
+ XalanDocument* docToRegister)
+{
+ if(0 != docHandler)
+ {
+ m_parserLiaison.parseXMLStream(inputSource, *docHandler);
+
+ return docToRegister;
+ }
+ else
+ {
+ return m_parserLiaison.parseXMLStream(inputSource);
+ }
+}
+
+
+
+Stylesheet*
+XSLTEngineImpl::getStylesheetFromPIURL(
+ const XalanDOMString& xslURLString,
+ XalanNode& fragBase,
+ const XalanDOMString& xmlBaseIdent,
+ bool isRoot,
+ StylesheetConstructionContext& constructionContext)
+{
+ Stylesheet* stylesheet = 0;
+
+ XalanDOMString stringHolder;
+
+ XalanDOMString localXSLURLString = trim(xslURLString);
+
+ const unsigned int fragIndex = indexOf(localXSLURLString, XalanUnicode::charNumberSign);
+
+ const XalanDocument* stylesheetDoc = 0;
+
+ if(fragIndex == 0)
+ {
+ diag("Locating stylesheet from fragment identifier...");
+
+ const XalanDOMString fragID = substring(localXSLURLString, 1);
+
+ const XalanElement* nsNode = 0;
+
+ const XalanNode::NodeType theType = fragBase.getNodeType();
+
+ if (theType == XalanNode::DOCUMENT_NODE)
+ {
+ const XalanDocument& doc =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (const XalanDocument&)fragBase;
+#else
+ static_cast<const XalanDocument&>(fragBase);
+#endif
+
+ nsNode = doc.getDocumentElement();
+ }
+ else if (theType == XalanNode::ELEMENT_NODE)
+ {
+#if defined(XALAN_OLD_STYLE_CASTS)
+ nsNode = (const XalanElement*)&fragBase;
+#else
+ nsNode = static_cast<const XalanElement*>(&fragBase);
+#endif
+ }
+ else
+ {
+ XalanNode* const node = fragBase.getParentNode();
+
+ if (node->getNodeType() == XalanNode::ELEMENT_NODE)
+ {
+#if defined(XALAN_OLD_STYLE_CASTS)
+ nsNode = (const XalanElement*)&fragBase;
+#else
+ nsNode = static_cast<XalanElement*>(node);
+#endif
+ }
+ else
+ {
+ error("Could not identify fragment: " + fragID);
+ }
+ }
+
+ // Try a bunch of really ugly stuff to find the fragment.
+ // What's the right way to do this?
+ XalanDOMString ds(XALAN_STATIC_UCODE_STRING("id("));
+
+ ds += fragID;
+ ds += XALAN_STATIC_UCODE_STRING(")");
+
+ ElementPrefixResolverProxy theProxy(nsNode, m_xpathEnvSupport, m_domSupport);
+
+ XPathExecutionContextDefault theExecutionContext(m_xpathEnvSupport,
+ m_domSupport,
+ m_xobjectFactory,
+ &fragBase,
+ 0,
+ &theProxy);
+
+ const XObjectPtr xobj(evalXPathStr(ds, theExecutionContext));
+ assert(xobj.null() == false);
+
+ NodeRefList nl(xobj->nodeset());
+
+ if(nl.getLength() == 0)
+ {
+ NodeRefList theEmptyList;
+
+ ds = XALAN_STATIC_UCODE_STRING("//*[@id='");
+ ds += fragID;
+ ds += XALAN_STATIC_UCODE_STRING("']");
+
+ theExecutionContext.setContextNodeList(theEmptyList);
+
+ const XObjectPtr xobj(evalXPathStr(ds, theExecutionContext));
+ assert(xobj.null() == false);
+
+ nl = xobj->nodeset();
+
+ if(nl.getLength() == 0)
+ {
+ ds = XALAN_STATIC_UCODE_STRING("//*[@name='");
+ ds += fragID;
+ ds += XALAN_STATIC_UCODE_STRING("']");
+
+ theExecutionContext.setContextNodeList(theEmptyList);
+
+ const XObjectPtr xobj(evalXPathStr(ds, theExecutionContext));
+ assert(xobj.null() == false);
+
+ nl = xobj->nodeset();
+
+ if(nl.getLength() == 0)
+ {
+ // Well, hell, maybe it's an XPath...
+ theExecutionContext.setContextNodeList(theEmptyList);
+
+ const XObjectPtr xobj(evalXPathStr(fragID, theExecutionContext));
+ assert(xobj.null() == false);
+
+ nl = xobj->nodeset();
+ }
+ }
+ }
+
+ if(nl.getLength() == 0)
+ {
+ error("Could not find fragment: " + fragID);
+ }
+
+ XalanNode* const frag = nl.item(0);
+
+ if(XalanNode::ELEMENT_NODE == frag->getNodeType())
+ {
+ pushTime(frag);
+
+ XalanAutoPtr<Stylesheet> theGuard;
+
+ if(isRoot)
+ {
+ StylesheetRoot* const theLocalRoot =
+ constructionContext.create(stringHolder);
+
+ stylesheet = theLocalRoot;
+
+ m_stylesheetRoot = theLocalRoot;
+ }
+ else
+ {
+#if defined(XALAN_OLD_STYLE_CASTS)
+ stylesheet = constructionContext.create(*((StylesheetRoot*)m_stylesheetRoot), stringHolder);
+#else
+ stylesheet = constructionContext.create(*const_cast<StylesheetRoot*>(m_stylesheetRoot), stringHolder);
+#endif
+
+ theGuard.reset(stylesheet);
+ }
+
+ StylesheetHandler stylesheetProcessor(*stylesheet, constructionContext);
+
+ FormatterTreeWalker tw(stylesheetProcessor);
+
+ tw.traverse(frag, frag->getParentNode());
+
+ displayDuration(
+ XalanDOMString(XALAN_STATIC_UCODE_STRING("Setup of ")) +
+ localXSLURLString,
+ frag);
+
+ stylesheet->postConstruction(constructionContext);
+
+ theGuard.release();
+ }
+ else
+ {
+ stylesheetDoc = 0;
+ error("Node pointed to by fragment identifier was not an element: " + fragID);
+ }
+ }
+ else
+ {
+ diag(XalanDOMString(XALAN_STATIC_UCODE_STRING("========= Parsing and preparing ")) +
+ localXSLURLString +
+ XALAN_STATIC_UCODE_STRING(" =========="));
+ pushTime(&localXSLURLString);
+
+ XalanAutoPtr<Stylesheet> theGuard;
+
+ const XalanDocument* const theOwnerDocument =
+ fragBase.getNodeType() == XalanNode::DOCUMENT_NODE ?
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (const XalanDocument*)&fragBase :
+#else
+ static_cast<const XalanDocument*>(&fragBase) :
+#endif
+ fragBase.getOwnerDocument();
+ assert(theOwnerDocument != 0);
+
+ if (length(xmlBaseIdent) == 0)
+ {
+ localXSLURLString =
+ URISupport::getURLStringFromString(
+ localXSLURLString,
+ m_xpathEnvSupport.findURIFromDoc(theOwnerDocument));
+ }
+ else
+ {
+ localXSLURLString =
+ URISupport::getURLStringFromString(
+ localXSLURLString,
+ xmlBaseIdent);
+ }
+
+ if(isRoot)
+ {
+ StylesheetRoot* const theLocalRoot =
+ constructionContext.create(localXSLURLString);
+
+ stylesheet = theLocalRoot;
+
+ m_stylesheetRoot = theLocalRoot;
+ }
+ else
+ {
+#if defined(XALAN_OLD_STYLE_CASTS)
+ stylesheet = new Stylesheet(*(StylesheetRoot*)m_stylesheetRoot, localXSLURLString, constructionContext);
+#else
+ stylesheet = new Stylesheet(*const_cast<StylesheetRoot*>(m_stylesheetRoot), localXSLURLString, constructionContext);
+#endif
+
+ theGuard.reset(stylesheet);
+ }
+
+ StylesheetHandler stylesheetProcessor(*stylesheet, constructionContext);
+
+ typedef StylesheetConstructionContext::URLAutoPtrType URLAutoPtrType;
+
+ URLAutoPtrType xslURL(constructionContext.getURLFromString(localXSLURLString));
+
+ XSLTInputSource inputSource(xslURL->getURLText());
+
+ m_parserLiaison.parseXMLStream(inputSource, stylesheetProcessor);
+
+ stylesheet->postConstruction(constructionContext);
+
+ theGuard.release();
+
+ displayDuration("Parsing and init of " + localXSLURLString, &localXSLURLString);
+ }
+
+ return stylesheet;
+}
+
+
+//==========================================================
+// SECTION: Stylesheet Tables
+//==========================================================
+
+
+double
+XSLTEngineImpl::getXSLTVerSupported()
+{
+ return s_XSLTVerSupported;
+}
+
+
+//==========================================================
+// SECTION: XSL directive handling functions
+//==========================================================
+
+
+
+int
+XSLTEngineImpl::getXSLToken(const XalanNode& node) const
+{
+ int tok = -2;
+
+ if(XalanNode::ELEMENT_NODE != node.getNodeType()) return tok;
+
+ const XalanDOMString& ns = node.getNamespaceURI();
+
+ if(equals(ns, s_XSLNameSpaceURL))
+ {
+ const XalanDOMString& localName =
+ DOMServices::getLocalNameOfNode(node);
+
+ const ElementKeysMapType::const_iterator j =
+ s_elementKeys.find(localName);
+
+ if(j != s_elementKeys.end())
+ {
+ tok = (*j).second;
+ }
+ }
+ else if(equals(ns, s_XSLT4JNameSpaceURL))
+ {
+ const XalanDOMString& localName =
+ DOMServices::getLocalNameOfNode(node);
+
+ const ElementKeysMapType::const_iterator j =
+ s_XSLT4JElementKeys.find(localName);
+
+ if(j != s_XSLT4JElementKeys.end())
+ {
+ tok = (*j).second;
+ }
+ }
+
+ return tok;
+}
+
+
+
+void
+XSLTEngineImpl::outputToResultTree(
+ StylesheetExecutionContext& executionContext,
+ const XObject& value)
+{
+ const XObject::eObjectType type = value.getType();
+
+ switch(type)
+ {
+ case XObject::eTypeBoolean:
+ case XObject::eTypeNumber:
+ case XObject::eTypeString:
+ {
+ const XalanDOMString& s = value.str();
+
+ characters(toCharArray(s), 0, length(s));
+ }
+ break;
+
+ case XObject::eTypeNodeSet:
+ {
+ const NodeRefListBase& nl = value.nodeset();
+
+ const unsigned int nChildren = nl.getLength();
+
+ for(unsigned int i = 0; i < nChildren; i++)
+ {
+ XalanNode* pos = nl.item(i);
+ assert(pos != 0);
+
+ XalanNode* const top = pos;
+
+ while(0 != pos)
+ {
+ flushPending();
+
+ XalanNode::NodeType posNodeType = pos->getNodeType();
+
+ cloneToResultTree(*pos, posNodeType, false, false, true);
+
+ XalanNode* nextNode = pos->getFirstChild();
+
+ while(0 == nextNode)
+ {
+ if(XalanNode::ELEMENT_NODE == posNodeType)
+ {
+ endElement(c_wstr(pos->getNodeName()));
+ }
+
+ if(top == pos)
+ break;
+
+ nextNode = pos->getNextSibling();
+
+ if(0 == nextNode)
+ {
+ pos = pos->getParentNode();
+ assert(pos != 0);
+
+ posNodeType = pos->getNodeType();
+
+ if(top == pos)
+ {
+ if(XalanNode::ELEMENT_NODE == posNodeType)
+ {
+ endElement(c_wstr(pos->getNodeName()));
+ }
+
+ nextNode = 0;
+ break;
+ }
+ }
+ }
+
+ pos = nextNode;
+
+ if (pos != 0)
+ {
+ posNodeType = pos->getNodeType();
+ }
+ }
+ }
+ }
+ break;
+
+ case XObject::eTypeResultTreeFrag:
+ outputResultTreeFragment(executionContext, value);
+ break;
+
+ case XObject::eTypeNull:
+ case XObject::eTypeUnknown:
+ case XObject::eUnknown:
+ default:
+ assert(0);
+ }
+}
+
+
+
+const StylesheetRoot*
+XSLTEngineImpl::getStylesheetRoot() const
+{
+ return m_stylesheetRoot;
+}
+
+
+
+void
+XSLTEngineImpl::setStylesheetRoot(const StylesheetRoot* theStylesheet)
+{
+ m_stylesheetRoot = theStylesheet;
+}
+
+
+
+void
+XSLTEngineImpl::setExecutionContext(StylesheetExecutionContext* theExecutionContext)
+{
+ m_executionContext = theExecutionContext;
+}
+
+
+
+//==========================================================
+// SECTION: Diagnostic functions
+//==========================================================
+
+unsigned long
+XSLTEngineImpl::getTraceListeners() const
+{
+ return m_traceListeners.size();
+}
+
+
+
+void
+XSLTEngineImpl::addTraceListener(TraceListener* tl)
+{
+ if (tl != 0)
+ {
+ m_traceListeners.push_back(tl);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::removeTraceListener(TraceListener* tl)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::remove;
+#endif
+
+ const TraceListenerVectorType::iterator i =
+ remove(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ tl);
+
+ m_traceListeners.erase(i);
+}
+
+
+
+void
+XSLTEngineImpl::fireGenerateEvent(const GenerateEvent& ge)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ for_each(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ TraceListener::TraceListenerGenerateFunctor(ge));
+}
+
+
+
+void
+XSLTEngineImpl::fireSelectEvent(const SelectionEvent& se)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ for_each(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ TraceListener::TraceListenerSelectFunctor(se));
+}
+
+
+
+void
+XSLTEngineImpl::fireTraceEvent(const TracerEvent& te)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ for_each(
+ m_traceListeners.begin(),
+ m_traceListeners.end(),
+ TraceListener::TraceListenerTraceFunctor(te));
+}
+
+
+
+bool
+XSLTEngineImpl::getTraceSelects() const
+{
+ return m_traceSelects;
+}
+
+
+
+void
+XSLTEngineImpl::setTraceSelects(bool b)
+{
+ m_traceSelects = b;
+}
+
+
+
+void
+XSLTEngineImpl::message(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const XalanNode* styleNode) const
+{
+ problem(msg, ProblemListener::eMESSAGE, sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::message(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const
+{
+ problem(msg, ProblemListener::eMESSAGE, sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::message(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const XalanNode* styleNode) const
+{
+ message(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::problem(
+ const XalanDOMString& msg,
+ ProblemListener::eClassification classification,
+ const XalanNode* sourceNode,
+ const XalanNode* styleNode) const
+{
+ const Locator* const locator = getLocatorFromStack();
+
+ const XalanDOMChar* id = 0;
+
+ XalanDOMString uri;
+
+ int lineNumber = -1;
+ int columnNumber = -1;
+
+ if (locator != 0)
+ {
+ id = locator->getPublicId();
+
+ if (id == 0)
+ {
+ id = locator->getSystemId();
+ }
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+
+ lineNumber = locator->getLineNumber();
+ columnNumber = locator->getColumnNumber();
+ }
+
+ if (m_problemListener != 0)
+ {
+ m_problemListener->problem(
+ ProblemListener::eXSLPROCESSOR,
+ classification,
+ sourceNode,
+ styleNode,
+ msg,
+ id,
+ lineNumber,
+ columnNumber);
+ }
+
+ if (classification == ProblemListener::eERROR)
+ {
+ throw XSLTProcessorException(msg, uri, lineNumber, columnNumber);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::problem(
+ const XalanDOMString& msg,
+ ProblemListener::eClassification classification,
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const
+{
+ const XalanDOMChar* id = 0;
+
+ XalanDOMString uri;
+
+ int lineNumber = -1;
+ int columnNumber = -1;
+
+ const Locator* locator = getLocatorFromStack();
+
+ if (locator == 0)
+ {
+ locator = styleNode->getLocator();
+ }
+
+ if (locator != 0)
+ {
+ id = locator->getPublicId();
+
+ if (id == 0)
+ {
+ id = locator->getSystemId();
+ }
+
+ if (id != 0)
+ {
+ uri = id;
+ }
+
+ lineNumber = locator->getLineNumber();
+ columnNumber = locator->getColumnNumber();
+ }
+ else if (styleNode != 0)
+ {
+ lineNumber = styleNode->getLineNumber();
+ columnNumber = styleNode->getColumnNumber();
+
+ uri = styleNode->getURI();
+ }
+
+ if (m_problemListener != 0)
+ {
+ m_problemListener->problem(
+ ProblemListener::eXSLPROCESSOR,
+ classification,
+ styleNode,
+ sourceNode,
+ msg,
+ id,
+ lineNumber,
+ columnNumber);
+ }
+
+ if (classification == ProblemListener::eERROR)
+ {
+ throw XSLTProcessorException(msg, uri, lineNumber, columnNumber);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::warn(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const XalanNode* styleNode) const
+{
+ problem(msg, ProblemListener::eWARNING, sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::warn(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const
+{
+ problem(msg, ProblemListener::eWARNING, sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::warn(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const XalanNode* styleNode) const
+{
+ warn(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::error(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const XalanNode* styleNode) const
+{
+ problem(msg, ProblemListener::eERROR, sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::error(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode,
+ const ElemTemplateElement* styleNode) const
+{
+ problem(msg, ProblemListener::eERROR, sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::error(
+ const char* msg,
+ const XalanNode* sourceNode,
+ const XalanNode* styleNode) const
+{
+ error(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
+}
+
+
+
+void
+XSLTEngineImpl::pushTime(const void* key)
+{
+ if(0 != key)
+ {
+ m_durationsTable[key] = clock();
+ }
+}
+
+
+
+clock_t
+XSLTEngineImpl::popDuration(const void* key)
+{
+ clock_t clockTicksDuration = 0;
+
+ if(0 != key)
+ {
+ const DurationsTableMapType::iterator i =
+ m_durationsTable.find(key);
+
+ if (i != m_durationsTable.end())
+ {
+ clockTicksDuration = clock() - (*i).second;
+
+ m_durationsTable.erase(i);
+ }
+ }
+
+ return clockTicksDuration;
+}
+
+
+
+void
+XSLTEngineImpl::displayDuration(
+ const XalanDOMString& info,
+ const void* key)
+{
+ if(0 != key)
+ {
+ const clock_t theDuration = popDuration(key);
+
+ if(0 != m_diagnosticsPrintWriter)
+ {
+ const double millis = (double(theDuration) / CLOCKS_PER_SEC) * 1000.0L;
+
+ XalanDOMString msg(info);
+
+ msg += XALAN_STATIC_UCODE_STRING(" took ");
+ msg += DoubleToDOMString(millis);
+ msg += XALAN_STATIC_UCODE_STRING(" milliseconds");
+
+ m_diagnosticsPrintWriter->println(msg);
+ }
+ }
+}
+
+
+
+void
+XSLTEngineImpl::setDiagnosticsOutput(PrintWriter* pw)
+{
+ m_diagnosticsPrintWriter = pw;
+
+ m_problemListener->setPrintWriter(pw);
+}
+
+
+
+void
+XSLTEngineImpl::diag(const XalanDOMString& s) const
+{
+ if (0 != m_diagnosticsPrintWriter)
+ {
+ m_diagnosticsPrintWriter->println(s);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::diag(const char* s) const
+{
+ diag(TranscodeFromLocalCodePage(s));
+}
+
+
+
+void
+XSLTEngineImpl::setQuietConflictWarnings(bool b)
+{
+ m_quietConflictWarnings = b;
+}
+
+
+
+void
+XSLTEngineImpl::setDocumentLocator(const Locator* const /* locator */)
+{
+ // Do nothing for now
+}
+
+
+
+void
+XSLTEngineImpl::traceSelect(
+ const XalanElement& theTemplate,
+ const NodeRefListBase& nl) const
+{
+ if (0 != m_diagnosticsPrintWriter)
+ {
+ XalanDOMString msg = theTemplate.getNodeName() + XalanDOMString(XALAN_STATIC_UCODE_STRING(": "));
+
+ XalanAttr* attr = theTemplate.getAttributeNode(Constants::ATTRNAME_SELECT);
+
+ if(0 != attr)
+ {
+ msg += attr->getValue();
+ msg += XALAN_STATIC_UCODE_STRING(", ");
+ msg += LongToDOMString(nl.getLength());
+ msg += XALAN_STATIC_UCODE_STRING(" selected");
+ }
+ else
+ {
+ msg += XALAN_STATIC_UCODE_STRING("*|text(), (default select), ");
+ msg += LongToDOMString(nl.getLength());
+ msg += XALAN_STATIC_UCODE_STRING(" selected");
+ }
+
+ attr = theTemplate.getAttributeNode(Constants::ATTRNAME_MODE);
+
+ if(0 != attr)
+ {
+ msg += XalanDOMString(XALAN_STATIC_UCODE_STRING(", mode = ")) + attr->getValue();
+ }
+
+ m_diagnosticsPrintWriter->println(msg);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::startDocument()
+{
+ assert(getFormatterListener() != 0);
+ assert(m_executionContext != 0);
+
+ if (getHasPendingStartDocument() == false)
+ {
+ m_resultNamespacesStack.pushContext();
+
+ setHasPendingStartDocument(true);
+
+ setMustFlushPendingStartDocument(false);
+ }
+ else if (getMustFlushPendingStartDocument() == true)
+ {
+ getFormatterListener()->startDocument();
+
+ if(getTraceListeners() > 0)
+ {
+ const GenerateEvent ge(GenerateEvent::EVENTTYPE_STARTDOCUMENT);
+
+ fireGenerateEvent(ge);
+ }
+
+ // Reset this, but leave getMustFlushPendingStartDocument() alone,
+ // since it will still be needed.
+ setHasPendingStartDocument(false);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::endDocument()
+{
+ assert(getFormatterListener() != 0);
+ assert(m_executionContext != 0);
+
+ setMustFlushPendingStartDocument(true);
+
+ flushPending();
+
+ getFormatterListener()->endDocument();
+
+ if(getTraceListeners() > 0)
+ {
+ const GenerateEvent ge(GenerateEvent::EVENTTYPE_ENDDOCUMENT);
+
+ fireGenerateEvent(ge);
+ }
+
+ m_resultNamespacesStack.popContext();
+
+ assert(m_resultNamespacesStack.size() == 0);
+}
+
+
+
+void
+XSLTEngineImpl::addResultNamespaceDecl(
+ const XalanDOMString& prefix,
+ const XalanDOMString& namespaceVal)
+{
+ m_resultNamespacesStack.addDeclaration(prefix, namespaceVal);
+}
+
+
+
+void
+XSLTEngineImpl::addResultAttribute(
+ AttributeListImpl& attList,
+ const XalanDOMString& aname,
+ const XalanDOMString& value)
+{
+ bool fExcludeAttribute = false;
+
+ if (equals(aname, DOMServices::s_XMLNamespace))
+ {
+ // OK, we're adding a default namespace declaration. So see if the length
+ // of the namespace is 0. If it's not, go ahead and add the declaration.
+ // If it's not, it means we're "turning off" the previous default
+ // declaration.
+
+ const XalanDOMString* const currentDefaultNamespace =
+ getNamespaceForPrefix(s_emptyString);
+
+ // Note that we use an empty string for the prefix, instead of "xmlns", since the
+ // prefix really is "".
+ if (length(value) != 0)
+ {
+ if (currentDefaultNamespace != 0 &&
+ equals(*currentDefaultNamespace, value) == true)
+ {
+ fExcludeAttribute = true;
+ }
+ else
+ {
+ addResultNamespaceDecl(s_emptyString, value);
+ }
+ }
+ else
+ {
+ // OK, we're turning of the previous default namespace declaration.
+ // Check to see if there is one, and if there isn't, don't add
+ // the namespace declaration _and_ don't add the attribute.
+ if (currentDefaultNamespace != 0 && length(*currentDefaultNamespace) != 0)
+ {
+ addResultNamespaceDecl(s_emptyString, value);
+ }
+ else
+ {
+ fExcludeAttribute = true;
+ }
+ }
+ }
+ else if (startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator) == true)
+ {
+ assert(m_executionContext != 0);
+
+ StylesheetExecutionContext::GetAndReleaseCachedString prefixGuard(*m_executionContext);
+
+ XalanDOMString& prefix = prefixGuard.get();
+
+ prefix = substring(aname, DOMServices::s_XMLNamespaceWithSeparatorLength);
+
+ addResultNamespaceDecl(prefix, value);
+ }
+
+ if (fExcludeAttribute == false)
+ {
+ attList.addAttribute(
+ c_wstr(aname),
+ c_wstr(Constants::ATTRTYPE_CDATA),
+ c_wstr(value));
+ }
+}
+
+
+
+bool
+XSLTEngineImpl::pendingAttributesHasDefaultNS() const
+{
+ const AttributeListImpl& thePendingAttributes =
+ getPendingAttributes();
+
+ const unsigned int n = thePendingAttributes.getLength();
+
+ for(unsigned int i = 0; i < n; i++)
+ {
+ if(equals(thePendingAttributes.getName(i),
+ DOMServices::s_XMLNamespace) == true)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+void
+XSLTEngineImpl::flushPending()
+{
+ if(getHasPendingStartDocument() == true && 0 != length(getPendingElementName()))
+ {
+ assert(getFormatterListener() != 0);
+ assert(m_executionContext != 0);
+
+ if (m_stylesheetRoot->isOutputMethodSet() == false)
+ {
+ if (equalsIgnoreCaseASCII(getPendingElementName(),
+ Constants::ELEMNAME_HTML_STRING) == true &&
+ pendingAttributesHasDefaultNS() == false)
+ {
+ if (getFormatterListener()->getOutputFormat() == FormatterListener::OUTPUT_METHOD_XML)
+ {
+ // Yuck!!! Ugly hack to switch to HTML on-the-fly.
+ FormatterToXML* const theFormatter =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (FormatterToXML*)getFormatterListener();
+#else
+ static_cast<FormatterToXML*>(getFormatterListener());
+#endif
+
+ setFormatterListenerImpl(
+ m_executionContext->createFormatterToHTML(
+ *theFormatter->getWriter(),
+ theFormatter->getEncoding(),
+ theFormatter->getMediaType(),
+ theFormatter->getDoctypeSystem(),
+ theFormatter->getDoctypePublic(),
+ true, // indent
+ theFormatter->getIndent() > 0 ? theFormatter->getIndent() :
+ StylesheetExecutionContext::eDefaultHTMLIndentAmount));
+ }
+ }
+ }
+ }
+
+ XalanDOMString& thePendingElementName = getPendingElementNameImpl();
+
+ if(getHasPendingStartDocument() == true && getMustFlushPendingStartDocument() == true)
+ {
+ startDocument();
+ }
+
+ if(0 != length(thePendingElementName) && getMustFlushPendingStartDocument() == true)
+ {
+ assert(getFormatterListener() != 0);
+ assert(m_executionContext != 0);
+
+ m_cdataStack.push_back(isCDataResultElem(thePendingElementName) ? true : false);
+
+ AttributeListImpl& thePendingAttributes =
+ getPendingAttributesImpl();
+
+ getFormatterListener()->startElement(c_wstr(thePendingElementName), thePendingAttributes);
+
+ if(getTraceListeners() > 0)
+ {
+ const GenerateEvent ge(
+ GenerateEvent::EVENTTYPE_STARTELEMENT,
+ thePendingElementName,
+ &thePendingAttributes);
+
+ fireGenerateEvent(ge);
+ }
+
+ thePendingAttributes.clear();
+
+ clear(thePendingElementName);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::startElement(const XMLCh* const name)
+{
+ assert(getFormatterListener() != 0);
+ assert(name != 0);
+
+ flushPending();
+
+ m_resultNamespacesStack.pushContext();
+
+ setPendingElementName(name);
+
+ setMustFlushPendingStartDocument(true);
+}
+
+
+
+void
+XSLTEngineImpl::startElement(
+ const XMLCh* const name,
+ AttributeList& atts)
+{
+ assert(getFormatterListener() != 0);
+ assert(name != 0);
+
+ flushPending();
+
+ const unsigned int nAtts = atts.getLength();
+
+ assert(m_outputContextStack.size() > 0);
+
+ AttributeListImpl& thePendingAttributes =
+ getPendingAttributesImpl();
+
+ thePendingAttributes.clear();
+
+ for(unsigned int i = 0; i < nAtts; i++)
+ {
+ thePendingAttributes.addAttribute(
+ atts.getName(i),
+ atts.getType(i),
+ atts.getValue(i));
+ }
+
+ m_resultNamespacesStack.pushContext();
+
+ setPendingElementName(name);
+}
+
+
+
+void
+XSLTEngineImpl::endElement(const XMLCh* const name)
+{
+ assert(getFormatterListener() != 0);
+ assert(name != 0);
+
+ flushPending();
+
+ getFormatterListener()->endElement(name);
+
+ if(getTraceListeners() > 0)
+ {
+ const GenerateEvent ge(GenerateEvent::EVENTTYPE_ENDELEMENT, name);
+
+ fireGenerateEvent(ge);
+ }
+
+ m_resultNamespacesStack.popContext();
+
+ if(m_stylesheetRoot->hasCDATASectionElements() == true)
+ {
+ m_cdataStack.pop_back();
+ }
+}
+
+
+
+void
+XSLTEngineImpl::characters(
+ const XMLCh* const ch,
+ const unsigned int length)
+{
+ characters(ch,
+ 0,
+ length);
+}
+
+
+
+void
+XSLTEngineImpl::characters(
+ const XMLCh* const ch,
+ const unsigned int start,
+ const unsigned int length)
+{
+ assert(getFormatterListener() != 0);
+ assert(ch != 0);
+
+ doFlushPending();
+
+ if(generateCDATASection() == true)
+ {
+ getFormatterListener()->cdata(ch + start, length);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(ch, start, length, true);
+ }
+ }
+ else
+ {
+ getFormatterListener()->characters(ch + start, length);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(ch, start, length, false);
+ }
+ }
+}
+
+
+
+void
+XSLTEngineImpl::characters(const XalanNode& node)
+{
+ assert(getFormatterListener() != 0);
+
+ doFlushPending();
+
+ if(generateCDATASection() == true)
+ {
+ DOMServices::getNodeData(node, *getFormatterListener(), &FormatterListener::cdata);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(node, true);
+ }
+ }
+ else
+ {
+ DOMServices::getNodeData(node, *getFormatterListener(), &FormatterListener::characters);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(node, false);
+ }
+ }
+}
+
+
+
+void
+XSLTEngineImpl::characters(const XObjectPtr& xobject)
+{
+ assert(getFormatterListener() != 0);
+ assert(xobject.null() == false);
+
+ doFlushPending();
+
+ if(generateCDATASection() == true)
+ {
+ xobject->str(*getFormatterListener(), &FormatterListener::cdata);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(xobject, true);
+ }
+ }
+ else
+ {
+ xobject->str(*getFormatterListener(), &FormatterListener::characters);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(xobject, false);
+ }
+ }
+}
+
+
+
+void
+XSLTEngineImpl::charactersRaw(
+ const XMLCh* const ch,
+ const unsigned int start,
+ const unsigned int length)
+{
+ assert(ch != 0);
+
+ doFlushPending();
+
+ getFormatterListener()->charactersRaw(ch, length);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(ch, start, length, false);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::charactersRaw(const XalanNode& node)
+{
+ doFlushPending();
+
+ DOMServices::getNodeData(node, *getFormatterListener(), &FormatterListener::charactersRaw);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(node, false);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::charactersRaw(const XObjectPtr& xobject)
+{
+ doFlushPending();
+
+ xobject->str(*getFormatterListener(), &FormatterListener::charactersRaw);
+
+ if(getTraceListeners() > 0)
+ {
+ fireCharacterGenerateEvent(xobject, false);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::resetDocument()
+{
+ assert(getFormatterListener() != 0);
+
+ flushPending();
+
+ getFormatterListener()->resetDocument();
+}
+
+
+
+void
+XSLTEngineImpl::ignorableWhitespace(
+ const XMLCh* const ch,
+ const unsigned int length)
+{
+ assert(getFormatterListener() != 0);
+ assert(ch != 0);
+
+ doFlushPending();
+
+ getFormatterListener()->ignorableWhitespace(ch, length);
+
+ if(getTraceListeners() > 0)
+ {
+ GenerateEvent ge(GenerateEvent::EVENTTYPE_IGNORABLEWHITESPACE,
+ ch, 0, length);
+
+ fireGenerateEvent(ge);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::processingInstruction(
+ const XMLCh* const target,
+ const XMLCh* const data)
+{
+ assert(getFormatterListener() != 0);
+ assert(target != 0);
+ assert(data != 0);
+
+ doFlushPending();
+
+ getFormatterListener()->processingInstruction(target, data);
+
+ if(getTraceListeners() > 0)
+ {
+ GenerateEvent ge(
+ GenerateEvent::EVENTTYPE_PI,
+ target,
+ data);
+
+ fireGenerateEvent(ge);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::comment(const XMLCh* const data)
+{
+ assert(getFormatterListener() != 0);
+ assert(data != 0);
+
+ doFlushPending();
+
+ getFormatterListener()->comment(data);
+
+ if(getTraceListeners() > 0)
+ {
+ GenerateEvent ge(GenerateEvent::EVENTTYPE_COMMENT,
+ data);
+ fireGenerateEvent(ge);
+ }
+}
+
+
+void
+XSLTEngineImpl::entityReference(const XMLCh* const name)
+{
+ assert(getFormatterListener() != 0);
+ assert(name != 0);
+
+ doFlushPending();
+
+ getFormatterListener()->entityReference(name);
+
+ if(getTraceListeners() > 0)
+ {
+ GenerateEvent ge(GenerateEvent::EVENTTYPE_ENTITYREF,
+ name);
+
+ fireGenerateEvent(ge);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::cdata(
+ const XMLCh* const ch,
+ const unsigned int start,
+ const unsigned int length)
+{
+ assert(getFormatterListener() != 0);
+ assert(ch != 0);
+
+ setMustFlushPendingStartDocument(true);
+
+ flushPending();
+
+ if(m_stylesheetRoot->hasCDATASectionElements() == true &&
+ 0 != m_cdataStack.size())
+ {
+ getFormatterListener()->cdata(ch, length);
+
+ if(getTraceListeners() > 0)
+ {
+ GenerateEvent ge(GenerateEvent::EVENTTYPE_CDATA, ch, start,
+ length);
+
+ fireGenerateEvent(ge);
+ }
+ }
+ else
+ {
+ getFormatterListener()->characters(ch, length);
+
+ if(getTraceListeners() > 0)
+ {
+ GenerateEvent ge(GenerateEvent::EVENTTYPE_CHARACTERS, ch,
+ start, length);
+
+ fireGenerateEvent(ge);
+ }
+ }
+}
+
+
+
+void
+XSLTEngineImpl::cloneToResultTree(
+ XalanNode& node,
+ XalanNode::NodeType nodeType,
+ bool isLiteral,
+ bool overrideStrip,
+ bool shouldCloneAttributes)
+{
+ assert(nodeType == node.getNodeType());
+
+ switch(nodeType)
+ {
+ case XalanNode::TEXT_NODE:
+ {
+ bool stripWhiteSpace = false;
+
+ // If stripWhiteSpace is false, then take this as an override and
+ // just preserve the space, otherwise use the XSL whitespace rules.
+ if(!overrideStrip)
+ {
+ stripWhiteSpace = isLiteral ? true : false;
+ // was: stripWhiteSpace = isLiteral ? true : shouldStripSourceNode(node);
+ }
+
+ const XalanText& tx =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (const XalanText&)node;
+#else
+ static_cast<const XalanText&>(node);
+#endif
+
+ const bool isIgnorableWhitespace = tx.isIgnorableWhitespace();
+
+ if(stripWhiteSpace == false || isIgnorableWhitespace == false)
+ {
+ assert(tx.getParentNode() == 0 ||
+ tx.getParentNode()->getNodeType() != XalanNode::DOCUMENT_NODE);
+
+ const XalanDOMString& data = tx.getData();
+
+ if(0 != length(data))
+ {
+ if(isIgnorableWhitespace == true)
+ {
+ ignorableWhitespace(toCharArray(data), length(data));
+ }
+ else
+ {
+ characters(toCharArray(data), 0, length(data));
+ }
+ }
+ }
+ }
+ break;
+
+ case XalanNode::ELEMENT_NODE:
+ startElement(c_wstr(node.getNodeName()));
+
+ if(shouldCloneAttributes == true)
+ {
+ copyAttributesToAttList(
+ m_stylesheetRoot,
+ node,
+ getPendingAttributesImpl());
+
+ copyNamespaceAttributes(node);
+ }
+ break;
+
+ case XalanNode::CDATA_SECTION_NODE:
+ {
+ const XalanDOMString& data = node.getNodeValue();
+
+ cdata(toCharArray(data), 0, length(data));
+ }
+ break;
+
+ case XalanNode::ATTRIBUTE_NODE:
+ addResultAttribute(
+ getPendingAttributesImpl(),
+#if defined(XALAN_OLD_STYLE_CASTS)
+ DOMServices::getNameOfNode((const XalanAttr&)node),
+#else
+ DOMServices::getNameOfNode(static_cast<const XalanAttr&>(node)),
+#endif
+ node.getNodeValue());
+ break;
+
+ case XalanNode::COMMENT_NODE:
+ comment(c_wstr(node.getNodeValue()));
+ break;
+
+ case XalanNode::DOCUMENT_FRAGMENT_NODE:
+ error("No clone of a document fragment!");
+ break;
+
+ case XalanNode::ENTITY_REFERENCE_NODE:
+ entityReference(c_wstr(node.getNodeName()));
+ break;
+
+ case XalanNode::PROCESSING_INSTRUCTION_NODE:
+ processingInstruction(
+ c_wstr(node.getNodeName()),
+ c_wstr(node.getNodeValue()));
+ break;
+
+ // Can't really do this, but we won't throw an error so that copy-of will
+ // work
+ case XalanNode::DOCUMENT_NODE:
+ case XalanNode::DOCUMENT_TYPE_NODE:
+ break;
+
+ default:
+ error("Cannot create item in result tree: " + node.getNodeName());
+ break;
+
+ }
+}
+
+
+
+void
+XSLTEngineImpl::outputResultTreeFragment(
+ StylesheetExecutionContext& executionContext,
+ const XObject& theTree)
+{
+ const ResultTreeFragBase& docFrag = theTree.rtree(executionContext);
+
+ const XalanNodeList* const nl = docFrag.getChildNodes();
+ assert(nl != 0);
+
+ const unsigned int nChildren = nl->getLength();
+
+ for(unsigned int i = 0; i < nChildren; i++)
+ {
+ XalanNode* pos = nl->item(i);
+ assert(pos != 0);
+
+ XalanNode::NodeType posNodeType = pos->getNodeType();
+
+ XalanNode* const top = pos;
+
+ while(0 != pos)
+ {
+ flushPending();
+
+ cloneToResultTree(*pos, posNodeType, false, false, true);
+
+ XalanNode* nextNode = pos->getFirstChild();
+
+ while(0 == nextNode)
+ {
+ if(XalanNode::ELEMENT_NODE == posNodeType)
+ {
+ endElement(c_wstr(pos->getNodeName()));
+ }
+
+ if(top == pos)
+ break;
+
+ nextNode = pos->getNextSibling();
+
+ if(0 == nextNode)
+ {
+ pos = pos->getParentNode();
+
+ if(0 == pos)
+ {
+ nextNode = 0;
+
+ break;
+ }
+ else
+ {
+ assert(0 != pos);
+
+ posNodeType = pos->getNodeType();
+
+ if(top == pos)
+ {
+ if(XalanNode::ELEMENT_NODE == posNodeType)
+ {
+ endElement(c_wstr(pos->getNodeName()));
+ }
+
+ nextNode = 0;
+
+ break;
+ }
+ }
+ }
+ }
+
+ pos = nextNode;
+
+ if (pos != 0)
+ {
+ posNodeType = pos->getNodeType();
+ }
+ }
+ }
+}
+
+
+
+bool
+XSLTEngineImpl::isCDataResultElem(const XalanDOMString& elementName) const
+{
+ assert(m_executionContext != 0);
+
+ if(m_stylesheetRoot->hasCDATASectionElements() == false)
+ {
+ return false;
+ }
+ else
+ {
+ bool fResult = false;
+
+ const unsigned int indexOfNSSep = indexOf(elementName, XalanUnicode::charColon);
+
+ if(indexOfNSSep == length(elementName))
+ {
+ fResult = m_stylesheetRoot->isCDATASectionElementName(XalanQNameByReference(s_emptyString, elementName));
+ }
+ else
+ {
+ typedef StylesheetExecutionContext::GetAndReleaseCachedString GetAndReleaseCachedString;
+
+ GetAndReleaseCachedString elemLocalNameGuard(*m_executionContext);
+ GetAndReleaseCachedString prefixGuard(*m_executionContext);
+
+ XalanDOMString& elemLocalName = elemLocalNameGuard.get();
+ XalanDOMString& prefix = prefixGuard.get();
+
+ substring(elementName, prefix, 0, indexOfNSSep);
+ substring(elementName, elemLocalName, indexOfNSSep + 1);
+
+ if(equals(prefix, DOMServices::s_XMLString))
+ {
+ fResult =
+ m_stylesheetRoot->isCDATASectionElementName(XalanQNameByReference(DOMServices::s_XMLNamespaceURI, elementName));
+ }
+ else
+ {
+ const XalanDOMString* const elemNS =
+ getResultNamespaceForPrefix(prefix);
+
+ if(elemNS == 0)
+ {
+ error("Prefix must resolve to a namespace: " + prefix);
+ }
+ else
+ {
+ fResult =
+ m_stylesheetRoot->isCDATASectionElementName(XalanQNameByReference(*elemNS, elementName));
+ }
+ }
+ }
+
+ return fResult;
+ }
+}
+
+
+
+const XalanDOMString*
+XSLTEngineImpl::getResultNamespaceForPrefix(const XalanDOMString& prefix) const
+{
+ return m_resultNamespacesStack.getNamespaceForPrefix(prefix);
+}
+
+
+
+const XalanDOMString*
+XSLTEngineImpl::getResultPrefixForNamespace(const XalanDOMString& theNamespace) const
+{
+ return m_resultNamespacesStack.getPrefixForNamespace(theNamespace);
+}
+
+
+
+inline bool
+isPrefixUsed(
+ const XalanDOMString& thePrefix,
+ unsigned int thePrefixLength,
+ const XalanDOMChar* theName,
+ unsigned int theNameLength)
+{
+ assert(thePrefixLength != 0);
+
+ // The name must be greater than the length of the prefix + 1, since
+ // there must be a ':' to separate the prefix from the local part...
+ if (theNameLength <= thePrefixLength + 1)
+ {
+ return false;
+ }
+ else
+ {
+ assert(theName != 0);
+
+ const unsigned int theIndex = indexOf(
+ theName,
+ XalanUnicode::charColon);
+
+ // OK, if the index of the ':' is the same as the length of the prefix,
+ // and theElementName starts with thePrefix, then the prefix is in use.
+ if (theIndex == thePrefixLength &&
+ startsWith(theName, thePrefix) == true)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
+
+
+inline bool
+isPrefixUsed(
+ const XalanDOMString& thePrefix,
+ unsigned int thePrefixLength,
+ const XalanDOMString& theName)
+{
+ return isPrefixUsed(thePrefix, thePrefixLength, c_wstr(theName), length(theName));
+}
+
+
+
+inline bool
+isPrefixUsedOrDeclared(
+ const XalanDOMString& thePrefix,
+ unsigned int thePrefixLength,
+ const XalanDOMChar* theName,
+ unsigned int theNameLength)
+{
+ if (isPrefixUsed(thePrefix, thePrefixLength, theName, theNameLength) == true)
+ {
+ return true;
+ }
+ else
+ {
+ const unsigned int theDeclarationLength =
+ thePrefixLength + DOMServices::s_XMLNamespaceWithSeparatorLength;
+
+ // If this is a namespace declaration for this prefix, then all of
+ // these conditions must be true...
+ if (theDeclarationLength == theNameLength &&
+ startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true &&
+ endsWith(theName, c_wstr(thePrefix)) == true)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
+
+
+inline bool
+isPendingAttributePrefix(
+ const AttributeList& thePendingAttributes,
+ const XalanDOMString& thePrefix,
+ unsigned int thePrefixLength)
+{
+ const unsigned int thePendingAttributesCount =
+ thePendingAttributes.getLength();
+
+ if (thePendingAttributesCount == 0)
+ {
+ // No attributes, no problem...
+ return false;
+ }
+ else
+ {
+ bool fResult = false;
+
+ // Check each attribute...
+ for (unsigned int i = 0; i < thePendingAttributesCount; ++i)
+ {
+ const XalanDOMChar* const thePendingAttributeName =
+ thePendingAttributes.getName(i);
+ assert(thePendingAttributeName != 0);
+
+ if (isPrefixUsedOrDeclared(
+ thePrefix,
+ thePrefixLength,
+ thePendingAttributeName,
+ length(thePendingAttributeName)) == true)
+ {
+ fResult = true;
+
+ break;
+ }
+ }
+
+ return fResult;
+ }
+}
+
+
+
+bool
+XSLTEngineImpl::isPendingResultPrefix(const XalanDOMString& thePrefix) const
+{
+ const unsigned int thePrefixLength = length(thePrefix);
+ assert(thePrefixLength > 0);
+
+ // The element name must be greater than the length of the prefix + 1, since
+ // there must be a ':' to separate the prefix from the local part...
+ if (isPrefixUsed(thePrefix, thePrefixLength, getPendingElementName()) == true)
+ {
+ return true;
+ }
+ else
+ {
+ // The element is not using the prefix, so check the
+ // pending attributes...
+ return isPendingAttributePrefix(
+ getPendingAttributes(),
+ thePrefix,
+ thePrefixLength);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::addResultNamespace(
+ const XalanNode& theNode,
+ AttributeListImpl& thePendingAttributes,
+ bool fOnlyIfPrefixNotPresent)
+{
+ assert(theNode.getNodeType() == XalanNode::ATTRIBUTE_NODE);
+
+ const XalanDOMString& aname = theNode.getNodeName();
+
+ const bool isPrefix = startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator);
+
+ const XalanDOMString prefix = isPrefix == true ?
+ substring(aname, DOMServices::s_XMLNamespaceWithSeparatorLength) : XalanDOMString();
+
+ if (equals(aname, DOMServices::s_XMLNamespace) || isPrefix)
+ {
+ if (fOnlyIfPrefixNotPresent == true)
+ {
+ if (m_resultNamespacesStack.prefixIsPresentLocal(prefix) == false)
+ {
+ const XalanDOMString* const desturi = getResultNamespaceForPrefix(prefix);
+ const XalanDOMString& srcURI = theNode.getNodeValue();
+
+ if(desturi == 0 || equals(srcURI, *desturi) == false)
+ {
+ addResultAttribute(thePendingAttributes, aname, srcURI);
+ }
+ }
+ }
+ else
+ {
+ const XalanDOMString* const desturi = getResultNamespaceForPrefix(prefix);
+ const XalanDOMString& srcURI = theNode.getNodeValue();
+
+ if(desturi == 0 || equals(srcURI, *desturi) == false)
+ {
+ addResultAttribute(thePendingAttributes, aname, srcURI);
+ }
+ }
+ }
+}
+
+
+
+void
+XSLTEngineImpl::copyNamespaceAttributes(const XalanNode& src)
+{
+ const XalanNode* parent = &src;
+
+ while (parent != 0 &&
+ parent->getNodeType() == XalanNode::ELEMENT_NODE)
+ {
+ const XalanNamedNodeMap* const nnm =
+ parent->getAttributes();
+ assert(nnm != 0);
+
+ const unsigned int nAttrs = nnm->getLength();
+
+ assert(m_outputContextStack.size() > 0);
+
+ AttributeListImpl& thePendingAttributes =
+ getPendingAttributesImpl();
+
+ for (unsigned int i = 0; i < nAttrs; i++)
+ {
+ const XalanNode* const attr = nnm->item(i);
+ assert(attr != 0);
+
+ addResultNamespace(*attr, thePendingAttributes, true);
+ }
+
+ parent = parent->getParentNode();
+ }
+}
+
+
+
+const XObjectPtr
+XSLTEngineImpl::evalXPathStr(
+ const XalanDOMString& str,
+ XPathExecutionContext& executionContext)
+{
+ assert(executionContext.getPrefixResolver() != 0);
+
+ XPath* const theXPath = m_xpathFactory.create();
+
+ XPathGuard theGuard(m_xpathFactory,
+ theXPath);
+
+ m_xpathProcessor->initXPath(*theXPath,
+ str,
+ *executionContext.getPrefixResolver(),
+ getLocatorFromStack());
+
+ return theXPath->execute(executionContext.getCurrentNode(),
+ *executionContext.getPrefixResolver(),
+ executionContext);
+}
+
+
+
+const XObjectPtr
+XSLTEngineImpl::evalXPathStr(
+ const XalanDOMString& str,
+ XalanNode* contextNode,
+ const PrefixResolver& prefixResolver,
+ XPathExecutionContext& executionContext)
+{
+ XPath* const theXPath = m_xpathFactory.create();
+
+ XPathGuard theGuard(m_xpathFactory,
+ theXPath);
+
+ m_xpathProcessor->initXPath(*theXPath,
+ str,
+ prefixResolver,
+ getLocatorFromStack());
+
+ return theXPath->execute(contextNode, prefixResolver, executionContext);
+}
+
+
+
+const XObjectPtr
+XSLTEngineImpl::evalXPathStr(
+ const XalanDOMString& str,
+ XalanNode* contextNode,
+ const XalanElement& prefixResolver,
+ XPathExecutionContext& executionContext)
+{
+ ElementPrefixResolverProxy theProxy(&prefixResolver,
+ m_xpathEnvSupport,
+ m_domSupport);
+
+ return evalXPathStr(str, contextNode, theProxy, executionContext);
+}
+
+
+
+
+/**
+ * Create and initialize an xpath and return it.
+ */
+const XPath*
+XSLTEngineImpl::createMatchPattern(
+ const XalanDOMString& str,
+ const PrefixResolver& resolver)
+{
+ XPath* const xpath = m_xpathFactory.create();
+
+ m_xpathProcessor->initMatchPattern(*xpath, str, resolver, getLocatorFromStack());
+
+ return xpath;
+}
+
+
+
+void
+XSLTEngineImpl::returnXPath(const XPath* xpath)
+{
+ m_xpathFactory.returnObject(xpath);
+}
+
+
+
+inline void
+XSLTEngineImpl::copyAttributeToTarget(
+ const XalanDOMString& attrName,
+ const XalanDOMString& attrValue,
+ AttributeListImpl& attrList)
+{
+ // TODO: Find out about empty attribute template expression handling.
+ if(0 != length(attrValue))
+ {
+ addResultAttribute(attrList, attrName, attrValue);
+ }
+}
+
+
+
+void
+XSLTEngineImpl::copyAttributesToAttList(
+ const Stylesheet* stylesheetTree,
+ const XalanNode& node,
+ AttributeListImpl& attList)
+{
+ assert(m_stylesheetRoot != 0);
+ assert(stylesheetTree != 0);
+
+ const XalanNamedNodeMap* const attributes =
+ node.getAttributes();
+
+ if (attributes != 0)
+ {
+ const unsigned int nAttributes = attributes->getLength();
+
+ for(unsigned int i = 0; i < nAttributes; ++i)
+ {
+ const XalanNode* const attr = attributes->item(i);
+ assert(attr != 0);
+
+ copyAttributeToTarget(
+ attr->getNodeName(),
+ attr->getNodeValue(),
+ attList);
+ }
+ }
+}
+
+
+
+bool
+XSLTEngineImpl::shouldStripSourceNode(
+ XPathExecutionContext& executionContext,
+ const XalanNode& textNode) const
+{
+ if (m_stylesheetRoot == 0)
+ {
+ return false;
+ }
+ else
+ {
+ bool strip = false; // return value
+
+ if((m_stylesheetRoot->getWhitespacePreservingElements().size() > 0 ||
+ m_stylesheetRoot->getWhitespaceStrippingElements().size() > 0))
+ {
+ const XalanNode::NodeType type = textNode.getNodeType();
+
+ if(XalanNode::TEXT_NODE == type || XalanNode::CDATA_SECTION_NODE == type)
+ {
+ const XalanText& theTextNode =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (const XalanText&)textNode;
+#else
+ static_cast<const XalanText&>(textNode);
+#endif
+
+ if(!theTextNode.isIgnorableWhitespace())
+ {
+ const XalanDOMString& data = theTextNode.getData();
+
+ if(0 == length(data))
+ {
+ return true;
+ }
+ else if(!isXMLWhitespace(data))
+ {
+ return false;
+ }
+ }
+
+ XalanNode* parent = DOMServices::getParentOfNode(textNode);
+
+ while(0 != parent)
+ {
+ if(parent->getNodeType() == XalanNode::ELEMENT_NODE)
+ {
+ const XalanElement* const parentElem =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (const XalanElement*)parent;
+#else
+ static_cast<const XalanElement*>(parent);
+#endif
+
+ XPath::eMatchScore highPreserveScore = XPath::eMatchScoreNone;
+ XPath::eMatchScore highStripScore = XPath::eMatchScoreNone;
+
+ ElementPrefixResolverProxy theProxy(parentElem, m_xpathEnvSupport, m_domSupport);
+
+ {
+ // $$$ ToDo: All of this should be moved into a member of
+ // Stylesheet, so as not to expose these two data members...
+ typedef Stylesheet::XPathVectorType XPathVectorType;
+
+ const XPathVectorType& theElements =
+ m_stylesheetRoot->getWhitespacePreservingElements();
+
+ const XPathVectorType::size_type nTests =
+ theElements.size();
+
+ for(XPathVectorType::size_type i = 0; i < nTests; i++)
+ {
+ const XPath* const matchPat = theElements[i];
+ assert(matchPat != 0);
+
+ const XPath::eMatchScore score = matchPat->getMatchScore(parent, theProxy, executionContext);
+
+ if(score > highPreserveScore)
+ highPreserveScore = score;
+ }
+ }
+
+ {
+ typedef Stylesheet::XPathVectorType XPathVectorType;
+
+ const XPathVectorType& theElements =
+ m_stylesheetRoot->getWhitespaceStrippingElements();
+
+ const XPathVectorType::size_type nTests =
+ theElements.size();
+
+ for(XPathVectorType::size_type i = 0; i < nTests; i++)
+ {
+ const XPath* const matchPat =
+ theElements[i];
+ assert(matchPat != 0);
+
+ const XPath::eMatchScore score = matchPat->getMatchScore(parent, theProxy, executionContext);
+
+ if(score > highStripScore)
+ highStripScore = score;
+ }
+ }
+
+ if(highPreserveScore > XPath::eMatchScoreNone ||
+ highStripScore > XPath::eMatchScoreNone)
+ {
+ if(highPreserveScore > highStripScore)
+ {
+ strip = false;
+ }
+ else if(highStripScore > highPreserveScore)
+ {
+ strip = true;
+ }
+ else
+ {
+ warn("Match conflict between xsl:strip-space and xsl:preserve-space");
+ }
+ break;
+ }
+ }
+
+ parent = parent->getParentNode();
+ }
+ }
+ }
+
+ return strip;
+ }
+}
+
+
+
+XMLParserLiaison&
+XSLTEngineImpl::getXMLParserLiaison() const
+{
+ return m_parserLiaison;
+}
+
+
+
+const XalanDOMString
+XSLTEngineImpl::getUniqueNamespaceValue()
+{
+ XalanDOMString theResult;
+
+ getUniqueNamespaceValue(theResult);
+
+ return theResult;
+}
+
+
+
+void
+XSLTEngineImpl::getUniqueNamespaceValue(XalanDOMString& theValue)
+{
+ append(theValue, s_uniqueNamespacePrefix);
+
+ UnsignedLongToDOMString(m_uniqueNSValue++, theValue);
+}
+
+
+
+XalanDocument*
+XSLTEngineImpl::getDOMFactory() const
+{
+ if(m_domResultTreeFactory == 0)
+ {
+#if defined(XALAN_NO_MUTABLE)
+ ((XSLTEngineImpl*)this)->m_domResultTreeFactory = m_parserLiaison.createDOMFactory();
+#else
+ m_domResultTreeFactory = m_parserLiaison.createDOMFactory();
+#endif
+ }
+
+ return m_domResultTreeFactory;
+}
+
+
+
+void
+XSLTEngineImpl::setStylesheetParam(
+ const XalanDOMString& theName,
+ const XalanDOMString& expression)
+{
+ const XalanQNameByValue qname(theName, 0, m_xpathEnvSupport, m_domSupport);
+
+ m_topLevelParams.push_back(ParamVectorType::value_type(qname, expression));
+}
+
+
+
+void
+XSLTEngineImpl::setStylesheetParam(
+ const XalanDOMString& theName,
+ XObjectPtr theValue)
+{
+ const XalanQNameByValue qname(theName, 0, m_xpathEnvSupport, m_domSupport);
+
+ m_topLevelParams.push_back(ParamVectorType::value_type(qname, theValue));
+}
+
+
+
+void
+XSLTEngineImpl::resolveTopLevelParams(StylesheetExecutionContext& executionContext)
+{
+ executionContext.pushTopLevelVariables(m_topLevelParams);
+}
+
+
+
+FormatterListener*
+XSLTEngineImpl::getFormatterListener() const
+{
+ return getFormatterListenerImpl();
+}
+
+
+
+void
+XSLTEngineImpl::setFormatterListener(FormatterListener* flistener)
+{
+ if (getHasPendingStartDocument() == true && getFormatterListener() != 0)
+ {
+ setMustFlushPendingStartDocument(true);
+
+ flushPending();
+ }
+
+ setFormatterListenerImpl(flistener);
+}
+
+
+
+void
+XSLTEngineImpl::fireCharacterGenerateEvent(
+ const XalanNode& theNode,
+ bool isCDATA)
+{
+ fireCharacterGenerateEvent(DOMServices::getNodeData(theNode), isCDATA);
+}
+
+
+
+void
+XSLTEngineImpl::fireCharacterGenerateEvent(
+ const XObjectPtr& theXObject,
+ bool isCDATA)
+{
+ fireCharacterGenerateEvent(theXObject->str(), isCDATA);
+}
+
+
+
+void
+XSLTEngineImpl::fireCharacterGenerateEvent(
+ const XalanDOMString& theString,
+ bool isCDATA)
+{
+ fireCharacterGenerateEvent(c_wstr(theString), 0, length(theString), isCDATA);
+}
+
+
+
+void
+XSLTEngineImpl::fireCharacterGenerateEvent(
+ const XMLCh* ch,
+ unsigned int start,
+ unsigned int length,
+ bool isCDATA)
+{
+ const GenerateEvent ge(
+ isCDATA == true ? GenerateEvent::EVENTTYPE_CDATA : GenerateEvent::EVENTTYPE_CHARACTERS,
+ ch,
+ start,
+ length);
+
+ fireGenerateEvent(ge);
+}
+
+
+
+void
+XSLTEngineImpl::installFunctions()
+{
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("current")), FunctionCurrent());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("document")), FunctionDocument());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("element-available")), FunctionElementAvailable());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("function-available")), FunctionFunctionAvailable());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("format-number")), FunctionFormatNumber());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("generate-id")), FunctionGenerateID());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("key")), FunctionKey());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("system-property")), FunctionSystemProperty());
+ XPath::installFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("unparsed-entity-uri")), FunctionUnparsedEntityURI());
+}
+
+
+
+void
+XSLTEngineImpl::uninstallFunctions()
+{
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("current")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("document")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("element-available")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("function-available")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("format-number")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("generate-id")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("key")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("system-property")));
+ XPath::uninstallFunction(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("unparsed-entity-uri")));
+}
+
+
+
+void
+XSLTEngineImpl::initializeAttributeKeysTable(AttributeKeysMapType& theAttributeKeys)
+{
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_METHOD] = Constants::TATTRNAME_OUTPUT_METHOD;
+ theAttributeKeys[Constants::ATTRNAME_AMOUNT] = Constants::TATTRNAME_AMOUNT;
+ theAttributeKeys[Constants::ATTRNAME_ANCESTOR] = Constants::TATTRNAME_ANCESTOR;
+ theAttributeKeys[Constants::ATTRNAME_ARCHIVE] = Constants::TATTRNAME_ARCHIVE;
+ theAttributeKeys[Constants::ATTRNAME_ATTRIBUTE] = Constants::TATTRNAME_ATTRIBUTE;
+ theAttributeKeys[Constants::ATTRNAME_ATTRIBUTE_SET] = Constants::TATTRNAME_ATTRIBUTE_SET;
+ theAttributeKeys[Constants::ATTRNAME_CASEORDER] = Constants::TATTRNAME_CASEORDER;
+ theAttributeKeys[Constants::ATTRNAME_CLASS] = Constants::TATTRNAME_CLASS;
+ theAttributeKeys[Constants::ATTRNAME_CLASSID] = Constants::TATTRNAME_CLASSID;
+ theAttributeKeys[Constants::ATTRNAME_CODEBASE] = Constants::TATTRNAME_CODEBASE;
+ theAttributeKeys[Constants::ATTRNAME_CODETYPE] = Constants::TATTRNAME_CODETYPE;
+ theAttributeKeys[Constants::ATTRNAME_CONDITION] = Constants::TATTRNAME_CONDITION;
+ theAttributeKeys[Constants::ATTRNAME_COPYTYPE] = Constants::TATTRNAME_COPYTYPE;
+ theAttributeKeys[Constants::ATTRNAME_COUNT] = Constants::TATTRNAME_COUNT;
+ theAttributeKeys[Constants::ATTRNAME_DATATYPE] = Constants::TATTRNAME_DATATYPE;
+ theAttributeKeys[Constants::ATTRNAME_DEFAULT] = Constants::TATTRNAME_DEFAULT;
+ theAttributeKeys[Constants::ATTRNAME_DEFAULTSPACE] = Constants::TATTRNAME_DEFAULTSPACE;
+ theAttributeKeys[Constants::ATTRNAME_DEPTH] = Constants::TATTRNAME_DEPTH;
+ theAttributeKeys[Constants::ATTRNAME_DIGITGROUPSEP] = Constants::TATTRNAME_DIGITGROUPSEP;
+ theAttributeKeys[Constants::ATTRNAME_DISABLE_OUTPUT_ESCAPING] = Constants::TATTRNAME_DISABLE_OUTPUT_ESCAPING;
+ theAttributeKeys[Constants::ATTRNAME_ELEMENT] = Constants::TATTRNAME_ELEMENT;
+ theAttributeKeys[Constants::ATTRNAME_ELEMENTS] = Constants::TATTRNAME_ELEMENTS;
+ theAttributeKeys[Constants::ATTRNAME_EXPR] = Constants::TATTRNAME_EXPR;
+ theAttributeKeys[Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES] = Constants::TATTRNAME_EXTENSIONELEMENTPREFIXES;
+ theAttributeKeys[Constants::ATTRNAME_FORMAT] = Constants::TATTRNAME_FORMAT;
+ theAttributeKeys[Constants::ATTRNAME_FROM] = Constants::TATTRNAME_FROM;
+ theAttributeKeys[Constants::ATTRNAME_GROUPINGSEPARATOR] = Constants::TATTRNAME_GROUPINGSEPARATOR;
+ theAttributeKeys[Constants::ATTRNAME_GROUPINGSIZE] = Constants::TATTRNAME_GROUPINGSIZE;
+ theAttributeKeys[Constants::ATTRNAME_HREF] = Constants::TATTRNAME_HREF;
+ theAttributeKeys[Constants::ATTRNAME_ID] = Constants::TATTRNAME_ID;
+ theAttributeKeys[Constants::ATTRNAME_IMPORTANCE] = Constants::TATTRNAME_IMPORTANCE;
+ theAttributeKeys[Constants::ATTRNAME_INDENTRESULT] = Constants::TATTRNAME_INDENTRESULT;
+ theAttributeKeys[Constants::ATTRNAME_LANG] = Constants::TATTRNAME_LANG;
+ theAttributeKeys[Constants::ATTRNAME_LETTERVALUE] = Constants::TATTRNAME_LETTERVALUE;
+ theAttributeKeys[Constants::ATTRNAME_LEVEL] = Constants::TATTRNAME_LEVEL;
+ theAttributeKeys[Constants::ATTRNAME_MATCH] = Constants::TATTRNAME_MATCH;
+ theAttributeKeys[Constants::ATTRNAME_METHOD] = Constants::TATTRNAME_METHOD;
+ theAttributeKeys[Constants::ATTRNAME_MODE] = Constants::TATTRNAME_MODE;
+ theAttributeKeys[Constants::ATTRNAME_NAME] = Constants::TATTRNAME_NAME;
+ theAttributeKeys[Constants::ATTRNAME_NAMESPACE] = Constants::TATTRNAME_NAMESPACE;
+ theAttributeKeys[Constants::ATTRNAME_NDIGITSPERGROUP] = Constants::TATTRNAME_NDIGITSPERGROUP;
+ theAttributeKeys[Constants::ATTRNAME_NS] = Constants::TATTRNAME_NS;
+ theAttributeKeys[Constants::ATTRNAME_ONLY] = Constants::TATTRNAME_ONLY;
+ theAttributeKeys[Constants::ATTRNAME_ORDER] = Constants::TATTRNAME_ORDER;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS] = Constants::TATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_DOCTYPE_PUBLIC] = Constants::TATTRNAME_OUTPUT_DOCTYPE_PUBLIC;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_DOCTYPE_SYSTEM] = Constants::TATTRNAME_OUTPUT_DOCTYPE_SYSTEM;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_ENCODING] = Constants::TATTRNAME_OUTPUT_ENCODING;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_INDENT] = Constants::TATTRNAME_OUTPUT_INDENT;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_MEDIATYPE] = Constants::TATTRNAME_OUTPUT_MEDIATYPE;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_STANDALONE] = Constants::TATTRNAME_OUTPUT_STANDALONE;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_VERSION] = Constants::TATTRNAME_OUTPUT_VERSION;
+ theAttributeKeys[Constants::ATTRNAME_OUTPUT_OMITXMLDECL] = Constants::TATTRNAME_OUTPUT_OMITXMLDECL;
+ theAttributeKeys[Constants::ATTRNAME_PRIORITY] = Constants::TATTRNAME_PRIORITY;
+ theAttributeKeys[Constants::ATTRNAME_REFID] = Constants::TATTRNAME_REFID;
+ theAttributeKeys[Constants::ATTRNAME_RESULTNS] = Constants::TATTRNAME_RESULTNS;
+ theAttributeKeys[Constants::ATTRNAME_SELECT] = Constants::TATTRNAME_SELECT;
+ theAttributeKeys[Constants::ATTRNAME_SEQUENCESRC] = Constants::TATTRNAME_SEQUENCESRC;
+ theAttributeKeys[Constants::ATTRNAME_STYLE] = Constants::TATTRNAME_STYLE;
+ theAttributeKeys[Constants::ATTRNAME_TEST] = Constants::TATTRNAME_TEST;
+ theAttributeKeys[Constants::ATTRNAME_TOSTRING] = Constants::TATTRNAME_TOSTRING;
+ theAttributeKeys[Constants::ATTRNAME_TYPE] = Constants::TATTRNAME_TYPE;
+ theAttributeKeys[Constants::ATTRNAME_USE] = Constants::TATTRNAME_USE;
+ theAttributeKeys[Constants::ATTRNAME_USEATTRIBUTESETS] = Constants::TATTRNAME_USEATTRIBUTESETS;
+ theAttributeKeys[Constants::ATTRNAME_VALUE] = Constants::TATTRNAME_VALUE;
+
+ theAttributeKeys[Constants::ATTRNAME_XMLNSDEF] = Constants::TATTRNAME_XMLNSDEF;
+ theAttributeKeys[Constants::ATTRNAME_XMLNS] = Constants::TATTRNAME_XMLNS;
+ theAttributeKeys[Constants::ATTRNAME_XMLSPACE] = Constants::TATTRNAME_XMLSPACE;
+}
+
+
+
+void
+XSLTEngineImpl::initializeElementKeysTable(ElementKeysMapType& theElementKeys)
+{
+ theElementKeys[Constants::ELEMNAME_APPLY_TEMPLATES_STRING] = Constants::ELEMNAME_APPLY_TEMPLATES;
+ theElementKeys[Constants::ELEMNAME_WITHPARAM_STRING] = Constants::ELEMNAME_WITHPARAM;
+ theElementKeys[Constants::ELEMNAME_CONSTRUCT_STRING] = Constants::ELEMNAME_CONSTRUCT;
+ theElementKeys[Constants::ELEMNAME_CONTENTS_STRING] = Constants::ELEMNAME_CONTENTS;
+ theElementKeys[Constants::ELEMNAME_COPY_STRING] = Constants::ELEMNAME_COPY;
+ theElementKeys[Constants::ELEMNAME_COPY_OF_STRING] = Constants::ELEMNAME_COPY_OF;
+
+ theElementKeys[Constants::ELEMNAME_ATTRIBUTESET_STRING] = Constants::ELEMNAME_DEFINEATTRIBUTESET;
+
+ theElementKeys[Constants::ELEMNAME_USE_STRING] = Constants::ELEMNAME_USE;
+
+ theElementKeys[Constants::ELEMNAME_VARIABLE_STRING] = Constants::ELEMNAME_VARIABLE;
+ theElementKeys[Constants::ELEMNAME_PARAMVARIABLE_STRING] = Constants::ELEMNAME_PARAMVARIABLE;
+
+ theElementKeys[Constants::ELEMNAME_DISPLAYIF_STRING] = Constants::ELEMNAME_DISPLAYIF;
+ theElementKeys[Constants::ELEMNAME_EMPTY_STRING] = Constants::ELEMNAME_EMPTY;
+ theElementKeys[Constants::ELEMNAME_EVAL_STRING] = Constants::ELEMNAME_EVAL;
+ theElementKeys[Constants::ELEMNAME_CALLTEMPLATE_STRING] = Constants::ELEMNAME_CALLTEMPLATE;
+ theElementKeys[Constants::ELEMNAME_TEMPLATE_STRING] = Constants::ELEMNAME_TEMPLATE;
+ theElementKeys[Constants::ELEMNAME_STYLESHEET_STRING] = Constants::ELEMNAME_STYLESHEET;
+ theElementKeys[Constants::ELEMNAME_TRANSFORM_STRING] = Constants::ELEMNAME_STYLESHEET;
+ theElementKeys[Constants::ELEMNAME_IMPORT_STRING] = Constants::ELEMNAME_IMPORT;
+ theElementKeys[Constants::ELEMNAME_INCLUDE_STRING] = Constants::ELEMNAME_INCLUDE;
+ theElementKeys[Constants::ELEMNAME_FOREACH_STRING] = Constants::ELEMNAME_FOREACH;
+ theElementKeys[Constants::ELEMNAME_VALUEOF_STRING] = Constants::ELEMNAME_VALUEOF;
+ theElementKeys[Constants::ELEMNAME_KEY_STRING] = Constants::ELEMNAME_KEY;
+ theElementKeys[Constants::ELEMNAME_STRIPSPACE_STRING] = Constants::ELEMNAME_STRIPSPACE;
+ theElementKeys[Constants::ELEMNAME_PRESERVESPACE_STRING] = Constants::ELEMNAME_PRESERVESPACE;
+ theElementKeys[Constants::ELEMNAME_NUMBER_STRING] = Constants::ELEMNAME_NUMBER;
+ theElementKeys[Constants::ELEMNAME_IF_STRING] = Constants::ELEMNAME_IF;
+ theElementKeys[Constants::ELEMNAME_CHOOSE_STRING] = Constants::ELEMNAME_CHOOSE;
+ theElementKeys[Constants::ELEMNAME_WHEN_STRING] = Constants::ELEMNAME_WHEN;
+ theElementKeys[Constants::ELEMNAME_OTHERWISE_STRING] = Constants::ELEMNAME_OTHERWISE;
+ theElementKeys[Constants::ELEMNAME_TEXT_STRING] = Constants::ELEMNAME_TEXT;
+ theElementKeys[Constants::ELEMNAME_ELEMENT_STRING] = Constants::ELEMNAME_ELEMENT;
+ theElementKeys[Constants::ELEMNAME_ATTRIBUTE_STRING] = Constants::ELEMNAME_ATTRIBUTE;
+ theElementKeys[Constants::ELEMNAME_SORT_STRING] = Constants::ELEMNAME_SORT;
+ theElementKeys[Constants::ELEMNAME_PI_STRING] = Constants::ELEMNAME_PI;
+ theElementKeys[Constants::ELEMNAME_COMMENT_STRING] = Constants::ELEMNAME_COMMENT;
+
+ theElementKeys[Constants::ELEMNAME_COUNTER_STRING] = Constants::ELEMNAME_COUNTER;
+ theElementKeys[Constants::ELEMNAME_COUNTERS_STRING] = Constants::ELEMNAME_COUNTERS;
+ theElementKeys[Constants::ELEMNAME_COUNTERINCREMENT_STRING] = Constants::ELEMNAME_COUNTERINCREMENT;
+ theElementKeys[Constants::ELEMNAME_COUNTERRESET_STRING] = Constants::ELEMNAME_COUNTERRESET;
+ theElementKeys[Constants::ELEMNAME_COUNTERSCOPE_STRING] = Constants::ELEMNAME_COUNTERSCOPE;
+
+ theElementKeys[Constants::ELEMNAME_APPLY_IMPORTS_STRING] = Constants::ELEMNAME_APPLY_IMPORTS;
+
+ theElementKeys[Constants::ELEMNAME_EXTENSION_STRING] = Constants::ELEMNAME_EXTENSION;
+ theElementKeys[Constants::ELEMNAME_MESSAGE_STRING] = Constants::ELEMNAME_MESSAGE;
+ theElementKeys[Constants::ELEMNAME_LOCALE_STRING] = Constants::ELEMNAME_LOCALE;
+ theElementKeys[Constants::ELEMNAME_FALLBACK_STRING] = Constants::ELEMNAME_FALLBACK;
+ theElementKeys[Constants::ELEMNAME_OUTPUT_STRING] = Constants::ELEMNAME_OUTPUT;
+
+ theElementKeys[Constants::ELEMNAME_DECIMALFORMAT_STRING] = Constants::ELEMNAME_DECIMALFORMAT;
+ theElementKeys[Constants::ELEMNAME_NSALIAS_STRING] = Constants::ELEMNAME_NSALIAS;
+}
+
+
+
+void
+XSLTEngineImpl::initializeXSLT4JElementKeys(ElementKeysMapType& theElementKeys)
+{
+ theElementKeys[Constants::ELEMNAME_COMPONENT_STRING] = Constants::ELEMNAME_COMPONENT;
+ theElementKeys[Constants::ELEMNAME_SCRIPT_STRING] = Constants::ELEMNAME_SCRIPT;
+}
+
+
+
+static XalanDOMString s_XSLNameSpaceURL;
+
+static XalanDOMString s_XSLT4JNameSpaceURL;
+
+static XalanDOMString s_uniqueNamespacePrefix;
+
+static XSLTEngineImpl::AttributeKeysMapType s_attributeKeys;
+
+static XSLTEngineImpl::ElementKeysMapType s_elementKeys;
+
+static XSLTEngineImpl::ElementKeysMapType s_XSLT4JElementKeys;
+
+
+
+const double XSLTEngineImpl::s_XSLTVerSupported(1.0);
+
+const XalanDOMString& XSLTEngineImpl::s_XSLNameSpaceURL = ::s_XSLNameSpaceURL;
+
+const XalanDOMString& XSLTEngineImpl::s_XSLT4JNameSpaceURL = ::s_XSLT4JNameSpaceURL;
+
+const XalanDOMString& XSLTEngineImpl::s_uniqueNamespacePrefix = ::s_uniqueNamespacePrefix;
+
+
+const XSLTEngineImpl::AttributeKeysMapType& XSLTEngineImpl::s_attributeKeys = ::s_attributeKeys;
+
+const XSLTEngineImpl::ElementKeysMapType& XSLTEngineImpl::s_elementKeys = ::s_elementKeys;
+
+const XSLTEngineImpl::ElementKeysMapType& XSLTEngineImpl::s_XSLT4JElementKeys = ::s_XSLT4JElementKeys;
+
+
+
+void
+XSLTEngineImpl::initialize()
+{
+ ::s_XSLNameSpaceURL = XALAN_STATIC_UCODE_STRING("http://www.w3.org/1999/XSL/Transform");
+
+ ::s_XSLT4JNameSpaceURL = XALAN_STATIC_UCODE_STRING("http://xml.apache.org/xslt");
+
+ ::s_uniqueNamespacePrefix = XALAN_STATIC_UCODE_STRING("ns");
+
+ installFunctions();
+
+ initializeAttributeKeysTable(::s_attributeKeys);
+
+ initializeElementKeysTable(::s_elementKeys);
+
+ initializeXSLT4JElementKeys(::s_XSLT4JElementKeys);
+}
+
+
+
+void
+XSLTEngineImpl::terminate()
+{
+ ElementKeysMapType().swap(::s_XSLT4JElementKeys);
+
+ ElementKeysMapType().swap(::s_elementKeys);
+
+ AttributeKeysMapType().swap(::s_attributeKeys);
+
+ uninstallFunctions();
+
+ releaseMemory(::s_uniqueNamespacePrefix);
+
+ releaseMemory(::s_XSLT4JNameSpaceURL);
+
+ releaseMemory(::s_XSLNameSpaceURL);
+}
diff --git a/src/XalanExtensions/FunctionEvaluate.cpp b/src/XalanExtensions/FunctionEvaluate.cpp
new file mode 100644
index 0000000..90a4ef0
--- /dev/null
+++ b/src/XalanExtensions/FunctionEvaluate.cpp
@@ -0,0 +1,207 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#include "FunctionEvaluate.hpp"
+
+
+
+#include <PlatformSupport/PrefixResolver.hpp>
+
+
+
+#include <XPath/XObjectFactory.hpp>
+#include <XPath/XPath.hpp>
+#include <XPath/XPathProcessorImpl.hpp>
+
+
+
+FunctionEvaluate::FunctionEvaluate()
+{
+}
+
+
+
+FunctionEvaluate::~FunctionEvaluate()
+{
+}
+
+
+
+XObjectPtr
+FunctionEvaluate::execute(
+ XPathExecutionContext& executionContext,
+ XalanNode* context)
+{
+ executionContext.error(getError(), context);
+
+ return XObjectPtr(0);
+}
+
+
+
+XObjectPtr
+FunctionEvaluate::execute(
+ XPathExecutionContext& executionContext,
+ XalanNode* context,
+ const XObjectPtr arg1)
+{
+ assert(arg1.null() == false);
+
+ const PrefixResolver* const theResolver =
+ executionContext.getPrefixResolver();
+
+ if (theResolver == 0)
+ {
+ executionContext.warn(
+ "No prefix resolver available in evaluate()!",
+ context);
+
+ return arg1;
+ }
+ else
+ {
+ const XalanDOMString& theString =
+ arg1->str();
+
+ if (length(theString) == 0)
+ {
+ return XObjectPtr(0);
+ }
+ else
+ {
+ XPathProcessorImpl theProcessor;
+
+ XPath theXPath;
+
+ theProcessor.initXPath(
+ theXPath,
+ theString,
+ *theResolver);
+
+ return theXPath.execute(context, *theResolver, executionContext);
+ }
+ }
+}
+
+
+
+XObjectPtr
+FunctionEvaluate::execute(
+ XPathExecutionContext& executionContext,
+ XalanNode* context,
+ const XObjectPtr /* arg1 */,
+ const XObjectPtr /* arg2 */)
+{
+ executionContext.error(getError(), context);
+
+ return XObjectPtr(0);
+}
+
+
+
+XObjectPtr
+FunctionEvaluate::execute(
+ XPathExecutionContext& executionContext,
+ XalanNode* context,
+ const XObjectPtr /* arg1 */,
+ const XObjectPtr /* arg2 */,
+ const XObjectPtr /* arg3 */)
+{
+ executionContext.error(getError(), context);
+
+ return XObjectPtr(0);
+}
+
+
+
+XObjectPtr
+FunctionEvaluate::execute(
+ XPathExecutionContext& executionContext,
+ XalanNode* context,
+ int /* opPos */,
+ const XObjectArgVectorType& args)
+{
+ if (args.size() != 1)
+ {
+ executionContext.error(getError(), context);
+
+ return XObjectPtr(0);
+ }
+ else
+ {
+ return execute(executionContext, context, args[0]);
+ }
+}
+
+
+
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+Function*
+#else
+FunctionEvaluate*
+#endif
+FunctionEvaluate::clone() const
+{
+ return new FunctionEvaluate(*this);
+}
+
+
+
+const XalanDOMString
+FunctionEvaluate::getError() const
+{
+ return XALAN_STATIC_UCODE_STRING("The evaluate() function takes one argument");
+}
diff --git a/src/XalanSourceTree/XalanSourceTreeParserLiaison.cpp b/src/XalanSourceTree/XalanSourceTreeParserLiaison.cpp
new file mode 100644
index 0000000..f2a98cb
--- /dev/null
+++ b/src/XalanSourceTree/XalanSourceTreeParserLiaison.cpp
@@ -0,0 +1,523 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+// Class header file.
+#include "XalanSourceTreeParserLiaison.hpp"
+
+
+
+#include <algorithm>
+
+
+
+#include <sax2/XMLReaderFactory.hpp>
+
+
+
+#include <Include/XalanAutoPtr.hpp>
+#include <Include/STLHelper.hpp>
+
+
+
+#include <PlatformSupport/XalanUnicode.hpp>
+
+
+
+#include "XalanSourceTreeContentHandler.hpp"
+#include "XalanSourceTreeDOMSupport.hpp"
+#include "XalanSourceTreeDocument.hpp"
+
+
+
+// http://xml.org/sax/features/validation
+const XalanDOMChar XalanSourceTreeParserLiaison::validationString[] = {
+ XalanUnicode::charLetter_h,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charColon,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charLetter_x,
+ XalanUnicode::charLetter_m,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charFullStop,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_g,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_x,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charLetter_f,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_u,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charLetter_v,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_n,
+ 0
+};
+
+
+
+XalanSourceTreeParserLiaison::XalanSourceTreeParserLiaison(XalanSourceTreeDOMSupport& /* theSupport */) :
+ m_documentNumber(0),
+ m_xercesParserLiaison(),
+ m_documentMap(),
+ m_persistentDocumentMap(),
+ m_poolAllText(true)
+{
+}
+
+
+
+XalanSourceTreeParserLiaison::XalanSourceTreeParserLiaison() :
+ m_xercesParserLiaison(),
+ m_documentMap(),
+ m_persistentDocumentMap(),
+ m_poolAllText(true)
+{
+}
+
+
+
+XalanSourceTreeParserLiaison::~XalanSourceTreeParserLiaison()
+{
+ reset();
+
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ // Delete any persistent documents.
+ for_each(m_persistentDocumentMap.begin(),
+ m_persistentDocumentMap.end(),
+ makeMapValueDeleteFunctor(m_persistentDocumentMap));
+
+ m_persistentDocumentMap.clear();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::reset()
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ // Delete any documents.
+ for_each(m_documentMap.begin(),
+ m_documentMap.end(),
+ makeMapValueDeleteFunctor(m_documentMap));
+
+ m_documentMap.clear();
+
+ m_xercesParserLiaison.reset();
+}
+
+
+
+ExecutionContext*
+XalanSourceTreeParserLiaison::getExecutionContext() const
+{
+ return m_xercesParserLiaison.getExecutionContext();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setExecutionContext(ExecutionContext& theContext)
+{
+ m_xercesParserLiaison.setExecutionContext(theContext);
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::parseXMLStream(
+ const InputSource& inputSource,
+ DocumentHandler& handler,
+ const XalanDOMString& identifier)
+{
+ m_xercesParserLiaison.parseXMLStream(inputSource, handler, identifier);
+}
+
+
+
+XalanDocument*
+XalanSourceTreeParserLiaison::parseXMLStream(
+ const InputSource& inputSource,
+ const XalanDOMString& /* identifier */)
+{
+ XalanSourceTreeContentHandler theContentHandler(createXalanSourceTreeDocument());
+
+ XalanAutoPtr<SAX2XMLReader> theReader(XMLReaderFactory::createXMLReader());
+
+ theReader->setFeature(
+ validationString,
+ m_xercesParserLiaison.getUseValidation());
+
+ theReader->setContentHandler(&theContentHandler);
+
+ theReader->setDTDHandler(&theContentHandler);
+
+ theReader->setErrorHandler(&m_xercesParserLiaison);
+
+ theReader->setLexicalHandler(&theContentHandler);
+
+ theReader->setEntityResolver(getEntityResolver());
+
+ theReader->parse(inputSource);
+
+ return theContentHandler.getDocument();
+}
+
+
+
+XalanDocument*
+XalanSourceTreeParserLiaison::createDocument()
+{
+ return createXalanSourceTreeDocument();
+}
+
+
+
+XalanDocument*
+XalanSourceTreeParserLiaison::createDOMFactory()
+{
+ return m_xercesParserLiaison.createDocument();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::destroyDocument(XalanDocument* theDocument)
+{
+ if (mapDocument(theDocument) != 0)
+ {
+ m_documentMap.erase(theDocument);
+
+ delete theDocument;
+ }
+}
+
+
+
+unsigned long
+XalanSourceTreeParserLiaison::getDocumentNumber()
+{
+ return m_documentNumber++;
+}
+
+
+
+int
+XalanSourceTreeParserLiaison::getIndent() const
+{
+ return m_xercesParserLiaison.getIndent();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setIndent(int i)
+{
+ m_xercesParserLiaison.setIndent(i);
+}
+
+
+
+bool
+XalanSourceTreeParserLiaison::getUseValidation() const
+{
+ return m_xercesParserLiaison.getUseValidation();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setUseValidation(bool b)
+{
+ m_xercesParserLiaison.setUseValidation(b);
+}
+
+
+
+const XalanDOMString
+XalanSourceTreeParserLiaison::getParserDescription() const
+{
+ return XALAN_STATIC_UCODE_STRING("XalanSourceTree");
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::parseXMLStream(
+ const InputSource& theInputSource,
+ ContentHandler& theContentHandler,
+ DTDHandler* theDTDHandler,
+ LexicalHandler* theLexicalHandler,
+ const XalanDOMString& /* theIdentifier */)
+{
+ XalanAutoPtr<SAX2XMLReader> theReader(XMLReaderFactory::createXMLReader());
+
+ theReader->setFeature(
+ validationString,
+ m_xercesParserLiaison.getUseValidation());
+
+ theReader->setContentHandler(&theContentHandler);
+
+ theReader->setDTDHandler(theDTDHandler);
+
+ theReader->setErrorHandler(&m_xercesParserLiaison);
+
+ theReader->setLexicalHandler(theLexicalHandler);
+
+ EntityResolver* const theResolver = getEntityResolver();
+
+ if (theResolver != 0)
+ {
+ theReader->setEntityResolver(theResolver);
+ }
+
+ theReader->parse(theInputSource);
+}
+
+
+
+bool
+XalanSourceTreeParserLiaison::getIncludeIgnorableWhitespace() const
+{
+ return m_xercesParserLiaison.getIncludeIgnorableWhitespace();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setIncludeIgnorableWhitespace(bool include)
+{
+ m_xercesParserLiaison.setIncludeIgnorableWhitespace(include);
+}
+
+
+
+ErrorHandler*
+XalanSourceTreeParserLiaison::getErrorHandler()
+{
+ return m_xercesParserLiaison.getErrorHandler();
+}
+
+
+
+const ErrorHandler*
+XalanSourceTreeParserLiaison::getErrorHandler() const
+{
+ return m_xercesParserLiaison.getErrorHandler();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setErrorHandler(ErrorHandler* handler)
+{
+ m_xercesParserLiaison.setErrorHandler(handler);
+}
+
+
+
+bool
+XalanSourceTreeParserLiaison::getDoNamespaces() const
+{
+ return m_xercesParserLiaison.getDoNamespaces();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setDoNamespaces(bool newState)
+{
+ m_xercesParserLiaison.setDoNamespaces(newState);
+}
+
+
+
+bool
+XalanSourceTreeParserLiaison::getExitOnFirstFatalError() const
+{
+ return m_xercesParserLiaison.getExitOnFirstFatalError();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setExitOnFirstFatalError(bool newState)
+{
+ m_xercesParserLiaison.setExitOnFirstFatalError(newState);
+}
+
+
+
+EntityResolver*
+XalanSourceTreeParserLiaison::getEntityResolver()
+{
+ return m_xercesParserLiaison.getEntityResolver();
+}
+
+
+
+void
+XalanSourceTreeParserLiaison::setEntityResolver(EntityResolver* resolver)
+{
+ m_xercesParserLiaison.setEntityResolver(resolver);
+}
+
+
+
+XalanSourceTreeDocument*
+XalanSourceTreeParserLiaison::mapDocument(const XalanDocument* theDocument) const
+{
+ DocumentMapType::const_iterator i =
+ m_documentMap.find(theDocument);
+
+ if (i != m_documentMap.end())
+ {
+ return (*i).second;
+ }
+ else
+ {
+ i = m_persistentDocumentMap.find(theDocument);
+
+ if (i != m_persistentDocumentMap.end())
+ {
+ return (*i).second;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+}
+
+
+
+XalanSourceTreeDocument*
+XalanSourceTreeParserLiaison::createXalanSourceTreeDocument()
+{
+ XalanSourceTreeDocument* const theNewDocument =
+ new XalanSourceTreeDocument(m_documentNumber++, m_poolAllText);
+
+ m_documentMap[theNewDocument] = theNewDocument;
+
+ return theNewDocument;
+}
+
+
+
+bool
+XalanSourceTreeParserLiaison::setPersistent(XalanSourceTreeDocument* theDocument)
+{
+ const DocumentMapType::iterator i =
+ m_documentMap.find(theDocument);
+
+ if (i != m_documentMap.end())
+ {
+ return false;
+ }
+ else
+ {
+ m_persistentDocumentMap[(*i).first] = (*i).second;
+
+ m_documentMap.erase(i);
+
+ return true;
+ }
+}
+
+
+bool
+XalanSourceTreeParserLiaison::unsetPersistent(XalanSourceTreeDocument* theDocument)
+{
+ const DocumentMapType::iterator i =
+ m_persistentDocumentMap.find(theDocument);
+
+ if (i != m_persistentDocumentMap.end())
+ {
+ return false;
+ }
+ else
+ {
+ m_documentMap[(*i).first] = (*i).second;
+
+ m_persistentDocumentMap.erase(i);
+
+ return true;
+ }
+}
diff --git a/src/XalanTransformer/XalanCompiledStylesheet.hpp b/src/XalanTransformer/XalanCompiledStylesheet.hpp
new file mode 100644
index 0000000..4d174e7
--- /dev/null
+++ b/src/XalanTransformer/XalanCompiledStylesheet.hpp
@@ -0,0 +1,88 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#if !defined(XALANCOMPILEDSTYLESHEET_HEADER_GUARD)
+#define XALANCOMPILEDSTYLESHEET_HEADER_GUARD
+
+
+
+// Base include file. Must be first.
+#include <XalanTransformer/XalanTransformerDefinitions.hpp>
+
+
+
+class StylesheetRoot;
+
+
+
+/**
+ * This is an abstraction of the StylesheetRoot class. It is designed
+ * to allow a XalanTranfomer object to reuse a compliled stylesheet.
+ */
+class XALAN_TRANSFORMER_EXPORT XalanCompiledStylesheet
+{
+public:
+
+ virtual
+ ~XalanCompiledStylesheet() {}
+
+ virtual const StylesheetRoot*
+ getStylesheetRoot() const = 0;
+};
+
+
+
+#endif // XALANCOMPILEDSTYLESHEET_HEADER_GUARD
diff --git a/src/XalanTransformer/XalanDefaultDocumentBuilder.cpp b/src/XalanTransformer/XalanDefaultDocumentBuilder.cpp
new file mode 100644
index 0000000..9b5782a
--- /dev/null
+++ b/src/XalanTransformer/XalanDefaultDocumentBuilder.cpp
@@ -0,0 +1,130 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+// Class header file.
+#include "XalanDefaultDocumentBuilder.hpp"
+
+
+
+#include <XalanSourceTree/XalanSourceTreeDocument.hpp>
+
+
+
+#include "XalanDefaultParsedSource.hpp"
+
+
+
+XalanDefaultDocumentBuilder::XalanDefaultDocumentBuilder(const XalanDOMString& theURI) :
+ m_domSupport(),
+ m_parserLiaison(),
+ m_contentHandler(m_parserLiaison.mapDocument(m_parserLiaison.createDocument())),
+ m_uri(theURI)
+{
+ m_domSupport.setParserLiaison(&m_parserLiaison);
+}
+
+
+
+XalanDefaultDocumentBuilder::~XalanDefaultDocumentBuilder()
+{
+}
+
+
+
+XalanDocument*
+XalanDefaultDocumentBuilder::getDocument() const
+{
+ return m_contentHandler.getDocument();
+}
+
+
+
+XalanParsedSourceHelper*
+XalanDefaultDocumentBuilder::createHelper() const
+{
+ return new XalanDefaultParsedSourceHelper(m_domSupport);
+}
+
+
+ContentHandler*
+XalanDefaultDocumentBuilder::getContentHandler()
+{
+ return &m_contentHandler;
+}
+
+
+
+DTDHandler*
+XalanDefaultDocumentBuilder::getDTDHandler()
+{
+ return &m_contentHandler;
+}
+
+
+
+LexicalHandler*
+XalanDefaultDocumentBuilder::getLexicalHandler()
+{
+ return &m_contentHandler;
+}
+
+
+
+const XalanDOMString&
+XalanDefaultDocumentBuilder::getURI() const
+{
+ return m_uri;
+}
diff --git a/src/XalanTransformer/XalanDefaultDocumentBuilder.hpp b/src/XalanTransformer/XalanDefaultDocumentBuilder.hpp
new file mode 100644
index 0000000..c9db42d
--- /dev/null
+++ b/src/XalanTransformer/XalanDefaultDocumentBuilder.hpp
@@ -0,0 +1,126 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#if !defined(XALANDEFAULTDOCUMENTBUILDER_HEADER_GUARD)
+#define XALANDEFAULTDOCUMENTBUILDER_HEADER_GUARD
+
+
+
+// Base include file. Must be first.
+#include <XalanTransformer/XalanTransformerDefinitions.hpp>
+
+
+
+#include <XalanTransformer/XalanDocumentBuilder.hpp>
+
+
+
+#include <XalanSourceTree/XalanSourceTreeContentHandler.hpp>
+#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
+#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
+
+
+
+/**
+ * This is class is designed to allow a XalanTranfomer object
+ * to use a document that is build dynamically by a user.
+ */
+class XALAN_TRANSFORMER_EXPORT XalanDefaultDocumentBuilder : public XalanDocumentBuilder
+{
+public:
+
+ /**
+ * Create a XalanDefaultDocumentBuilder instance,
+ *
+ * @param theURI An optional string to identify the document.
+ */
+ XalanDefaultDocumentBuilder(const XalanDOMString& theURI = XalanDOMString());
+
+ virtual
+ ~XalanDefaultDocumentBuilder();
+
+ virtual XalanDocument*
+ getDocument() const;
+
+ virtual XalanParsedSourceHelper*
+ createHelper() const;
+
+ virtual const XalanDOMString&
+ getURI() const;
+
+ virtual ContentHandler*
+ getContentHandler();
+
+ virtual DTDHandler*
+ getDTDHandler();
+
+ virtual LexicalHandler*
+ getLexicalHandler();
+
+private:
+
+ XalanSourceTreeDOMSupport m_domSupport;
+
+ XalanSourceTreeParserLiaison m_parserLiaison;
+
+ XalanSourceTreeContentHandler m_contentHandler;
+
+ const XalanDOMString m_uri;
+};
+
+
+
+#endif // XALANDEFAULTDOCUMENTBUILDER_HEADER_GUARD
diff --git a/src/XalanTransformer/XalanDefaultParsedSource.cpp b/src/XalanTransformer/XalanDefaultParsedSource.cpp
new file mode 100644
index 0000000..8f3d39f
--- /dev/null
+++ b/src/XalanTransformer/XalanDefaultParsedSource.cpp
@@ -0,0 +1,225 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#include "XalanDefaultParsedSource.hpp"
+
+
+
+#include <XalanDOM/XalanDocument.hpp>
+
+
+
+#include <PlatformSupport/URISupport.hpp>
+
+
+
+#include <XalanSourceTree/XalanSourceTreeDocument.hpp>
+#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
+
+
+
+XalanDefaultParsedSourceDOMSupport::XalanDefaultParsedSourceDOMSupport(const XalanSourceTreeDOMSupport& theDOMSupport) :
+ XalanSourceTreeDOMSupport(),
+ m_domSupport(theDOMSupport)
+{
+}
+
+
+
+XalanDefaultParsedSourceDOMSupport::~XalanDefaultParsedSourceDOMSupport()
+{
+}
+
+
+
+void
+XalanDefaultParsedSourceDOMSupport::reset()
+{
+}
+
+
+
+const XalanDOMString*
+XalanDefaultParsedSourceDOMSupport::getNamespaceForPrefix(
+ const XalanDOMString& prefix,
+ const XalanElement& namespaceContext) const
+{
+ return m_domSupport.getNamespaceForPrefix(
+ prefix,
+ namespaceContext);
+}
+
+
+
+const XalanDOMString&
+XalanDefaultParsedSourceDOMSupport::getUnparsedEntityURI(
+ const XalanDOMString& theName,
+ const XalanDocument& theDocument) const
+{
+ const XalanDOMString& theURI =
+ m_domSupport.getUnparsedEntityURI(
+ theName,
+ theDocument);
+
+ if (length(theURI) != 0)
+ {
+ return theURI;
+ }
+ else
+ {
+ return XalanSourceTreeDOMSupport::getUnparsedEntityURI(
+ theName,
+ theDocument);
+ }
+}
+
+
+
+bool
+XalanDefaultParsedSourceDOMSupport::isNodeAfter(
+ const XalanNode& node1,
+ const XalanNode& node2) const
+{
+ return m_domSupport.isNodeAfter(
+ node1,
+ node2);
+}
+
+
+
+XalanDefaultParsedSourceHelper::XalanDefaultParsedSourceHelper(const XalanSourceTreeDOMSupport& theSourceDOMSupport) :
+ m_domSupport(theSourceDOMSupport),
+ m_parserLiaison()
+{
+ m_domSupport.setParserLiaison(&m_parserLiaison);
+}
+
+
+
+DOMSupport&
+XalanDefaultParsedSourceHelper::getDOMSupport()
+{
+ return m_domSupport;
+}
+
+
+
+XMLParserLiaison&
+XalanDefaultParsedSourceHelper::getParserLiaison()
+{
+ return m_parserLiaison;
+}
+
+
+
+XalanDefaultParsedSource::XalanDefaultParsedSource(const XSLTInputSource& theInputSource):
+ XalanParsedSource(),
+ m_domSupport(),
+ m_parserLiaison(m_domSupport),
+ m_parsedSource(m_parserLiaison.mapDocument(m_parserLiaison.parseXMLStream(theInputSource)))
+{
+ assert(m_parsedSource != 0);
+
+ m_domSupport.setParserLiaison(&m_parserLiaison);
+
+ const XalanDOMChar* const theSystemID = theInputSource.getSystemId();
+
+ if (theSystemID != 0)
+ {
+ try
+ {
+ m_uri = URISupport::getURLStringFromString(theSystemID);
+ }
+ catch(const XMLException&)
+ {
+ // Assume that any exception here relates to get the url from
+ // the system ID. We'll assume that it's just a fake base identifier
+ // since the parser would have thrown an error if the system ID
+ // wasn't resolved.
+ m_uri = theSystemID;
+ }
+ }
+}
+
+
+
+XalanDefaultParsedSource::~XalanDefaultParsedSource()
+{
+}
+
+
+
+XalanDocument*
+XalanDefaultParsedSource::getDocument() const
+{
+ return m_parsedSource;
+}
+
+
+
+XalanParsedSourceHelper*
+XalanDefaultParsedSource::createHelper() const
+{
+ return new XalanDefaultParsedSourceHelper(m_domSupport);
+}
+
+
+
+const XalanDOMString&
+XalanDefaultParsedSource::getURI() const
+{
+ return m_uri;
+}
diff --git a/src/XalanTransformer/XalanDefaultParsedSource.hpp b/src/XalanTransformer/XalanDefaultParsedSource.hpp
new file mode 100644
index 0000000..a4c1408
--- /dev/null
+++ b/src/XalanTransformer/XalanDefaultParsedSource.hpp
@@ -0,0 +1,179 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#if !defined(XALANDEFAULTPARSEDSOURCE_HEADER_GUARD)
+#define XALANDEFAULTPARSEDSOURCE_HEADER_GUARD
+
+
+
+// Base include file. Must be first.
+#include <XalanTransformer/XalanTransformerDefinitions.hpp>
+
+
+
+#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
+#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
+
+
+
+#include <XSLT/XSLTInputSource.hpp>
+
+
+
+#include <XalanTransformer/XalanParsedSource.hpp>
+
+
+
+class XalanSourceTreeDocument;
+
+
+
+class XalanDefaultParsedSourceDOMSupport : public XalanSourceTreeDOMSupport
+{
+public:
+
+ XalanDefaultParsedSourceDOMSupport(const XalanSourceTreeDOMSupport& theDOMSupport);
+
+ virtual
+ ~XalanDefaultParsedSourceDOMSupport();
+
+ virtual void
+ reset();
+
+ // These interfaces are inherited from DOMSupport...
+
+ virtual const XalanDOMString*
+ getNamespaceForPrefix(
+ const XalanDOMString& prefix,
+ const XalanElement& namespaceContext) const;
+
+ virtual const XalanDOMString&
+ getUnparsedEntityURI(
+ const XalanDOMString& theName,
+ const XalanDocument& theDocument) const;
+
+ virtual bool
+ isNodeAfter(
+ const XalanNode& node1,
+ const XalanNode& node2) const;
+
+private:
+
+ const XalanSourceTreeDOMSupport& m_domSupport;
+};
+
+
+
+class XALAN_TRANSFORMER_EXPORT XalanDefaultParsedSourceHelper : public XalanParsedSourceHelper
+{
+public:
+
+ XalanDefaultParsedSourceHelper(const XalanSourceTreeDOMSupport& theSourceDOMSupport);
+
+ virtual DOMSupport&
+ getDOMSupport();
+
+ virtual XMLParserLiaison&
+ getParserLiaison();
+
+private:
+
+ XalanDefaultParsedSourceDOMSupport m_domSupport;
+
+ XalanSourceTreeParserLiaison m_parserLiaison;
+};
+
+
+
+/**
+ * This is designed to allow a XalanTranfomer object to reuse a parsed
+ * document.
+ */
+class XALAN_TRANSFORMER_EXPORT XalanDefaultParsedSource : public XalanParsedSource
+{
+public:
+
+ XalanDefaultParsedSource(const XSLTInputSource& theInputSource);
+
+ virtual
+ ~XalanDefaultParsedSource();
+
+ virtual XalanDocument*
+ getDocument() const;
+
+ virtual XalanParsedSourceHelper*
+ createHelper() const;
+
+ virtual const XalanDOMString&
+ getURI() const;
+
+private:
+
+ XalanSourceTreeDOMSupport m_domSupport;
+
+ XalanSourceTreeParserLiaison m_parserLiaison;
+
+ XalanSourceTreeDocument* const m_parsedSource;
+
+ XalanDOMString m_uri;
+};
+
+
+
+#endif // XALANDEFAULTPARSEDSOURCE_HEADER_GUARD
+
+
+
diff --git a/src/XalanTransformer/XalanDocumentBuilder.hpp b/src/XalanTransformer/XalanDocumentBuilder.hpp
new file mode 100644
index 0000000..40be256
--- /dev/null
+++ b/src/XalanTransformer/XalanDocumentBuilder.hpp
@@ -0,0 +1,118 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#if !defined(XALANDOCUMENTBUILDER_HEADER_GUARD)
+#define XALANDOCUMENTBUILDER_HEADER_GUARD
+
+
+
+// Base include file. Must be first.
+#include <XalanTransformer/XalanTransformerDefinitions.hpp>
+
+
+
+// Base class include file.
+#include <XalanTransformer/XalanParsedSource.hpp>
+
+
+
+class ContentHandler;
+class DOMSupport;
+class DTDHandler;
+class LexicalHandler;
+class XalanDocument;
+
+
+
+/**
+ * This is abstract base class designed to allow a XalanTranfomer
+ * object to use a document that is build dynamically by a user.
+ */
+class XALAN_TRANSFORMER_EXPORT XalanDocumentBuilder : public XalanParsedSource
+{
+public:
+
+ virtual
+ ~XalanDocumentBuilder()
+ {
+ }
+
+ // These are inherited from XalanParsedSource...
+ virtual XalanDocument*
+ getDocument() const = 0;
+
+ virtual XalanParsedSourceHelper*
+ createHelper() const = 0;
+
+ virtual const XalanDOMString&
+ getURI() const = 0;
+
+ // These are new to XalanDocumentBuilder...
+ virtual ContentHandler*
+ getContentHandler() = 0;
+
+ virtual DTDHandler*
+ getDTDHandler() = 0;
+
+ virtual LexicalHandler*
+ getLexicalHandler() = 0;
+
+private:
+};
+
+
+
+#endif // XALANDOCUMENTBUILDER_HEADER_GUARD
diff --git a/src/XalanTransformer/XalanParsedSource.hpp b/src/XalanTransformer/XalanParsedSource.hpp
new file mode 100644
index 0000000..f18ed20
--- /dev/null
+++ b/src/XalanTransformer/XalanParsedSource.hpp
@@ -0,0 +1,154 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#if !defined(XALANPARSEDSOURCE_HEADER_GUARD)
+#define XALANPARSEDSOURCE_HEADER_GUARD
+
+
+
+// Base include file. Must be first.
+#include <XalanTransformer/XalanTransformerDefinitions.hpp>
+
+
+
+// We're bringing in XalanDocument so that its derivation from XalanNode
+// is known...
+#include <XalanDOM/XalanDocument.hpp>
+
+
+
+class DOMSupport;
+class XMLParserLiaison;
+
+
+
+class XALAN_TRANSFORMER_EXPORT XalanParsedSourceHelper
+{
+public:
+
+ virtual
+ ~XalanParsedSourceHelper()
+ {
+ }
+
+ /**
+ * Get the DOMSupport instance.
+ *
+ * @return A reference to a DOMSupport instance.
+ */
+ virtual DOMSupport&
+ getDOMSupport() = 0;
+
+ /**
+ * Get the XMLParserLiaison instance.
+ *
+ * @return A rerefernce to an XMLParserLiaison instance.
+ */
+ virtual XMLParserLiaison&
+ getParserLiaison() = 0;
+};
+
+
+
+/**
+ * This is abstract base class designed to allow a XalanTranfomer
+ * object to reuse a parsed document.
+ */
+class XALAN_TRANSFORMER_EXPORT XalanParsedSource
+{
+public:
+
+ XalanParsedSource();
+
+ virtual
+ ~XalanParsedSource();
+
+ /**
+ * Get a pointer to the XalanDocument instance for the source
+ * document
+ *
+ * @return A pointer to a XalanDocument instance.
+ */
+ virtual XalanDocument*
+ getDocument() const = 0;
+
+ /**
+ * Create the appropriate XalanParsedSourceHelper instance to
+ * use for transforming with the instance.
+ *
+ * The caller is responsible for deleting the object when finished.
+ *
+ * @return A pointer to a XalanParsedSourceHelper instance.
+ */
+ virtual XalanParsedSourceHelper*
+ createHelper() const = 0;
+
+ /**
+ * Get the URI for the parsed source, if any.
+ * use for transforming with the instance.
+ *
+ * @return A const reference to a string containing the URI
+ */
+ virtual const XalanDOMString&
+ getURI() const = 0;
+};
+
+
+
+#endif // XALANPARSEDSOURCE_HEADER_GUARD
+
+
+
diff --git a/src/XalanTransformer/XalanTransformer.cpp b/src/XalanTransformer/XalanTransformer.cpp
new file mode 100644
index 0000000..bf56996
--- /dev/null
+++ b/src/XalanTransformer/XalanTransformer.cpp
@@ -0,0 +1,1142 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#include "XalanTransformer.hpp"
+
+
+
+#include <algorithm>
+
+
+
+#include <sax/SAXException.hpp>
+
+
+
+#include <XalanDOM/XalanDOMException.hpp>
+
+
+
+#include <PlatformSupport/DOMStringHelper.hpp>
+#include <PlatformSupport/DOMStringPrintWriter.hpp>
+#include <PlatformSupport/XalanOutputStreamPrintWriter.hpp>
+
+
+
+#include <XPath/XObjectFactoryDefault.hpp>
+#include <XPath/XPathFactoryBlock.hpp>
+#include <XPath/XPathFactoryDefault.hpp>
+
+
+
+#include <XSLT/StylesheetConstructionContextDefault.hpp>
+#include <XSLT/StylesheetExecutionContextDefault.hpp>
+#include <XSLT/StylesheetRoot.hpp>
+#include <XSLT/XSLTEngineImpl.hpp>
+#include <XSLT/XSLTInit.hpp>
+#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
+
+
+
+#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
+#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
+
+
+
+#include <XalanExtensions/XalanExtensions.hpp>
+
+
+
+//#define XALAN_USE_ICU
+#if defined(XALAN_USE_ICU)
+#include <ICUBridge/ICUBridge.hpp>
+#include <ICUBridge/FunctionICUFormatNumber.hpp>
+#include <ICUBridge/ICUBridgeCollationCompareFunctor.hpp>
+#endif
+
+
+
+#include "XalanCompiledStylesheetDefault.hpp"
+#include "XalanDefaultDocumentBuilder.hpp"
+#include "XalanDefaultParsedSource.hpp"
+#include "XalanTransformerOutputStream.hpp"
+#include "XercesDOMParsedSource.hpp"
+
+
+
+const XSLTInit* XalanTransformer::s_xsltInit = 0;
+
+#if defined(XALAN_USE_ICU)
+static const ICUBridgeCollationCompareFunctor* theICUFunctor = 0;
+#endif
+
+
+
+XalanTransformer::XalanTransformer():
+ m_compiledStylesheets(),
+ m_parsedSources(),
+ m_paramPairs(),
+ m_functionPairs(),
+ m_errorMessage(1, '\0'),
+ m_stylesheetExecutionContext(new StylesheetExecutionContextDefault)
+{
+#if defined(XALAN_USE_ICU)
+ m_stylesheetExecutionContext->installCollationCompareFunctor(theICUFunctor);
+#endif
+}
+
+
+
+XalanTransformer::~XalanTransformer()
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ // Clean up all entries in the compliledStylesheets vector.
+ for_each(m_compiledStylesheets.begin(),
+ m_compiledStylesheets.end(),
+ DeleteFunctor<XalanCompiledStylesheet>());
+
+ // Clean up all entries in the compliledStylesheets vector.
+ for_each(m_parsedSources.begin(),
+ m_parsedSources.end(),
+ DeleteFunctor<XalanParsedSource>());
+
+ for (FunctionParamPairVectorType::size_type i = 0; i < m_functionPairs.size(); ++i)
+ {
+ delete m_functionPairs[i].second;
+ }
+
+ m_functionPairs.clear();
+
+ delete m_stylesheetExecutionContext;
+}
+
+
+
+void
+XalanTransformer::initialize()
+{
+ // Initialize Xalan.
+ s_xsltInit = new XSLTInit;
+
+ const XalanDOMString theXalanNamespace(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("http://xml.apache.org/xalan")));
+
+ XalanTransformer::installExternalFunctionGlobal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("difference")),
+ FunctionDifference());
+
+ XalanTransformer::installExternalFunctionGlobal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("distinct")),
+ FunctionDistinct());
+
+ XalanTransformer::installExternalFunctionGlobal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("evaluate")),
+ FunctionEvaluate());
+
+ XalanTransformer::installExternalFunctionGlobal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("hasSameNodes")),
+ FunctionHasSameNodes());
+
+ XalanTransformer::installExternalFunctionGlobal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("intersection")),
+ FunctionIntersection());
+
+ XalanTransformer::installExternalFunctionGlobal(
+ theXalanNamespace,
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("nodeset")),
+ FunctionNodeSet());
+
+#if defined(XALAN_USE_ICU)
+ theICUFunctor = new ICUBridgeCollationCompareFunctor;
+
+ // Install the ICU version of format-number...
+ XPath::installFunction(
+ StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("format-number")),
+ FunctionICUFormatNumber());
+#endif
+}
+
+
+
+void
+XalanTransformer::terminate()
+{
+ // Terminate Xalan and release memory.
+#if defined(XALAN_CANNOT_DELETE_CONST)
+ (XSLTInit*) s_xsltInit;
+#else
+ delete s_xsltInit;
+#endif
+
+ s_xsltInit = 0;
+
+#if defined(XALAN_USE_ICU)
+#if defined(XALAN_CANNOT_DELETE_CONST)
+ delete (ICUBridgeCollationCompareFunctor*)theICUFunctor;
+#else
+ delete theICUFunctor;
+#endif
+
+ theICUFunctor = 0;
+#endif
+}
+
+
+
+int
+XalanTransformer::transform(
+ const XalanParsedSource& theParsedXML,
+ const XSLTInputSource& theStylesheetSource,
+ const XSLTResultTarget& theResultTarget)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ int theResult = 0;
+
+ // Clear the error message.
+ m_errorMessage.resize(1, '\0');
+
+ // Store error messages from problem listener.
+ XalanDOMString theErrorMessage;
+
+ try
+ {
+ XalanDocument* const theSourceDocument = theParsedXML.getDocument();
+ assert(theSourceDocument != 0);
+
+ // Create the helper object that is necessary for running the processor...
+ XalanAutoPtr<XalanParsedSourceHelper> theHelper(theParsedXML.createHelper());
+ assert(theHelper.get() != 0);
+
+ DOMSupport& theDOMSupport = theHelper->getDOMSupport();
+
+ XMLParserLiaison& theParserLiaison = theHelper->getParserLiaison();
+
+ // Create some more support objects...
+ XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
+
+ XObjectFactoryDefault theXObjectFactory;
+
+ XPathFactoryDefault theXPathFactory;
+
+ // Create a processor...
+ XSLTEngineImpl theProcessor(
+ theParserLiaison,
+ theXSLTProcessorEnvSupport,
+ theDOMSupport,
+ theXObjectFactory,
+ theXPathFactory);
+
+ theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
+
+ const XalanDOMString& theSourceURI = theParsedXML.getURI();
+
+ if (length(theSourceURI) > 0)
+ {
+ theXSLTProcessorEnvSupport.setSourceDocument(theSourceURI, theSourceDocument);
+ }
+
+ // Create a problem listener and send output to a XalanDOMString.
+ DOMStringPrintWriter thePrintWriter(theErrorMessage);
+
+ ProblemListenerDefault theProblemListener(&thePrintWriter);
+
+ theProcessor.setProblemListener(&theProblemListener);
+
+ theParserLiaison.setExecutionContext(*m_stylesheetExecutionContext);
+
+ // Create a stylesheet construction context,
+ // using the stylesheet's factory support objects.
+ StylesheetConstructionContextDefault theStylesheetConstructionContext(
+ theProcessor,
+ theXSLTProcessorEnvSupport,
+ theXPathFactory);
+
+ // Hack used to cast away const.
+ XSLTResultTarget tempResultTarget(theResultTarget);
+
+ const EnsureReset theReset(*this);
+
+ // Set up the stylesheet execution context.
+ m_stylesheetExecutionContext->setXPathEnvSupport(&theXSLTProcessorEnvSupport);
+
+ m_stylesheetExecutionContext->setDOMSupport(&theDOMSupport);
+
+ m_stylesheetExecutionContext->setXObjectFactory(&theXObjectFactory);
+
+ m_stylesheetExecutionContext->setXSLTProcessor(&theProcessor);
+
+ // Set the parameters if any.
+ for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i)
+ {
+ theProcessor.setStylesheetParam(
+ m_paramPairs[i].first,
+ m_paramPairs[i].second);
+ }
+
+ // Set the functions if any.
+ for (FunctionParamPairVectorType::size_type f = 0; f < m_functionPairs.size(); ++f)
+ {
+ theXSLTProcessorEnvSupport.installExternalFunctionLocal(
+ m_functionPairs[f].first.getNamespace(),
+ m_functionPairs[f].first.getLocalPart(),
+ *(m_functionPairs[f].second));
+ }
+
+ // Create an input source for the source document...
+ XSLTInputSource theDocumentInputSource(theSourceDocument);
+
+ // Set the system ID, so relative URIs are resolved properly...
+ theDocumentInputSource.setSystemId(c_wstr(theSourceURI));
+
+ // Do the transformation...
+ theProcessor.process(
+ theDocumentInputSource,
+ theStylesheetSource,
+ tempResultTarget,
+ theStylesheetConstructionContext,
+ *m_stylesheetExecutionContext);
+ }
+ catch (XSLException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -1;
+ }
+ catch (SAXException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -2;
+ }
+ catch (XMLException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -3;
+ }
+ catch(const XalanDOMException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ XalanDOMString theMessage("XalanDOMException caught. The code is ");
+
+ append(theMessage, LongToDOMString(long(e.getExceptionCode())));
+ append(theMessage, XalanDOMString("."));
+
+ TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
+ }
+
+ theResult = -4;
+ }
+
+ return theResult;
+}
+
+
+
+int
+XalanTransformer::transform(
+ const XalanParsedSource& theParsedXML,
+ const XalanCompiledStylesheet* theCompiledStylesheet,
+ const XSLTResultTarget& theResultTarget)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ int theResult = 0;
+
+ // Clear the error message.
+ m_errorMessage.resize(1, '\0');
+
+ // Store error messages from problem listener.
+ XalanDOMString theErrorMessage;
+
+ try
+ {
+ XalanDocument* const theSourceDocument = theParsedXML.getDocument();
+ assert(theSourceDocument != 0);
+
+ // Create the helper object that is necessary for running the processor...
+ XalanAutoPtr<XalanParsedSourceHelper> theHelper(theParsedXML.createHelper());
+ assert(theHelper.get() != 0);
+
+ DOMSupport& theDOMSupport = theHelper->getDOMSupport();
+
+ XMLParserLiaison& theParserLiaison = theHelper->getParserLiaison();
+
+ // Create some more support objects...
+ XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
+
+ XObjectFactoryDefault theXObjectFactory;
+
+ XPathFactoryDefault theXPathFactory;
+
+ // Create a processor...
+ XSLTEngineImpl theProcessor(
+ theParserLiaison,
+ theXSLTProcessorEnvSupport,
+ theDOMSupport,
+ theXObjectFactory,
+ theXPathFactory);
+
+ theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
+
+ const XalanDOMString& theSourceURI = theParsedXML.getURI();
+
+ if (length(theSourceURI) > 0)
+ {
+ theXSLTProcessorEnvSupport.setSourceDocument(theSourceURI, theSourceDocument);
+ }
+
+ // Create a problem listener and send output to a XalanDOMString.
+ DOMStringPrintWriter thePrintWriter(theErrorMessage);
+
+ ProblemListenerDefault theProblemListener(&thePrintWriter);
+
+ theProcessor.setProblemListener(&theProblemListener);
+
+ // Since the result target is not const in our
+ // internal intefaces, we'll pass in a local copy
+ // of the one provided...
+ XSLTResultTarget tempResultTarget(theResultTarget);
+
+ const EnsureReset theReset(*this);
+
+ // Set up the stylesheet execution context.
+ m_stylesheetExecutionContext->setXPathEnvSupport(&theXSLTProcessorEnvSupport);
+
+ m_stylesheetExecutionContext->setDOMSupport(&theDOMSupport);
+
+ m_stylesheetExecutionContext->setXObjectFactory(&theXObjectFactory);
+
+ m_stylesheetExecutionContext->setXSLTProcessor(&theProcessor);
+
+ // Set the compiled stylesheet.
+ m_stylesheetExecutionContext->setStylesheetRoot(theCompiledStylesheet->getStylesheetRoot());
+
+ // Set the parameters if any.
+ for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i)
+ {
+ theProcessor.setStylesheetParam(
+ m_paramPairs[i].first,
+ m_paramPairs[i].second);
+ }
+
+ // Set the functions if any.
+ for (FunctionParamPairVectorType::size_type f = 0; f < m_functionPairs.size(); ++f)
+ {
+ theXSLTProcessorEnvSupport.installExternalFunctionLocal(
+ m_functionPairs[f].first.getNamespace(),
+ m_functionPairs[f].first.getLocalPart(),
+ *(m_functionPairs[f].second));
+ }
+
+ // Create an input source for the source document...
+ XSLTInputSource theDocumentInputSource(theSourceDocument);
+
+ // Set the system ID, so relative URIs are resolved properly...
+ theDocumentInputSource.setSystemId(c_wstr(theSourceURI));
+
+ // Do the transformation...
+ theProcessor.process(
+ theDocumentInputSource,
+ tempResultTarget,
+ *m_stylesheetExecutionContext);
+ }
+ catch (XSLException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -1;
+ }
+ catch (SAXException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -2;
+ }
+ catch (XMLException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -3;
+ }
+ catch(const XalanDOMException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ XalanDOMString theMessage("XalanDOMException caught. The code is ");
+
+ append(theMessage, LongToDOMString(long(e.getExceptionCode())));
+ append(theMessage, XalanDOMString("."));
+
+ TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
+ }
+
+ theResult = -4;
+ }
+
+ return theResult;
+}
+
+
+
+int
+XalanTransformer::transform(
+ const XSLTInputSource& theInputSource,
+ const XalanCompiledStylesheet* theCompiledStylesheet,
+ const XSLTResultTarget& theResultTarget)
+{
+ const XalanParsedSource* theParsedSource = 0;
+
+ const int theResult = parseSource(theInputSource, theParsedSource);
+
+ if (theResult != 0)
+ {
+ return theResult;
+ }
+ else
+ {
+ assert(theParsedSource != 0);
+
+ // Make sure the parsed source is destroyed when
+ // the transformation is finished...
+ EnsureDestroyParsedSource theGuard(*this, theParsedSource);
+
+ // Do the transformation...
+ return transform(
+ *theParsedSource,
+ theCompiledStylesheet,
+ theResultTarget);
+ }
+}
+
+int
+XalanTransformer::transform(
+ const XSLTInputSource& theInputSource,
+ const XSLTInputSource& theStylesheetSource,
+ const XSLTResultTarget& theResultTarget)
+{
+ // Parse the source document.
+ const XalanParsedSource* theParsedSource = 0;
+
+ const int theResult = parseSource(theInputSource, theParsedSource);
+
+ if (theResult != 0)
+ {
+ return theResult;
+ }
+ else
+ {
+ assert(theParsedSource != 0);
+
+ // Make sure the parsed source is destroyed when
+ // the transformation is finished...
+ EnsureDestroyParsedSource theGuard(*this, theParsedSource);
+
+ // Do the transformation...
+ return transform(
+ *theParsedSource,
+ theStylesheetSource,
+ theResultTarget);
+ }
+}
+
+
+
+int
+XalanTransformer::transform(
+ const XSLTInputSource& theInputSource,
+ const XSLTResultTarget& theResultTarget)
+{
+ // Do the transformation...
+ return transform(
+ theInputSource,
+ XSLTInputSource(),
+ theResultTarget);
+}
+
+
+
+int
+XalanTransformer::transform(
+ const XSLTInputSource& theInputSource,
+ const XSLTInputSource& theStylesheetSource,
+ void* theOutputHandle,
+ XalanOutputHandlerType theOutputHandler,
+ XalanFlushHandlerType theFlushHandler)
+{
+ // Set to output target to the callback
+ XalanTransformerOutputStream theOutputStream(theOutputHandle, theOutputHandler, theFlushHandler);
+
+ XalanOutputStreamPrintWriter thePrintWriter(theOutputStream);
+
+ XSLTResultTarget theResultTarget(&thePrintWriter);
+
+ // Do the transformation...
+ return transform(
+ theInputSource,
+ theStylesheetSource,
+ theResultTarget);
+}
+
+
+
+int
+XalanTransformer::transform(
+ const XalanParsedSource& theParsedSource,
+ const XalanCompiledStylesheet* theCompiledStylesheet,
+ void* theOutputHandle,
+ XalanOutputHandlerType theOutputHandler,
+ XalanFlushHandlerType theFlushHandler)
+{
+ // Set to output target to the callback
+ XalanTransformerOutputStream theOutputStream(theOutputHandle, theOutputHandler, theFlushHandler);
+
+ XalanOutputStreamPrintWriter thePrintWriter(theOutputStream);
+
+ XSLTResultTarget theResultTarget(&thePrintWriter);
+
+ // Do the transformation...
+ return transform(
+ theParsedSource,
+ theCompiledStylesheet,
+ theResultTarget);
+}
+
+
+
+int
+XalanTransformer::transform(
+ const XSLTInputSource& theInputSource,
+ void* theOutputHandle,
+ XalanOutputHandlerType theOutputHandler,
+ XalanFlushHandlerType theFlushHandler)
+{
+ // Set to output target to the callback
+ XalanTransformerOutputStream theOutputStream(theOutputHandle, theOutputHandler, theFlushHandler);
+
+ XalanOutputStreamPrintWriter thePrintWriter(theOutputStream);
+
+ XSLTResultTarget theResultTarget(&thePrintWriter);
+
+ // Do the transformation...
+ return transform(
+ theInputSource,
+ XSLTInputSource(),
+ theResultTarget);
+}
+
+
+
+int
+XalanTransformer::compileStylesheet(
+ const XSLTInputSource& theStylesheetSource,
+ const XalanCompiledStylesheet*& theCompiledStylesheet)
+{
+ // Clear the error message.
+ m_errorMessage.resize(1, '\0');
+
+ // Store error messages from problem listener.
+ XalanDOMString theErrorMessage;
+
+ int theResult = 0;
+
+ try
+ {
+ // Create some support objects that are necessary for running the processor...
+ XalanSourceTreeDOMSupport theDOMSupport;
+
+ XalanSourceTreeParserLiaison theParserLiaison(theDOMSupport);
+
+ // Hook the two together...
+ theDOMSupport.setParserLiaison(&theParserLiaison);
+
+ // Create some more support objects...
+ XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
+
+ XObjectFactoryDefault theXObjectFactory;
+
+ XPathFactoryDefault theXPathFactory;
+
+ // Create a processor...
+ XSLTEngineImpl theProcessor(
+ theParserLiaison,
+ theXSLTProcessorEnvSupport,
+ theDOMSupport,
+ theXObjectFactory,
+ theXPathFactory);
+
+ // Create a problem listener and send output to a XalanDOMString.
+ DOMStringPrintWriter thePrintWriter(theErrorMessage);
+
+ ProblemListenerDefault theProblemListener(&thePrintWriter);
+
+ theProcessor.setProblemListener(&theProblemListener);
+
+ // Create a new XalanCompiledStylesheet.
+ theCompiledStylesheet =
+ new XalanCompiledStylesheetDefault(
+ theStylesheetSource,
+ theXSLTProcessorEnvSupport,
+ theProcessor);
+
+ // Store it in a vector.
+ m_compiledStylesheets.push_back(theCompiledStylesheet);
+ }
+ catch (XSLException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -1;
+ }
+ catch (SAXException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -2;
+ }
+ catch (XMLException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+ }
+
+ theResult = -3;
+ }
+ catch(const XalanDOMException& e)
+ {
+ if (length(theErrorMessage) != 0)
+ {
+ TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
+ }
+ else
+ {
+ XalanDOMString theMessage("XalanDOMException caught. The code is ");
+
+ append(theMessage, LongToDOMString(long(e.getExceptionCode())));
+
+ append(theMessage, XalanDOMString("."));
+
+ TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
+ }
+
+ theResult = -4;
+ }
+
+ return theResult;
+}
+
+
+
+int
+XalanTransformer::destroyStylesheet(const XalanCompiledStylesheet* theStylesheet)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ const CompiledStylesheetPtrVectorType::iterator i =
+ find(
+ m_compiledStylesheets.begin(),
+ m_compiledStylesheets.end(),
+ theStylesheet);
+
+ if (i == m_compiledStylesheets.end())
+ {
+ const char* const theStylesheetErrorMessage =
+ "An invalid compiled stylesheet was provided.";
+
+ const unsigned int theLength =
+ length(theStylesheetErrorMessage);
+
+ m_errorMessage.resize(theLength + 1, '\0');
+
+ strncpy(&*m_errorMessage.begin(), theStylesheetErrorMessage, theLength);
+
+ return -1;
+ }
+ else
+ {
+ m_compiledStylesheets.erase(i);
+
+#if defined(XALAN_CANNOT_DELETE_CONST)
+ delete (XalanCompiledStylesheet*) theStylesheet;
+#else
+ delete theStylesheet;
+#endif
+
+ return 0;
+ }
+}
+
+
+
+int
+XalanTransformer::parseSource(
+ const XSLTInputSource& theInputSource,
+ const XalanParsedSource*& theParsedSource,
+ bool useXercesDOM)
+{
+ // Clear the error message.
+ m_errorMessage.clear();
+ m_errorMessage.push_back(0);
+
+ int theResult = 0;
+
+ try
+ {
+ if(useXercesDOM == true)
+ {
+ theParsedSource = new XercesDOMParsedSource(theInputSource);
+ }
+ else
+ {
+ theParsedSource = new XalanDefaultParsedSource(theInputSource);
+ }
+
+ // Store it in a vector.
+ m_parsedSources.push_back(theParsedSource);
+ }
+ catch (XSLException& e)
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+
+ theResult = -1;
+ }
+ catch (SAXException& e)
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+
+ theResult = -2;
+ }
+ catch (XMLException& e)
+ {
+ TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
+
+ theResult = -3;
+ }
+ catch(const XalanDOMException& e)
+ {
+ XalanDOMString theMessage("XalanDOMException caught. The code is ");
+
+ append(theMessage, LongToDOMString(long(e.getExceptionCode())));
+
+ append(theMessage, XalanDOMString("."));
+
+ TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
+
+ theResult = -3;
+ }
+
+ return theResult;
+}
+
+
+
+int
+XalanTransformer::destroyParsedSource(const XalanParsedSource* theParsedSource)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ const ParsedSourcePtrVectorType::iterator i =
+ find(
+ m_parsedSources.begin(),
+ m_parsedSources.end(),
+ theParsedSource);
+
+ if (i == m_parsedSources.end())
+ {
+ const char* const theParsedSourceErrorMessage =
+ "An invalid parsed source was provided.";
+
+ const unsigned int theLength =
+ length(theParsedSourceErrorMessage);
+
+ m_errorMessage.resize(theLength + 1, '\0');
+
+ strncpy(&*m_errorMessage.begin(), theParsedSourceErrorMessage, theLength);
+
+ return -1;
+ }
+ else
+ {
+ m_parsedSources.erase(i);
+
+#if defined(XALAN_CANNOT_DELETE_CONST)
+ delete (XalanCompiledStylesheet*) theParsedSource;
+#else
+ delete theParsedSource;
+#endif
+
+ return 0;
+ }
+}
+
+
+
+void
+XalanTransformer::setStylesheetParam(
+ const XalanDOMString& key,
+ const XalanDOMString& expression)
+{
+ // Store the stylesheet parameter in a vector.
+ m_paramPairs.push_back(ParamPairType(key, expression));
+}
+
+
+
+XalanDocumentBuilder*
+XalanTransformer::createDocumentBuilder()
+{
+ m_parsedSources.reserve(m_parsedSources.size() + 1);
+
+ XalanDocumentBuilder* const theNewBuilder = new XalanDefaultDocumentBuilder;
+
+ m_parsedSources.push_back(theNewBuilder);
+
+ return theNewBuilder;
+}
+
+
+
+void
+XalanTransformer::destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder)
+{
+ destroyParsedSource(theDocumentBuilder);
+}
+
+
+
+void
+XalanTransformer::installExternalFunction(
+ const XalanDOMString& theNamespace,
+ const XalanDOMString& functionName,
+ const Function& function)
+{
+ m_functionPairs.push_back(FunctionPairType(XalanQNameByValue(theNamespace, functionName), function.clone()));
+}
+
+
+
+void
+XalanTransformer::installExternalFunctionGlobal(
+ const XalanDOMString& theNamespace,
+ const XalanDOMString& functionName,
+ const Function& function)
+{
+ XSLTProcessorEnvSupportDefault::installExternalFunctionGlobal(
+ theNamespace,
+ functionName,
+ function);
+}
+
+
+
+void
+XalanTransformer::uninstallExternalFunction(
+ const XalanDOMString& theNamespace,
+ const XalanDOMString& functionName)
+{
+ for (FunctionParamPairVectorType::size_type i = 0; i < m_functionPairs.size(); ++i)
+ {
+ if(XalanQNameByReference(theNamespace, functionName).equals(m_functionPairs[i].first))
+ {
+ delete m_functionPairs[i].second;
+
+ m_functionPairs.erase(m_functionPairs.begin() + i);
+ }
+ }
+}
+
+
+
+void
+XalanTransformer::uninstallExternalFunctionGlobal(
+ const XalanDOMString& theNamespace,
+ const XalanDOMString& functionName)
+{
+ XSLTProcessorEnvSupportDefault::uninstallExternalFunctionGlobal(
+ theNamespace,
+ functionName);
+}
+
+
+
+
+const char*
+XalanTransformer::getLastError() const
+{
+ return &m_errorMessage[0];
+}
+
+
+
+void
+XalanTransformer::reset()
+{
+ try
+ {
+ // Reset objects.
+ m_stylesheetExecutionContext->setXPathEnvSupport(0);
+
+ m_stylesheetExecutionContext->setDOMSupport(0);
+
+ m_stylesheetExecutionContext->setXObjectFactory(0);
+
+ m_stylesheetExecutionContext->setXSLTProcessor(0);
+
+ m_stylesheetExecutionContext->reset();
+
+ // Clear the ParamPairVectorType.
+ m_paramPairs.clear();
+ }
+ catch(...)
+ {
+ }
+}
+
+
+
+
+XalanTransformer::EnsureReset::~EnsureReset()
+{
+ m_transformer.m_stylesheetExecutionContext->reset();
+
+ m_transformer.reset();
+}
diff --git a/src/XalanTransformer/XercesDOMParsedSource.cpp b/src/XalanTransformer/XercesDOMParsedSource.cpp
new file mode 100644
index 0000000..b00623c
--- /dev/null
+++ b/src/XalanTransformer/XercesDOMParsedSource.cpp
@@ -0,0 +1,146 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#include "XercesDOMParsedSource.hpp"
+
+
+
+#include <XalanDOM/XalanDocument.hpp>
+
+
+
+#include <PlatformSupport/URISupport.hpp>
+
+
+
+class XALAN_TRANSFORMER_EXPORT XercesDOMParsedSourceHelper : public XalanParsedSourceHelper
+{
+public:
+
+ virtual DOMSupport&
+ getDOMSupport()
+ {
+ return m_domSupport;
+ }
+
+ virtual XMLParserLiaison&
+ getParserLiaison()
+ {
+ return m_parserLiaison;
+ }
+
+private:
+
+ XercesDOMSupport m_domSupport;
+
+ XercesParserLiaison m_parserLiaison;
+};
+
+
+
+XercesDOMParsedSource::XercesDOMParsedSource(const XSLTInputSource& theInputSource):
+ XalanParsedSource(),
+ m_parserLiaison(),
+ m_parsedSource(m_parserLiaison.parseXMLStream(theInputSource))
+{
+ const XalanDOMChar* const theSystemID = theInputSource.getSystemId();
+
+ if (theSystemID != 0)
+ {
+ try
+ {
+ m_uri = URISupport::getURLStringFromString(theSystemID);
+ }
+ catch(const XMLException&)
+ {
+ // Assume that any exception here relates to get the url from
+ // the system ID. We'll assume that it's just a fake base identifier
+ // since the parser would have thrown an error if the system ID
+ // wasn't resolved.
+ m_uri = theSystemID;
+ }
+ }
+}
+
+
+
+XercesDOMParsedSource::~XercesDOMParsedSource()
+{
+}
+
+
+
+XalanDocument*
+XercesDOMParsedSource::getDocument() const
+{
+ return m_parsedSource;
+}
+
+
+
+XalanParsedSourceHelper*
+XercesDOMParsedSource::createHelper() const
+{
+ return new XercesDOMParsedSourceHelper;
+}
+
+
+
+const XalanDOMString&
+XercesDOMParsedSource::getURI() const
+{
+ return m_uri;
+}
diff --git a/src/XalanTransformer/XercesDOMParsedSource.hpp b/src/XalanTransformer/XercesDOMParsedSource.hpp
new file mode 100644
index 0000000..cd65564
--- /dev/null
+++ b/src/XalanTransformer/XercesDOMParsedSource.hpp
@@ -0,0 +1,116 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+#if !defined(XERCESDOMPARSEDSOURCE_HEADER_GUARD)
+#define XERCESDOMPARSEDSOURCE_HEADER_GUARD
+
+
+
+// Base include file. Must be first.
+#include <XalanTransformer/XalanTransformerDefinitions.hpp>
+
+
+
+#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
+#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
+
+
+
+#include <XSLT/XSLTInputSource.hpp>
+
+
+
+#include <XalanTransformer/XalanParsedSource.hpp>
+
+
+
+/**
+ * This is designed to allow a XalanTranfomer object to reuse a parsed
+ * document.
+ */
+class XALAN_TRANSFORMER_EXPORT XercesDOMParsedSource : public XalanParsedSource
+{
+public:
+
+ XercesDOMParsedSource(const XSLTInputSource& theInputSource);
+
+ virtual
+ ~XercesDOMParsedSource();
+
+ virtual XalanDocument*
+ getDocument() const;
+
+ virtual XalanParsedSourceHelper*
+ createHelper() const;
+
+ virtual const XalanDOMString&
+ getURI() const;
+
+private:
+
+ XercesParserLiaison m_parserLiaison;
+
+ XalanDocument* const m_parsedSource;
+
+ XalanDOMString m_uri;
+};
+
+
+
+#endif // XERCESDOMPARSEDSOURCE_HEADER_GUARD
+
+
+