robweir 99/12/18 11:48:15
Added: c BUGS CREDITS DONE License README STATUS
c/Projects/Win32/VC6 Xalan.dsw
c/Projects/Win32/VC6/DOMSupport DOMSupport.dsp
c/Projects/Win32/VC6/PlatformSupport PlatformSupport.dsp
c/Projects/Win32/VC6/TestXPath TestXPath.dsp
c/Projects/Win32/VC6/TestXSLT TestXSLT.dsp
c/Projects/Win32/VC6/XMLSupport XMLSupport.dsp
c/Projects/Win32/VC6/XPath XPath.dsp
c/Projects/Win32/VC6/XSLT XSLT.dsp
c/Projects/Win32/VC6/XercesInit XercesInit.dsp
c/Projects/Win32/VC6/XercesParserLiaison
XercesParserLiaison.dsp
c/Projects/Win32/VC6/XercesPlatformSupport
XercesPlatformSupport.dsp
c/samples/XPathWrapper DLL.dsp TestDriver.cpp TestDriver.dsp
XPathWrapper.cpp XPathWrapper.dsw XPathWrapper.hpp
c/src/DOMSupport DOMServices.cpp DOMServices.hpp
DOMSupport.cpp DOMSupport.hpp DOMSupportDefault.cpp
DOMSupportDefault.hpp DOMSupportDefinitions.hpp
DOMSupportException.cpp DOMSupportException.hpp
NSInfo.hpp NamespaceResolver.cpp
NamespaceResolver.hpp TreeWalker.cpp TreeWalker.hpp
UnimplementedDocument.cpp UnimplementedDocument.hpp
UnimplementedDocumentFragment.cpp
UnimplementedDocumentFragment.hpp
UnimplementedElement.cpp UnimplementedElement.hpp
UnimplementedNode.cpp UnimplementedNode.hpp
c/src/Include DOMHelper.hpp PlatformDefinitions.hpp
VCPPDefinitions.hpp
c/src/PlatformSupport AttributeListImpl.cpp
AttributeListImpl.hpp Cloneable.cpp Cloneable.hpp
DOMStringHelper.cpp DOMStringHelper.hpp
DOMStringPrintWriter.cpp DOMStringPrintWriter.hpp
DecimalFormat.cpp DecimalFormat.hpp
DecimalFormatSymbols.cpp DecimalFormatSymbols.hpp
DirectoryEnumerator.hpp DoubleSupport.cpp
DoubleSupport.hpp Factory.cpp Factory.hpp
FactoryObject.cpp FactoryObject.hpp
NamedNodeMapAttributeList.cpp
NamedNodeMapAttributeList.hpp NullPrintWriter.cpp
NullPrintWriter.hpp NumberFormat.cpp
NumberFormat.hpp PlatformSupport.cpp
PlatformSupport.hpp PlatformSupportDefinitions.hpp
PrintWriter.cpp PrintWriter.hpp Resettable.cpp
Resettable.hpp STLHelper.hpp StringTokenizer.cpp
StringTokenizer.hpp Writer.cpp Writer.hpp
XSLException.cpp XSLException.hpp
c/src/TestXPath NodeNameTreeWalker.cpp
NodeNameTreeWalker.hpp TestXPath.cpp
c/src/TestXSLT process.cpp
c/src/XMLSupport Formatter.cpp Formatter.hpp
FormatterListener.cpp FormatterListener.hpp
FormatterToDOM.cpp FormatterToDOM.hpp
FormatterToHTML.cpp FormatterToHTML.hpp
FormatterToText.cpp FormatterToText.hpp
FormatterToXML.cpp FormatterToXML.hpp
FormatterTreeWalker.cpp FormatterTreeWalker.hpp
NSInfo.hpp XMLParserLiaison.cpp
XMLParserLiaison.hpp XMLParserLiaisonDefault.cpp
XMLParserLiaisonDefault.hpp
XMLSupportDefinitions.hpp XMLSupportException.cpp
XMLSupportException.hpp
c/src/XPath ElementPrefixResolverProxy.cpp
ElementPrefixResolverProxy.hpp FoundIndex.cpp
FoundIndex.hpp Function.hpp FunctionBoolean.hpp
FunctionCeiling.hpp FunctionConcat.hpp
FunctionContains.hpp FunctionCount.hpp
FunctionDefaultStringArgument.hpp FunctionDoc.hpp
FunctionFalse.hpp FunctionFloor.hpp FunctionID.hpp
FunctionLang.hpp FunctionLast.hpp
FunctionLocalName.hpp FunctionName.hpp
FunctionNamespaceURI.hpp FunctionNormalize.hpp
FunctionNot.hpp FunctionNumber.hpp
FunctionPosition.hpp FunctionRound.hpp
FunctionStartsWith.hpp FunctionString.hpp
FunctionStringLength.hpp FunctionSubstring.hpp
FunctionSubstringAfter.hpp
FunctionSubstringBefore.hpp FunctionSum.hpp
FunctionTranslate.hpp FunctionTrue.hpp
MutableNodeRefList.cpp MutableNodeRefList.hpp
NameSpace.hpp NodeListImplSurrogate.cpp
NodeListImplSurrogate.hpp NodeRefList.cpp
NodeRefList.hpp NodeRefListBase.cpp
NodeRefListBase.hpp PrefixResolver.cpp
PrefixResolver.hpp QName.cpp QName.hpp
ResultTreeFrag.cpp ResultTreeFrag.hpp
ResultTreeFragBase.cpp ResultTreeFragBase.hpp
SimpleNodeLocator.cpp SimpleNodeLocator.hpp
XBoolean.cpp XBoolean.hpp XBooleanStatic.cpp
XBooleanStatic.hpp XLocator.cpp XLocator.hpp
XNodeSet.cpp XNodeSet.hpp XNull.cpp XNull.hpp
XNumber.cpp XNumber.hpp XObject.cpp XObject.hpp
XObjectFactory.cpp XObjectFactory.hpp
XObjectFactoryDefault.cpp XObjectFactoryDefault.hpp
XObjectTypeCallback.cpp XObjectTypeCallback.hpp
XPath.cpp XPath.hpp XPathDefinitions.hpp
XPathEnvSupport.cpp XPathEnvSupport.hpp
XPathEnvSupportDefault.cpp
XPathEnvSupportDefault.hpp XPathException.cpp
XPathException.hpp XPathExecutionContext.cpp
XPathExecutionContext.hpp XPathExpression.cpp
XPathExpression.hpp XPathFactory.cpp
XPathFactory.hpp XPathFactoryDefault.cpp
XPathFactoryDefault.hpp XPathFunctionTable.cpp
XPathFunctionTable.hpp XPathParserException.cpp
XPathParserException.hpp XPathProcessor.cpp
XPathProcessor.hpp XPathProcessorImpl.cpp
XPathProcessorImpl.hpp XPathSupport.cpp
XPathSupport.hpp XPathSupportDefault.cpp
XPathSupportDefault.hpp XPointer.cpp XPointer.hpp
XResultTreeFrag.cpp XResultTreeFrag.hpp XSpan.cpp
XSpan.hpp XString.cpp XString.hpp XUnknown.cpp
XUnknown.hpp
c/src/XSLT AVT.cpp AVT.hpp AVTPart.cpp AVTPart.hpp
AVTPartSimple.cpp AVTPartSimple.hpp
AVTPartXPath.cpp AVTPartXPath.hpp Arg.cpp Arg.hpp
Constants.hpp ContextMarker.cpp ContextMarker.hpp
ContextState.cpp ContextState.hpp
DecimalToRoman.cpp DecimalToRoman.hpp
ElemApplyImport.cpp ElemApplyImport.hpp
ElemApplyTemplates.cpp ElemApplyTemplates.hpp
ElemAttribute.cpp ElemAttribute.hpp
ElemAttributeSet.cpp ElemAttributeSet.hpp
ElemCallTemplate.cpp ElemCallTemplate.hpp
ElemChoose.cpp ElemChoose.hpp ElemComment.cpp
ElemComment.hpp ElemCopy.cpp ElemCopy.hpp
ElemCopyOf.cpp ElemCopyOf.hpp ElemElement.cpp
ElemElement.hpp ElemEmpty.cpp ElemEmpty.hpp
ElemExtensionCall.cpp ElemExtensionCall.hpp
ElemForEach.cpp ElemForEach.hpp ElemIf.cpp
ElemIf.hpp ElemLiteralResult.cpp
ElemLiteralResult.hpp ElemMessage.cpp
ElemMessage.hpp ElemNumber.cpp ElemNumber.hpp
ElemOtherwise.cpp ElemOtherwise.hpp ElemPI.cpp
ElemPI.hpp ElemParam.cpp ElemParam.hpp ElemPriv.hpp
ElemSort.cpp ElemSort.hpp ElemTemplate.cpp
ElemTemplate.hpp ElemTemplateElement.cpp
ElemTemplateElement.hpp ElemText.cpp ElemText.hpp
ElemTextLiteral.cpp ElemTextLiteral.hpp ElemUse.cpp
ElemUse.hpp ElemValueOf.cpp ElemValueOf.hpp
ElemVariable.cpp ElemVariable.hpp ElemWhen.cpp
ElemWhen.hpp ElemWithParam.cpp ElemWithParam.hpp
ElementMarker.cpp ElementMarker.hpp
ExtensionFunctionHandler.cpp
ExtensionFunctionHandler.hpp ExtensionNSHandler.cpp
ExtensionNSHandler.hpp FunctionCurrent.cpp
FunctionCurrent.hpp FunctionDoclocation.cpp
FunctionDoclocation.hpp FunctionFormatNumber.cpp
FunctionFormatNumber.hpp FunctionGenerateID.cpp
FunctionGenerateID.hpp FunctionKey.cpp
FunctionKey.hpp FunctionSystemProperty.cpp
FunctionSystemProperty.hpp
FunctionUnparsedEntityURI.cpp
FunctionUnparsedEntityURI.hpp GenerateEvent.cpp
GenerateEvent.hpp Java2STL.hpp KeyDeclaration.hpp
KeyTable.cpp KeyTable.hpp NodeSortKey.cpp
NodeSortKey.hpp NodeSorter.cpp NodeSorter.hpp
NumeratorFormatter.cpp NumeratorFormatter.hpp
ProblemListener.cpp ProblemListener.hpp
ProblemListenerDefault.cpp
ProblemListenerDefault.hpp SelectionEvent.cpp
SelectionEvent.hpp StackEntry.cpp StackEntry.hpp
Stylesheet.cpp Stylesheet.hpp StylesheetHandler.cpp
StylesheetHandler.hpp StylesheetRoot.cpp
StylesheetRoot.hpp TraceListener.hpp
TracerEvent.cpp TracerEvent.hpp
XSLProcessorException.cpp XSLProcessorException.hpp
XSLTDefinitions.hpp XSLTEngineImpl.cpp
XSLTEngineImpl.hpp XSLTInputSource.cpp
XSLTInputSource.hpp XSLTProcessor.cpp
XSLTProcessor.hpp
XSLTProcessorEnvSupportDefault.cpp
XSLTProcessorEnvSupportDefault.hpp
XSLTProcessorException.cpp
XSLTProcessorException.hpp XSLTResultTarget.cpp
XSLTResultTarget.hpp
c/src/XercesInit XercesInit.cpp XercesInit.hpp
XercesInitDefinitions.hpp
c/src/XercesParserLiaison XercesParserLiaison.cpp
XercesParserLiaison.hpp
XercesParserLiaisonDefinitions.hpp
c/src/XercesPlatformSupport NullTextOutputStream.cpp
NullTextOutputStream.hpp TextFileOutputStream.cpp
TextFileOutputStream.hpp XercesDOMPrintWriter.cpp
XercesDOMPrintWriter.hpp
XercesPlatformSupportDefinitions.hpp
XercesPlatformSupportException.cpp
XercesPlatformSupportException.hpp
Log:
Initial check-in of Xalan/C++
Revision Changes Path
1.1 xml-xalan/c/BUGS
Index: BUGS
===================================================================
s3 title="Known bugs">
<p>We are aware of the following bugs (SPR ID# and description):</p>
<ul>
</ul>
/s3>
1.1 xml-xalan/c/CREDITS
Index: CREDITS
===================================================================
David N Bertoni
Scott Boag
Shane Curcuru
Jack Donohue
Paul Dick
Emily Farmer
Donald Leslie
David Marston
Myriam Midy
Robert Weir
1.1 xml-xalan/c/DONE
Index: DONE
===================================================================
<s3 title="Things completed since the last version">
</s3>
1.1 xml-xalan/c/License
Index: License
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
1.1 xml-xalan/c/README
Index: README
===================================================================
README for xml-xalan/C++ project at apache.org
Basic Build Instructions for xml-xalan/c:
- We currently have checked in project files for MSVC++ 6.0. Load and build
the "TestXSLT" subproject from
Projects\Win32\VC6\Xalan.dsw. Note that the STL headers are very noisy in
MSVC with hundreds of warnings that
can be safely ignored. Once you're built, copy the DLL's (8 of them) and the
testXSLT.exe executable into a directory
containing the xerces-c_1_0 DLL from Xerces. Then run. The command line is
the same as Xalan/J.
1.1 xml-xalan/c/STATUS
Index: STATUS
===================================================================
<s3 title="Things still to be done">
<p>We still need to do the following:</p>
<ul>
<li><p>Linux build support</p></li>
<li><p>Conformance work</p></li>
<li><p>Performance work.</p></li>
<li><p>Robustness work</p></li>
</ul>
</s3>
1.1 xml-xalan/c/Projects/Win32/VC6/Xalan.dsw
Index: Xalan.dsw
===================================================================
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "DOMSupport"=".\DOMSupport\DOMSupport.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name PlatformSupport
End Project Dependency
}}}
###############################################################################
Project: "PlatformSupport"=".\PlatformSupport\PlatformSupport.dsp" - Package
Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name XercesInit
End Project Dependency
}}}
###############################################################################
Project: "TestXPath"=".\TestXPath\TestXPath.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name XPath
End Project Dependency
Begin Project Dependency
Project_Dep_Name DOMSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name XercesParserLiaison
End Project Dependency
Begin Project Dependency
Project_Dep_Name XMLSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name XercesPlatformSupport
End Project Dependency
}}}
###############################################################################
Project: "TestXSLT"=".\TestXSLT\TestXSLT.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name DOMSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name XercesParserLiaison
End Project Dependency
Begin Project Dependency
Project_Dep_Name XercesPlatformSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name PlatformSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name XPath
End Project Dependency
Begin Project Dependency
Project_Dep_Name XSLT
End Project Dependency
}}}
###############################################################################
Project: "XMLSupport"=".\XMLSupport\XMLSupport.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name PlatformSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name DOMSupport
End Project Dependency
}}}
###############################################################################
Project: "XPath"=".\XPath\XPath.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name PlatformSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name DOMSupport
End Project Dependency
}}}
###############################################################################
Project: "XSLT"=".\XSLT\XSLT.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name DOMSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name PlatformSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name XMLSupport
End Project Dependency
Begin Project Dependency
Project_Dep_Name XPath
End Project Dependency
Begin Project Dependency
Project_Dep_Name XercesPlatformSupport
End Project Dependency
}}}
###############################################################################
Project: "XercesInit"=".\XercesInit\XercesInit.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project:
"XercesParserLiaison"=".\XercesParserLiaison\XercesParserLiaison.dsp" - Package
Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name XMLSupport
End Project Dependency
}}}
###############################################################################
Project:
"XercesPlatformSupport"=".\XercesPlatformSupport\XercesPlatformSupport.dsp" -
Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name PlatformSupport
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
1.1 xml-xalan/c/Projects/Win32/VC6/DOMSupport/DOMSupport.dsp
Index: DOMSupport.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="DOMSupport" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=DOMSupport - 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 "DOMSupport.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 "DOMSupport.mak" CFG="DOMSupport - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "DOMSupport - Win32 Release" (based on "Win32 (x86) Dynamic-Link
Library")
!MESSAGE "DOMSupport - Win32 Debug" (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)" == "DOMSupport - 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\DOMSupport"
# 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" /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_DOMSUPPORT_BUILD_DLL"
/FD /c
# SUBTRACT CPP /YX /Yc /Yu
# 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 ..\..\..\..\Build\Win32\Vc6\Release\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo
/dll /pdb:none /machine:I386
# SUBTRACT LINK32 /debug
!ELSEIF "$(CFG)" == "DOMSupport - 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\DOMSupport"
# 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" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_DOMSUPPORT_BUILD_DLL"
/YX /FD /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 ..\..\..\..\Build\Win32\Vc6\Debug\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib /nologo
/dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "DOMSupport - Win32 Release"
# Name "DOMSupport - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMServices.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMSupport.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMSupportDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMSupportException.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\NamespaceResolver.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\TreeWalker.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedDocument.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedDocumentFragment.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedElement.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedNode.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMServices.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMSupport.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMSupportDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMSupportDefinitions.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\DOMSupportException.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\NamespaceResolver.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\TreeWalker.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedDocument.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedDocumentFragment.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedElement.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\DOMSupport\UnimplementedNode.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
1.1
xml-xalan/c/Projects/Win32/VC6/PlatformSupport/PlatformSupport.dsp
Index: PlatformSupport.dsp
===================================================================
# 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
# 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" /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 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 ..\..\..\..\Build\Win32\Vc6\Release\XercesInit.lib
..\..\..\..\..\..\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 /Gi /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"XALAN_PLATFORMSUPPORT_BUILD_DLL" /D "XALAN_XERCES" /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 ..\..\..\..\Build\Win32\Vc6\Debug\XercesInit.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib /nologo
/dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "PlatformSupport - Win32 Release"
# Name "PlatformSupport - Win32 Debug"
# 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\Cloneable.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\DecimalFormat.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\DecimalFormatSymbols.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\Factory.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\FactoryObject.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\NumberFormat.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\PlatformSupport.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\StringTokenizer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\Writer.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\AttributeListImpl.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\Cloneable.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\DecimalFormat.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\DecimalFormatSymbols.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\Factory.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\FactoryObject.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\NumberFormat.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\PlatformSupport.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\PlatformSupportDefinitions.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\STLHelper.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\StringTokenizer.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\PlatformSupport\Writer.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
1.1 xml-xalan/c/Projects/Win32/VC6/TestXPath/TestXPath.dsp
Index: TestXPath.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="TestXPath" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=TestXPath - 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 "TestXPath.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 "TestXPath.mak" CFG="TestXPath - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "TestXPath - Win32 Release" (based on "Win32 (x86) Console
Application")
!MESSAGE "TestXPath - Win32 Debug" (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)" == "TestXPath - 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\TestXPath"
# 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 /W4 /GX /O2 /I "..\..\..\..\..\..\xml-xerces\c\src" /I
"..\..\..\..\src\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D
"XALAN_XERCES" /YX /FD /c
# 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\Debug\PlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Release\XercesPlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Release\XPath.lib /nologo /subsystem:console
/pdb:none /machine:I386
# SUBTRACT LINK32 /debug
!ELSEIF "$(CFG)" == "TestXPath - 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\TestXPath"
# 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 /Gm /GX /Zi /Od /Ob1 /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"WIN32" /D "_CONSOLE" /D "_MBCS" /D "XALAN_XERCES" /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_1.lib
..\..\..\..\Build\Win32\VC6\Debug\PlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XercesPlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XPath.lib /nologo /subsystem:console /debug
/machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "TestXPath - Win32 Release"
# Name "TestXPath - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\TestXPath\TestXPath.cpp
# 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
1.1 xml-xalan/c/Projects/Win32/VC6/TestXSLT/TestXSLT.dsp
Index: TestXSLT.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="TestXSLT" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=TestXSLT - 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 "TestXSLT.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 "TestXSLT.mak" CFG="TestXSLT - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "TestXSLT - Win32 Release" (based on "Win32 (x86) Console
Application")
!MESSAGE "TestXSLT - Win32 Debug" (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)" == "TestXSLT - 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\TestXSLT"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"
/D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W4 /GR /GX /O2 /I "..\..\..\..\..\..\xml-xerces\c\src"
/I "..\..\..\..\src\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D
"_USRDLL" /D "XALAN_XERCES" /D "_CONSOLE" /FD /c
# 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\PlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Release\XercesPlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Release\XPath.lib
..\..\..\..\Build\Win32\VC6\Release\XMLSupport.lib
..\..\..\..\Build\Win32\VC6\Release\DOMSupport.lib
..\..\..\..\Build\Win32\VC6\Release\XSLT.lib
..\..\..\..\Build\Win32\VC6\Release\XercesParserLiaison.lib /nologo /pdb:none
/machine:I386
!ELSEIF "$(CFG)" == "TestXSLT - 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\TestXSLT"
# 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 "XSLT_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "WIN32" /D
"_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "XALAN_XERCES" /D "_CONSOLE" /FR /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 /nologo /debug /machine:I386 /pdbtype:sept
# ADD LINK32
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib
..\..\..\..\Build\Win32\VC6\Debug\PlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XercesPlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XPath.lib
..\..\..\..\Build\Win32\VC6\Debug\XMLSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\DOMSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XSLT.lib
..\..\..\..\Build\Win32\VC6\Debug\XercesParserLiaison.lib /nologo
/incremental:no /debug /machine:I386 /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "TestXSLT - Win32 Release"
# Name "TestXSLT - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\TestXSLT\process.cpp
# 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
1.1 xml-xalan/c/Projects/Win32/VC6/XMLSupport/XMLSupport.dsp
Index: XMLSupport.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="XMLSupport" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=XMLSupport - 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 "XMLSupport.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 "XMLSupport.mak" CFG="XMLSupport - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "XMLSupport - Win32 Release" (based on "Win32 (x86) Dynamic-Link
Library")
!MESSAGE "XMLSupport - Win32 Debug" (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)" == "XMLSupport - 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\XMLSupport"
# 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" /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_XMLSUPPORT_BUILD_DLL"
/FD /c
# SUBTRACT CPP /YX /Yc /Yu
# 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 ..\..\..\..\Build\Win32\Vc6\Release\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo
/dll /pdb:none /machine:I386
# SUBTRACT LINK32 /debug
!ELSEIF "$(CFG)" == "XMLSupport - 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\XMLSupport"
# 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" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_XMLSUPPORT_BUILD_DLL"
/YX /FD /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 ..\..\..\..\Build\Win32\Vc6\Debug\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib /nologo
/dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "XMLSupport - Win32 Release"
# Name "XMLSupport - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\Formatter.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterListener.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToDOM.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToHTML.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToText.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToXML.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterTreeWalker.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\XMLParserLiaison.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\XMLParserLiaisonDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\XMLSupportException.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\Formatter.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterListener.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToDOM.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToHTML.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToText.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterToXML.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\FormatterTreeWalker.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\NSInfo.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\XMLParserLiaison.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\XMLParserLiaisonDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\XMLSupportDefinitions.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XMLSupport\XMLSupportException.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
1.1 xml-xalan/c/Projects/Win32/VC6/XPath/XPath.dsp
Index: XPath.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="XPath" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=XPath - 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 "XPath.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 "XPath.mak" CFG="XPath - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "XPath - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "XPath - Win32 Debug" (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)" == "XPath - 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\XPath"
# 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" /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_XPATH_BUILD_DLL" /D
"XALAN_XERCES" /FD /I /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 ..\..\..\..\Build\Win32\Vc6\Release\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo
/dll /pdb:none /machine:I386
# SUBTRACT LINK32 /debug
!ELSEIF "$(CFG)" == "XPath - 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\XPath"
# 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" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_XPATH_BUILD_DLL" /D
"XALAN_XERCES" /YX /FD /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 ..\..\..\..\Build\Win32\Vc6\Debug\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib /nologo
/dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "XPath - Win32 Release"
# Name "XPath - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\XPath\ElementPrefixResolverProxy.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FoundIndex.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\MutableNodeRefList.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\NodeListImplSurrogate.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\NodeRefList.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\NodeRefListBase.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\PrefixResolver.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\QName.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\ResultTreeFrag.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\ResultTreeFragBase.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\SimpleNodeLocator.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XBoolean.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XBooleanStatic.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XLocator.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XNodeSet.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XNull.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XNumber.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObject.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObjectFactory.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObjectFactoryDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObjectTypeCallback.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPath.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathEnvSupport.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathEnvSupportDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathException.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathExecutionContext.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathExpression.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathFactory.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathFactoryDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathFunctionTable.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathParserException.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathProcessor.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathProcessorImpl.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathSupport.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathSupportDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPointer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XResultTreeFrag.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XSpan.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XString.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XUnknown.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FoundIndex.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\Function.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionBoolean.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionCeiling.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionConcat.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionContains.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionCount.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionDefaultStringArgument.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionFalse.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionFloor.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionID.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionLang.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionLast.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionLocalName.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionName.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionNamespaceURI.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionNormalize.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionNot.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionNumber.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionPosition.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionRound.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionStartsWith.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionString.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionStringLength.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionSubstring.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionSubstringAfter.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionSubstringBefore.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionSum.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionTranslate.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\FunctionTrue.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\MutableNodeRefList.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\NameSpace.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\NodeListImplSurrogate.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\NodeRefList.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\NodeRefListBase.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\PrefixResolver.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\QName.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\ResultTreeFrag.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\ResultTreeFragBase.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\SimpleNodeLocator.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XBoolean.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XBooleanStatic.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XLocator.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XNodeSet.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XNull.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XNumber.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObject.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObjectFactory.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObjectFactoryDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XObjectTypeCallback.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPath.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathDefinitions.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathEnvSupport.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathEnvSupportDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathException.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathExecutionContext.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathExpression.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathFactory.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathFactoryDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathFunctionTable.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathParserException.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathProcessor.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathProcessorImpl.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathSupport.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPathSupportDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XPointer.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XResultTreeFrag.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XSpan.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XString.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XPath\XUnknown.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
1.1 xml-xalan/c/Projects/Win32/VC6/XSLT/XSLT.dsp
Index: XSLT.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="XSLT" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=XSLT - 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 "XSLT.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 "XSLT.mak" CFG="XSLT - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "XSLT - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "XSLT - Win32 Debug" (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)" == "XSLT - 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\XSLT"
# 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 "XSLT_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W4 /GR /GX /O2 /I "..\..\..\..\..\..\xml-xerces\c\src"
/I "..\..\..\..\src\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D
"_USRDLL" /D "XALAN_XSLT_BUILD_DLL" /D "XALAN_XERCES" /FD /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
..\..\..\..\Build\Win32\VC6\Release\PlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Release\XercesPlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Release\XPath.lib
..\..\..\..\Build\Win32\VC6\Release\XMLSupport.lib
..\..\..\..\Build\Win32\VC6\Release\DOMSupport.lib /nologo /dll /debug
/machine:I386
!ELSEIF "$(CFG)" == "XSLT - 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\XSLT"
# 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 "XSLT_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "WIN32" /D
"_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_XSLT_BUILD_DLL" /D
"XALAN_XERCES" /YX /FD /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 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib
..\..\..\..\Build\Win32\VC6\Debug\PlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XercesPlatformSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XPath.lib
..\..\..\..\Build\Win32\VC6\Debug\XMLSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\DOMSupport.lib
..\..\..\..\Build\Win32\VC6\Debug\XercesParserLiaison.lib /nologo /dll /debug
/machine:I386 /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "XSLT - Win32 Release"
# Name "XSLT - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\Arg.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVT.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVTPart.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVTPartSimple.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVTPartXPath.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ContextMarker.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ContextState.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\DecimalToRoman.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemApplyImport.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemApplyTemplates.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemAttribute.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemAttributeSet.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemCallTemplate.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemChoose.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemComment.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemCopy.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemCopyOf.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemElement.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemEmpty.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElementMarker.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemExtensionCall.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemForEach.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemIf.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemLiteralResult.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemMessage.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemNumber.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemOtherwise.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemParam.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemPI.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemSort.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemTemplate.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemTemplateElement.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemText.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemTextLiteral.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemUse.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemValueOf.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemVariable.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemWhen.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemWithParam.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ExtensionFunctionHandler.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ExtensionNSHandler.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionCurrent.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionFormatNumber.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionGenerateID.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionKey.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionSystemProperty.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionUnparsedEntityURI.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\GenerateEvent.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\KeyTable.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\NodeSorter.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\NodeSortKey.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\NumeratorFormatter.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ProblemListener.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ProblemListenerDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\SelectionEvent.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\StackEntry.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\Stylesheet.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\StylesheetHandler.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\StylesheetRoot.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\TracerEvent.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTEngineImpl.cpp
!IF "$(CFG)" == "XSLT - Win32 Release"
!ELSEIF "$(CFG)" == "XSLT - Win32 Debug"
# ADD CPP /YX
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTInputSource.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTProcessor.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTProcessorEnvSupportDefault.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTProcessorException.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTResultTarget.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\Arg.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVT.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVTPart.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVTPartSimple.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\AVTPartXPath.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\Constants.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ContextMarker.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ContextState.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\DecimalToRoman.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemApplyImport.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemApplyTemplates.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemAttribute.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemAttributeSet.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemCallTemplate.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemChoose.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemComment.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemCopy.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemCopyOf.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemElement.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemEmpty.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemExtensionCall.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemForEach.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemIf.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemLiteralResult.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemMessage.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemNumber.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemOtherwise.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemParam.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemPI.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemPriv.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemSort.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemTemplate.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemTemplateElement.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemText.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemTextLiteral.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemUse.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemValueOf.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemVariable.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemWhen.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ElemWithParam.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ExtensionFunctionHandler.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionCurrent.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionFormatNumber.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionKey.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\FunctionUnparsedEntityURI.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\GenerateEvent.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\Java2STL.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\KeyDeclaration.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\KeyTable.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\NodeSorter.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\NodeSortKey.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ProblemListener.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\ProblemListenerDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\SelectionEvent.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\StackEntry.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\Stylesheet.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\StylesheetHandler.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\StylesheetRoot.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\TracerEvent.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTDefinitions.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTEngineImpl.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTInputSource.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTProcessor.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTProcessorEnvSupportDefault.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTProcessorException.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XSLT\XSLTResultTarget.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
1.1 xml-xalan/c/Projects/Win32/VC6/XercesInit/XercesInit.dsp
Index: XercesInit.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="XercesInit" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=XercesInit - 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 "XercesInit.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 "XercesInit.mak" CFG="XercesInit - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "XercesInit - Win32 Release" (based on "Win32 (x86) Dynamic-Link
Library")
!MESSAGE "XercesInit - Win32 Debug" (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)" == "XercesInit - 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\XercesInit"
# 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_XERCESINIT_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_XERCESINIT_EXPORTS" /D
"XALAN_XERCESINIT_BUILD_DLL" /FD /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 /machine:I386
# SUBTRACT LINK32 /debug
!ELSEIF "$(CFG)" == "XercesInit - 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\XercesInit"
# 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 "XALAN_XERCESINIT_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XALAN_XERCESINIT_EXPORTS" /D
"XALAN_XERCESINIT_BUILD_DLL" /FD /GZ /c
# SUBTRACT CPP /YX
# 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_1.lib /nologo
/dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "XercesInit - Win32 Release"
# Name "XercesInit - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\XercesInit\XercesInit.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\src\XercesInit\XercesInit.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesInit\XercesInitDefinitions.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
1.1
xml-xalan/c/Projects/Win32/VC6/XercesParserLiaison/XercesParserLiaison.dsp
Index: XercesParserLiaison.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="XercesParserLiaison" -
Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=XercesParserLiaison - 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 "XercesParserLiaison.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 "XercesParserLiaison.mak" CFG="XercesParserLiaison - Win32
Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "XercesParserLiaison - Win32 Release" (based on "Win32 (x86)
Dynamic-Link Library")
!MESSAGE "XercesParserLiaison - Win32 Debug" (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)" == "XercesParserLiaison - 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\XercesParserLiaison"
# 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" /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_XERCESPARSERLIAISON_BUILD_DLL" /FD /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 ..\..\..\..\Build\Win32\Vc6\Release\XMLSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo
/dll /pdb:none /machine:I386
# SUBTRACT LINK32 /debug
!ELSEIF "$(CFG)" == "XercesParserLiaison - 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\XercesParserLiaison"
# 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" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"XALAN_XERCESPARSERLIAISON_BUILD_DLL" /YX /FD /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 ..\..\..\..\Build\Win32\Vc6\Debug\XMLSupport.lib
..\..\..\..\Build\Win32\Vc6\Debug\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib /nologo
/dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "XercesParserLiaison - Win32 Release"
# Name "XercesParserLiaison - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\XercesParserLiaison\XercesParserLiaison.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\src\XercesParserLiaison\XercesParserLiaison.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesParserLiaison\XercesParserLiaisonDefinitions.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
1.1
xml-xalan/c/Projects/Win32/VC6/XercesPlatformSupport/XercesPlatformSupport.dsp
Index: XercesPlatformSupport.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="XercesPlatformSupport" -
Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=XercesPlatformSupport - 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 "XercesPlatformSupport.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 "XercesPlatformSupport.mak" CFG="XercesPlatformSupport -
Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "XercesPlatformSupport - Win32 Release" (based on "Win32 (x86)
Dynamic-Link Library")
!MESSAGE "XercesPlatformSupport - Win32 Debug" (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)" == "XercesPlatformSupport - 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\XercesPlatformSupport"
# 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 "LOTUSXALAN_PLATFORMSUPPORT_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W4 /GR /GX /O2 /Ob2 /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "NDEBUG" /D
"XALAN_XERCESPLATFORMSUPPORT_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D
"_USRDLL" /D "XALAN_XERCESPLATFORMSUPPORT_BUILD_DLL" /FD /I /xml4c/include" /I
/lotusxsl4c/stl" /I /lotusxsl4c/src/include" /I /xml4c/include" /I
/LotusXSL4C/src/stl" /I /LotusXSL4C/src/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 ..\..\..\..\Build\Win32\Vc6\Release\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib /nologo
/dll /pdb:none /machine:I386
# SUBTRACT LINK32 /debug
!ELSEIF "$(CFG)" == "XercesPlatformSupport - 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\XercesPlatformSupport"
# 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 "LOTUSXALAN_PLATFORMSUPPORT_EXPORTS" /YX
/FD /GZ /c
# ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I
"..\..\..\..\..\..\xml-xerces\c\src" /I "..\..\..\..\src\\" /D "_DEBUG" /D
"XALAN_PLATFORMSUPPORT_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D
"_USRDLL" /D "XALAN_XERCESPLATFORMSUPPORT_BUILD_DLL" /YX /FD /I /xml4c/include"
/I /lotusxsl4c/stl" /I /lotusxsl4c/src/include" /I /xml4c/include" /I
/LotusXSL4C/src/stl" /I /LotusXSL4C/src/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 ..\..\..\..\Build\Win32\Vc6\Debug\PlatformSupport.lib
..\..\..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1.lib /nologo
/dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "XercesPlatformSupport - Win32 Release"
# Name "XercesPlatformSupport - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\NullTextOutputStream.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\TextFileOutputStream.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\XercesDOMPrintWriter.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\XercesPlatformSupportException.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\NullTextOutputStream.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\TextFileOutputStream.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\XercesDOMPrintWriter.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\XercesPlatformSupportDefinitions.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\src\XercesPlatformSupport\XercesPlatformSupportException.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
1.1 xml-xalan/c/samples/XPathWrapper/DLL.dsp
Index: DLL.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="DLL" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=DLL - 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 "DLL.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 "DLL.mak" CFG="DLL - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "DLL - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "DLL - Win32 Debug" (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)" == "DLL - 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 "Release"
# PROP Intermediate_Dir "Release"
# 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 "DLL_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\..\xml-xerces\c\src" /I
"..\..\src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"DLL_EXPORTS" /D "_XPathWrapper" /YX /FD /c
# 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
..\..\Build\Win32\VC6\Release\PlatformSupport.lib
..\..\Build\Win32\VC6\Release\XercesPlatformSupport.lib
..\..\Build\Win32\VC6\Release\XPath.lib
..\..\Build\Win32\VC6\Release\DOMSupport.lib
..\..\Build\Win32\VC6\Release\XercesParserLiaison.lib /nologo /dll /machine:I386
!ELSEIF "$(CFG)" == "DLL - 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 "Debug"
# PROP Intermediate_Dir "Debug"
# 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 "DLL_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /I "..\..\..\..\xml-xerces\c\src"
/I "..\..\src" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"DLL_EXPORTS" /D "_XPathWrapper" /YX /FD /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_1.lib
..\..\Build\Win32\VC6\Debug\PlatformSupport.lib
..\..\Build\Win32\VC6\Debug\XercesPlatformSupport.lib
..\..\Build\Win32\VC6\Debug\XPath.lib
..\..\Build\Win32\VC6\Debug\DOMSupport.lib
..\..\Build\Win32\VC6\Debug\XercesParserLiaison.lib /nologo /dll /debug
/machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "DLL - Win32 Release"
# Name "DLL - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\XPathWrapper.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\XPathWrapper.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
1.1 xml-xalan/c/samples/XPathWrapper/TestDriver.cpp
Index: TestDriver.cpp
===================================================================
#include <iostream>
#include <fstream>
#include "XPathWrapper.hpp"
int main(int argc, const char* argv[])
{
if (argc<4)
{
std::cerr << "Syntax: TestDriver XMLFilePath Context
XPathExpression\n";
return -1;
}
std::string theXML;
std::ifstream in(argv[1]);
// slow and dirty dump of the xml file into a buffer
char c;
while(in.get(c))
theXML += c;
///////////////////////////////////////////..
// create your XPath helper object
XPathWrapper helper;
// call evaluate, passing in the XML string, the context string and the
xpath string
std::vector<std::string> result = helper.evaluate(theXML, argv[2],
argv[3]);
// take the resulting string vector and do whatever you want with
it:
size_t len = result.size();
std::cout<< "the result set has " << len << " strings\n";
for (size_t i=0; i<len; i++)
std::cout<< "item " << (i+1) << "= \"" << result[i] << "\"" <<
std::endl;
return 0;
}
1.1 xml-xalan/c/samples/XPathWrapper/TestDriver.dsp
Index: TestDriver.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="TestDriver" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=TestDriver - 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 "TestDriver.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 "TestDriver.mak" CFG="TestDriver - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "TestDriver - Win32 Release" (based on "Win32 (x86) Console
Application")
!MESSAGE "TestDriver - Win32 Debug" (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)" == "TestDriver - 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 "Release"
# PROP Intermediate_Dir "Release"
# 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 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D
"_MBCS" /YX /FD /c
# 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 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
!ELSEIF "$(CFG)" == "TestDriver - 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 "Debug"
# PROP Intermediate_Dir "Debug"
# 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 /W3 /Gm /GX /ZI /Od /I "..\..\..\..\xml-xerces\c\src"
/I "..\..\src" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "TestDriver - Win32 Release"
# Name "TestDriver - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\TestDriver.cpp
# 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
1.1 xml-xalan/c/samples/XPathWrapper/XPathWrapper.cpp
Index: XPathWrapper.cpp
===================================================================
#include <string>
#include <vector>
#include <cassert>
#include <iostream>
#include <parsers/DOMParser.hpp>
#include <util/PlatformUtils.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NodeList.hpp>
#include <internal/URLInputSource.hpp>
#include <PlatformSupport/DirectoryEnumerator.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <DOMSupport/DOMSupportDefault.hpp>
#include <XPath/XObjectFactoryDefault.hpp>
#include <XPath/XPathEnvSupportDefault.hpp>
#include <XPath/XPathSupportDefault.hpp>
#include <XPath/XPath.hpp>
#include <XPath/XPathProcessorImpl.hpp>
#include <XPath/XPathFactoryDefault.hpp>
#include <XPath/ElementPrefixResolverProxy.hpp>
#include <XMLSupport/FormatterTreeWalker.hpp>
#include <XMLSupport/FormatterToXML.hpp>
#include <XercesParserLiaison/XercesParserLiaison.hpp>
#include <internal/MemBufInputSource.hpp>
#include "XPathWrapper.hpp"
////////////////////////////////////////////////////
// the implementation class, that does all calls to XPath and Xerces
class XPathWrapperImpl
{
private:
std::string DOMStringToStdString(const DOMString& domString)
{
std::string ret;
for (int i=0; i< domString.length(); i++)
{
ret += (char)domString.charAt(i);
}
return ret;
}
public:
std::vector<std::string> evaluate(
const std::string& xml,
const std::string& context,
const std::string& expr)
{
//initialize XML4C
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException& e)
{
throw;
}
// parse the XML file
DOM_Element rootNode;
DOMParser parser;
try
{
// parse XML and get root element
MemBufInputSource inStream((const XMLByte*)xml.c_str(),
xml.length(), "foo", false);
parser.parse(inStream);
DOM_Document doc = parser.getDocument();
rootNode = doc.getDocumentElement();
}
catch(const XMLException& e)
{
throw;
}
// configure the objects needed for XPath to work with the
Xerces DOM
XPathEnvSupportDefault theEnvSupport;
DOMSupportDefault theDOMSupport;
XPathSupportDefault theSupport(theDOMSupport);
XObjectFactoryDefault theXObjectFactory(theEnvSupport,
theSupport);
XPathFactoryDefault
theXPathFactory(theXObjectFactory, theEnvSupport, theSupport);
XPathProcessorImpl
theXPathProcessor(theEnvSupport, theSupport);
XercesParserLiaison theLiaison(theDOMSupport);
std::vector<std::string> theResultList;
try
{
// first get the context nodeset
XPath *contextXPath = theXPathFactory.create();
theXPathProcessor.initXPath(*contextXPath,
DOMString(context.c_str()), ElementPrefixResolverProxy(rootNode,theSupport));
contextXPath->shrink();
MutableNodeRefList contextNodeList;
//default empty context
XObject* xObj = contextXPath->execute(rootNode,
ElementPrefixResolverProxy(rootNode,theSupport), contextNodeList);
contextNodeList = xObj->mutableNodeset();
// and now get the result of the primary xpath
expression
XPath *xpath = theXPathFactory.create();
theXPathProcessor.initXPath(*xpath,
DOMString(expr.c_str()), ElementPrefixResolverProxy(rootNode, theSupport));
xpath->shrink();
xObj = xpath->execute(rootNode,
ElementPrefixResolverProxy(rootNode,theSupport), contextNodeList);
// now encode the results. For all types but nodelist,
we'll just convert it to a string
// but, for nodelist, we'll convert each node to a
string and return a list of them
switch (xObj->getType())
{
case XObject::eTypeNodeSet:
{
const NodeRefListBase& nodeset =
xObj->nodeset();
size_t len = nodeset.getLength();
for (size_t i=0; i<len; i++)
{
DOM_Node node = nodeset.item(i);
DOMString str;
const int theType =
node.getNodeType();
if
(theType==DOM_Node::COMMENT_NODE ||
theType==DOM_Node::PROCESSING_INSTRUCTION_NODE)
str =
node.getNodeValue();
else
str =
theSupport.getNodeData(node);
theResultList.push_back(DOMStringToStdString(str));
}
break;
}
default:
{
theResultList.push_back(DOMStringToStdString(xObj->str()));
break;
}
}
}
catch(const XMLException& e)
{
throw;
}
return theResultList;
}
};
////////////////////////////////////////////////////
// The public XPathWrapper methods just delegate to our impl class
XPathWrapper::XPathWrapper()
{
pImpl = new XPathWrapperImpl();
}
XPathWrapper::~XPathWrapper()
{
delete pImpl;
}
std::vector<std::string> XPathWrapper::evaluate(
const std::string& xml,
const std::string& context,
const std::string& path)
{
return pImpl->evaluate(xml,context,path);
}
1.1 xml-xalan/c/samples/XPathWrapper/XPathWrapper.dsw
Index: XPathWrapper.dsw
===================================================================
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "DLL"=".\DLL.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "TestDriver"=".\TestDriver.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name DLL
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
1.1 xml-xalan/c/samples/XPathWrapper/XPathWrapper.hpp
Index: XPathWrapper.hpp
===================================================================
#include <string>
#include <vector>
#ifdef _XPathWrapper
#define XPathWrapperDecl __declspec(dllexport)
#else
#define XPathWrapperDecl __declspec(dllimport)
#endif
class XPathWrapperImpl;
class XPathWrapperDecl XPathWrapper
{
public:
XPathWrapper();
virtual ~XPathWrapper();
// Given an xml document and an xpath context and expression in the
form of (ascii) string objects,
// this function parses the XML document, evaluates the xpath and
returns the result, as a list of
// string objects
std::vector<std::string> evaluate(
const std::string& xml,
const std::string& context,
const std::string& path);
private:
// not implemented
XPathWrapper(const XPathWrapper&);
XPathWrapper& operator=(const XPathWrapper&);
bool operator==(const XPathWrapper&) const;
XPathWrapperImpl* pImpl;
};
1.1 xml-xalan/c/src/DOMSupport/DOMServices.cpp
Index: DOMServices.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DOMServices.hpp"
#include <vector>
#include <dom/DOM_Attr.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOM_Text.hpp>
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include "DOMSupportException.hpp"
DOMServices::WhitespaceSupport::WhitespaceSupport()
{
}
DOMServices::WhitespaceSupport::~WhitespaceSupport()
{
}
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOMString)
DOMServices::getNodeData(
const DOM_Node& node,
const WhitespaceSupport& theResolver)
{
DOMString data;
switch(node.getNodeType())
{
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
case DOM_Node::DOCUMENT_NODE:
case DOM_Node::ELEMENT_NODE:
{
DOM_NodeList children = node.getChildNodes();
const int nNodes = children.getLength();
for(int i = 0; i < nNodes; i++)
{
const DOMString nodeData =
getNodeData(children.item(i),
theResolver);
if(0 < length(nodeData))
{
data += nodeData;
}
}
}
break;
case DOM_Node::TEXT_NODE:
case DOM_Node::CDATA_SECTION_NODE:
{
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(node);
if(theResolver.isIgnorableWhitespace(theTextNode) ==
false)
{
// data = fixWhiteSpace(theTextNode.getData(),
false, false, true);
data = theTextNode.getData();
}
}
break;
case DOM_Node::ATTRIBUTE_NODE:
data = node.getNodeValue();
break;
default:
// ignore
break;
}
return data;
}
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOMString)
DOMServices::getLocalNameOfNode(const DOM_Node& n)
{
const DOMString qname = n.getNodeName();
const int index = indexOf(qname, ':');
return (index < 0) ? qname : substring(qname, index + 1);
}
/**
* Support for getParentOfNode.
*/
namespace {
DOM_Node
locateAttrParent(
const DOM_Element& elem,
const DOM_Node& attr)
{
DOM_Node parent;
DOM_NamedNodeMap attrs = elem.getAttributes();
if(attrs != 0)
{
const int nAttrs = attrs.getLength();
for(int i = 0; i < nAttrs; i++)
{
if(attrs.item(i) == attr)
{
parent = elem;
break;
}
}
}
if(parent == 0)
{
DOM_NodeList children = elem.getChildNodes();
const int nChildren = children.getLength();
for(int i = 0; i < nChildren; i++)
{
DOM_Node node = children.item(i);
if(node.getNodeType() == DOM_Node::ELEMENT_NODE)
{
parent =
locateAttrParent(static_cast<DOM_Element&>(node), attr);
if(parent != 0)
break;
}
}
}
return parent;
}
}; // namespace
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOM_Node)
DOMServices::getParentOfNode(const DOM_Node& node)
{
DOM_Node parent;
const short nodeType = node.getNodeType();
if(DOM_Node::ATTRIBUTE_NODE == nodeType)
{
const DOM_Document doc = node.getOwnerDocument();
if(doc == 0)
{
throw DOMSupportException("Attribute child does not
have an owner document!");
}
else
{
const DOM_Element rootElem =
doc.getDocumentElement();
assert(rootElem != 0);
parent = locateAttrParent(rootElem, node);
}
}
else
{
parent = node.getParentNode();
if(nodeType != DOM_Node::DOCUMENT_NODE && parent == 0)
{
throw DOMSupportException("Child does not have
parent!");
}
}
return parent;
}
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOMString)
DOMServices::getNamespaceForPrefix(
const DOMString& prefix,
const DOM_Element& namespaceContext)
{
DOMString theNamespace;
if(equals(prefix, "xml") == true)
{
theNamespace = theXMLNamespaceURI;
}
else
{
short type;
DOM_Node parent = namespaceContext;
while (parent != 0 && length(theNamespace) == 0
&& ((type = parent.getNodeType()) ==
DOM_Node::ELEMENT_NODE
|| type == DOM_Node::ENTITY_REFERENCE_NODE))
{
if (type == DOM_Node::ELEMENT_NODE)
{
DOM_NamedNodeMap nnm = parent.getAttributes();
for (int i = 0; i < nnm.getLength(); i ++)
{
DOM_Node attr = nnm.item(i);
DOMString aname =
attr.getNodeName();
const char* const theXMLNS =
"xmlns:";
const bool isPrefix =
equals(substring(aname,
0,
0 + strlen(theXMLNS)),
theXMLNS);
if (equals(aname, "xmlns") || isPrefix)
{
const int index =
indexOf(aname,
':');
const DOMString p =
isPrefix ?
substring(aname,
index + 1,
length(aname)) : DOMString();
if (equals(p, prefix) == true)
{
theNamespace =
attr.getNodeValue();
break;
}
}
}
}
parent = getParentOfNode(parent);
}
}
return theNamespace;
}
1.1 xml-xalan/c/src/DOMSupport/DOMServices.hpp
Index: DOMServices.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMSERVICES_HEADER_GUARD_1357924680)
#define DOMSERVICES_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOMString.hpp>
class DOM_Element;
class DOM_Text;
namespace DOMServices
{
const char* const theXMLNamespaceURI =
"http://www.w3.org/XML/1998/namespace";
class XALAN_DOMSUPPORT_EXPORT WhitespaceSupport
{
public:
WhitespaceSupport();
virtual
~WhitespaceSupport();
/**
* Tell if the node is ignorable whitespace.
* This should be in the DOM. Return false if the
* parser doesn't handle this.
*/
virtual bool
isIgnorableWhitespace(const DOM_Text& node) const = 0;
};
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOMString)
getNodeData(
const DOM_Node& node,
const WhitespaceSupport& theResolver);
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOMString)
getLocalNameOfNode(const DOM_Node& n);
/**
* I have to write this silly, and expensive function,
* because the DOM WG decided that attributes don't
* have parents. If this function is used with a DOM implementation
* that reuses attribute nodes, this will not work correctly.
*/
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOM_Node)
getParentOfNode(const DOM_Node& node);
XALAN_DOMSUPPORT_EXPORT_FUNCTION(DOMString)
getNamespaceForPrefix(
const DOMString& prefix,
const DOM_Element& namespaceContext);
}; // namespace DOMServices
#endif // DOMSERVICES_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/DOMSupport.cpp
Index: DOMSupport.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DOMSupport.hpp"
DOMSupport::DOMSupport() :
Resettable()
{
}
DOMSupport::~DOMSupport()
{
}
1.1 xml-xalan/c/src/DOMSupport/DOMSupport.hpp
Index: DOMSupport.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMSUPPORT_HEADER_GUARD_1357924680)
#define DOMSUPPORT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/Resettable.hpp>
class DOM_Attr;
class DOM_Element;
class DOM_Node;
class DOM_Text;
class XALAN_DOMSUPPORT_EXPORT DOMSupport : public Resettable
{
public:
DOMSupport();
virtual
~DOMSupport();
// These interfaces are inherited from Resettable...
virtual void
reset() = 0;
// These interfaces are new to DOMSupport...
virtual DOMString
getNamespaceOfNode(const DOM_Node& theNode) const = 0;
virtual DOMString
getExpandedElementName(const DOM_Element& elem) const = 0;
virtual DOMString
getExpandedAttributeName(const DOM_Attr& attr) const = 0;
};
#endif // DOMSUPPORT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/DOMSupportDefault.cpp
Index: DOMSupportDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DOMSupportDefault.hpp"
#include <vector>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Attr.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include "DOMServices.hpp"
#include "DOMSupportException.hpp"
DOMSupportDefault::DOMSupportDefault() :
DOMSupport(),
m_resolver()
{
}
DOMSupportDefault::~DOMSupportDefault()
{
}
void
DOMSupportDefault::reset()
{
m_resolver.reset();
}
DOMString
DOMSupportDefault::getNamespaceOfNode(const DOM_Node& theNode) const
{
return m_resolver.getNamespaceOfNode(theNode);
}
DOMString
DOMSupportDefault::getExpandedElementName(const DOM_Element& elem) const
{
DOMString theNamespace = getNamespaceOfNode(elem);
return (0 != length(theNamespace)) ? theNamespace + ":" +
DOMServices::getLocalNameOfNode(elem)
:
DOMServices::getLocalNameOfNode(elem);
}
DOMString
DOMSupportDefault::getExpandedAttributeName(const DOM_Attr& attr)
const
{
DOMString theNamespace = getNamespaceOfNode(attr);
return (0 != length(theNamespace)) ? theNamespace + ":" +
DOMServices::getLocalNameOfNode(attr)
: DOMServices::getLocalNameOfNode(attr);
}
1.1 xml-xalan/c/src/DOMSupport/DOMSupportDefault.hpp
Index: DOMSupportDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMSUPPORTDEFAULT_HEADER_GUARD_1357924680)
#define DOMSUPPORTDEFAULT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOMString.hpp>
#include <DOMSupport/DOMSupport.hpp>
#include <DOMSupport/NamespaceResolver.hpp>
class XALAN_DOMSUPPORT_EXPORT DOMSupportDefault : public DOMSupport
{
public:
DOMSupportDefault();
virtual
~DOMSupportDefault();
// These interfaces are inherited from Resettable...
virtual void
reset();
// These interfaces are inherited from DOMSupport...
virtual DOMString
getNamespaceOfNode(const DOM_Node& theNode) const;
virtual DOMString
getExpandedElementName(const DOM_Element& elem) const;
virtual DOMString
getExpandedAttributeName(const DOM_Attr& attr) const;
private:
mutable NamespaceResolver m_resolver;
};
#endif // DOMSUPPORTDEFAULT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/DOMSupportDefinitions.hpp
Index: DOMSupportDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMSUPPORT_DEFINITIONS_HEADER_GUARD_1357924680)
#define DOMSUPPORT_DEFINITIONS_HEADER_GUARD_1357924680
#include <Include/PlatformDefinitions.hpp>
#if defined(XALAN_DOMSUPPORT_BUILD_DLL)
#define XALAN_DOMSUPPORT_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_DOMSUPPORT_EXPORT_FUNCTION(T) XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_DOMSUPPORT_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_DOMSUPPORT_EXPORT_FUNCTION(T) XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // DOMSUPPORT_DEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/DOMSupportException.cpp
Index: DOMSupportException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DOMSupportException.hpp"
DOMSupportException::DOMSupportException(const DOMString& message) :
XSLException(message)
{
}
DOMSupportException::~DOMSupportException()
{
}
1.1 xml-xalan/c/src/DOMSupport/DOMSupportException.hpp
Index: DOMSupportException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMSUPPORTEXCEPTION_HEADER_GUARD_1357924680)
#define DOMSUPPORTEXCEPTION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
// Base class header file.
#include <PlatformSupport/XSLException.hpp>
class XALAN_DOMSUPPORT_EXPORT DOMSupportException : public XSLException
{
public:
explicit
DOMSupportException(
const DOMString& message = DOMString());
virtual
~DOMSupportException();
private:
};
#endif // DOMSUPPORTEXCEPTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/NSInfo.hpp
Index: NSInfo.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NSINFO_HEADER_GUARD_1357924680)
#define NSINFO_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Note that this call has no export definition, since everything is inline.
class NSInfo
{
public:
enum eHasXMLNSAttrs { ANCESTORXMLNSUNPROCESSED,
ANCESTORHASXMLNS,
ANCESTORNOXMLNS };
explicit
NSInfo(bool hasProcessedNS = false,
bool hasXMLNSAttrs = false) :
m_hasProcessedNS(hasProcessedNS),
m_hasXMLNSAttrs(hasXMLNSAttrs),
m_namespace(),
m_ancestorHasXMLNSAttrs(ANCESTORXMLNSUNPROCESSED)
{
};
// Unused at the moment
NSInfo(bool hasProcessedNS,
bool hasXMLNSAttrs,
eHasXMLNSAttrs ancestorHasXMLNSAttrs) :
m_hasProcessedNS(hasProcessedNS),
m_hasXMLNSAttrs(hasXMLNSAttrs),
m_ancestorHasXMLNSAttrs(ancestorHasXMLNSAttrs),
m_namespace()
{
};
NSInfo(DOMString theNamespace,
bool hasXMLNSAttrs) :
m_hasProcessedNS(true),
m_hasXMLNSAttrs(hasXMLNSAttrs),
m_namespace(theNamespace),
m_ancestorHasXMLNSAttrs(ANCESTORXMLNSUNPROCESSED)
{
};
~NSInfo()
{
}
bool
operator==(const NSInfo& theRHS) const
{
return equals(m_namespace, theRHS.m_namespace) &&
equals(m_hasXMLNSAttrs, theRHS.m_hasXMLNSAttrs) &&
equals(m_hasProcessedNS, theRHS.m_hasProcessedNS) &&
equals(m_ancestorHasXMLNSAttrs,
theRHS.m_ancestorHasXMLNSAttrs);
}
DOMString m_namespace;
bool m_hasXMLNSAttrs;
bool m_hasProcessedNS;
eHasXMLNSAttrs m_ancestorHasXMLNSAttrs;
};
#endif // NSINFO_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/NamespaceResolver.cpp
Index: NamespaceResolver.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NamespaceResolver.hpp"
#include <vector>
#include <Include/DOMHelper.hpp>
#include "DOMServices.hpp"
NamespaceResolver::NamespaceResolver() :
Resettable(),
m_NSInfos()
{
}
NamespaceResolver::~NamespaceResolver()
{
}
void
NamespaceResolver::reset()
{
m_NSInfos.clear();
}
namespace
{
NSInfo theNSInfoUnProcWithXMLNS(false, true);
NSInfo theNSInfoUnProcWithoutXMLNS(false, false);
NSInfo theNSInfoUnProcNoAncestorXMLNS(false, false,
NSInfo::ANCESTORNOXMLNS);
NSInfo theNSInfoNullWithXMLNS(true, true);
NSInfo theNSInfoNullWithoutXMLNS(true, false);
NSInfo theNSInfoNullNoAncestorXMLNS(true, false,
NSInfo::ANCESTORNOXMLNS);
};
DOMString
NamespaceResolver::getNamespaceOfNode(const DOM_Node& theNode)
{
using std::make_pair;
using std::pair;
using std::vector;
DOM_Node
theLocalNode(theNode);
bool hasProcessedNS;
NSInfo nsInfo;
const int ntype =
theLocalNode.getNodeType();
NSInfoMapType::const_iterator theIterator = m_NSInfos.end();
// Find the node in the map of cached DOM_Nodes, if it's not an
// attribute node.
if(DOM_Node::ATTRIBUTE_NODE != ntype)
{
theIterator = m_NSInfos.find(theLocalNode);
if (theIterator == m_NSInfos.end())
{
// Not found.
hasProcessedNS = false;
}
else
{
// Ahh, we found it.
nsInfo = (*theIterator).second;
hasProcessedNS = nsInfo.m_hasProcessedNS;
}
}
else
{
hasProcessedNS = false;
}
DOMString namespaceOfPrefix;
if(hasProcessedNS)
{
namespaceOfPrefix = nsInfo.m_namespace;
}
else
{
DOMString nodeName = theLocalNode.getNodeName();
int indexOfNSSep = indexOf(nodeName, ':');
DOMString prefix;
// If we have an attribute node without a prefix, then
// we should use the prefix of the element parent.
if(DOM_Node::ATTRIBUTE_NODE == ntype)
{
if(indexOfNSSep >= 0)
{
prefix = substring(nodeName, 0, indexOfNSSep);
}
else
{
theLocalNode =
DOMServices::getParentOfNode(theLocalNode);
nodeName = theLocalNode.getNodeName();
indexOfNSSep = indexOf(nodeName, ':');
prefix = (indexOfNSSep >= 0) ?
substring(nodeName, 0, indexOfNSSep) : DOMString();
}
}
else
{
prefix = (indexOfNSSep >= 0) ? substring(nodeName, 0,
indexOfNSSep) : DOMString();
}
bool ancestorsHaveXMLNS = false;
bool nHasXMLNS = false;
if(equals(prefix, "xml") == true)
{
namespaceOfPrefix = DOMServices::theXMLNamespaceURI;
}
else
{
int parentType = 0;
DOM_Node parent = theLocalNode;
typedef pair<DOM_Node, NSInfo>
CandidateNoAncestorEntryType;
typedef vector<CandidateNoAncestorEntryType>
CandidateNoAncestorVectorType;
CandidateNoAncestorVectorType
candidateNoAncestorXMLNS;
while (0 != parent && length(namespaceOfPrefix) == 0)
{
if(theIterator != m_NSInfos.end()
&& nsInfo.m_ancestorHasXMLNSAttrs ==
nsInfo.ANCESTORNOXMLNS)
{
break;
}
parentType = parent.getNodeType();
if(theIterator == m_NSInfos.end() ||
nsInfo.m_hasXMLNSAttrs == true)
{
bool elementHasXMLNS = false;
if (parentType ==
DOM_Node::ELEMENT_NODE)
{
// $$$ TODO:
DOM_NamedNodeMap::getLength() should be const.
DOM_NamedNodeMap nnm =
parent.getAttributes();
for (int i = 0; i <
nnm.getLength(); i ++)
{
DOM_Node
attr = nnm.item(i);
const DOMString
aname = attr.getNodeName();
if(charAt(aname, 0) ==
'x')
{
const char*
const theXMLNS = "xmlns:";
bool isPrefix =
startsWith(aname, theXMLNS);
if
(equals(aname, "xmlns") == true || isPrefix == true)
{
if(theLocalNode == parent)
{
nHasXMLNS = true;
}
elementHasXMLNS = true;
ancestorsHaveXMLNS = true;
const
DOMString p = isPrefix == true ?
substring(aname, strlen(theXMLNS)) : DOMString();
if
(equals(p, prefix) == true)
{
namespaceOfPrefix = attr.getNodeValue();
break;
}
}
}
}
}
if((DOM_Node::ATTRIBUTE_NODE !=
parentType) &&
(theIterator ==
m_NSInfos.end()) &&
(theLocalNode != parent))
{
nsInfo = elementHasXMLNS ?
theNSInfoUnProcWithXMLNS :
theNSInfoUnProcWithoutXMLNS;
m_NSInfos[parent] = nsInfo;
}
}
if(DOM_Node::ATTRIBUTE_NODE == parentType)
{
parent =
DOMServices::getParentOfNode(parent);
}
else
{
candidateNoAncestorXMLNS.push_back(make_pair(parent, nsInfo));
parent = parent.getParentNode();
}
if(0 != parent)
{
theIterator = m_NSInfos.find(parent);
if (theIterator != m_NSInfos.end())
{
nsInfo = (*theIterator).second;
}
}
}
const int nCandidates =
candidateNoAncestorXMLNS.size();
if(nCandidates > 0)
{
if(false == ancestorsHaveXMLNS && 0 == parent)
{
for(int i = 0; i < nCandidates; i++)
{
const NSInfo& candidateInfo =
candidateNoAncestorXMLNS[i].second;
if(candidateInfo ==
theNSInfoUnProcWithoutXMLNS ||
candidateInfo ==
theNSInfoNullWithoutXMLNS)
{
m_NSInfos[parent] =
candidateInfo;
}
}
}
candidateNoAncestorXMLNS.clear();
}
}
if(DOM_Node::ATTRIBUTE_NODE != ntype)
{
if(0 == length(namespaceOfPrefix))
{
if(ancestorsHaveXMLNS == true)
{
if(nHasXMLNS == true)
{
m_NSInfos[theLocalNode] =
theNSInfoNullWithXMLNS;
}
else
{
m_NSInfos[theLocalNode] =
theNSInfoNullWithoutXMLNS;
}
}
else
{
m_NSInfos[theLocalNode] =
theNSInfoNullNoAncestorXMLNS;
}
}
else
{
m_NSInfos[theLocalNode] =
NSInfo(namespaceOfPrefix, nHasXMLNS);
}
}
}
return namespaceOfPrefix;
}
1.1 xml-xalan/c/src/DOMSupport/NamespaceResolver.hpp
Index: NamespaceResolver.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NAMESPACERESOLVER_HEADER_GUARD_1357924680)
#define NAMESPACERESOLVER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
// Standard Library header files.
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
#include <hash_map>
#else
#include <map>
#endif
#include <dom/DOM_Node.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/Resettable.hpp>
#include <DOMSupport/NSInfo.hpp>
class XALAN_DOMSUPPORT_EXPORT NamespaceResolver : public Resettable
{
public:
NamespaceResolver();
virtual
~NamespaceResolver();
// These interfaces are inherited from Resettable...
virtual void
reset();
// These interfaces are new to NamespaceResolver...
virtual DOMString
getNamespaceOfNode(const DOM_Node& theNode);
protected:
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef std::hash_map<DOM_Node, NSInfo, DOM_NodeHashFunction>
NSInfoMapType;
#else
typedef std::map<DOM_Node, NSInfo>
NSInfoMapType;
#endif
NSInfoMapType m_NSInfos;
};
#endif // NAMESPACERESOLVER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/TreeWalker.cpp
Index: TreeWalker.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "TreeWalker.hpp"
// Xerces header files...
#include <dom/DOM_Node.hpp>
// XSL4C header files.
#include <Include/DOMHelper.hpp>
TreeWalker::TreeWalker()
{
}
TreeWalker::~TreeWalker()
{
}
void
TreeWalker::traverse(const DOM_Node& pos)
{
DOM_Node thePos(pos);
while(0 != thePos)
{
startNode(thePos);
DOM_Node nextNode = thePos.getFirstChild();
while(0 == nextNode)
{
endNode(thePos);
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
thePos = thePos.getParentNode();
if(0 == thePos)
{
nextNode = thePos;
break;
}
}
}
thePos = nextNode;
}
}
void
TreeWalker::traverse(
const DOM_Node& pos,
const DOM_Node& parent)
{
DOM_Node thePos(pos);
while(parent != thePos)
{
startNode(thePos);
DOM_Node nextNode = thePos.getFirstChild();
while(0 == nextNode)
{
endNode(thePos);
nextNode = thePos.getNextSibling();
if(0 == nextNode)
{
thePos = thePos.getParentNode();
if(parent == thePos)
{
nextNode = thePos;
break;
}
}
}
thePos = nextNode;
}
}
1.1 xml-xalan/c/src/DOMSupport/TreeWalker.hpp
Index: TreeWalker.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(TREEWALKER_HEADER_GUARD_1357924680)
#define TREEWALKER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
class DOM_Node;
class XALAN_DOMSUPPORT_EXPORT TreeWalker
{
public:
/**
* Constructor.
*/
TreeWalker();
virtual
~TreeWalker();
/**
* Perform a pre-order traversal non-recursive style.
*/
virtual void
traverse(const DOM_Node& pos);
/**
* Perform a pre-order traversal non-recursive style.
*/
virtual void
traverse(
const DOM_Node& pos,
const DOM_Node& parent);
protected:
virtual void
startNode(const DOM_Node& node) = 0;
virtual void
endNode(const DOM_Node& node) = 0;
private:
};
#endif // TREEWALKER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/UnimplementedDocument.cpp
Index: UnimplementedDocument.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "UnimplementedDocument.hpp"
#include <cassert>
UnimplementedDocument::UnimplementedDocument() :
DocumentImpl()
{
}
UnimplementedDocument::UnimplementedDocument(
const UnimplementedDocument& theOther) :
DocumentImpl(theOther)
{
}
UnimplementedDocument::~UnimplementedDocument()
{
}
void
UnimplementedDocument::referenced()
{
}
void
UnimplementedDocument::unreferenced()
{
}
NodeImpl*
UnimplementedDocument::appendChild(NodeImpl* /* newChild */)
{
assert(false);
return 0;
}
void
UnimplementedDocument::changed()
{
assert(false);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
NodeImpl*
#else
UnimplementedDocument*
#endif
UnimplementedDocument:: cloneNode(bool /* deep */)
{
assert(false);
return 0;
}
bool
UnimplementedDocument::isDocumentImpl()
{
return true;
}
NamedNodeMapImpl*
UnimplementedDocument::getAttributes()
{
assert(false);
return 0;
}
NodeListImpl*
UnimplementedDocument:: getChildNodes()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::getFirstChild()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument:: getLastChild()
{
assert(false);
return 0;
}
int
UnimplementedDocument::getLength()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::getNextSibling()
{
assert(false);
return 0;
}
DOMString
UnimplementedDocument::getNodeName()
{
assert(false);
return DOMString();
}
short
UnimplementedDocument::getNodeType()
{
assert(false);
return 0;
}
DOMString
UnimplementedDocument::getNodeValue()
{
assert(false);
return DOMString();
}
DocumentImpl*
UnimplementedDocument::getOwnerDocument()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::getParentNode()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::getPreviousSibling()
{
assert(false);
return 0;
}
void*
UnimplementedDocument::getUserData()
{
assert(false);
return 0;
}
bool
UnimplementedDocument::hasChildNodes()
{
assert(false);
return false;
}
NodeImpl*
UnimplementedDocument::insertBefore(
NodeImpl* /* newChild */,
NodeImpl* /* refChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::item(int /* index */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::removeChild(NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::replaceChild(
NodeImpl* /* newChild */,
NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
void
UnimplementedDocument::setNodeValue(const DOMString& /* value */)
{
assert(false);
}
void
UnimplementedDocument::setReadOnly(
bool /* readOnly */,
bool /* deep */)
{
assert(false);
}
void
UnimplementedDocument::setUserData(void* /* value */)
{
assert(false);
}
DOMString
UnimplementedDocument::toString()
{
assert(false);
return DOMString();
}
AttrImpl*
UnimplementedDocument::createAttribute(const DOMString& /* name
*/)
{
assert(false);
return 0;
}
CDATASectionImpl*
UnimplementedDocument::createCDATASection(const DOMString& /* data */)
{
assert(false);
return 0;
}
CommentImpl*
UnimplementedDocument::createComment(const DOMString& /* data */)
{
assert(false);
return 0;
}
DocumentFragmentImpl*
UnimplementedDocument::createDocumentFragment()
{
assert(false);
return 0;
}
DocumentTypeImpl*
UnimplementedDocument::createDocumentType(const DOMString& /* name */)
{
assert(false);
return 0;
}
ElementImpl*
UnimplementedDocument::createElement(const DOMString& /* tagName */)
{
assert(false);
return 0;
}
ElementImpl*
UnimplementedDocument::createElement(const XMLCh* /* tagName */)
{
assert(false);
return 0;
}
EntityImpl*
UnimplementedDocument::createEntity(const DOMString& /* name */)
{
assert(false);
return 0;
}
EntityReferenceImpl*
UnimplementedDocument::createEntityReference(const DOMString& /* name */)
{
assert(false);
return 0;
}
NotationImpl*
UnimplementedDocument::createNotation(const DOMString& /* name */)
{
assert(false);
return 0;
}
ProcessingInstructionImpl*
UnimplementedDocument::createProcessingInstruction(
const DOMString& /* target */,
const DOMString& /* data */)
{
assert(false);
return 0;
}
TextImpl*
UnimplementedDocument::createTextNode(const DOMString& /* data */)
{
assert(false);
return 0;
}
DocumentTypeImpl*
UnimplementedDocument::getDoctype()
{
return 0;
}
ElementImpl*
UnimplementedDocument::getDocumentElement()
{
assert(false);
return 0;
}
DeepNodeListImpl*
UnimplementedDocument::getElementsByTagName(const DOMString& /* tagname */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocument::importNode(
NodeImpl* /* source */,
bool /* deep */)
{
assert(false);
return 0;
}
DOM_UnimplementedDocument::DOM_UnimplementedDocument(UnimplementedDocument*
theDocument) :
DOM_Document(theDocument)
{
}
DOM_UnimplementedDocument::DOM_UnimplementedDocument() :
DOM_Document()
{
}
DOM_UnimplementedDocument::DOM_UnimplementedDocument(const
DOM_UnimplementedDocument& theDocument) :
DOM_Document(theDocument)
{
}
DOM_UnimplementedDocument::~DOM_UnimplementedDocument()
{
}
1.1 xml-xalan/c/src/DOMSupport/UnimplementedDocument.hpp
Index: UnimplementedDocument.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(UNIMPLEMENTEDDOCUMENT_HEADER_GUARD_1357924680)
#define UNIMPLEMENTEDDOCUMENT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DocumentImpl.hpp>
class XALAN_DOMSUPPORT_EXPORT UnimplementedDocument : public DocumentImpl
{
public:
/**
* Constructor.
*/
explicit
UnimplementedDocument();
UnimplementedDocument(
const UnimplementedDocument& theOther);
virtual
~UnimplementedDocument();
// These interfaces are inherited from RefCountedImpl...
virtual void
referenced();
virtual void
unreferenced();
// These interfaces are inherited from NodeListImpl...
virtual NodeImpl*
item(int index);
virtual int
getLength();
// These interfaces are inherited from NodeImpl...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual NodeImpl*
#else
virtual UnimplementedDocument*
#endif
cloneNode(bool deep) = 0;
// Dynamic Cast replacement functions.
virtual bool
isDocumentImpl();
virtual NodeImpl*
appendChild(NodeImpl* newChild);
virtual void
changed();
virtual NamedNodeMapImpl*
getAttributes();
virtual NodeListImpl*
getChildNodes();
virtual NodeImpl*
getFirstChild();
virtual NodeImpl*
getLastChild();
virtual NodeImpl*
getNextSibling();
virtual DOMString
getNodeName();
virtual short
getNodeType();
virtual DOMString
getNodeValue();
virtual DocumentImpl*
getOwnerDocument();
virtual NodeImpl*
getParentNode();
virtual NodeImpl*
getPreviousSibling();
virtual void*
getUserData();
virtual bool
hasChildNodes();
virtual NodeImpl*
insertBefore(NodeImpl *newChild, NodeImpl *refChild);
virtual NodeImpl*
removeChild(NodeImpl *oldChild);
virtual NodeImpl*
replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
virtual void
setNodeValue(const DOMString& value);
virtual void
setReadOnly(bool readOnly, bool deep);
virtual void
setUserData(void *value);
virtual DOMString
toString();
// These interfaces are inherited from DocumentImpl...
virtual AttrImpl*
createAttribute(const DOMString& name);
virtual CDATASectionImpl*
createCDATASection(const DOMString& data);
virtual CommentImpl*
createComment(const DOMString& data);
virtual DocumentFragmentImpl*
createDocumentFragment();
virtual DocumentTypeImpl*
createDocumentType(const DOMString& name);
virtual ElementImpl*
createElement(const DOMString& tagName);
virtual ElementImpl*
createElement(const XMLCh* tagName);
virtual EntityImpl*
createEntity(const DOMString& name);
virtual EntityReferenceImpl*
createEntityReference(const DOMString& name);
virtual NotationImpl*
createNotation(const DOMString& name);
virtual ProcessingInstructionImpl*
createProcessingInstruction(
const DOMString& target,
const DOMString& data);
virtual TextImpl*
createTextNode(const DOMString& data);
virtual DocumentTypeImpl*
getDoctype();
virtual ElementImpl*
getDocumentElement();
virtual DeepNodeListImpl*
getElementsByTagName(const DOMString& tagname);
virtual NodeImpl*
importNode(
NodeImpl* source,
bool deep);
};
class XALAN_DOMSUPPORT_EXPORT DOM_UnimplementedDocument : public DOM_Document
{
public:
/**
* Constructors.
*/
DOM_UnimplementedDocument(UnimplementedDocument* theDocument);
DOM_UnimplementedDocument();
DOM_UnimplementedDocument(const DOM_UnimplementedDocument&
theNode);
/**
* Destructor.
*/
~DOM_UnimplementedDocument();
/**
* Assignment operator.
*
* @param other The source to be assigned.
*/
DOM_UnimplementedDocument&
operator=(const DOM_UnimplementedDocument& other)
{
DOM_Document::operator=(other);
return *this;
}
/**
* Assignment operator. This overloaded variant is provided for
* the sole purpose of setting a DOM_Node reference variable to
* zero. Nulling out a reference variable in this way will
decrement
* the reference count on the underlying Node object that the
variable
* formerly referenced. This effect is normally obtained when
reference
* variable goes out of scope, but zeroing them can be useful for
* global instances, or for local instances that will remain in
scope
* for an extended time, when the storage belonging to the
underlying
* node needs to be reclaimed.
*
* @param val. Only a value of 0, or null, is allowed.
*/
DOM_UnimplementedDocument&
operator=(const DOM_NullPtr* val)
{
DOM_Document::operator=(val);
return *this;
}
/**
* The equality operator. This compares to references to nodes, and
* returns true if they both refer to the same underlying node. It
* is exactly analogous to Java's operator == on object reference
* variables. This operator can not be used to compare the values
* of two different nodes in the document tree.
*
* @param other The object reference with which <code>this</code>
object is compared
* @returns True if both <code>DOM_Node</code>s refer to the same
* actual node, or are both null; return false otherwise.
*/
bool
operator==(const DOM_Node& other) const
{
return DOM_Document::operator==(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator==(const DOM_NullPtr* other) const
{
return DOM_Document::operator==(other);
}
/**
* The inequality operator. See operator ==.
*
*/
bool
operator!=(const DOM_Node& other) const
{
return DOM_Document::operator!=(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator!=(const DOM_NullPtr* other) const
{
return DOM_Document::operator!=(other);
}
protected:
private:
// Not implemented...
// I think it's dangerous to allow this conversion...
DOM_UnimplementedDocument(const DOM_Document& theNode);
};
#endif // UNIMPLEMENTEDDOCUMENT_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/DOMSupport/UnimplementedDocumentFragment.cpp
Index: UnimplementedDocumentFragment.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "UnimplementedDocumentFragment.hpp"
#include <cassert>
UnimplementedDocumentFragment::UnimplementedDocumentFragment(DocumentImpl*
ownerDoc) :
DocumentFragmentImpl(ownerDoc)
{
}
UnimplementedDocumentFragment::UnimplementedDocumentFragment(
const UnimplementedDocumentFragment& theOther) :
DocumentFragmentImpl(theOther)
{
}
UnimplementedDocumentFragment::~UnimplementedDocumentFragment()
{
}
void
UnimplementedDocumentFragment::referenced()
{
}
void
UnimplementedDocumentFragment::unreferenced()
{
}
NodeImpl*
UnimplementedDocumentFragment::appendChild(NodeImpl* /* newChild */)
{
assert(false);
return 0;
}
void
UnimplementedDocumentFragment::changed()
{
assert(false);
}
NodeImpl*
UnimplementedDocumentFragment:: cloneNode(bool /* deep */)
{
assert(false);
return 0;
}
bool
UnimplementedDocumentFragment::isDocumentFragmentImpl()
{
return true;
}
NamedNodeMapImpl*
UnimplementedDocumentFragment::getAttributes()
{
assert(false);
return 0;
}
NodeListImpl*
UnimplementedDocumentFragment:: getChildNodes()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment::getFirstChild()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment:: getLastChild()
{
assert(false);
return 0;
}
int
UnimplementedDocumentFragment::getLength()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment::getNextSibling()
{
assert(false);
return 0;
}
DOMString
UnimplementedDocumentFragment::getNodeName()
{
assert(false);
return DOMString();
}
short
UnimplementedDocumentFragment::getNodeType()
{
assert(false);
return 0;
}
DOMString
UnimplementedDocumentFragment::getNodeValue()
{
assert(false);
return DOMString();
}
DocumentImpl*
UnimplementedDocumentFragment::getOwnerDocument()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment::getParentNode()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment::getPreviousSibling()
{
assert(false);
return 0;
}
bool
UnimplementedDocumentFragment::hasChildNodes()
{
assert(false);
return false;
}
NodeImpl*
UnimplementedDocumentFragment::insertBefore(
NodeImpl* /* newChild */,
NodeImpl* /* refChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment::item(int /* index */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment::removeChild(NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedDocumentFragment::replaceChild(
NodeImpl* /* newChild */,
NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
void
UnimplementedDocumentFragment::setNodeValue(const DOMString& /* value */)
{
}
void
UnimplementedDocumentFragment::setReadOnly(
bool /* readOnly */,
bool /* deep */)
{
assert(false);
}
DOMString
UnimplementedDocumentFragment::toString()
{
assert(false);
return DOMString();
}
DOM_UnimplementedDocumentFragment::DOM_UnimplementedDocumentFragment(UnimplementedDocumentFragment*
theDocument) :
DOM_DocumentFragment(theDocument)
{
}
DOM_UnimplementedDocumentFragment::DOM_UnimplementedDocumentFragment() :
DOM_DocumentFragment()
{
}
DOM_UnimplementedDocumentFragment::DOM_UnimplementedDocumentFragment(const
DOM_UnimplementedDocumentFragment& theDocument) :
DOM_DocumentFragment(theDocument)
{
}
DOM_UnimplementedDocumentFragment::~DOM_UnimplementedDocumentFragment()
{
}
1.1
xml-xalan/c/src/DOMSupport/UnimplementedDocumentFragment.hpp
Index: UnimplementedDocumentFragment.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(UNIMPLEMENTEDDOCUMENTFRAGMENT_HEADER_GUARD_1357924680)
#define UNIMPLEMENTEDDOCUMENTFRAGMENT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DocumentFragmentImpl.hpp>
#include <dom/DocumentImpl.hpp>
// This class is a stub base class for any
class XALAN_DOMSUPPORT_EXPORT UnimplementedDocumentFragment : public
DocumentFragmentImpl
{
public:
/**
* Constructor.
*/
UnimplementedDocumentFragment(DocumentImpl* ownerDoc = 0);
UnimplementedDocumentFragment(
const UnimplementedDocumentFragment& theOther);
virtual
~UnimplementedDocumentFragment();
// These interfaces are inherited from RefCountedImpl...
// Deriving classes do not need to override these.
virtual void
referenced();
virtual void
unreferenced();
// These interfaces are inherited from NodeListImpl...
// Deriving classes _must_ override these.
virtual NodeImpl*
item(int index);
virtual int
getLength();
// These interfaces are inherited from NodeImpl...
// Deriving classes _must_ override these, unless noted.
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual NodeImpl*
#else
virtual UnimplementedDocumentFragment*
#endif
cloneNode(bool deep) = 0;
// Dynamic Cast replacement functions.
// Deriving classes do not need to override this.
virtual bool
isDocumentFragmentImpl();
virtual NodeImpl*
appendChild(NodeImpl* newChild);
virtual void
changed();
virtual NamedNodeMapImpl*
getAttributes();
virtual NodeListImpl*
getChildNodes();
virtual NodeImpl*
getFirstChild();
virtual NodeImpl*
getLastChild();
virtual NodeImpl*
getNextSibling();
virtual DOMString
getNodeName();
virtual short
getNodeType();
virtual DOMString
getNodeValue();
virtual DocumentImpl*
getOwnerDocument();
virtual NodeImpl*
getParentNode();
virtual NodeImpl*
getPreviousSibling();
virtual bool
hasChildNodes();
virtual NodeImpl*
insertBefore(NodeImpl *newChild, NodeImpl *refChild);
virtual NodeImpl*
removeChild(NodeImpl *oldChild);
virtual NodeImpl*
replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
virtual void
setNodeValue(const DOMString& value);
virtual void
setReadOnly(bool readOnly, bool deep);
virtual DOMString
toString();
// There are no new interfaces that are inherited from
DocumentFragmentImpl...
};
class XALAN_DOMSUPPORT_EXPORT DOM_UnimplementedDocumentFragment : public
DOM_DocumentFragment
{
public:
/**
* Constructors.
*/
DOM_UnimplementedDocumentFragment(UnimplementedDocumentFragment*
theDocument);
DOM_UnimplementedDocumentFragment();
DOM_UnimplementedDocumentFragment(const
DOM_UnimplementedDocumentFragment& theNode);
/**
* Destructor.
*/
~DOM_UnimplementedDocumentFragment();
/**
* Assignment operator.
*
* @param other The source to be assigned.
*/
DOM_UnimplementedDocumentFragment&
operator=(const DOM_UnimplementedDocumentFragment& other)
{
DOM_DocumentFragment::operator=(other);
return *this;
}
/**
* Assignment operator. This overloaded variant is provided for
* the sole purpose of setting a DOM_Node reference variable to
* zero. Nulling out a reference variable in this way will
decrement
* the reference count on the underlying Node object that the
variable
* formerly referenced. This effect is normally obtained when
reference
* variable goes out of scope, but zeroing them can be useful for
* global instances, or for local instances that will remain in
scope
* for an extended time, when the storage belonging to the
underlying
* node needs to be reclaimed.
*
* @param val. Only a value of 0, or null, is allowed.
*/
DOM_UnimplementedDocumentFragment&
operator=(const DOM_NullPtr* val)
{
DOM_DocumentFragment::operator=(val);
return *this;
}
/**
* The equality operator. This compares to references to nodes, and
* returns true if they both refer to the same underlying node. It
* is exactly analogous to Java's operator == on object reference
* variables. This operator can not be used to compare the values
* of two different nodes in the document tree.
*
* @param other The object reference with which <code>this</code>
object is compared
* @returns True if both <code>DOM_Node</code>s refer to the same
* actual node, or are both null; return false otherwise.
*/
bool
operator==(const DOM_Node& other) const
{
return DOM_DocumentFragment::operator==(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator==(const DOM_NullPtr* other) const
{
return DOM_DocumentFragment::operator==(other);
}
/**
* The inequality operator. See operator ==.
*
*/
bool
operator!=(const DOM_Node& other) const
{
return DOM_DocumentFragment::operator!=(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator!=(const DOM_NullPtr* other) const
{
return DOM_DocumentFragment::operator!=(other);
}
protected:
private:
// Not implemented...
// I think it's dangerous to allow this conversion...
DOM_UnimplementedDocumentFragment(const DOM_DocumentFragment&
theFragment);
};
#endif // UNIMPLEMENTEDDOCUMENTFRAGMENT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/UnimplementedElement.cpp
Index: UnimplementedElement.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "UnimplementedElement.hpp"
#include <cassert>
UnimplementedElement::UnimplementedElement(DocumentImpl* ownerDoc) :
ElementImpl(ownerDoc,
DOMString())
{
}
UnimplementedElement::UnimplementedElement(
const UnimplementedElement& theOther,
bool deep) :
ElementImpl(theOther,
deep)
{
}
UnimplementedElement::~UnimplementedElement()
{
}
void
UnimplementedElement::referenced()
{
}
void
UnimplementedElement::unreferenced()
{
}
NodeImpl*
UnimplementedElement::appendChild(NodeImpl* /* newChild */)
{
assert(false);
return 0;
}
void
UnimplementedElement::changed()
{
assert(false);
}
bool
UnimplementedElement::isElementImpl()
{
return true;
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
NodeImpl*
#else
UnimplementedElement*
#endif
UnimplementedElement::cloneNode(bool /* deep */)
{
assert(false);
return 0;
}
NamedNodeMapImpl*
UnimplementedElement::getAttributes()
{
assert(false);
return 0;
}
NodeListImpl*
UnimplementedElement::getChildNodes()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement::getFirstChild()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement:: getLastChild()
{
assert(false);
return 0;
}
int
UnimplementedElement::getLength()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement::getNextSibling()
{
assert(false);
return 0;
}
DOMString
UnimplementedElement::getNodeName()
{
assert(false);
return DOMString();
}
short
UnimplementedElement::getNodeType()
{
assert(false);
return 0;
}
DOMString
UnimplementedElement::getNodeValue()
{
assert(false);
return DOMString();
}
DocumentImpl*
UnimplementedElement::getOwnerDocument()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement::getParentNode()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement::getPreviousSibling()
{
assert(false);
return 0;
}
void*
UnimplementedElement::getUserData()
{
assert(false);
return 0;
}
bool
UnimplementedElement::hasChildNodes()
{
assert(false);
return false;
}
NodeImpl*
UnimplementedElement::insertBefore(
NodeImpl* /* newChild */,
NodeImpl* /* refChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement::item(int /* index */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement::removeChild(NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedElement::replaceChild(
NodeImpl* /* newChild */,
NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
void
UnimplementedElement::setNodeValue(const DOMString& /* value */)
{
assert(false);
}
void
UnimplementedElement::setReadOnly(
bool /* readOnly */,
bool /* deep */)
{
assert(false);
}
void
UnimplementedElement::setUserData(void* /* value */)
{
assert(false);
}
DOMString
UnimplementedElement::toString()
{
assert(false);
return DOMString();
}
DOMString
UnimplementedElement::getAttribute(const DOMString& /* name */)
{
return DOMString();
}
AttrImpl*
UnimplementedElement::getAttributeNode(const DOMString& /* name
*/)
{
assert(false);
return 0;
}
DeepNodeListImpl*
UnimplementedElement::getElementsByTagName(const DOMString& /*
tagname */)
{
assert(false);
return 0;
}
DOMString
UnimplementedElement::getTagName()
{
assert(false);
return DOMString();
}
void
UnimplementedElement::normalize()
{
assert(false);
}
void
UnimplementedElement::removeAttribute(const DOMString& /* name */)
{
assert(false);
}
AttrImpl*
UnimplementedElement::removeAttributeNode(AttrImpl* /* oldAttr */)
{
assert(false);
return 0;
}
void
UnimplementedElement::setAttribute(
const DOMString& /* name */,
const DOMString& /* value */)
{
assert(false);
}
AttrImpl*
UnimplementedElement::setAttributeNode(AttrImpl* /* newAttr */)
{
assert(false);
return 0;
}
DOM_UnimplementedElement::DOM_UnimplementedElement(UnimplementedElement*
theElement) :
DOM_Element(theElement)
{
}
DOM_UnimplementedElement::DOM_UnimplementedElement() :
DOM_Element()
{
}
DOM_UnimplementedElement::DOM_UnimplementedElement(const
DOM_UnimplementedElement& theElement) :
DOM_Element(theElement)
{
}
DOM_UnimplementedElement::~DOM_UnimplementedElement()
{
}
1.1 xml-xalan/c/src/DOMSupport/UnimplementedElement.hpp
Index: UnimplementedElement.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(UNIMPLEMENTEDELEMENT_HEADER_GUARD_1357924680)
#define UNIMPLEMENTEDELEMENT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/ElementImpl.hpp>
class XALAN_DOMSUPPORT_EXPORT UnimplementedElement : public ElementImpl
{
public:
/**
* Constructor.
*/
UnimplementedElement(DocumentImpl* ownerDoc);
UnimplementedElement(
const UnimplementedElement& theOther,
bool deep =
false);
virtual
~UnimplementedElement();
// These interfaces are inherited from RefCountedImpl...
virtual void
referenced();
virtual void
unreferenced();
// These interfaces are inherited from NodeListImpl...
virtual NodeImpl*
item(int index);
virtual int
getLength();
// These interfaces are inherited from NodeImpl...
virtual bool
isElementImpl();
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual NodeImpl*
#else
virtual UnimplementedElement*
#endif
cloneNode(bool deep) = 0;
virtual NodeImpl*
appendChild(NodeImpl* newChild);
virtual void
changed();
virtual NamedNodeMapImpl*
getAttributes();
virtual NodeListImpl*
getChildNodes();
virtual NodeImpl*
getFirstChild();
virtual NodeImpl*
getLastChild();
virtual NodeImpl*
getNextSibling();
virtual DOMString
getNodeName();
virtual short
getNodeType();
virtual DOMString
getNodeValue();
virtual DocumentImpl*
getOwnerDocument();
virtual NodeImpl*
getParentNode();
virtual NodeImpl*
getPreviousSibling();
virtual void*
getUserData();
virtual bool
hasChildNodes();
virtual NodeImpl*
insertBefore(NodeImpl *newChild, NodeImpl *refChild);
virtual NodeImpl*
removeChild(NodeImpl *oldChild);
virtual NodeImpl*
replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
virtual void
setNodeValue(const DOMString& value);
virtual void
setReadOnly(bool readOnly, bool deep);
virtual void
setUserData(void *value);
virtual DOMString
toString();
// These interfaces are inherited from ElementImpl...
virtual DOMString
getAttribute(const DOMString& name);
virtual AttrImpl*
getAttributeNode(const DOMString& name);
virtual DeepNodeListImpl*
getElementsByTagName(const DOMString& tagname);
virtual DOMString
getTagName();
virtual void
normalize();
virtual void
removeAttribute(const DOMString& name);
virtual AttrImpl*
removeAttributeNode(AttrImpl* oldAttr);
virtual void
setAttribute(
const DOMString& name,
const DOMString& value);
virtual AttrImpl*
setAttributeNode(AttrImpl* newAttr);
};
class XALAN_DOMSUPPORT_EXPORT DOM_UnimplementedElement : public DOM_Element
{
public:
/**
* Constructors.
*/
DOM_UnimplementedElement(UnimplementedElement* theElement);
DOM_UnimplementedElement();
DOM_UnimplementedElement(const DOM_UnimplementedElement&
theElement);
/**
* Destructor.
*/
~DOM_UnimplementedElement();
/**
* Assignment operator.
*
* @param other The source to be assigned.
*/
DOM_UnimplementedElement&
operator=(const DOM_UnimplementedElement& other)
{
DOM_Element::operator=(other);
return *this;
}
/**
* Assignment operator. This overloaded variant is provided for
* the sole purpose of setting a DOM_Node reference variable to
* zero. Nulling out a reference variable in this way will
decrement
* the reference count on the underlying Node object that the
variable
* formerly referenced. This effect is normally obtained when
reference
* variable goes out of scope, but zeroing them can be useful for
* global instances, or for local instances that will remain in
scope
* for an extended time, when the storage belonging to the
underlying
* node needs to be reclaimed.
*
* @param val. Only a value of 0, or null, is allowed.
*/
DOM_UnimplementedElement&
operator=(const DOM_NullPtr* val)
{
DOM_Element::operator=(val);
return *this;
}
/**
* The equality operator. This compares to references to nodes, and
* returns true if they both refer to the same underlying node. It
* is exactly analogous to Java's operator == on object reference
* variables. This operator can not be used to compare the values
* of two different nodes in the document tree.
*
* @param other The object reference with which <code>this</code>
object is compared
* @returns True if both <code>DOM_Node</code>s refer to the same
* actual node, or are both null; return false otherwise.
*/
bool
operator==(const DOM_Node& other) const
{
return DOM_Node::operator==(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator==(const DOM_NullPtr* other) const
{
return DOM_Node::operator==(other);
}
/**
* The inequality operator. See operator ==.
*
*/
bool
operator!=(const DOM_Node& other) const
{
return DOM_Node::operator!=(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator!=(const DOM_NullPtr* other) const
{
return DOM_Node::operator!=(other);
}
protected:
private:
// Not implemented...
// I think it's dangerous to allow this conversion...
DOM_UnimplementedElement(const DOM_Node& theNode);
};
#endif // UNIMPLEMENTEDELEMENT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/DOMSupport/UnimplementedNode.cpp
Index: UnimplementedNode.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "UnimplementedNode.hpp"
#include <cassert>
UnimplementedNode::UnimplementedNode(DocumentImpl* ownerDoc) :
NodeImpl(ownerDoc,
DOMString(),
0,
false,
DOMString())
{
}
UnimplementedNode::UnimplementedNode(
const UnimplementedNode& theOther,
bool deep) :
NodeImpl(theOther,
deep)
{
}
UnimplementedNode::~UnimplementedNode()
{
}
void
UnimplementedNode::referenced()
{
}
void
UnimplementedNode::unreferenced()
{
}
NodeImpl*
UnimplementedNode::appendChild(NodeImpl* /* newChild */)
{
assert(false);
return 0;
}
void
UnimplementedNode::changed()
{
assert(false);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
NodeImpl*
#else
UnimplementedNode*
#endif
UnimplementedNode:: cloneNode(bool /* deep */)
{
assert(false);
return 0;
}
NamedNodeMapImpl*
UnimplementedNode::getAttributes()
{
assert(false);
return 0;
}
NodeListImpl*
UnimplementedNode:: getChildNodes()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode::getFirstChild()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode:: getLastChild()
{
assert(false);
return 0;
}
int
UnimplementedNode::getLength()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode::getNextSibling()
{
assert(false);
return 0;
}
DOMString
UnimplementedNode::getNodeName()
{
assert(false);
return DOMString();
}
short
UnimplementedNode::getNodeType()
{
assert(false);
return 0;
}
DOMString
UnimplementedNode::getNodeValue()
{
assert(false);
return DOMString();
}
DocumentImpl*
UnimplementedNode::getOwnerDocument()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode::getParentNode()
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode::getPreviousSibling()
{
assert(false);
return 0;
}
void*
UnimplementedNode::getUserData()
{
assert(false);
return 0;
}
bool
UnimplementedNode::hasChildNodes()
{
assert(false);
return false;
}
NodeImpl*
UnimplementedNode::insertBefore(
NodeImpl* /* newChild */,
NodeImpl* /* refChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode::item(int /* index */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode::removeChild(NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
NodeImpl*
UnimplementedNode::replaceChild(
NodeImpl* /* newChild */,
NodeImpl* /* oldChild */)
{
assert(false);
return 0;
}
void
UnimplementedNode::setNodeValue(const DOMString& /* value */)
{
assert(false);
}
void
UnimplementedNode::setReadOnly(
bool /* readOnly */,
bool /* deep */)
{
assert(false);
}
void
UnimplementedNode::setUserData(void* /* value */)
{
assert(false);
}
DOMString
UnimplementedNode::toString()
{
assert(false);
return DOMString();
}
DOM_UnimplementedNode::DOM_UnimplementedNode(UnimplementedNode*
theNode) :
DOM_Node(theNode)
{
}
DOM_UnimplementedNode::DOM_UnimplementedNode() :
DOM_Node()
{
}
DOM_UnimplementedNode::DOM_UnimplementedNode(const DOM_UnimplementedNode&
theNode) :
DOM_Node(theNode)
{
}
DOM_UnimplementedNode::~DOM_UnimplementedNode()
{
}
1.1 xml-xalan/c/src/DOMSupport/UnimplementedNode.hpp
Index: UnimplementedNode.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(UNIMPLEMENTEDNODE_HEADER_GUARD_1357924680)
#define UNIMPLEMENTEDNODE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <DOMSupport/DOMSupportDefinitions.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/NodeImpl.hpp>
class XALAN_DOMSUPPORT_EXPORT UnimplementedNode : public NodeImpl
{
public:
/**
* Constructor.
*/
UnimplementedNode(DocumentImpl* ownerDoc);
UnimplementedNode(
const UnimplementedNode& theOther,
bool deep =
false);
virtual
~UnimplementedNode();
// These interfaces are inherited from RefCountedImpl...
virtual void
referenced();
virtual void
unreferenced();
// These interfaces are inherited from NodeListImpl...
virtual NodeImpl*
item(int index);
virtual int
getLength();
// These interfaces are inherited from NodeImpl...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual NodeImpl*
#else
virtual UnimplementedNode*
#endif
cloneNode(bool deep) = 0;
virtual NodeImpl*
appendChild(NodeImpl* newChild);
virtual void
changed();
virtual NamedNodeMapImpl*
getAttributes();
virtual NodeListImpl*
getChildNodes();
virtual NodeImpl*
getFirstChild();
virtual NodeImpl*
getLastChild();
virtual NodeImpl*
getNextSibling();
virtual DOMString
getNodeName();
virtual short
getNodeType();
virtual DOMString
getNodeValue();
virtual DocumentImpl*
getOwnerDocument();
virtual NodeImpl*
getParentNode();
virtual NodeImpl*
getPreviousSibling();
virtual void*
getUserData();
virtual bool
hasChildNodes();
virtual NodeImpl*
insertBefore(NodeImpl *newChild, NodeImpl *refChild);
virtual NodeImpl*
removeChild(NodeImpl *oldChild);
virtual NodeImpl*
replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
virtual void
setNodeValue(const DOMString& value);
virtual void
setReadOnly(bool readOnly, bool deep);
virtual void
setUserData(void *value);
virtual DOMString
toString();
};
class XALAN_DOMSUPPORT_EXPORT DOM_UnimplementedNode : public DOM_Node
{
public:
/**
* Constructors.
*/
DOM_UnimplementedNode(UnimplementedNode* theNode);
DOM_UnimplementedNode();
DOM_UnimplementedNode(const DOM_UnimplementedNode& theNode);
/**
* Destructor.
*/
~DOM_UnimplementedNode();
/**
* Assignment operator.
*
* @param other The source to be assigned.
*/
DOM_UnimplementedNode&
operator=(const DOM_UnimplementedNode& other)
{
DOM_Node::operator=(other);
return *this;
}
/**
* Assignment operator. This overloaded variant is provided for
* the sole purpose of setting a DOM_Node reference variable to
* zero. Nulling out a reference variable in this way will
decrement
* the reference count on the underlying Node object that the
variable
* formerly referenced. This effect is normally obtained when
reference
* variable goes out of scope, but zeroing them can be useful for
* global instances, or for local instances that will remain in
scope
* for an extended time, when the storage belonging to the
underlying
* node needs to be reclaimed.
*
* @param val. Only a value of 0, or null, is allowed.
*/
DOM_UnimplementedNode&
operator=(const DOM_NullPtr* val)
{
DOM_Node::operator=(val);
return *this;
}
/**
* The equality operator. This compares to references to nodes, and
* returns true if they both refer to the same underlying node. It
* is exactly analogous to Java's operator == on object reference
* variables. This operator can not be used to compare the values
* of two different nodes in the document tree.
*
* @param other The object reference with which <code>this</code>
object is compared
* @returns True if both <code>DOM_Node</code>s refer to the same
* actual node, or are both null; return false otherwise.
*/
bool
operator==(const DOM_Node& other) const
{
return DOM_Node::operator==(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator==(const DOM_NullPtr* other) const
{
return DOM_Node::operator==(other);
}
/**
* The inequality operator. See operator ==.
*
*/
bool
operator!=(const DOM_Node& other) const
{
return DOM_Node::operator!=(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator!=(const DOM_NullPtr* other) const
{
return DOM_Node::operator!=(other);
}
protected:
private:
// Not implemented...
// I think it's dangerous to allow this conversion...
DOM_UnimplementedNode(const DOM_Node& theNode);
};
#endif // UNIMPLEMENTEDNODE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/Include/DOMHelper.hpp
Index: DOMHelper.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMHELPER_HEADER_GUARD_1357924680)
#define DOMHELPER_HEADER_GUARD_1357924680
// STL header file for class unary_function.
#include <functional>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_NodeList.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOM_Element.hpp>
class DOM_NullPtr;
class NodeImpl;
#if 0
template<class T>
inline int
operator==(void* theAddress,
const T& theProxy)
{
return theProxy.operator==(reinterpret_cast<const
DOM_NullPtr*>(theAddress));
}
#else
inline int
operator==(void* theAddress,
const DOM_Node& theProxy)
{
return theProxy.operator==(reinterpret_cast<const
DOM_NullPtr*>(theAddress));
}
inline int
operator==(void* theAddress,
const DOM_NamedNodeMap& theProxy)
{
return theProxy.operator==(reinterpret_cast<const
DOM_NullPtr*>(theAddress));
}
inline int
operator==(void* theAddress,
const DOM_NodeList& theProxy)
{
return theProxy.operator==(reinterpret_cast<const
DOM_NullPtr*>(theAddress));
}
#endif
template<class T>
inline int
operator!=(void* theAddress,
const T& theProxy)
{
return !(theAddress == theProxy);
}
template<class T, class U>
class DOM_ConstSurrogate
{
public:
DOM_ConstSurrogate(const T& theInstance) :
m_instance(theInstance)
{
}
const U&
operator&() const
{
return reinterpret_cast<const U&>(m_instance);
}
const U&
operator*() const
{
return reinterpret_cast<const U&>(m_instance);
}
const U*
operator->() const
{
return reinterpret_cast<const U*>(&m_instance);
}
protected:
T m_instance;
};
template<class T, class U>
class DOM_Surrogate : public DOM_ConstSurrogate<T, U>
{
public:
DOM_Surrogate(const T& theInstance) :
DOM_ConstSurrogate(theInstance)
{
}
U&
operator&()
{
return reinterpret_cast<U&>(m_instance);
}
U&
operator*()
{
return reinterpret_cast<U&>(m_instance);
}
U*
operator->()
{
return reinterpret_cast<U*>(&m_instance);
}
};
// This class is a big hack, so we can get at the pointer to the
// internal implementation of a DOM_Node, for the purposes of hashing
// and implementing operator<().
class XALAN_DOM_NodeHack : public DOM_Node
{
public:
XALAN_DOM_NodeHack(const DOM_Node& theOtherNode) :
DOM_Node(theOtherNode)
{
}
XALAN_DOM_NodeHack(NodeImpl* theOtherNode) :
DOM_Node(theOtherNode)
{
}
~XALAN_DOM_NodeHack()
{
}
NodeImpl*
getImplementationObject() const
{
return fImpl;
}
friend bool operator<(const XALAN_DOM_NodeHack&, const
XALAN_DOM_NodeHack&);
friend struct DOM_NodeHashFunction;
};
// $$$ ToDo: This sort of address comparison, is undefined behavior
// according to the C++ standard, but it should work on 99.99% of
// architectures. We're only using it until STL hash containers are
// available.
inline bool
operator<(
const XALAN_DOM_NodeHack& theLHS,
const XALAN_DOM_NodeHack& theRHS)
{
return theLHS.fImpl < theRHS.fImpl ? true : false;
}
// Functor for hashing DOM_Nodes.
struct DOM_NodeHashFunction : public std::unary_function<DOM_Node, size_t>
{
result_type
operator() (const argument_type& theKey) const
{
return
reinterpret_cast<result_type>(XALAN_DOM_NodeHack(theKey).fImpl);
}
};
// Functor for hashing DOM_Elements.
struct DOM_ElementHashFunction : public std::unary_function<DOM_Element,
size_t>
{
result_type
operator() (const argument_type& theKey) const
{
return static_cast<result_type>(DOM_NodeHashFunction()(theKey));
}
};
#endif // DOMHELPER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/Include/PlatformDefinitions.hpp
Index: PlatformDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(PLATFORMDEFINITIONS_HEADER_GUARD_1357924680)
#define PLATFORMDEFINITIONS_HEADER_GUARD_1357924680
#if defined(_MSC_VER)
#include "VCPPDefinitions.hpp"
#else
#error Unsupported platform!
#endif
#endif // PLATFORMDEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/Include/VCPPDefinitions.hpp
Index: VCPPDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(VCPPDEFINITIONS_HEADER_GUARD_1357924680)
#define VCPPDEFINITIONS_HEADER_GUARD_1357924680
#pragma warning(disable: 4127 4251 4511 4512 4514 4702 4710 4711 4786 4097;
error: 4150 4172 4238 4239 4715)
// ---------------------------------------------------------------------------
// A define in the build for each project is also used to control whether
// the export keyword is from the project's viewpoint or the client's.
// These defines provide the platform specific keywords that they need
// to do this.
// ---------------------------------------------------------------------------
#define XALAN_PLATFORM_EXPORT __declspec(dllexport)
#define XALAN_PLATFORM_IMPORT __declspec(dllimport)
#define XALAN_PLATFORM_EXPORT_FUNCTION(T) T XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT_FUNCTION(T) T XALAN_PLATFORM_IMPORT
#define XALAN_OLD_AUTO_PTR
#define XALAN_NO_COVARIANT_RETURN_TYPE
#define XALAN_XTREE_BUG
#define XALAN_NEED_SPECIAL_NAN_SUPPORT
#endif // VCPPDEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/AttributeListImpl.cpp
Index: AttributeListImpl.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "AttributeListImpl.hpp"
#include <algorithm>
#include <cassert>
AttributeListImpl::AttributeListImpl() :
AttributeList(),
m_AttributeKeyMap(),
m_AttributeVector()
{
}
AttributeListImpl::~AttributeListImpl()
{
// Clean up everything...
clear();
}
AttributeListImpl::AttributeListImpl(const AttributeListImpl& theSource) :
AttributeList(),
m_AttributeKeyMap(),
m_AttributeVector()
{
// Use the assignment operator to do the dirty work...
*this = theSource;
assert(getLength() == theSource.getLength());
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
}
AttributeListImpl::AttributeListImpl(const AttributeList& theSource) :
AttributeList(),
m_AttributeKeyMap(),
m_AttributeVector()
{
// Use the assignment operator to do the dirty work...
*this = theSource;
assert(getLength() == theSource.getLength());
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
}
AttributeListImpl&
AttributeListImpl::operator=(const AttributeListImpl& theRHS)
{
if (this != &theRHS)
{
// Note that we can't chain up to our base class operator=()
// because it's private.
// Clear everything out...
clear();
const unsigned int theLength = theRHS.getLength();
// Reserve the appropriate capacity right now...
m_AttributeVector.reserve(theLength);
// Copy the vector entries, and build the index map...
for(unsigned int i = 0; i < theLength; i++)
{
assert(theRHS.m_AttributeVector[i] != 0);
const AttributeVectorEntry* const theEntry =
new
AttributeVectorEntry(*theRHS.m_AttributeVector[i]);
// Add the item...
m_AttributeVector.push_back(theEntry);
// Create an entry in the index map...
m_AttributeKeyMap.insert(std::make_pair(theEntry->m_Name.begin(),
theEntry));
}
assert(getLength() == theLength);
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
}
return *this;
}
AttributeListImpl&
AttributeListImpl::operator=(const AttributeList& theRHS)
{
if (this != &theRHS)
{
// Note that we can't chain up to our base class operator=()
// because it's private.
// Clear everything out.
clear();
const unsigned int theLength = theRHS.getLength();
// Reserve the appropriate capacity right now...
m_AttributeVector.reserve(theLength);
// Add each attribute.
for(unsigned int i = 0; i < theLength; i++)
{
addAttribute(theRHS.getName(i),
theRHS.getType(i),
theRHS.getValue(i));
}
assert(getLength() == theLength);
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
}
return *this;
}
unsigned int
AttributeListImpl::getLength() const
{
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
return m_AttributeVector.size();
}
const XMLCh*
AttributeListImpl::getName(const unsigned int index) const
{
assert(index < getLength());
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
return m_AttributeVector[index]->m_Name.begin();
}
const XMLCh*
AttributeListImpl::getType(const unsigned int index) const
{
assert(index < getLength());
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
return m_AttributeVector[index]->m_Type.begin();
}
const XMLCh*
AttributeListImpl::getValue(const unsigned int index) const
{
assert(index < getLength());
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
return m_AttributeVector[index]->m_Value.begin();
}
const XMLCh*
AttributeListImpl::getType(const XMLCh* const name) const
{
assert(name != 0);
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
// Find the name in the key map.
const AttributeKeyMapType::const_iterator i =
m_AttributeKeyMap.find(name);
if (i != m_AttributeKeyMap.end())
{
// Found it, so return a pointer to the type.
return i->second->m_Type.begin();
}
else
{
return 0;
}
}
const XMLCh*
AttributeListImpl::getValue(const char* const name) const
{
return getValue(XMLString::transcode(name));
}
const XMLCh*
AttributeListImpl::getValue(const XMLCh* const name) const
{
assert(name != 0);
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
// Find the name in the key map.
const AttributeKeyMapType::const_iterator i =
m_AttributeKeyMap.find(name);
if (i != m_AttributeKeyMap.end())
{
// Found it, so return a pointer to the value.
return i->second->m_Value.begin();
}
else
{
return 0;
}
}
void
AttributeListImpl::clear()
{
// Delete all of the objects in the vector.
std::for_each(m_AttributeVector.begin(),
m_AttributeVector.end(),
DeleteFunctor<AttributeVectorEntry>());
// Clear everything out.
m_AttributeVector.clear();
m_AttributeKeyMap.clear();
}
bool
AttributeListImpl::addAttribute(
const XMLCh* const name,
const XMLCh* const type,
const XMLCh* const value)
{
assert(name != 0);
assert(type != 0);
assert(value != 0);
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
bool fResult = false;
// Don't add it if it's already there.
if (m_AttributeKeyMap.find(name) == m_AttributeKeyMap.end())
{
AttributeVectorEntry* const theEntry =
new
AttributeVectorEntry(MakeXMLChVector(name),
MakeXMLChVector(value),
MakeXMLChVector(type));
// Add the new one.
m_AttributeVector.push_back(theEntry);
// Create an entry in the index map.
m_AttributeKeyMap.insert(std::make_pair(theEntry->m_Name.begin(), theEntry));
fResult = true;
}
assert(m_AttributeKeyMap.find(name) != m_AttributeKeyMap.end());
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
return fResult;
}
bool
AttributeListImpl::removeAttribute(const XMLCh* const name)
{
assert(name != 0);
assert(m_AttributeKeyMap.size() == m_AttributeVector.size());
using std::find_if;
using std::equal_to;
using std::bind1st;
bool fResult = false;
// Find it in the key map.
AttributeKeyMapType::iterator i =
m_AttributeKeyMap.find(name);
if (i != m_AttributeKeyMap.end())
{
// Found it, so now find the entry in the
// vector.
AttributeVectorType::iterator j =
find_if(m_AttributeVector.begin(),
m_AttributeVector.end(),
bind1st(equal_to<const
AttributeVectorEntry*>(), (*i).second));
assert(j != m_AttributeVector.end());
// Erase it from the vector.
m_AttributeVector.erase(j);
assert(m_AttributeVector.size() ==
m_AttributeKeyMap.size() - 1);
// Erase it from the key map.
m_AttributeKeyMap.erase(i);
assert(m_AttributeVector.size() ==
m_AttributeKeyMap.size());
fResult = true;
}
return fResult;
}
1.1 xml-xalan/c/src/PlatformSupport/AttributeListImpl.hpp
Index: AttributeListImpl.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(ATTRIBUTELISTIMPL_HEADER_GUARD_1357924680)
#define ATTRIBUTELISTIMPL_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <map>
#include <vector>
#include <sax/AttributeList.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/STLHelper.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT AttributeListImpl : public AttributeList
{
public:
explicit
AttributeListImpl();
virtual
~AttributeListImpl();
AttributeListImpl(const AttributeListImpl& theSource);
AttributeListImpl(const AttributeList& theSource);
AttributeListImpl&
operator=(const AttributeListImpl& theRHS);
AttributeListImpl&
operator=(const AttributeList& theRHS);
// These are inherited from AttributeList
virtual unsigned int
getLength() const;
virtual const XMLCh*
getName(const unsigned int index) const;
virtual const XMLCh*
getType(const unsigned int index) const;
virtual const XMLCh*
getValue(const unsigned int index) const;
virtual const XMLCh*
getType(const XMLCh* const name) const;
virtual const XMLCh*
getValue(const XMLCh* const name) const;
virtual const XMLCh*
getValue(const char* const name) const;
// The mutators are new to this class.
virtual void
clear();
virtual bool
addAttribute(const XMLCh* const name,
const XMLCh* const type,
const XMLCh* const value);
virtual bool
removeAttribute(const XMLCh* const name);
protected:
// This is not implemented.
bool
operator==(const AttributeListImpl&) const;
// A struct to hold information about each attribute.
struct AttributeVectorEntry
{
AttributeVectorEntry(const XMLCharVectorType& theName =
XMLCharVectorType(),
const
XMLCharVectorType& theValue = XMLCharVectorType(),
const
XMLCharVectorType& theType = XMLCharVectorType()) :
m_Name(theName),
m_Value(theValue),
m_Type(theType)
{
}
const XMLCharVectorType m_Name;
const XMLCharVectorType m_Value;
const XMLCharVectorType m_Type;
};
// This vector will hold the entries.
typedef std::vector<const AttributeVectorEntry*>
AttributeVectorType;
// This map will associate a name with a pointer to the entry that
corresponds
// to that name.
typedef std::map<const XMLCh*,
const AttributeVectorEntry*,
less_null_terminated_arrays<XMLCh> >
AttributeKeyMapType;
AttributeKeyMapType m_AttributeKeyMap;
AttributeVectorType m_AttributeVector;
};
#endif // ATTRIBUTELISTIMPL_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/Cloneable.cpp
Index: Cloneable.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "Cloneable.hpp"
Cloneable::Cloneable()
{
}
Cloneable::~Cloneable()
{
}
1.1 xml-xalan/c/src/PlatformSupport/Cloneable.hpp
Index: Cloneable.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(CLONEABLE_HEADER_GUARD_1357924680)
#define CLONEABLE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT Cloneable
{
public:
Cloneable();
virtual
~Cloneable();
/**
* Clone the instance.
*/
virtual Cloneable*
clone(bool deep) const = 0;
};
#endif // CLONEABLE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp
Index: DOMStringHelper.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DOMStringHelper.hpp"
#include <util/XMLString.hpp>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <iosfwd>
#include <sstream>
#include <vector>
// Xerces header files
#include <util/TextOutputStream.hpp>
#include "DoubleSupport.hpp"
// Simulates the java String method indexOf(). Returns the index of theChar
// in theString, or -1 if the character is not found.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
indexOf(const DOMString& theString,
XMLCh theChar)
{
const int theLength = length(theString);
if (theLength == 0)
{
return -1;
}
else
{
int theIndex = 0;
while(theIndex < theLength &&
charAt(theString, theIndex) != theChar)
{
theIndex++;
}
return theIndex == theLength ? -1 : theIndex;
}
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
indexOf(const DOMString& theFirstString,
const DOMString& theSecondString)
{
const int theFirstStringLength = length(theFirstString);
const int theSecondStringLength = length(theSecondString);
// If the substring is longer than the string, then
// it's not a substring.
if (theFirstStringLength < theSecondStringLength)
{
return -1;
}
else
{
bool fMatch = false;
int theFirstStringIndex = 0;
// While we haven't matched, and we haven't finished with the
// first string, and the number of characters left in the first
// string is greater than the length of the second string, try
// to match the strings.
while(fMatch == false &&
theFirstStringIndex < theFirstStringLength &&
theFirstStringLength - theFirstStringIndex >=
theSecondStringLength)
{
// We always start over from the beginning of the
second string.
int theSecondStringIndex = 0;
// This variable will be incremented to index into the
first
// string. That way, we preserve the first string
index for
// when we have to restart the following loop with the
next
// position in the first string.
int theOffset = 0;
// Compare the characters in the two strings, at the
// current indices, until the characters don't match.
while(theFirstStringIndex < theFirstStringLength &&
theSecondStringIndex < theSecondStringLength
&&
charAt(theFirstString, theFirstStringIndex +
theOffset) ==
charAt(theSecondString,
theSecondStringIndex))
{
theOffset++;
theSecondStringIndex++;
}
// If we've reached the end of the second string,
// then we've found a match.
if (theSecondStringIndex == theSecondStringLength)
{
fMatch = true;
}
else
{
theFirstStringIndex++;
}
}
return fMatch == false ? -1 : theFirstStringIndex;
}
}
// Simulates the java String method lastIndexOf(). Returns the index of
theChar
// in theString, or -1 if the character is not found.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
lastIndexOf(const DOMString& theString, XMLCh theChar)
{
const int theLength = length(theString);
if (theLength == 0)
{
return -1;
}
else
{
int theIndex = theLength-1;
while(theIndex >=0 && charAt(theString, theIndex) != theChar)
{
theIndex--;
}
return theIndex == -1 ? -1 : theIndex;
}
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
startsWith(const DOMString& theDOMString,
const DOMString& theSubString)
{
bool fResult = false;
const int theStringLength = length(theDOMString);
assert(theStringLength >= 0);
const int theSubStringLength = length(theSubString);
assert(theSubStringLength >= 0);
// If either string is of length 0, or if the substring
// is longer, there's no point in continuing.
if (theStringLength >= theSubStringLength)
{
// Compare each character...
for (int i = 0;
i < theSubStringLength &&
charAt(theDOMString, i) ==
charAt(theSubString, i);
i++)
{
;
}
// If we've gotten to the end of the substring, then
// return true.
if (i == theSubStringLength)
{
fResult = true;
}
}
return fResult;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
endsWith(
const DOMString& theDOMString,
const DOMString& theSubString)
{
bool fResult = false;
const int theStringLength = length(theDOMString);
assert(theStringLength >= 0);
const int theSubStringLength = length(theSubString);
assert(theSubStringLength >= 0);
// If either string is of length 0, or if the substring
// is longer, there's no point in continuing.
if (theStringLength >= theSubStringLength)
{
int i = theStringLength - 1;
// Compare each character...
for (int j = theSubStringLength - 1;
j >= 0 &&
charAt(theDOMString, i) ==
charAt(theSubString, j);
--j, --i)
{
;
}
// If we've gotten to the beginning of the substring, then
// return true.
if (j == -1)
{
fResult = true;
}
}
return fResult;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
OutputString(TextOutputStream& theStream,
const DOMString& theString)
{
theStream << c_wstr(theString);
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
toLowerCase(const DOMString& theString)
{
const int theStringLength = length(theString);
assert(theStringLength >= 0);
if (theStringLength == 0)
{
return theString;
}
else
{
DOMString theLowerCaseString(theString.clone());
XMLCh* const theBuffer = theLowerCaseString.rawBuffer();
assert(theBuffer != 0);
for(int i = 0; i < theStringLength; i++)
{
theBuffer[i] = towlower(theBuffer[i]);
}
return theLowerCaseString;
}
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
toUpperCase(const DOMString& theString)
{
const int theStringLength = length(theString);
assert(theStringLength >= 0);
if (theStringLength == 0)
{
return theString;
}
else
{
DOMString theLowerCaseString(theString.clone());
XMLCh* const theBuffer = theLowerCaseString.rawBuffer();
assert(theBuffer != 0);
for(int i = 0; i < theStringLength; i++)
{
theBuffer[i] = towupper(theBuffer[i]);
}
return theLowerCaseString;
}
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
equals(const XMLCh* theLHS,
const XMLCh* theRHS)
{
assert(theLHS != 0 && theRHS != 0);
while(*theLHS != 0 && *theRHS != 0 && *theLHS == *theRHS)
{
theLHS++;
theRHS++;
}
return *theLHS == *theRHS ? true : false;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
equalsIgnoreCase(const DOMString& theLHS,
const DOMString& theRHS)
{
bool fResult = false;
const int theLength = length(theLHS);
// If they are equal, then compare
if (theLength == length(theRHS))
{
// Check each character, converting to uppercase
// for the test.
for(int i = 0; i < theLength; i++)
{
if (towupper(charAt(theLHS, i)) !=
towupper(charAt(theRHS, i)))
{
break;
}
}
// Did we reach the end of the string?
if (i == theLength)
{
fResult = true;
}
}
return fResult;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
compare(
const DOMString& theLHS,
const DOMString& theRHS)
{
const int theLHSLength = theLHS.length();
const int theRHSLength = theRHS.length();
int theResult = 0;
XMLCh theLHSChar = 0;
XMLCh theRHSChar = 0;
if (theLHSLength == 0 && theRHSLength == 0) return 0;
for(int i = 0; i < theLHSLength && i < theRHSLength; i++)
{
theLHSChar = charAt(theLHS, i);
theRHSChar = charAt(theRHS, i);
if (theLHSChar != theRHSChar)
{
break;
}
}
if (i == theLHSLength)
{
// We reached the end of theLHS...
if (i != theRHSLength)
{
// but not the end of theRHS.
theResult = -1;
}
}
else if (i == theRHSLength)
{
// We reached the end of theRHS string...
if (i != theLHSLength)
{
// but not the end of theLHS string.
theResult = 1;
}
}
else
{
// We didn't reach the end of _either_ string, so
// return the difference between the two characters
// that caused the problem.
theResult = theLHSChar - theRHSChar;
}
return theResult;
}
namespace
{
void
CopyDOMStringToVector(const DOMString& theString,
std::vector<char>& theVector)
{
using std::vector;
const int theLength = length(theString);
if (theLength != 0)
{
theVector.reserve(theLength + 1);
for(int i = 0; i < theLength; i++)
{
// Assert that the truncation will not affect the
resulting character.
assert(charAt(theString, i) ==
static_cast<char>(charAt(theString, i)));
theVector.push_back(static_cast<char>(charAt(theString,
i)));
}
assert(theVector.size() ==
static_cast<std::vector<char>::size_type >(theLength));
// Put a terminating 0 byte.
theVector.push_back(0);
}
}
};
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
DOMStringToInt(const DOMString& theString)
{
using std::vector;
int theResult = 0;
vector<char> theVector;
CopyDOMStringToVector(theString,
theVector);
if (theVector.size() > 0)
{
theResult = atoi(theVector.begin());
}
return theResult;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long)
DOMStringToLong(const DOMString& theString)
{
using std::vector;
long theResult = 0;
vector<char> theVector;
CopyDOMStringToVector(theString,
theVector);
if (theVector.size() > 0)
{
theResult = atol(theVector.begin());
}
return theResult;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double)
DOMStringToDouble(const DOMString& theString)
{
using std::vector;
double theResult = DoubleSupport::getNaN();
if (length(theString) > 0)
{
vector<char> theVector;
CopyDOMStringToVector(theString,
theVector);
if (theVector.size() > 0)
{
// $$$ ToDo: We really need better validation here.
And better
// localization as well.
bool fError = false;
std::vector<char>::const_iterator i =
theVector.begin();
std::vector<char>::const_iterator j =
theVector.end();
j--;
do
{
if ((*i < '0' || *i > '9') && !(*i == '.' || *i
== 'e' || *i == 'E' || *i == 'f' || *i == 'F' || *i == '-'))
{
fError = true;
}
else
{
i++;
}
}
while(i != j && fError == false);
if (fError == false)
{
theResult = atof(theVector.begin());
}
}
}
return theResult;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
trim(const DOMString& theString)
{
if (isEmpty(theString))
return theString;
const int strLen = theString.length();
// index of first non-whitespace character
int leadingSpace = 0;
for (leadingSpace=0; leadingSpace<strLen; leadingSpace++)
if (!isSpace(theString.charAt(leadingSpace)))
break;
// index of last non-whitespace character
int trailingSpace = 0;
for (trailingSpace=strLen-1; trailingSpace>=0; trailingSpace--)
if (!isSpace(theString.charAt(trailingSpace)))
break;
return substring(theString,leadingSpace,trailingSpace+1);
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
DoubleToDOMString(double theDouble)
{
if (DoubleSupport::isNaN(theDouble) == true)
{
return "NaN";
}
else if (DoubleSupport::isPositiveInfinity(theDouble) == true)
{
return "Infinity";
}
else if (DoubleSupport::isNegativeInfinity(theDouble) == true)
{
return "-Infinity";
}
else
{
using namespace std;
stringstream theFormatter;
// $$$ ToDo: this is all temporary, until we get the
NumberFormat and DecimalFormat
// classes working.
// According to the XPath standard, any values without
// a fractional part are printed as integers.
double intPart = 0;
double fracPart = fabs(modf(theDouble, &intPart));
string theResult;
if (fracPart == 0)
{
theFormatter << static_cast<long>(theDouble);
theResult = theFormatter.str().c_str();
}
else
{
theFormatter << theDouble;
// OK, now we have to clean up the output for
// the XPath standard, which says no trailing
// '0's for the decimal portion. So start with
// the last digit, and replace any '0's with the
// null character. We know at this point that
// we have at least 1 digit before the decimal
// point, and and least 1 non-zero digit after
// the decimal point, since any values with no
// fractional part were printed as integers
theResult = theFormatter.str().c_str();
string::iterator thePosition = theResult.end();
while(*--thePosition == '0')
{
}
theResult.erase(++thePosition);
}
return theResult.c_str();
}
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
LongToHexDOMString(long theLong)
{
using namespace std;
stringstream theFormatter;
theFormatter << hex << theLong;
return theFormatter.str().c_str();;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
LongToDOMString(long theLong)
{
using namespace std;
stringstream theFormatter;
theFormatter << theLong;
return theFormatter.str().c_str();;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
UnsignedLongToDOMString(unsigned long theUnsignedLong)
{
using namespace std;
stringstream theFormatter;
theFormatter << theUnsignedLong;
return theFormatter.str().c_str();
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XMLCharVectorType)
MakeXMLChVector(const XMLCh* data)
{
assert(data != 0);
const XMLCh* theEnd = data;
// Find the terminating 0.
while(*theEnd)
{
theEnd++;
}
// Create a vector which includes the terminating 0.
return XMLCharVectorType(data, theEnd + 1);
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
isWhiteSpace(const DOMString& string)
{
for(int s = 0; s < string.length(); s++)
{
if (!isSpace(charAt(string, s)))
return false;
}
return true;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
isWhiteSpace(const XMLCh* const ch, int start, int length)
{
int end = start+length;
for(int s = start; s < end; s++)
{
if (!isSpace(ch[s]))
return false;
}
return true;
}
1.1 xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp
Index: DOMStringHelper.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMSTRINGHELPER_HEADER_GUARD_1357924680)
#define DOMSTRINGHELPER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <functional>
#include <vector>
#include <dom/DOMString.hpp>
#include <util/XMLString.hpp>
class TextOutputStream;
// Simulates the java String method indexOf(). Returns the index of theChar
// in theString, or -1 if the character is not found.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
indexOf(
const DOMString& theString,
XMLCh theChar);
// Simulates the java String method indexOf(). Returns the index of
theSubString
// in theString, or -1 if the string is not found.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
indexOf(
const DOMString& theString,
const DOMString& theSubString);
// Simulates the java String method lastIndexOf(). Returns the index of
theChar
// in theString, or -1 if the character is not found.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
lastIndexOf(
const DOMString& theString,
XMLCh theChar);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
startsWith(
const DOMString& theDOMString,
const DOMString& theSubString);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
endsWith(
const DOMString& theDOMString,
const DOMString& theSubString);
inline int
length(const DOMString& theString)
{
return theString.length();
}
inline int
length(const XMLCh* theBuffer)
{
assert(theBuffer != 0);
const XMLCh* theBufferPointer = theBuffer;
while(*theBufferPointer != 0)
{
theBufferPointer++;
}
return theBufferPointer - theBuffer;
}
inline bool
isEmpty(const DOMString& str)
{
assert( (length(str)>0 && str!=0) || (length(str)==0 && str==0) );
return length(str) == 0;
}
inline bool
startsWith(
const DOMString& theDOMString,
const char* theSubString)
{
return startsWith(theDOMString,
DOMString(theSubString));
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
OutputString(
TextOutputStream& theStream,
const DOMString& theString);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
DoubleToDOMString(double theDouble);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
LongToHexDOMString(long theInt);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
LongToDOMString(long theInt);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
UnsignedLongToDOMString(unsigned long theInt);
inline TextOutputStream&
operator<<(
TextOutputStream& theStream,
const DOMString& theString)
{
OutputString(theStream,
theString);
return theStream;
}
inline DOMString
clone(const DOMString& theString)
{
return theString.clone();
}
inline DOMString
operator+(
const DOMString& theLHS,
const DOMString& theRHS)
{
return DOMString(theLHS) + theRHS;
}
inline DOMString&
operator+=(
DOMString& theLHS,
const DOMString& theRHS)
{
theLHS.appendData(theRHS);
return theLHS;
}
inline DOMString&
operator+=(
DOMString& theLHS,
XMLCh theRHS)
{
theLHS += DOMString(&theRHS, 1);
return theLHS;
}
inline bool
isSpace(XMLCh theChar)
{
return iswspace(theChar) ? true : false;
}
inline XMLCh
charAt(
const DOMString& theString,
int theIndex)
{
return theString.charAt(theIndex);
}
inline bool
isDigit(XMLCh theChar)
{
return iswdigit(theChar) ? true : false;
}
inline bool
isLetterOrDigit(XMLCh theChar)
{
return iswalnum(theChar) ? true : false;
}
inline DOMString
substring(
const DOMString& theString,
int theStartIndex,
int theEndIndex =
-1)
{
const int theStringLength = length(theString);
// $$$ ToDo: In Java-land, any failing of these
// assertions would result in an exception being thrown.
assert(theStartIndex <= theStringLength && theStartIndex >= 0);
if (theStartIndex == theStringLength)
{
// This is allowed, and should return an empty string.
return DOMString();
}
else
{
const int theLength = theEndIndex == -1 ? theStringLength
- theStartIndex :
theEndIndex - theStartIndex;
assert(theStartIndex + theLength <= theStringLength);
return theString.substringData(theStartIndex, theLength);
}
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
toLowerCase(const DOMString& theString);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
toUpperCase(const DOMString& theString);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
DOMStringToInt(const DOMString& theString);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long)
DOMStringToLong(const DOMString& theString);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double)
DOMStringToDouble(const DOMString& theString);
// These two function are specifically not defined, and
// should produce ambiguity during compilation. This
// is necessary because the Xerces DOMString class
// defines == as referring to the same underlying
// handle, not identical strings, as in Java.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
operator==(
const DOMString& theLHS,
const DOMString& theRHS);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
operator!=(
const DOMString& theLHS,
const DOMString& theRHS);
// Get the underlying representation of the wide string.
// returns a null-terminated string
inline const XMLCh*
c_wstr(const DOMString& theString)
{
XMLCh *ptr = theString.rawBuffer();
assert(!ptr || ptr[theString.length()] == '\0');
return ptr;
}
// not guaranteed to be null-terminated
inline const XMLCh*
toCharArray(const DOMString& theString)
{
return theString.rawBuffer();
}
inline XMLCh*
toCharArray(DOMString& theString)
{
return theString.rawBuffer();
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
equals(const XMLCh* theLHS,
const XMLCh* theRHS);
inline bool
equals(const XMLCh* theLHS,
const DOMString& theRHS)
{
return equals(theLHS, c_wstr(theRHS));
}
inline bool
equals(const DOMString& theLHS,
const XMLCh* theRHS)
{
return equals(c_wstr(theLHS), theRHS);
}
inline bool
equals(const DOMString& theLHS,
const char* theRHS)
{
return theLHS.equals(theRHS) ? true : false;
}
inline bool
equals(
const DOMString& theLHS,
const DOMString& theRHS)
{
return theLHS.equals(theRHS) ? true : false;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
equalsIgnoreCase(
const DOMString& theLHS,
const DOMString& theRHS);
// Returns 0 for equal strings, less than 0 if theLHS
// is less than theRHS, or greater than 0 if theRHS
// is greater than theLHS.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
compare(
const DOMString& theLHS,
const DOMString& theRHS);
inline bool
operator<(
const DOMString& theLHS,
const DOMString& theRHS)
{
return compare(theLHS, theRHS) < 0 ? true : false;
}
inline DOMString&
append(
DOMString& theString,
const DOMString& theStringToAppend)
{
theString.appendData(theStringToAppend);
return theString;
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
trim(const DOMString& theString);
inline void
clear(
DOMString& theString,
int theOffset = 0,
int theLength = -1)
{
assert(theOffset >= 0);
assert(theLength == -1 ||
theLength <= length(theString) - theOffset);
theString.deleteData(theOffset, theLength >= 0 ?
theLength :
length(theString) - theOffset);
}
inline void
setCharAt(
DOMString& theString,
int theIndex,
XMLCh theChar)
{
assert(theIndex < length(theString));
XMLCh* const theBuffer = toCharArray(theString);
theBuffer[theIndex] = theChar;
}
// A standard vector of XMLChs
typedef std::vector<XMLCh> XMLCharVectorType;
// Utility function to make a 0-terminated vector of XMLChs, from
// a 0-terminated array of them.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XMLCharVectorType)
MakeXMLChVector(const XMLCh* data);
// An inline version for DOMStrings....
inline XMLCharVectorType
MakeXMLChVector(const DOMString& data)
{
return MakeXMLChVector(c_wstr(data));
}
struct c_wstr_functor : public std::unary_function<DOMString, const XMLCh*>
{
result_type
operator() (const argument_type& theString) const
{
return c_wstr(theString);
}
};
// Hash functor for DOMStrings
struct DOMStringHashFunction : public std::unary_function<const DOMString&,
size_t>
{
result_type
operator() (argument_type theKey) const
{
const XMLCh* theRawBuffer = c_wstr(theKey);
unsigned long theHashValue = 0L;
if (theRawBuffer != 0)
{
while (*theRawBuffer)
{
theHashValue = 5 * theHashValue + *theRawBuffer;
theRawBuffer++;
}
}
return static_cast<result_type>(theHashValue++);
}
};
// Equals functor for DOMStrings
struct DOMStringEqualsFunction : public std::binary_function<const
DOMString&, const DOMString&, bool>
{
result_type
operator() (first_argument_type theLHS,
second_argument_type theRHS) const
{
return theLHS.equals(theRHS);
}
};
// not really safe in DBCS environments
inline std::string DOMStringToStdString(const DOMString& domString)
{
std::string ret;
for (int i=0; i< domString.length(); i++)
{
ret += (char)domString.charAt(i);
}
return ret;
}
// safe, but not very efficient
inline std::wstring DOMStringToStdWString(const DOMString& domString)
{
return (c_wstr(domString));
}
//Is the string just whitespace?
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
isWhiteSpace(const DOMString& string);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
isWhiteSpace(const XMLCh* const ch, int start, int length);
#endif // DOMSTRINGHELPER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.cpp
Index: DOMStringPrintWriter.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DOMStringPrintWriter.hpp"
#include <vector>
#include <util/TextOutputStream.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
DOMStringPrintWriter::DOMStringPrintWriter(const DOMString& theBaseString) :
PrintWriter(true),
m_outputString(theBaseString)
{
}
DOMStringPrintWriter::~DOMStringPrintWriter()
{
}
bool
DOMStringPrintWriter::checkError() const
{
return false;
}
void
DOMStringPrintWriter::close()
{
}
void
DOMStringPrintWriter::flush()
{
}
void
DOMStringPrintWriter::write(
const char* s,
long theOffset,
long theLength)
{
write(DOMString(s), theOffset, theLength);
}
void
DOMStringPrintWriter::write(
const XMLCh* s,
long theOffset,
long theLength)
{
using std::vector;
using std::copy;
assert(s != 0);
assert(theOffset >= 0);
assert(theLength >= 0);
if (theLength == -1)
{
m_outputString += (s + theOffset);
}
else
{
vector<XMLCh> theBuffer(theLength + 1);
// We'll copy the characters into the vector first.
copy(s + theOffset,
s + theOffset + theLength,
theBuffer.begin());
// Now append a terminated 0.
theBuffer.back() = 0;
// Now append the data.
m_outputString += theBuffer.begin();
}
}
void
DOMStringPrintWriter::write(XMLCh c)
{
m_outputString += c;
}
void
DOMStringPrintWriter::write(
const DOMString& s,
long theOffset,
long theLength)
{
assert(s != 0);
assert(theOffset >= 0);
assert(theLength >= 0 || theLength == -1);
assert(length(s) >= theOffset + theLength);
if (theOffset == 0 && theLength == -1)
{
m_outputString += s;
}
else
{
m_outputString += substring(s, theOffset, theOffset +
theLength);
}
}
void
DOMStringPrintWriter::print(bool b)
{
if (b == true)
{
print(DOMString("true"));
}
else
{
print(DOMString("false"));
}
}
void
DOMStringPrintWriter::print(char c)
{
write(c);
}
void
DOMStringPrintWriter::print(
const char* s,
long theLength)
{
write(s,
0,
theLength);
}
void
DOMStringPrintWriter::print(
const XMLCh* s,
long theLength)
{
write(s,
0,
theLength);
}
void
DOMStringPrintWriter::print(double d)
{
m_outputString += DoubleToDOMString(d);
}
void
DOMStringPrintWriter::print(int i)
{
m_outputString += LongToDOMString(i);
}
void
DOMStringPrintWriter::print(long l)
{
m_outputString += LongToDOMString(l);
}
void
DOMStringPrintWriter::print(const DOMString& s)
{
m_outputString += s;
}
void
DOMStringPrintWriter::println()
{
m_outputString += "\n";
}
void
DOMStringPrintWriter::println(bool b)
{
print(b);
println();
}
void
DOMStringPrintWriter::println(char c)
{
print(c);
println();
}
void
DOMStringPrintWriter::println(
const char* s,
long theLength)
{
print(s, theLength);
println();
}
void
DOMStringPrintWriter::println(
const XMLCh* s,
long theLength)
{
print(s, theLength);
println();
}
void
DOMStringPrintWriter::println(double d)
{
print(d);
println();
}
void
DOMStringPrintWriter::println(int i)
{
print(i);
println();
}
void
DOMStringPrintWriter::println(long l)
{
print(l);
println();
}
void
DOMStringPrintWriter::println(const DOMString& s)
{
print(s);
println();
}
1.1 xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.hpp
Index: DOMStringPrintWriter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOMSTRING_PRINTWRITER_HEADER_GUARD_1357924680)
#define DOMSTRING_PRINTWRITER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <PlatformSupport/PrintWriter.hpp>
#include <dom/DOMString.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT DOMStringPrintWriter : public PrintWriter
{
public:
// If a string is passed in, a copy will be made, and all
// output will be appended to that string.
explicit
DOMStringPrintWriter(const DOMString& theBaseString = DOMString());
virtual
~DOMStringPrintWriter();
const DOMString&
getString() const
{
return m_outputString;
}
// Flush the stream, then check the error status.
virtual bool
checkError() const;
virtual void
close();
virtual void
flush();
// Output functions
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const char* s,
long theOffset = 0,
long theLength = -1);
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const XMLCh* s,
long theOffset = 0,
long theLength = -1);
virtual void
write(XMLCh c);
// If the length is -1, then the entire string is printed.
virtual void
write(const DOMString& s,
long theOffset = 0,
long theLength = -1);
virtual void
print(bool b);
virtual void
print(char c);
virtual void
print(const char* s,
long theLength = -1);
virtual void
print(const XMLCh* s,
long theLength = -1);
virtual void
print(double d);
virtual void
print(int i);
virtual void
print(long l);
virtual void
print(const DOMString& s);
virtual void
println();
virtual void
println(bool b);
virtual void
println(char c);
virtual void
println(const char* s,
long theLength = -1);
virtual void
println(const XMLCh* s,
long theLength = -1);
virtual void
println(double d);
virtual void
println(int i);
virtual void
println(long l);
virtual void
println(const DOMString& s);
protected:
DOMString m_outputString;
private:
// Not implemented
DOMStringPrintWriter(const DOMStringPrintWriter&);
DOMStringPrintWriter&
operator=(const DOMStringPrintWriter&);
bool
operator==(const DOMStringPrintWriter&);
};
#endif // DOMSTRING_PRINTWRITER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/DecimalFormat.cpp
Index: DecimalFormat.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DecimalFormat.hpp"
#include "DOMStringHelper.hpp"
const DOMString DecimalFormat::s_defaultPatternString;
DecimalFormat::DecimalFormat(
const DOMString&
thePatternString,
const DecimalFormatSymbols& theSymbols) :
NumberFormat(),
m_patternString(length(thePatternString) == 0 ? s_defaultPatternString
: thePatternString),
m_decimalFormatSymbols(theSymbols)
{
}
DecimalFormat::~DecimalFormat()
{
}
DOMString
DecimalFormat::format(double theValue)
{
// $$$ ToDo: Fix this!!!
return NumberFormat::format(theValue);
}
DOMString
DecimalFormat::format(int theValue)
{
// $$$ ToDo: Fix this!!!
return NumberFormat::format(theValue);
}
DOMString
DecimalFormat::format(unsigned int theValue)
{
// $$$ ToDo: Fix this!!!
return NumberFormat::format(theValue);
}
DOMString
DecimalFormat::format(long theValue)
{
// $$$ ToDo: Fix this!!!
return NumberFormat::format(theValue);
}
DOMString
DecimalFormat::format(unsigned long theValue)
{
// $$$ ToDo: Fix this!!!
return NumberFormat::format(theValue);
}
DOMString
DecimalFormat::getNormalizedPattern(const DOMString& thePattern)
{
// A pattern may not have an explicit specification for
// negative numbers. If there is no pattern separator,
// and therefore no explicit specification for negative
// numbers, then assume that the pattern for negative
// numbers is the same as that for positive numbers.
const XMLCh thePatternSeparatorChar =
m_decimalFormatSymbols.getPatternSeparator();
// Is the a separator?
const int theSeparatorIndex =
indexOf(thePattern, thePatternSeparatorChar);
if (theSeparatorIndex != -1)
{
// There is, so the pattern is already normalized.
return thePattern;
}
else
{
// There isn't, so
DOMString theNewPattern(thePattern);
theNewPattern += thePatternSeparatorChar;
theNewPattern += m_decimalFormatSymbols.getMinusSign();
theNewPattern += thePattern;
return theNewPattern;
}
}
1.1 xml-xalan/c/src/PlatformSupport/DecimalFormat.hpp
Index: DecimalFormat.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DECIMALFORMAT_HEADER_GUARD_1357924680)
#define DECIMALFORMAT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
// Base class header file.
#include <PlatformSupport/DecimalFormatSymbols.hpp>
#include <PlatformSupport/NumberFormat.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT DecimalFormat : public NumberFormat
{
public:
explicit
DecimalFormat(
const DOMString&
thePatternString = DOMString(),
const DecimalFormatSymbols& theSymbols =
DecimalFormatSymbols());
virtual
~DecimalFormat();
// From NumberFormat...
virtual DOMString
format(double theValue);
virtual DOMString
format(int theValue);
virtual DOMString
format(unsigned int theValue);
virtual DOMString
format(long theValue);
virtual DOMString
format(unsigned long theValue);
// New for DecimalFormat...
const DecimalFormatSymbols&
getDecimalFormatSymbols() const
{
return m_decimalFormatSymbols;
}
void
setDecimalFormatSymbols(const DecimalFormatSymbols&
theDecimalFormatSymbols)
{
m_decimalFormatSymbols = theDecimalFormatSymbols;
}
protected:
DOMString
getNormalizedPattern(const DOMString& thePattern);
private:
// Not implemented
DecimalFormat(const DecimalFormat&);
DecimalFormat&
operator=(const DecimalFormat&);
bool
operator==(const DecimalFormat&);
// Data members...
DOMString m_patternString;
DecimalFormatSymbols m_decimalFormatSymbols;
static const DOMString s_defaultPatternString;
};
#endif // DECIMALFORMAT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/DecimalFormatSymbols.cpp
Index: DecimalFormatSymbols.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DecimalFormat.hpp"
#include "DOMStringHelper.hpp"
namespace
{
XMLCh theNaNDefault[] = { 0xFFFD, 0 };
XMLCh theInfinityDefault[] = { 0x221E, 0 };
};
DecimalFormatSymbols::DecimalFormatSymbols(const std::locale& /* theLocale
*/) :
m_currencySymbol("$"),
m_decimalSeparator('.'),
m_digit(0),
m_groupingSeparator(','),
m_infinity(theInfinityDefault),
m_internationalCurrencySymbol(""),
m_minusSign('-'),
m_monetaryDecimalSeparator('.'),
m_NaN(theNaNDefault),
m_patternSeparator(';'),
m_percent('%'),
m_perMill(0),
m_zeroDigit('0')
{
}
DecimalFormatSymbols::DecimalFormatSymbols(const DecimalFormatSymbols&
theSource) :
m_currencySymbol(theSource.m_currencySymbol),
m_decimalSeparator(theSource.m_decimalSeparator),
m_digit(theSource.m_digit),
m_groupingSeparator(theSource.m_groupingSeparator),
m_infinity(theSource.m_infinity),
m_internationalCurrencySymbol(theSource.m_internationalCurrencySymbol),
m_minusSign(theSource.m_minusSign),
m_monetaryDecimalSeparator(theSource.m_monetaryDecimalSeparator),
m_NaN(theSource.m_NaN),
m_patternSeparator(theSource.m_patternSeparator),
m_percent(theSource.m_percent),
m_perMill(theSource.m_perMill),
m_zeroDigit(theSource.m_zeroDigit)
{
}
DecimalFormatSymbols::~DecimalFormatSymbols()
{
}
DecimalFormatSymbols&
DecimalFormatSymbols::operator=(const DecimalFormatSymbols& theRHS)
{
if (&theRHS != this)
{
m_currencySymbol = theRHS.m_currencySymbol;
m_decimalSeparator = theRHS.m_decimalSeparator;
m_digit = theRHS.m_digit;
m_groupingSeparator = theRHS.m_groupingSeparator;
m_infinity = theRHS.m_infinity;
m_internationalCurrencySymbol =
theRHS.m_internationalCurrencySymbol;
m_minusSign = theRHS.m_minusSign;
m_monetaryDecimalSeparator = theRHS.m_monetaryDecimalSeparator;
m_NaN = theRHS.m_NaN;
m_patternSeparator = theRHS.m_patternSeparator;
m_percent = theRHS.m_percent;
m_perMill = theRHS.m_perMill;
m_zeroDigit = theRHS.m_zeroDigit;
}
return *this;
}
1.1 xml-xalan/c/src/PlatformSupport/DecimalFormatSymbols.hpp
Index: DecimalFormatSymbols.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DECIMALFORMATSYMBOLS_HEADER_GUARD_1357924680)
#define DECIMALFORMATSYMBOLS_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <locale>
#include <dom/DOMString.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT DecimalFormatSymbols
{
public:
explicit
DecimalFormatSymbols(const std::locale& theLocale = std::locale());
DecimalFormatSymbols(const DecimalFormatSymbols& theSource);
~DecimalFormatSymbols();
DecimalFormatSymbols&
operator=(const DecimalFormatSymbols& theRHS);
DOMString
getCurrencySymbol() const
{
return m_currencySymbol;
}
XMLCh
getDecimalSeparator() const
{
return m_decimalSeparator;
}
XMLCh
getDigit() const
{
return m_digit;
}
XMLCh
getGroupingSeparator() const
{
return m_groupingSeparator;
}
DOMString
getInfinity() const
{
return m_infinity;
}
DOMString
getInternationalCurrencySymbol() const
{
return m_internationalCurrencySymbol;
}
XMLCh
getMinusSign() const
{
return m_minusSign;
}
XMLCh
getMonetaryDecimalSeparator() const
{
return m_monetaryDecimalSeparator;
}
DOMString
getNaN() const
{
return m_NaN;
}
XMLCh
getPatternSeparator() const
{
return m_patternSeparator;
}
XMLCh
getPercent() const
{
return m_percent;
}
XMLCh
getPerMill() const
{
return m_perMill;
}
XMLCh
getZeroDigit() const
{
return m_zeroDigit;
}
void
setCurrencySymbol(const DOMString& theCurrencySymbol)
{
m_currencySymbol = theCurrencySymbol;
}
void
setDecimalSeparator(XMLCh theDecimalSeparator)
{
m_decimalSeparator = theDecimalSeparator;
}
void
setDigit(XMLCh theDigit)
{
m_digit = theDigit;
}
void
setGroupingSeparator(XMLCh theGoupingSeparator)
{
m_groupingSeparator = theGoupingSeparator;
}
void
setInfinity(const DOMString& theInfinity)
{
m_infinity = theInfinity;
}
void
setInternationalCurrencySymbol(const DOMString&
theInternationalCurrencySymbol)
{
m_internationalCurrencySymbol = theInternationalCurrencySymbol;
}
void
setMinusSign(XMLCh theMinusSign)
{
m_minusSign = theMinusSign;
}
void
setMonetaryDecimalSeparator(XMLCh theMonetaryDecimalSeparator)
{
m_monetaryDecimalSeparator = theMonetaryDecimalSeparator;
}
void
setNaN(const DOMString& theNaN)
{
m_NaN = theNaN;
}
void
setPatternSeparator(XMLCh thePatternSeparator)
{
m_patternSeparator = thePatternSeparator;
}
void
setPercent(XMLCh thePercent)
{
m_percent = thePercent;
}
void
setPerMill(XMLCh thePerMill)
{
m_perMill = thePerMill;
}
void
setZeroDigit(XMLCh theZeroDigit)
{
m_zeroDigit = theZeroDigit;
}
private:
// Not implemented
bool
operator==(const DecimalFormatSymbols&);
DOMString m_currencySymbol;
XMLCh m_decimalSeparator;
XMLCh m_digit;
XMLCh m_groupingSeparator;
DOMString m_infinity;
DOMString m_internationalCurrencySymbol;
XMLCh m_minusSign;
XMLCh m_monetaryDecimalSeparator;
DOMString m_NaN;
XMLCh m_patternSeparator;
XMLCh m_percent;
XMLCh m_perMill;
XMLCh m_zeroDigit;
};
#endif // DECIMALFORMATSYMBOLS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/DirectoryEnumerator.hpp
Index: DirectoryEnumerator.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680)
#define DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#if defined(_MSC_VER)
#include <io.h>
#else
#error Unsupport platform!!!
#endif
#include <functional>
#include <iterator>
#include <vector>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#if defined(_MSC_VER)
class FindFileStruct : public _wfinddata_t
{
public:
enum eAttributes
{
eAttributeArchive = _A_ARCH,
eAttributeDirectory = _A_SUBDIR,
eAttributeHidden = _A_HIDDEN,
eAttributeNormal = _A_NORMAL,
eReadOnly = _A_RDONLY,
eSystem = _A_SYSTEM
};
const XMLCh*
getName() const
{
return name;
}
bool
isArchive() const
{
return attrib & eAttributeArchive ? true : false;
}
bool
isDirectory() const
{
return attrib & eAttributeDirectory ? true : false;
}
bool
isHidden() const
{
return attrib & eAttributeHidden ? true : false;
}
bool
isNormal() const
{
return attrib == eAttributeNormal ? true : false;
}
bool
isReadOnly() const
{
return attrib & eReadOnly ? true : false;
}
bool
isSystem() const
{
return attrib & eSystem ? true : false;
}
};
#else
#error Unsupported platform!!!
#endif
struct ArchiveFileFilterPredicate : public
std::unary_function<FindFileStruct, bool>
{
result_type
operator()(const argument_type& theFindData) const
{
return theFindData.isArchive();
}
};
struct DirectoryFilterPredicate : public std::unary_function<FindFileStruct,
bool>
{
result_type
operator()(const argument_type& theFindData) const
{
return theFindData.isDirectory();
}
};
struct HiddenFileFilterPredicate : public std::unary_function<FindFileStruct,
bool>
{
result_type
operator()(const argument_type& theFindData) const
{
return theFindData.isHidden();
}
};
struct NormalFileFilterPredicate : public std::unary_function<FindFileStruct,
bool>
{
result_type
operator()(const argument_type& theFindData) const
{
return theFindData.isNormal();
}
};
struct ReadOnlyFileFilterPredicate : public
std::unary_function<FindFileStruct, bool>
{
result_type
operator()(const argument_type& theFindData) const
{
return theFindData.isReadOnly();
}
};
struct SystemFileFilterPredicate : public std::unary_function<FindFileStruct,
bool>
{
result_type
operator()(const argument_type& theFindData) const
{
return theFindData.isSystem();
}
};
struct FilesOnlyFilterPredicate : public std::unary_function<FindFileStruct,
bool>
{
result_type
operator()(const argument_type& theFindData) const
{
return !DirectoryFilterPredicate()(theFindData) &&
(ArchiveFileFilterPredicate()(theFindData) ||
NormalFileFilterPredicate()(theFindData) ||
ReadOnlyFileFilterPredicate()(theFindData));
}
// DirectoryFilterPredicate m_directoryPredicate;
// ArchiveFileFilterPredicate m_archivePredicate;
// NormalFileFilterPredicate m_normalPredicate;
// ReadOnlyFileFilterPredicate m_readOnlyPredicate;
};
template<class OutputIteratorType,
class FilterPredicateType,
class StringType,
class StringConversionFunction>
void
EnumerateDirectory(
const StringType& theDirectory,
OutputIteratorType
theOutputIterator,
FilterPredicateType
theFilterPredicate,
StringConversionFunction theConversionFunction)
{
#if defined(_MSC_VER)
StringType theSearchSpec(clone(theDirectory));
theSearchSpec += "\\*";
FindFileStruct theFindData;
long theSearchHandle =
_wfindfirst(const_cast<wchar_t*>(theConversionFunction(theSearchSpec)),
&theFindData);
if (theSearchHandle != -1)
{
try
{
do
{
if (theFilterPredicate(theFindData) == true)
{
*theOutputIterator =
theFindData.getName();
}
}
while(_wfindnext(theSearchHandle,
&theFindData) == 0);
}
catch(...)
{
_findclose(theSearchHandle);
throw;
}
_findclose(theSearchHandle);
}
#else
#error Unsupported platform!!!
#endif
}
template<class CollectionType,
class FilterPredicateType = FilesOnlyFilterPredicate,
class StringType = DOMString,
class StringConversionFunction = c_wstr_functor>
struct DirectoryEnumeratorFunctor : public std::unary_function<StringType,
CollectionType>
{
result_type
operator()(const argument_type& theDirectory) const
{
result_type theCollection;
operator()(theDirectory,
theCollection);
return theCollection;
}
void
operator()(const argument_type& theDirectory,
CollectionType& theCollection)
const
{
EnumerateDirectory(theDirectory,
std::back_inserter(theCollection),
m_filterPredicate,
m_conversionFunction);
}
private:
FilterPredicateType m_filterPredicate;
StringConversionFunction m_conversionFunction;
};
#endif // DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/DoubleSupport.cpp
Index: DoubleSupport.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DoubleSupport.hpp"
#include <limits>
#if defined(_MSC_VER)
const double DoubleSupport::s_NaN =
std::numeric_limits<double>::quiet_NaN();
const double DoubleSupport::s_positiveInfinity =
std::numeric_limits<double>::infinity();
const double DoubleSupport::s_negativeInfinity =
std::numeric_limits<double>::signaling_NaN();
#else
#error Unsupported platform!!!
#endif
#if defined(XALAN_NEED_SPECIAL_NAN_SUPPORT)
const unsigned long* DoubleSupport::s_NaNFirstDWORD =
reinterpret_cast<const unsigned
long*>(&s_NaN);
const unsigned long* DoubleSupport::s_NaNSecondDWORD =
s_NaNFirstDWORD + 1;
#endif
1.1 xml-xalan/c/src/PlatformSupport/DoubleSupport.hpp
Index: DoubleSupport.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(DOUBLESUPPORT_HEADER_GUARD_1357924680)
#define DOUBLESUPPORT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT DoubleSupport
{
public:
// Use these functions to determine if a value represents one of these
// values. It seems that under the IA32 architecture, NaN will compare
// as equal to any number, which is a big problem. Hence these helper
// functions.
static bool
isNaN(double theNumber)
{
#if !defined(XALAN_NEED_SPECIAL_NAN_SUPPORT)
return theNumber == s_NaN;
#else
// Compare the two DWORDs of the double as unsigned longs.
const unsigned long* const theFirstDWORD =
reinterpret_cast<const unsigned long*>(&theNumber);
const unsigned long* const theSecondDWORD =
theFirstDWORD + 1;
return *theFirstDWORD == *s_NaNFirstDWORD &&
*theSecondDWORD == *s_NaNSecondDWORD;
#endif
}
static bool
isPositiveInfinity(double theNumber)
{
#if !defined(XALAN_NEED_SPECIAL_NAN_SUPPORT)
return theNumber == s_positiveInfinity;
#else
return !isNaN(theNumber) && theNumber == s_positiveInfinity;
#endif
}
static bool
isNegativeInfinity(double theNumber)
{
#if !defined(XALAN_NEED_SPECIAL_NAN_SUPPORT)
return theNumber == s_negativeInfinity;
#else
return !isNaN(theNumber) && theNumber == s_negativeInfinity;
#endif
}
// These can be used to initialize values, but should not
// be used to do equality comparisons, as == may fail on
// some platforms.
//
static double
getNaN()
{
return s_NaN;
}
static double
getPositiveInfinity()
{
return s_positiveInfinity;
}
static double
getNegativeInfinity()
{
return s_negativeInfinity;
}
private:
static const double s_NaN;
static const double s_positiveInfinity;
static const double s_negativeInfinity;
#if defined(XALAN_NEED_SPECIAL_NAN_SUPPORT)
static const unsigned long* s_NaNFirstDWORD;
static const unsigned long* s_NaNSecondDWORD;
#endif
};
#endif // DOUBLESUPPORT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/Factory.cpp
Index: Factory.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "Factory.hpp"
#include "FactoryObject.hpp"
Factory::Factory() :
Resettable()
{
}
Factory::~Factory()
{
}
bool
Factory::deleteObject(const FactoryObject* theFactoryObject) const
{
delete theFactoryObject;
return true;
}
1.1 xml-xalan/c/src/PlatformSupport/Factory.hpp
Index: Factory.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FACTORY_HEADER_GUARD_1357924680)
#define FACTORY_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <cassert>
#include <functional>
#include <PlatformSupport/Resettable.hpp>
class FactoryObject;
class XALAN_PLATFORMSUPPORT_EXPORT Factory : public Resettable
{
public:
explicit
Factory();
virtual
~Factory();
// These interfaces are inherited from Resetable...
/**
* Reset the instance. This invalidates all existing FactoryObject
* instances created with this Factory.
*/
virtual void
reset() = 0;
// These interfaces are new...
/*
* Return an object to the factory.
*
*/
virtual bool
returnObject(const FactoryObject* theFactoryObject) = 0;
protected:
/**
* Delete a FactoryObject instance.
*/
virtual bool
deleteObject(const FactoryObject* theFactoryObject) const;
private:
// Not implemented...
Factory(const Factory&);
Factory&
operator=(const Factory&);
bool
operator==(const Factory&) const;
};
struct DeleteFactoryObjectFunctor : public std::unary_function<const
FactoryObject*, void>
{
public:
DeleteFactoryObjectFunctor(Factory& theFactoryInstance) :
m_factoryInstance(theFactoryInstance)
{
}
result_type
operator()(argument_type theFactoryObject) const
{
m_factoryInstance.returnObject(theFactoryObject);
}
private:
Factory& m_factoryInstance;
};
// auto_ptr-like class for FactoryObject instances (and it's derivatives).
template<class Type>
class FactoryObjectAutoPointer
{
public:
// Construct a FactoryObjectAutoPointer. Either both parameters should
// be valid or pointers or they should both be 0.
explicit
FactoryObjectAutoPointer(
Factory* theFactory = 0,
Type* theObject = 0) :
m_factory(theFactory),
m_object(theObject)
{
assert(theFactory != 0 && theObject != 0 ||
theFactory == 0 && theObject == 0);
}
// Note that copy construction is not const for the source object. Once
// copied, the source object will no longer refer to a valid object!
#if defined(XALAN_MEMBER_TEMPLATES)
template <class CompatibleType>
FactoryObjectAutoPointer(FactoryObjectAutoPointer<CompatibleType>&
theRHS)
#else
FactoryObjectAutoPointer(FactoryObjectAutoPointer<Type>& theRHS)
#endif
{
adopt(theRHS);
}
~FactoryObjectAutoPointer()
{
returnObject();
}
Type*
operator->() const
{
return m_object;
}
Type*
get() const
{
return m_object;
}
void
reset(Factory* theFactory = 0,
Type* theObject = 0)
{
assert(theFactory != 0 && theObject != 0 ||
theFactory == 0 && theObject == 0);
returnObject();
m_factory = theFactory;
m_object = theObject;
}
Type*
release()
{
Type* const theTemp = m_object;
m_object = 0;
m_factory = 0;
return theTemp;
}
bool
returnObject()
{
bool fReturn = false;
if (m_object != 0)
{
assert(m_factory != 0);
fReturn = m_factory->returnObject(m_object);
}
m_object = 0;
m_factory = 0;
return fReturn;
}
// Note that assignment is not const for the source object. Once
// copied, the source object will no longer refer to a valid object!
#if defined(XALAN_MEMBER_TEMPLATES)
template <class CompatibleType>
FactoryObjectAutoPointer&
operator=(FactoryObjectAutoPointer<CompatibleType& theRHS)
#else
FactoryObjectAutoPointer&
operator=(FactoryObjectAutoPointer<Type>& theRHS)
#endif
{
if (static_cast<void*>(this) != static_cast<void*>(&theRHS))
{
adopt(theRHS);
}
return *this;
}
#if defined(XALAN_MEMBER_TEMPLATES)
template <class CompatibleType>
bool
operator==(const FactoryObjectAutoPointer<CompatibleType&
theRHS) const
#else
bool
operator==(const FactoryObjectAutoPointer&) const
#endif
{
return m_object == theRHS.m_object ? true : false;
}
private:
#if defined(XALAN_MEMBER_TEMPLATES)
template <class CompatibleType>
void
adopt(FactoryObjectAutoPointer<CompatibleType& theRHS)
#else
void
adopt(FactoryObjectAutoPointer<Type>& theRHS)
#endif
{
if (m_object != theRHS.m_object)
{
// Return the object we're now pointing
// to.
returnObject();
}
// Adopt the object and factory of the source
// object.
m_factory = theRHS.m_factory;
m_object = theRHS.m_object;
// The source object will no longer refer
// to the object.
theRHS.m_object = 0;
theRHS.m_factory = 0;
}
// Data members...
Factory* m_factory;
Type* m_object;
};
#endif // FACTORY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/FactoryObject.cpp
Index: FactoryObject.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FactoryObject.hpp"
FactoryObject::FactoryObject()
{
}
FactoryObject::~FactoryObject()
{
}
1.1 xml-xalan/c/src/PlatformSupport/FactoryObject.hpp
Index: FactoryObject.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FACTORYOBJECT_HEADER_GUARD_1357924680)
#define FACTORYOBJECT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT FactoryObject
{
protected:
FactoryObject();
// Make it such that a Factory instance can delete a FactoryObject.
friend class Factory;
virtual
~FactoryObject();
private:
};
#endif // FACTORYOBJECT_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/PlatformSupport/NamedNodeMapAttributeList.cpp
Index: NamedNodeMapAttributeList.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NamedNodeMapAttributeList.hpp"
#include <dom/DOM_Attr.hpp>
#include "DOMStringHelper.hpp"
NamedNodeMapAttributeList::NamedNodeMapAttributeList(DOM_NamedNodeMap&
theMap) :
m_nodeMap(theMap),
m_lastIndex(theMap.getLength() - 1),
m_cachedData()
{
}
NamedNodeMapAttributeList::~NamedNodeMapAttributeList()
{
}
unsigned int
NamedNodeMapAttributeList::getLength() const
{
return m_nodeMap.getLength();
}
const XMLCh*
NamedNodeMapAttributeList::getName(const unsigned int index) const
{
// We have to return a pointer to a something, but the Xerces
// DOM classes return strings by value, so we have to get
// the value from the node and store the DOMString somewhere
// safe, so we have a vector of DOMStrings to hold everything.
const DOM_Node theNode = m_nodeMap.item(m_lastIndex - index);
const DOM_Attr& theAttr =
static_cast<const DOM_Attr&>(theNode);
m_cachedData.push_back(theAttr.getName());
return c_wstr(m_cachedData.back());
}
// This is out here so we don't have to worry about multithreading issues.
namespace
{
const DOMString theType("CDATA");
};
const XMLCh*
NamedNodeMapAttributeList::getType(const unsigned int /* index */) const
{
return c_wstr(theType);
}
const XMLCh*
NamedNodeMapAttributeList::getValue(const unsigned int index) const
{
// We have to return a pointer to a something, but the Xerces
// DOM classes return strings by value, so we have to get
// the value from the node and store the DOMString somewhere
// safe, so we have a vector of DOMStrings to hold everything.
const DOM_Node theNode = m_nodeMap.item(m_lastIndex - index);
const DOM_Attr& theAttr =
static_cast<const DOM_Attr&>(theNode);
m_cachedData.push_back(theAttr.getValue());
return c_wstr(m_cachedData.back());
}
const XMLCh*
NamedNodeMapAttributeList::getType(const XMLCh* const /* name */) const
{
return c_wstr(theType);
}
const XMLCh*
NamedNodeMapAttributeList::getValue(const XMLCh* const name) const
{
// We have to return a pointer to a something, but the Xerces
// DOM classes return strings by value, so we have to get
// the value from the node and store the DOMString somewhere
// safe, so we have a vector of DOMStrings to hold everything.
const DOM_Node theNode = m_nodeMap.getNamedItem(name);
const DOM_Attr& theAttr =
static_cast<const DOM_Attr&>(theNode);
m_cachedData.push_back(theAttr.getValue());
return c_wstr(m_cachedData.back());
}
const XMLCh*
NamedNodeMapAttributeList::getValue(const char* const name) const
{
return getValue(XMLString::transcode(name));
}
1.1
xml-xalan/c/src/PlatformSupport/NamedNodeMapAttributeList.hpp
Index: NamedNodeMapAttributeList.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NAMEDNODEMAPATTRIBUTELIST_HEADER_GUARD_1357924680)
#define NAMEDNODEMAPATTRIBUTELIST_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <vector>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT NamedNodeMapAttributeList : public
AttributeList
{
public:
explicit
NamedNodeMapAttributeList(DOM_NamedNodeMap& theMap);
virtual
~NamedNodeMapAttributeList();
// These are inherited from AttributeList
virtual unsigned int
getLength() const;
virtual const XMLCh*
getName(const unsigned int index) const;
virtual const XMLCh*
getType(const unsigned int index) const;
virtual const XMLCh*
getValue(const unsigned int index) const;
virtual const XMLCh*
getType(const XMLCh* const name) const;
virtual const XMLCh*
getValue(const XMLCh* const name) const;
virtual const XMLCh*
getValue(const char* const name) const;
private:
mutable DOM_NamedNodeMap m_nodeMap;
const int m_lastIndex;
mutable std::vector<DOMString> m_cachedData;
};
#endif // NAMEDNODEMAPATTRIBUTELIST_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/NullPrintWriter.cpp
Index: NullPrintWriter.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NullPrintWriter.hpp"
NullPrintWriter::NullPrintWriter() :
PrintWriter(false)
{
}
NullPrintWriter::~NullPrintWriter()
{
}
bool
NullPrintWriter::checkError() const
{
return false;
}
void
NullPrintWriter::close()
{
}
void
NullPrintWriter::flush()
{
}
void
NullPrintWriter::write(
const char* /* s */,
long /* theOffset */,
long /* theLength */)
{
}
void
NullPrintWriter::write(
const XMLCh* /* s */,
long /* theOffset */,
long /* theLength */)
{
}
void
NullPrintWriter::write(XMLCh /* c */)
{
}
void
NullPrintWriter::write(
const DOMString& /* s */,
long /* theOffset */,
long /* theLength */)
{
}
void
NullPrintWriter::print(bool /* b */)
{
}
void
NullPrintWriter::print(char /* c */)
{
}
void
NullPrintWriter::print(
const char* /* s */,
long /* theLength */)
{
}
void
NullPrintWriter::print(
const XMLCh* /* s */,
long /* theLength */)
{
}
void
NullPrintWriter::print(double /* d */)
{
}
void
NullPrintWriter::print(int /* i */)
{
}
void
NullPrintWriter::print(long /* l */)
{
}
void
NullPrintWriter::print(const DOMString& /* s */)
{
}
void
NullPrintWriter::println()
{
}
void
NullPrintWriter::println(bool /* x */)
{
}
void
NullPrintWriter::println(char /* x */)
{
}
void
NullPrintWriter::println(
const char* /* s */,
long /* theLength */)
{
}
void
NullPrintWriter::println(
const XMLCh* /* s */,
long /* theLength */)
{
}
void
NullPrintWriter::println(double /* x */)
{
}
void
NullPrintWriter::println(int /* x */)
{
}
void
NullPrintWriter::println(long /* x */)
{
}
void
NullPrintWriter::println(const DOMString& /* s */)
{
}
1.1 xml-xalan/c/src/PlatformSupport/NullPrintWriter.hpp
Index: NullPrintWriter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NULLPRINTWRITER_HEADER_GUARD_1357924680)
#define NULLPRINTWRITER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
// Base class header file.
#include <PlatformSupport/PrintWriter.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT NullPrintWriter : public PrintWriter
{
public:
explicit
NullPrintWriter();
virtual
~NullPrintWriter();
// Functions inherited from PrintWriter...
virtual bool
checkError() const;
virtual void
close();
virtual void
flush();
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const char* s,
long theOffset = 0,
long theLength = -1);
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const XMLCh* s,
long theOffset = 0,
long theLength = -1);
virtual void
write(XMLCh c);
// If the length is -1, then the entire string is printed.
virtual void
write(const DOMString& s,
long theOffset = 0,
long theLength = -1);
virtual void
print(bool b);
virtual void
print(char c);
virtual void
print(const char* s,
long theLength = -1);
virtual void
print(const XMLCh* s,
long theLength = -1);
virtual void
print(double d);
virtual void
print(int i);
virtual void
print(long l);
virtual void
print(const DOMString& s);
virtual void
println();
virtual void
println(bool x);
virtual void
println(char x);
virtual void
println(const char* s,
long theLength = -1);
virtual void
println(const XMLCh* s,
long theLength = -1);
virtual void
println(double x);
virtual void
println(int x);
virtual void
println(long x);
virtual void
println(const DOMString& s);
private:
// Not implemented
NullPrintWriter(const NullPrintWriter&);
NullPrintWriter&
operator=(const NullPrintWriter&);
bool
operator==(const NullPrintWriter&);
};
#endif // NULLPRINTWRITER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/NumberFormat.cpp
Index: NumberFormat.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NumberFormat.hpp"
#include "DOMStringHelper.hpp"
NumberFormat::NumberFormat() :
m_isGroupingUsed(false),
m_groupingSeparator(","),
m_groupingSize(3) // Default to US values
{
}
NumberFormat::~NumberFormat()
{
}
DOMString
NumberFormat::format(double theValue)
{
// $$$ ToDo: Fix this!
return applyGrouping(DoubleToDOMString(theValue));
}
DOMString
NumberFormat::format(int theValue)
{
// $$$ ToDo: Fix this!
return applyGrouping(LongToDOMString(theValue));
}
DOMString
NumberFormat::format(unsigned int theValue)
{
// $$$ ToDo: Fix this!
return applyGrouping(UnsignedLongToDOMString(theValue));
}
DOMString
NumberFormat::format(long theValue)
{
// $$$ ToDo: Fix this!
return applyGrouping(LongToDOMString(theValue));
}
DOMString NumberFormat::applyGrouping(const DOMString& value)
/*
* Convert a string value using the currently active values for grouping size
* and separator; returns the converted string
*/
{
if (!m_isGroupingUsed) return value;
int len = value.length();
if (len == 0) return value;
int bufsize = len + len/m_groupingSize + 1;
XMLCh* buffer = new XMLCh[bufsize];
XMLCh c;
XMLCh* p = buffer + bufsize -1;
*p-- = 0; // null terminate
for (int i= 0, ix = len-1; i < len; i++, ix--)
{
XMLCh c = charAt(value, ix);
if (i && !(i% m_groupingSize))
{
// Could be a multiple character separator??
for (int j= m_groupingSeparator.length()-1; j>=0; j--)
*p-- = charAt(m_groupingSeparator, j);
}
*p-- = charAt(value, ix);
}
DOMString s(++p);
delete [] buffer;
return s;
}
DOMString
NumberFormat::format(unsigned long theValue)
{
// $$$ ToDo: Fix this!
return UnsignedLongToDOMString(theValue);
}
bool NumberFormat::isGroupingUsed() const
{
return m_isGroupingUsed;
}
void NumberFormat::setGroupingUsed(bool bUsed)
{
m_isGroupingUsed = bUsed;
}
void NumberFormat::setGroupingSize(const DOMString& s)
{
m_groupingSize = DOMStringToInt(s);
assert(m_groupingSize >= 0); // Can't be zero
}
void NumberFormat::setGroupingSeparator(const DOMString& s)
{
m_groupingSeparator = s;
}
1.1 xml-xalan/c/src/PlatformSupport/NumberFormat.hpp
Index: NumberFormat.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NUMBERFORMAT_HEADER_GUARD_1357924680)
#define NUMBERFORMAT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT NumberFormat
{
public:
explicit
NumberFormat();
virtual
~NumberFormat();
virtual DOMString
format(double theValue);
virtual DOMString
format(int theValue);
virtual DOMString
format(unsigned int theValue);
virtual DOMString
format(long theValue);
virtual DOMString
format(unsigned long theValue);
virtual bool isGroupingUsed() const;
virtual void setGroupingUsed(bool bUsed);
virtual void setGroupingSize(const DOMString& s);
virtual void setGroupingSeparator(const DOMString& s);
private:
// Not implemented
NumberFormat(const NumberFormat&);
NumberFormat&
operator=(const NumberFormat&);
bool
operator==(const NumberFormat&);
bool m_isGroupingUsed;
DOMString m_groupingSeparator;
int m_groupingSize;
DOMString applyGrouping(const DOMString& value);
};
#endif // NUMBERFORMAT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/PlatformSupport.cpp
Index: PlatformSupport.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "PlatformSupport.hpp"
#if defined(XALAN_XERCES)
#include <XercesInit/XercesInit.hpp>
// This takes care of ensuring that the Xerces platform is
// initialized
XercesInit theInitializer;
#endif
PlatformSupportInitializer::PlatformSupportInitializer()
{
}
PlatformSupportInitializer::~PlatformSupportInitializer()
{
}
1.1 xml-xalan/c/src/PlatformSupport/PlatformSupport.hpp
Index: PlatformSupport.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(PLATFORMSUPPORT_HEADER_GUARD_1357924680)
#define PLATFORMSUPPORT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT PlatformSupportInitializer
{
public:
PlatformSupportInitializer();
~PlatformSupportInitializer();
private:
};
#endif // PLATFORMSUPPORT_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/PlatformSupport/PlatformSupportDefinitions.hpp
Index: PlatformSupportDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(PLATFORMSUPPORTDEFINITIONS_HEADER_GUARD_1357924680)
#define PLATFORMSUPPORTDEFINITIONS_HEADER_GUARD_1357924680
#include <include/PlatformDefinitions.hpp>
#if defined(XALAN_PLATFORMSUPPORT_BUILD_DLL)
#define XALAN_PLATFORMSUPPORT_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(T)
XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_PLATFORMSUPPORT_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(T)
XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // PLATFORMSUPPORTDEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/PrintWriter.cpp
Index: PrintWriter.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "PrintWriter.hpp"
PrintWriter::PrintWriter(bool fAutoFlush) :
Writer(),
m_fAutoFlush(fAutoFlush)
{
}
PrintWriter::~PrintWriter()
{
}
1.1 xml-xalan/c/src/PlatformSupport/PrintWriter.hpp
Index: PrintWriter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(PRINTWRITER_HEADER_GUARD_1357924680)
#define PRINTWRITER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
// Base class header file.
#include <PlatformSupport/Writer.hpp>
#include <util/XML4CDefs.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT PrintWriter : public Writer
{
public:
// If fAutoFlush is true, the output will not
// be buffered.
PrintWriter(bool fAutoFlush = false);
virtual
~PrintWriter();
// Flush the stream, then check the error status.
virtual bool
checkError() const = 0;
virtual void
close() = 0;
virtual void
flush() = 0;
// Output functions inherited from Writer...
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const char* s,
long theOffset = 0,
long theLength = -1) = 0;
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const XMLCh* s,
long theOffset = 0,
long theLength = -1) = 0;
virtual void
write(XMLCh c) = 0;
// If the length is -1, then the entire string is printed.
virtual void
write(const DOMString& s,
long theOffset = 0,
long theLength = -1) = 0;
// Output functions which are new...
virtual void
print(bool b) = 0;
virtual void
print(char c) = 0;
virtual void
print(const char* s,
long theLength = -1) = 0;
virtual void
print(const XMLCh* s,
long theLength = -1) = 0;
virtual void
print(double d) = 0;
virtual void
print(int i) = 0;
virtual void
print(long l) = 0;
virtual void
print(const DOMString& s) = 0;
virtual void
println() = 0;
virtual void
println(bool x) = 0;
virtual void
println(char x) = 0;
virtual void
println(const char* s,
long theLength = -1) = 0;
virtual void
println(const XMLCh* s,
long theLength = -1) = 0;
virtual void
println(double x) = 0;
virtual void
println(int x) = 0;
virtual void
println(long x) = 0;
virtual void
println(const DOMString& s) = 0;
protected:
const bool m_fAutoFlush;
private:
// Not implemented
PrintWriter(const PrintWriter&);
PrintWriter&
operator=(const PrintWriter&);
bool
operator==(const PrintWriter&);
};
#endif // PRINTWRITER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/Resettable.cpp
Index: Resettable.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "Resettable.hpp"
Resettable::Resettable()
{
}
Resettable::~Resettable()
{
}
1.1 xml-xalan/c/src/PlatformSupport/Resettable.hpp
Index: Resettable.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(RESETTABLE_HEADER_GUARD_1357924680)
#define RESETTABLE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT Resettable
{
public:
Resettable();
virtual
~Resettable();
/**
* Reset the instance.
*/
virtual void
reset() = 0;
};
#endif // RESETTABLE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/STLHelper.hpp
Index: STLHelper.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(STLHELPERS_HEADER_GUARD_1357924680)
#define STLHELPERS_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include "PlatformSupportDefinitions.hpp"
#include <functional>
template <class T>
struct DeleteFunctor : public std::unary_function<const T*, void>
{
result_type
operator()(argument_type thePointer) const
{
delete thePointer;
}
};
template <class PairType>
struct select1st : public std::unary_function<PairType, PairType::first_type>
{
typedef PairType value_type;
result_type
operator()(const argument_type& thePair) const
{
return thePair.first;
}
};
template <class PairType>
struct select2nd : public std::unary_function<PairType, PairType::second_type>
{
typedef PairType value_type;
result_type
operator()(const argument_type& thePair)
{
return thePair.second;
}
};
template <class OutputIteratorType, class PairMemberSelectType>
struct PairIsolatorOutputIterator
{
typedef std::output_iterator_tag
iterator_category;
typedef PairMemberSelectType::value_type value_type;
typedef void
difference_type;
typedef void
pointer;
typedef void
reference;
PairIsolatorOutputIterator(
OutputIteratorType theOutputIterator,
PairMemberSelectType thePairMemberSelector) :
m_OutputIterator(theOutputIterator),
m_PairMemberSelector(thePairMemberSelector)
{
}
PairIsolatorOutputIterator&
operator=(const value_type& theValue)
{
m_OutputIterator = m_PairMemberSelector(theValue);
return *this;
}
PairIsolatorOutputIterator&
operator*()
{
return *this;
}
PairIsolatorOutputIterator&
operator++()
{
++m_OutputIterator;
return *this;
}
PairIsolatorOutputIterator& operator++(int)
{
m_OutputIterator++;
return *this;
}
private:
OutputIteratorType m_OutputIterator;
PairMemberSelectType m_PairMemberSelector;
};
template <class T>
struct MapValueDeleteFunctor : public std::unary_function<const
T::value_type&, void>
{
result_type
operator()(argument_type thePair)
{
delete thePair.second;
}
};
template<class T, class Functor>
struct nested_for_each_functor : public std::unary_function<const
T::value_type&, Functor>
{
nested_for_each_functor(Functor theFunctor) :
m_functor(theFunctor)
{
}
result_type
operator()(argument_type theContainer)
{
return for_each(theContainer.begin(),
theContainer.end(),
m_functor);
}
private:
Functor m_functor;
};
/*
template <class InputIterator, class Function>
Function
nested_for_each(
InputIterator first,
InputIterator last,
Function function)
{
return function;
}
*/
// This functor is designed to compare 0-terminated arrays. It substitues for
// the default less<type*> so that pointers to arrays can be compared, rather
than
// copies of arrays. For example, you might want to use C-style strings as
keys
// in a map, rather than string objects. The default algorithm less<const
char*>
// would just compare the pointers, and not the vector of characters to which
it
// points. Using this algorithm instead of the default will allow the map to
// work as expected.
template<class T>
struct less_null_terminated_arrays : public std::binary_function<const T*,
const T*, bool>
{
result_type
operator()(first_argument_type theLHS,
second_argument_type theRHS) const
{
while(*theLHS && *theRHS)
{
if (*theLHS != *theRHS)
{
break;
}
else
{
theLHS++;
theRHS++;
}
}
return *theLHS < *theRHS ? true : false;
}
};
#endif // STLHELPERS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/StringTokenizer.cpp
Index: StringTokenizer.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "StringTokenizer.hpp"
#include <cassert>
#include "DOMStringHelper.hpp"
StringTokenizer::StringTokenizer(
const DOMString& theString,
const DOMString& theTokens,
bool fReturnTokens) :
m_String(theString),
m_Tokens(theTokens),
m_fReturnTokens(fReturnTokens),
m_CurrentIndex(0),
m_StringLength(theString.length())
{
}
StringTokenizer::~StringTokenizer()
{
}
bool
StringTokenizer::hasMoreTokens() const
{
return countTokens() > 0 ? true : false;
}
bool
FindCharInTokens(XMLCh theChar,
const DOMString& theTokens)
{
bool fFound = false;
const int theLength = theTokens.length();
for(int i = 0; i < theLength; i++)
{
if (charAt(theTokens, i) == theChar)
{
fFound = true;
break;
}
}
return fFound;
}
#if 0
DOMString
StringTokenizer::nextToken()
{
assert(m_CurrentIndex < m_StringLength);
DOMString theToken;
// Find the index of the next delimiter.
int theIndex = FindNextDelimiterIndex(m_CurrentIndex);
if (theIndex == m_CurrentIndex &&
m_fReturnTokens == true)
{
// The next delimiter is at the current index. If we're
// returning delimiters as tokens, then make that the
// return value. Otherwise, return an empty string.
theToken = substring(m_String,
theIndex,
theIndex + 1);
m_CurrentIndex = theIndex + 1;
}
else
{
if (theIndex == m_CurrentIndex)
{
theIndex = FindNextDelimiterIndex(m_CurrentIndex + 1);
}
assert(theIndex > m_CurrentIndex);
theToken = substring(m_String,
m_CurrentIndex,
theIndex);
if (m_fReturnTokens == true)
{
m_CurrentIndex = theIndex;
}
else
{
m_CurrentIndex = theIndex + 1;
}
}
return theToken;
}
#else
DOMString
StringTokenizer::nextToken()
{
assert(m_CurrentIndex < m_StringLength);
DOMString theToken;
// Find the index of the next delimiter.
int theIndex = FindNextDelimiterIndex(m_CurrentIndex);
if (theIndex == m_CurrentIndex)
{
m_CurrentIndex = theIndex + 1;
if (m_fReturnTokens == true)
{
// The next delimiter is at the current index. If we're
// returning delimiters as tokens, then make that the
// return value. Otherwise, return an empty string.
theToken = substring(m_String,
theIndex,
theIndex + 1);
}
else if (m_CurrentIndex < m_StringLength)
{
theToken = nextToken();
}
}
else
{
if (theIndex == m_CurrentIndex)
{
theIndex = FindNextDelimiterIndex(m_CurrentIndex + 1);
}
assert(theIndex > m_CurrentIndex);
theToken = substring(m_String,
m_CurrentIndex,
theIndex);
m_CurrentIndex = theIndex;
}
return theToken;
}
#endif
int
StringTokenizer::countTokens() const
{
int theCount = 0;
int theCurrentIndex = m_CurrentIndex;
if (theCurrentIndex < m_StringLength)
{
while(theCurrentIndex < m_StringLength)
{
const int theNextIndex =
FindNextDelimiterIndex(theCurrentIndex);
if (theNextIndex == theCurrentIndex)
{
theCurrentIndex = theNextIndex + 1;
if (m_fReturnTokens == true)
{
theCount++;
}
}
else
{
theCount++;
theCurrentIndex = theNextIndex;
}
}
}
return theCount;
}
int
StringTokenizer::FindNextDelimiterIndex(int theStartIndex) const
{
bool fTokenFound = false;
int theIndex = theStartIndex;
while(theIndex < m_StringLength &&
fTokenFound == false)
{
const XMLCh theCurrentChar = charAt(m_String,
theIndex);
if (FindCharInTokens(theCurrentChar,
m_Tokens) == true)
{
fTokenFound = true;
}
else
{
theIndex++;
}
}
return theIndex;
}
1.1 xml-xalan/c/src/PlatformSupport/StringTokenizer.hpp
Index: StringTokenizer.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(STRINGTOKENIZER_HEADER_GUARD_1357924680)
#define STRINGTOKENIZER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT StringTokenizer
{
public:
StringTokenizer(const DOMString& theString,
const DOMString& theTokens =
DOMString("\t\n\r\f"),
bool
fReturnTokens = false);
virtual
~StringTokenizer();
virtual bool
hasMoreTokens() const;
virtual DOMString
nextToken();
virtual int
countTokens() const;
protected:
int
FindNextDelimiterIndex(int theStartIndex) const;
private:
const DOMString m_String;
const DOMString m_Tokens;
const bool m_fReturnTokens;
int m_CurrentIndex;
const int m_StringLength;
};
#endif // STRINGTOKENIZER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/Writer.cpp
Index: Writer.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "Writer.hpp"
Writer::Writer()
{
}
Writer::~Writer()
{
}
1.1 xml-xalan/c/src/PlatformSupport/Writer.hpp
Index: Writer.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(WRITER_HEADER_GUARD_1357924680)
#define WRITER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <util/XML4CDefs.hpp>
class DOMString;
class XALAN_PLATFORMSUPPORT_EXPORT Writer
{
public:
Writer();
virtual
~Writer();
virtual void
close() = 0;
virtual void
flush() = 0;
// Output functions
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const char* s,
long theOffset = 0,
long theLength = -1) = 0;
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const XMLCh* s,
long theOffset = 0,
long theLength = -1) = 0;
virtual void
write(XMLCh c) = 0;
// If the length is -1, then the entire string is printed.
virtual void
write(const DOMString& s,
long theOffset = 0,
long theLength = -1) = 0;
private:
// Not implemented
Writer(const Writer&);
Writer&
operator=(const Writer&);
bool
operator==(const Writer&);
};
#endif // WRITER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/PlatformSupport/XSLException.cpp
Index: XSLException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XSLException.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
XSLException::XSLException(
const DOMString& theMessage,
const DOMString& theType) : m_message(theMessage),
m_type(theType)
{
}
XSLException::~XSLException()
{
}
1.1 xml-xalan/c/src/PlatformSupport/XSLException.hpp
Index: XSLException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XSLEXCEPTION_HEADER_GUARD_1357924680)
#define XSLEXCEPTION_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <PlatformSupport/PlatformSupportDefinitions.hpp>
#include <DOM/DOMString.hpp>
#include <util/XMLException.hpp>
class XALAN_PLATFORMSUPPORT_EXPORT XSLException
{
public:
XSLException(
const DOMString& theMessage,
const DOMString& theType = DOMString("XSLException"));
virtual
~XSLException();
DOMString getType() const
{
return m_type;
}
DOMString getMessage() const
{
return m_message;
}
private:
DOMString m_type;
DOMString m_message;
};
#endif // XSLEXCEPTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/TestXPath/NodeNameTreeWalker.cpp
Index: NodeNameTreeWalker.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 <dom/DOM_Node.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Class include file.
#include "NodeNameTreeWalker.hpp"
NodeNameTreeWalker::NodeNameTreeWalker() :
TreeWalker(),
m_nodeName(),
m_matchingNodes()
{
}
NodeNameTreeWalker::~NodeNameTreeWalker()
{
}
void
NodeNameTreeWalker::findMatchingNodes(
const DOMString& theNodeName,
const DOM_Node& theStartNode)
{
m_nodeName = theNodeName;
m_matchingNodes.clear();
traverse(theStartNode.getFirstChild(),
theStartNode);
}
void
NodeNameTreeWalker::startNode(const DOM_Node& node)
{
const DOMString theNodeName = node.getNodeName();
if (equals(theNodeName, m_nodeName) == true)
{
m_matchingNodes.push_back(node);
}
}
void
NodeNameTreeWalker::endNode(const DOM_Node& /* node */)
{
}
1.1 xml-xalan/c/src/TestXPath/NodeNameTreeWalker.hpp
Index: NodeNameTreeWalker.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NODENAMETREEWALKER_HEADER_GUARD_1357924680)
#define NODENAMETREEWALKER_HEADER_GUARD_1357924680
#include <vector>
#include <dom/DOMString.hpp>
// Base class include file.
#include <DOMSupport/TreeWalker.hpp>
class NodeNameTreeWalker : public TreeWalker
{
public:
/**
* Constructor.
*/
NodeNameTreeWalker();
virtual
~NodeNameTreeWalker();
virtual void
findMatchingNodes(
const DOMString& theNodeName,
const DOM_Node& theStartNode);
const std::vector<DOM_Node>&
getMatchingNodes() const
{
return m_matchingNodes;
}
protected:
virtual void
startNode(const DOM_Node& node);
virtual void
endNode(const DOM_Node& node);
private:
DOMString m_nodeName;
std::vector<DOM_Node> m_matchingNodes;
};
#endif // NODENAMETREEWALKER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/TestXPath/TestXPath.cpp
Index: TestXPath.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 <cstdio>
#include <vector>
#include <util/StdOut.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NodeList.hpp>
#include <internal/URLInputSource.hpp>
#include <PlatformSupport/DirectoryEnumerator.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <DOMSupport/DOMSupportDefault.hpp>
#include <XPath/XObjectFactoryDefault.hpp>
#include <XPath/XPathEnvSupportDefault.hpp>
#include <XPath/XPathSupportDefault.hpp>
#include <XPath/XPath.hpp>
#include <XPath/XPathProcessorImpl.hpp>
#include <XPath/XPathFactoryDefault.hpp>
#include <XPath/ElementPrefixResolverProxy.hpp>
#include <XMLSupport/FormatterTreeWalker.hpp>
#include <XMLSupport/FormatterToXML.hpp>
#include <XercesPlatformSupport/XercesDOMPrintWriter.hpp>
#include <XercesParserLiaison/XercesParserLiaison.hpp>
namespace
{
bool
TestNumericResult(
XPathSupport& theXPathSupport,
XPathProcessorImpl& theXPathProcessor,
XPath& theXPath,
const DOMString& theXPathString,
PrintWriter& thePrintWriter,
double
theExpectedResult,
const DOM_Node& theContextNode,
const DOM_Element& theNamespaceContext,
const DOM_NodeList& theContextNodeList)
{
bool fError = false;
theXPathProcessor.initXPath(theXPath,
theXPathString,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport));
MutableNodeRefList theList;
theList = theContextNodeList;
const XObject* const theResult =
theXPath.execute(theContextNode,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport),
theList);
thePrintWriter.print("Execution of XPath ");
thePrintWriter.print(theXPathString);
if (theResult->num() == theExpectedResult)
{
thePrintWriter.println(" succeeded.");
thePrintWriter.print("The result was ");
thePrintWriter.println(theResult->num());
}
else
{
fError = true;
thePrintWriter.println(" failed!");
thePrintWriter.print("The expected result was ");
thePrintWriter.println(theExpectedResult);
thePrintWriter.print("The actual result was ");
thePrintWriter.println(theResult->num());
}
return fError;
}
bool
TestStringResult(
XPathSupport& theXPathSupport,
XPathProcessorImpl& theXPathProcessor,
XPath& theXPath,
const DOMString& theXPathString,
PrintWriter& thePrintWriter,
const DOMString& theExpectedResult,
const DOM_Node& theContextNode,
const DOM_Element& theNamespaceContext,
const DOM_NodeList& theContextNodeList)
{
bool fError = false;
theXPathProcessor.initXPath(theXPath,
theXPathString,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport));
MutableNodeRefList theList;
theList = theContextNodeList;
const XObject* const theResult =
theXPath.execute(theContextNode,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport),
theList);
thePrintWriter.print("Execution of XPath ");
thePrintWriter.print(theXPathString);
if (equals(theResult->str(), theExpectedResult) == true)
{
thePrintWriter.println(" succeeded.");
thePrintWriter.print("The result was \"");
thePrintWriter.print(theResult->str());
thePrintWriter.println("\".");
}
else
{
fError = true;
thePrintWriter.println(" failed!");
thePrintWriter.print("The expected result was \"");
thePrintWriter.print(theExpectedResult);
thePrintWriter.println("\".");
thePrintWriter.print("The actual result was \"");
thePrintWriter.print(theResult->str());
thePrintWriter.println("\".");
}
return fError;
}
DOM_Document
ParseXML(
XMLParserLiaison& theLiaison,
const DOMString& theFileName)
{
URLInputSource theURLInputSource(c_wstr(theFileName));
return theLiaison.parseXMLStream(theURLInputSource);
}
bool
GetXSLInput(
const DOMString& theXSLFileURL,
DOMString&
theContextNodeMatchPattern,
DOMString& theXPathString)
{
bool fResult = false;
if (endsWith(theXSLFileURL, "axes01.xsl") == true)
{
theContextNodeMatchPattern = "//center";
// theXPathString = "ancestor::*";
theXPathString = "node()|@*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes02.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "ancestor-or-self::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes03.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "attribute::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes04.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "child::*";
fResult = true;
}
else
if (endsWith(theXSLFileURL, "axes05.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "descendant::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes06.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "descendant-or-self::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes07.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "following::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes08.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "preceding::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes09.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "following-sibling::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes10.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "preceding-sibling::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes11.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "parent::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes12.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "self::*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes16.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "ancestor::*[3]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes17.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "ancestor-or-self::*[1]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes18.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "attribute::*[2]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes19.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "@*";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes20.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "@*[2]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes21.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "child::*[2]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes22.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "child::near-south-west";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes23.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "descendant::*[3]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes24.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "descendant::far-south";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes25.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "descendant-or-self::*[3]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes26.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "descendant-or-self::far-south";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes27.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "descendant-or-self::center";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes28.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "following::*[4]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes29.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "following::out-yonder-east";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes30.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "preceding::*[4]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes31.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "preceding::out-yonder-west";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes32.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "following-sibling::*[2]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes33.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "following-sibling::east";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes34.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "preceding-sibling::*[2]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes35.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "preceding-sibling::west";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes35.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "preceding-sibling::west";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes36.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "parent::near-north";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes37.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "parent::*[1]";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes38.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "parent::foo";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes39.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "..";
fResult = true;
}
else if (endsWith(theXSLFileURL, "axes40.xsl") == true)
{
theContextNodeMatchPattern = "//center";
theXPathString = "self::center";
fResult = true;
}
return fResult;
}
DOM_Node
FindContextNode(
XPathSupport& theXPathSupport,
XPathProcessorImpl& theXPathProcessor,
XPathFactory& theXPathFactory,
const DOM_Document& theDocument,
const DOMString&
theContextNodeMatchPattern,
PrintWriter& thePrintWriter)
{
DOM_Node
theResult;
FactoryObjectAutoPointer<XPath> theXPath(&theXPathFactory,
theXPathFactory.create());
DOM_Element
theNamespaceContext;
theXPathProcessor.initXPath(*theXPath.get(),
theContextNodeMatchPattern,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport));
DOM_NodeList theContextNodeList;
MutableNodeRefList theList;
theList = theContextNodeList;
const XObject* const theXObject =
theXPath->execute(theDocument,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport),
theList);
try
{
assert(theXObject != 0);
const MutableNodeRefList& theResultList =
theXObject->mutableNodeset();
assert(theResultList.getLength() == 1);
theResult = theResultList.item(0);
}
catch(...)
{
thePrintWriter.print("FindContextNode: Error executing match
pattern \"");
thePrintWriter.print(theContextNodeMatchPattern);
thePrintWriter.println("\".");
}
return theResult;
}
bool
TestAxisResult(
XPathSupport& theXPathSupport,
XPathProcessorImpl& theXPathProcessor,
XMLParserLiaison& theLiaison,
XPathFactory& theXPathFactory,
const DOMString& theXMLFileURL,
const DOMString& theXSLFileURL,
PrintWriter& thePrintWriter)
{
bool fError = false;
const DOM_Document theXMLDocument = ParseXML(theLiaison,
theXMLFileURL);
if (theXMLDocument != 0)
{
DOMString theContextNodeMatchPattern;
DOMString theXPathString;
if (GetXSLInput(theXSLFileURL,
theContextNodeMatchPattern,
theXPathString) == true)
{
DOM_Node theContextNode =
FindContextNode(theXPathSupport,
theXPathProcessor,
theXPathFactory,
theXMLDocument,
theContextNodeMatchPattern,
thePrintWriter);
if (theContextNode != 0)
{
DOM_Element theNamespaceContext;
DOM_NodeList theContextNodeList;
FactoryObjectAutoPointer<XPath>
theXPath(&theXPathFactory,
theXPathFactory.create());
theXPathProcessor.initXPath(*theXPath.get(),
theXPathString,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport));
bool fDump = false;
if (fDump == true)
{
thePrintWriter.println();
thePrintWriter.println();
theXPath->getExpression().dumpOpCodeMap(thePrintWriter);
thePrintWriter.println();
theXPath->getExpression().dumpTokenQueue(thePrintWriter);
thePrintWriter.println();
thePrintWriter.println();
}
MutableNodeRefList theList;
theList = theContextNodeList;
const XObject* const theResult =
theXPath->execute(theContextNode,
ElementPrefixResolverProxy(theNamespaceContext,theXPathSupport),
theList);
try
{
assert(theResult != 0);
const MutableNodeRefList&
theResultList =
theResult->mutableNodeset();
const int theLength =
theResultList.getLength();
if (theLength > 0)
{
thePrintWriter.print("<out>");
for (int i = 0; i < theLength;
i++)
{
thePrintWriter.print(theResultList.item(i).getNodeName());
thePrintWriter.print("
");
}
}
thePrintWriter.println("</out>");
}
catch(...)
{
thePrintWriter.print("Execution of
XPath ");
thePrintWriter.print(theXPathString);
thePrintWriter.println(" failed!");
}
}
}
}
return fError;
}
const char* const theNumericTestInput[] =
{
"9 + 7 - 6 * 42 + 36 div 3 + 100 - 2 * 6",
"9 + 7 - 6 + 3 + 24 - 32 - 89 + 123 - 12256 + 89957",
"0 + 0",
"1 div 2",
"1 * 0.25",
0
};
const double theNumericTestExpectedOutput[] =
{
-136.0,
77740.0,
0,
0.5,
0.25,
0 // This is a dummy entry and should be last.
};
void
TestNumericResults(
XPathSupport& theXPathSupport,
XPathFactory& theXPathFactory,
XObjectFactory& /* theXObjectFactory */,
XPathProcessorImpl& theXPathProcessor,
PrintWriter& thePrintWriter)
{
assert(sizeof(theNumericTestInput) / sizeof(theNumericTestInput[0]) ==
sizeof(theNumericTestExpectedOutput) /
sizeof(theNumericTestExpectedOutput[0]));
for(int i = 0; theNumericTestInput[i] != 0; i++)
{
FactoryObjectAutoPointer<XPath>
theXPath(&theXPathFactory,
theXPathFactory.create());
TestNumericResult(theXPathSupport,
theXPathProcessor,
*theXPath.get(),
theNumericTestInput[i],
thePrintWriter,
theNumericTestExpectedOutput[i],
DOM_Node(),
DOM_Element(),
DOM_NodeList());
}
}
const char* const theStringTestInput[] =
{
"string(0)",
"string(1.5)",
"string(-1.5)",
"string(0.5)",
"string(-0.5)",
"string(9)",
"string(-9)",
"string(\"9\")",
"string(0.25)",
"concat(\"foo\", \"bar\")",
"concat(\"foo\", \"bar\", \"sky\")",
"contains(\"foobar\", \"oba\")",
"contains(\"Xalan is great\", \"boag\")",
"starts-with(\"foobar\", \"foo\")",
"starts-with(\"Xalan is great\", \"boag\")",
"substring-after(\"1999/04/01\", \"/\")",
"substring-after(\"1999/04/01\", \"19\")",
"substring-before(\"1999/04/01\", \"/\")",
"substring-before(\"1999/04/01\", \"01\")",
"substring(\"12345\", 1.5, 2.6)",
"substring(\"12345\", 0, 3)",
"substring(\"12345\", 5, 29)",
"substring(\"12345\", -1, 2)",
"substring(\"12345\", -2, -1)",
"substring(\"12345\", -2)",
"normalize(\" aa a \")",
"translate(\"---aaa--\", \"abc-\", \"ABC\")",
"5 = 0",
"5 = 5",
0
};
const char* const theStringTestExpectedOutput[] =
{
"0",
"1.5",
"-1.5",
"0.5",
"-0.5",
"9",
"-9",
"9",
"0.25",
"foobar",
"foobarsky",
"true",
"false",
"true",
"false",
"04/01",
"99/04/01",
"1999",
"1999/04/",
"234",
"12",
"5",
"",
"",
"12345",
"aa a",
"AAA",
"false",
"true",
0
};
void
TestStringResults(
XPathSupport& theXPathSupport,
XPathFactory& theXPathFactory,
XObjectFactory& /* theXObjectFactory */,
XPathProcessorImpl& theXPathProcessor,
PrintWriter& thePrintWriter)
{
assert(sizeof(theStringTestInput) ==
sizeof(theStringTestExpectedOutput));
for(int i = 0; theStringTestInput[i] != 0; i++)
{
FactoryObjectAutoPointer<XPath>
theXPath(&theXPathFactory,
theXPathFactory.create());
TestStringResult(theXPathSupport,
theXPathProcessor,
*theXPath.get(),
theStringTestInput[i],
thePrintWriter,
theStringTestExpectedOutput[i],
DOM_Node(),
DOM_Element(),
DOM_NodeList());
}
}
DOMString
GetXSLFileName(const DOMString& theXMLFileName)
{
DOMString theResult;
int thePeriodIndex = -1;
const int theLength = length(theXMLFileName);
for (int i = theLength - 1; i > 0; i--)
{
if (charAt(theXMLFileName, i) == '.')
{
thePeriodIndex = i;
break;
}
}
if (thePeriodIndex != -1)
{
theResult = substring(theXMLFileName,
0,
thePeriodIndex + 1);
theResult += "xsl";
}
return theResult;
}
void
TestAxes(
XPathSupport& theXPathSupport,
XPathFactory& theXPathFactory,
XObjectFactory& /* theXObjectFactory */,
XPathProcessorImpl& theXPathProcessor,
XMLParserLiaison& theLiaison,
PrintWriter& thePrintWriter)
{
const char* const theBaseURL = "file:///testsuite/conf/Axes/";
const char* const theSearchSpecification = "/testsuite/conf/Axes";
const char* const theXMLSuffix = ".xml";
typedef std::vector<DOMString> FileNameVectorType;
DirectoryEnumeratorFunctor<FileNameVectorType> theEnumerator;
FileNameVectorType theFiles;
theEnumerator(theSearchSpecification,
theFiles);
thePrintWriter.println();
for(FileNameVectorType::size_type i = 0; i < theFiles.size(); i++)
{
if (endsWith(theFiles[i], theXMLSuffix) == true)
{
// Create a fully qualified URL specification...
const DOMString theXMLFileName = theBaseURL +
theFiles[i];
// Get the name of the corresponding XSL file...
const DOMString theXSLFileName =
GetXSLFileName(theXMLFileName);
FactoryObjectAutoPointer<XPath>
theXPath(&theXPathFactory,
theXPathFactory.create());
TestAxisResult(theXPathSupport,
theXPathProcessor,
theLiaison,
theXPathFactory,
theXMLFileName,
theXSLFileName,
thePrintWriter);
}
}
}
void
RunTests(
XPathSupport& theXPathSupport,
XPathFactory& theXPathFactory,
XObjectFactory& theXObjectFactory,
XPathProcessorImpl& theXPathProcessor,
XMLParserLiaison& theLiaison,
PrintWriter& thePrintWriter)
{
TestNumericResults(theXPathSupport,
theXPathFactory,
theXObjectFactory,
theXPathProcessor,
thePrintWriter);
TestStringResults(theXPathSupport,
theXPathFactory,
theXObjectFactory,
theXPathProcessor,
thePrintWriter);
TestAxes(theXPathSupport,
theXPathFactory,
theXObjectFactory,
theXPathProcessor,
theLiaison,
thePrintWriter);
}
};
int
main(int /* argc */,
const char* /* argv[] */)
{
XPathEnvSupportDefault theEnvSupport;
DOMSupportDefault theDOMSupport;
XPathSupportDefault theSupport(theDOMSupport);
XObjectFactoryDefault theXObjectFactory(theEnvSupport, theSupport);
XPathFactoryDefault theXPathFactory(theXObjectFactory,
theEnvSupport, theSupport);
XPathProcessorImpl theXPathProcessor(theEnvSupport,
theSupport);
XMLStdOut theStdOut;
XercesDOMPrintWriter thePrintWriter(theStdOut);
XercesParserLiaison theLiaison(theDOMSupport);
RunTests(theSupport,
theXPathFactory,
theXObjectFactory,
theXPathProcessor,
theLiaison,
thePrintWriter);
return 0;
}
1.1 xml-xalan/c/src/TestXSLT/process.cpp
Index: process.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 <cstdio>
#include <cstring>
#include <iostream>
#include <util/StdOut.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NodeList.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/NullPrintWriter.hpp>
#include <DOMSupport/DOMSupportDefault.hpp>
#include <XPath/XObjectFactoryDefault.hpp>
#include <XPath/XPathEnvSupportDefault.hpp>
#include <XPath/XPathSupportDefault.hpp>
#include <XPath/XPath.hpp>
#include <XPath/XPathProcessorImpl.hpp>
#include <XPath/XPathFactoryDefault.hpp>
#include <Xslt/XSLTEngineImpl.hpp>
#include <Xslt/StylesheetRoot.hpp>
#include <XercesPlatformSupport/XercesDOMPrintWriter.hpp>
#include <XercesPlatformSupport/TextFileOutputStream.hpp>
#include <XercesPlatformSupport/NullTextOutputStream.hpp>
#include <XercesParserLiaison/XercesParserLiaison.hpp>
#include <DOMSupport/DOMSupport.hpp>
#include <XMLSupport/Formatter.hpp>
#include <sax/SAXException.hpp>
#include <Xslt/XSLTProcessorEnvSupportDefault.hpp>
/**
* Print argument options.
*/
void printArgOptions(XercesDOMPrintWriter& writer)
{
writer.println("xslproc options: ");
writer.println(" -IN inputXMLURL");
writer.println(" [-XSL XSLTransformationURL]");
writer.println(" [-OUT outputFileName]");
writer.println(" [-E (Do not expand entity refs)]");
writer.println(" [-V (Version info)]");
writer.println(" [-QC (Quiet Pattern Conflicts Warnings)]");
writer.println(" [-Q (Quiet Mode)]");
writer.println(" [-ESCAPE (Which characters to escape {default
is <>&\"\'\\r\\n}]");
writer.println(" [-INDENT (Control how many spaces to indent
{default is 0})]");
writer.println(" [-TT (Trace the templates as they are being
called.)]");
writer.println(" [-TG (Trace each generation event.)]");
writer.println(" [-TS (Trace each selection event.)]");
writer.println(" [-TTC (Trace the template children as they are
being processed.)]");
writer.println(" [-TCLASS (TraceListener class for trace
extensions.)]");
writer.println(" [-VALIDATE (Set whether validation occurs.
Validation is off by default.)]");
writer.println(" [-XML (Use XML formatter and add XML
header.)]");
writer.println(" [-TEXT (Use simple Text formatter.)]");
writer.println(" [-HTML (Use HTML formatter.)]");
writer.println(" [-PARAM name expression (Set a stylesheet
parameter)]");
}
void printChildren(const DOM_Node& theNode, int level=0)
{
XMLCh *nodeTypeNames[] =
{
L"", L"ELEMENT_NODE", L"ATTRIBUTE_NODE", L"TEXT_NODE",
L"CDATA_SECTION_NODE",
L"ENTITY_REFERENCE_NODE", L"ENTITY_NODE",
L"PROCESSING_INSTRUCTION_NODE",
L"COMMENT_NODE", L"DOCUMENT_NODE", L"DOCUMENT_TYPE_NODE",
L"DOCUMENT_FRAGMENT_NODE", L"NOTATION_NODE",
};
DOM_NodeList nl = theNode.getChildNodes();
level++;
for (int i=0; i< nl.getLength(); i++)
{
for (int j=1; j< level; j++) printf("\t");
printf("%d.%d: ", level, i);
const DOM_Node n = nl.item(i);
std::basic_string<XMLCh> s(c_wstr(n.getNodeName()));
s.append(L"(");
int t = n.getNodeType();
s.append(nodeTypeNames[t]);
s.append(L")");
printf("%-20ws ", s.c_str());
printf( t==3 ? "= %ws\n": "\n", c_wstr(n.getNodeValue()));
printChildren(n, level);
}
}
void xsltMain(int argc, const char* argv[] ) throw(XMLException)
{
/**
* Command line interface to transform the XML according to
* the instructions found in the XSL document.
* -in inputXMLURL
* -xsl XSLTransformationURL
* -out outputFileName
* -F (Format output pretty-printed)
*/
bool doStackDumpOnError = false;
bool setQuietMode = false;
// @@ This should become a command line switch
bool shouldWriteXMLHeader = false;
// Runtime.getRuntime().traceMethodCalls(false);
// Runtime.getRuntime().traceInstructions(false);
/**
* The default diagnostic writer...
*/
XMLStdOut theStdOut;
XMLStdErr theStdErr;
NullTextOutputStream theNullStream;
XercesDOMPrintWriter diagnosticsWriter(theStdErr);
XercesDOMPrintWriter dumpWriter(theStdErr);
if(argc < 2)
{
printArgOptions(diagnosticsWriter);
}
else
{
DOMSupportDefault theDOMSupport;
XercesParserLiaison xmlParserLiaison(theDOMSupport);
DOMStringPrintWriter pw;
XPathSupportDefault theXPathSupport(theDOMSupport);
XSLTProcessorEnvSupportDefault theXSLProcessorSupport;
XObjectFactoryDefault theXObjectFactory(theXSLProcessorSupport,
theXPathSupport);
XPathFactoryDefault theXPathFactory( theXObjectFactory,
theXSLProcessorSupport,
theXPathSupport);
XSLTEngineImpl processor(
xmlParserLiaison, theXPathSupport,
theXSLProcessorSupport,
&theXObjectFactory,
&theXPathFactory);
theXSLProcessorSupport.setProcessor(&processor);
processor.setFormatter(&xmlParserLiaison);
bool formatOutput = false;
QName mode;
DOMString inFileName;
DOMString outFileName;
DOMString dumpFileName;
DOMString xslFileName;
DOMString compiledStylesheetFileNameOut;
DOMString compiledStylesheetFileNameIn;
DOMString treedumpFileName;
bool didSetCR = false;
bool didSetLF = false;
bool stripCData = false;
bool escapeCData = false;
std::auto_ptr<TextFileOutputStream> outputFileStream;
TextOutputStream*
outputStream = &theStdOut;
int outputType = -1;
for (int i = 1; i < argc; i ++)
{
if (!stricmp("-ESCAPE", argv[i]))
{
xmlParserLiaison.setSpecialCharacters(argv[++i]);
}
else if (!stricmp("-INDENT", argv[i]))
{
int indentAmount;
if(((i+1) < argc) && (argv[i+1][0] != '-'))
{
indentAmount = atoi( argv[++i] );
}
else
{
indentAmount = 0;
}
xmlParserLiaison.setIndent(indentAmount);
}
else if (!stricmp("-IN", argv[i]))
{
inFileName = argv[++i];
}
else if (!stricmp("-OUT", argv[i]))
{
outFileName = argv[++i];
}
else if (!stricmp("-XSL", argv[i]))
{
xslFileName = argv[++i];
}
else if (!stricmp("-PARAM", argv[i]))
{
DOMString name = argv[++i];
DOMString expression = argv[++i];
processor.setStylesheetParam(name, expression);
}
else if (!stricmp("-treedump", argv[i]))
{
treedumpFileName = argv[++i];
}
else if(!stricmp("-F", argv[i]))
{
formatOutput = true;
}
else if(!stricmp("-E", argv[i]))
{
xmlParserLiaison.SetShouldExpandEntityRefs(false);
}
else if(!stricmp("-V", argv[i]))
{
}
else if(!stricmp("-QC", argv[i]))
{
processor.setQuietConflictWarnings(true);
}
else if(!stricmp("-Q", argv[i]))
{
setQuietMode = true;
}
else if(!stricmp("-VALIDATE", argv[i]))
{
DOMString shouldValidate;
if(((i+1) < argc) && (argv[i+1][0] != '-'))
{
shouldValidate = argv[++i];
}
else
{
shouldValidate = "yes";
}
}
else if(!stricmp("-PARSER", argv[i]))
{
i++;
// Handled above
}
else if(!stricmp("-XML", argv[i]))
{
outputType = Formatter::OUTPUT_METH_XML;
}
else if(!stricmp("-TEXT", argv[i]))
{
outputType = Formatter::OUTPUT_METH_TEXT;
}
else if(!stricmp("-HTML", argv[i]))
{
outputType = Formatter::OUTPUT_METH_HTML;
}
else if(!stricmp("-STRIPCDATA", argv[i]))
{
stripCData = true;
}
else if(!stricmp("-ESCAPECDATA", argv[i]))
{
escapeCData = true;
}
else if(!stricmp("-EDUMP", argv[i]))
{
doStackDumpOnError = true;
if(((i+1) < argc) && (argv[i+1][0] != '-'))
{
dumpFileName = argv[++i];
}
}
}
// The main XSL transformation occurs here!
if (! setQuietMode)
processor.setDiagnosticsOutput(
&diagnosticsWriter );
StylesheetRoot* stylesheet = 0;
if(0 != xslFileName.length())
{
stylesheet =
processor.processStylesheet(xslFileName);
}
if (length(outFileName) != 0)
{
outputFileStream =
std::auto_ptr<TextFileOutputStream>(new
TextFileOutputStream(outFileName));
outputStream = outputFileStream.get();
}
XercesDOMPrintWriter resultWriter(*outputStream);
DOMString mimeEncoding("UTF-8");
DOMString encoding("UTF-8");
FormatterListener* formatter = 0;
assert(inFileName.length());
XSLTInputSource theInputSource(c_wstr(inFileName));
DOM_Node sourceTree =
processor.getSourceTreeFromInput(&theInputSource);
/*
* Output the source tree
*/
if (0)
if (! setQuietMode)
printChildren(sourceTree);
if(0 != stylesheet)
{
if(Formatter::OUTPUT_METH_XML == outputType)
{
FormatterToXML* fToXML = new
FormatterToXML(resultWriter,
stylesheet->m_version,
stylesheet->getOutputIndent(),
xmlParserLiaison.getIndent(),
mimeEncoding,
stylesheet->m_mediatype,
stylesheet->getOutputDoctypeSystem(),
stylesheet->getOutputDoctypePublic(),
true, // xmlDecl
stylesheet->m_standalone,
&(stylesheet->getCdataSectionElems()));
fToXML->m_shouldWriteXMLHeader =
shouldWriteXMLHeader;
fToXML->m_attrSpecialChars =
xmlParserLiaison.getSpecialCharacters();
fToXML->m_stripCData = stripCData;
fToXML->m_escapeCData = escapeCData;
formatter = fToXML;
}
else if(Formatter::OUTPUT_METH_TEXT ==
outputType)
{
FormatterToText* fToText = new
FormatterToText(resultWriter);
formatter = fToText;
}
else if(Formatter::OUTPUT_METH_HTML ==
outputType)
{
FormatterToHTML* fToHTML
= new
FormatterToHTML(resultWriter,
stylesheet->m_version,
stylesheet->getOutputIndent(),
xmlParserLiaison.getIndent(), mimeEncoding,
stylesheet->m_mediatype,
stylesheet->getOutputDoctypeSystem(),
stylesheet->getOutputDoctypePublic(),
false, // xmlDecl
stylesheet->m_standalone,
&(stylesheet->getCdataSectionElems()));
fToHTML->m_attrSpecialChars =
xmlParserLiaison.getSpecialCharacters();
fToHTML->m_stripCData = stripCData;
formatter = fToHTML;
}
}
XSLTResultTarget* rTreeTarget = 0;
if(0 == formatter)
{
rTreeTarget = new
XSLTResultTarget(&resultWriter);
}
else
{
rTreeTarget = new XSLTResultTarget();
rTreeTarget->setFormatterListener(formatter);
xmlParserLiaison.setFormatterListener(formatter);
}
stylesheet->process(sourceTree, rTreeTarget);
delete formatter;
delete rTreeTarget;
}
}
int main(int argc, const char* argv[]) throw()
{
try
{
xsltMain(argc, argv);
}
catch (XSLException& e)
{
std::cout << "\nXSLException ";
std::string type = DOMStringToStdString(e.getType());
if (!type.empty())
std::cout << "Type is : " << type << std::endl;
std::string msg = DOMStringToStdString(e.getMessage());
if (!msg.empty())
std::cout << "Message is : " << msg << std::endl;
return -1;
}
catch (SAXException& e)
{
std::cout << "\nSAXException ";
std::string msg = DOMStringToStdString(e.getMessage());
if (!msg.empty())
std::cout << "Message is : " << msg << std::endl;
return -1;
}
catch (XMLException& e)
{
std::cout << "\nXMLException ";
std::string type = DOMStringToStdString(e.getType());
if (!type.empty())
std::cout << "Type is : " << type << std::endl;
std::string msg = DOMStringToStdString(e.getMessage());
if (!msg.empty())
std::cout << "Message is : " << msg << std::endl;
return -1;
}
return 0;
}
1.1 xml-xalan/c/src/XMLSupport/Formatter.cpp
Index: Formatter.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "Formatter.hpp"
Formatter::Formatter()
{
}
Formatter::~Formatter()
{
}
1.1 xml-xalan/c/src/XMLSupport/Formatter.hpp
Index: Formatter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FORMATTER_HEADER_GUARD_1357924680)
#define FORMATTER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
class DOM_Document;
class DOMString;
class FormatterListener;
class PrintWriter;
class XALAN_XMLSUPPORT_EXPORT Formatter
{
public:
#if defined(XALAN_INLINE_INITIALIZATION)
/**
* Output results as XML.
*/
const int OUTPUT_METH_XML = 1;
/**
* Output results as HTML.
*/
const int OUTPUT_METH_HTML = 2;
/**
* Output results as TEXT.
*/
const int OUTPUT_METH_TEXT = 3;
#else
enum eFormats
{
OUTPUT_METH_XML = 1,
OUTPUT_METH_HTML = 2,
OUTPUT_METH_TEXT = 3
};
#endif
Formatter();
virtual
~Formatter();
/**
* Print the result tree.
* @param doc The result tree.
* @param pw The PrintWriter to print the contents to.
* @param resultns the value of the resultns attribute.
* @param format Tells if it should be pretty-printed.
* @exception Exception thrown if the result tree is corrupted.
*/
virtual void
toMarkup(
const DOM_Document& doc,
PrintWriter& pw,
const DOMString& resultns,
bool format) = 0;
// throws Exception;
/**
* Get an instance of the formatter listener that is associated
* with this formatter.
*/
virtual FormatterListener*
getFormatterListener() const = 0;
/**
* Set an instance of the formatter listener that is associated
* with this formatter.
*/
virtual void
setFormatterListener(
PrintWriter& pw,
const DOMString& resultns,
bool format) = 0;
/**
* Set an instance of the formatter listener that is associated
* with this formatter.
*/
virtual void
setFormatterListener(FormatterListener* fl) = 0;
};
#endif // FORMATTER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/FormatterListener.cpp
Index: FormatterListener.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: FormatterListener.cpp,v 1.1 1999/12/18 19:47:52 robweir Exp $
*
* $State: Exp $
*
* @author David N. Bertoni ([email protected])
*/
// Class header file.
#include "FormatterListener.hpp"
FormatterListener::FormatterListener() :
DocumentHandler()
{
}
FormatterListener::~FormatterListener()
{
}
1.1 xml-xalan/c/src/XMLSupport/FormatterListener.hpp
Index: FormatterListener.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FORMATTERLISTENER_HEADER_GUARD_1357924680)
#define FORMATTERLISTENER_HEADER_GUARD_1357924680
/**
* $Id: FormatterListener.hpp,v 1.1 1999/12/18 19:47:52 robweir Exp $
*
* $State: Exp $
*
* @author David N. Bertoni ([email protected])
*/
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <sax/DocumentHandler.hpp>
class DOMString;
/**
* A SAX-based formatter interface for the XSL processor. This interface
* will be called as result tree elements are constructed.
*/
class XALAN_XMLSUPPORT_EXPORT FormatterListener : public DocumentHandler
{
public:
FormatterListener();
virtual
~FormatterListener();
virtual void
characters(
const XMLCh* const chars,
const unsigned int length) = 0;
virtual void
charactersRaw(
const XMLCh* const chars,
const unsigned int length) = 0;
virtual void
endDocument() = 0;
virtual void
endElement(const XMLCh* const name) = 0;
virtual void
ignorableWhitespace(
const XMLCh* const chars,
const unsigned int length) = 0;
virtual void
processingInstruction(
const XMLCh* const target,
const XMLCh* const data) = 0;
virtual void
resetDocument() = 0;
virtual void
setDocumentLocator(Locator* const locator) = 0;
virtual void
startDocument() = 0;
virtual void
startElement(
const XMLCh* const name,
AttributeList& attrs) = 0;
virtual void
comment(const XMLCh* const data) = 0;
virtual void
cdata(
const XMLCh* const ch,
const unsigned int length) = 0;
virtual void
entityReference(const XMLCh* const name) = 0;
};
#endif // FORMATTERLISTENER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/FormatterToDOM.cpp
Index: FormatterToDOM.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FormatterToDOM.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <include/DOMHelper.hpp>
FormatterToDOM::FormatterToDOM(
const DOM_Document& doc,
const DOM_DocumentFragment& docFrag,
const DOM_Element&
currentElement) :
m_docFrag(docFrag),
m_doc(doc),
m_currentElem(currentElement),
m_elemStack()
{
}
FormatterToDOM::FormatterToDOM(
const DOM_Document& doc,
const DOM_Element& elem) :
m_docFrag(),
m_doc(doc),
m_currentElem(elem),
m_elemStack()
{
}
FormatterToDOM::~FormatterToDOM()
{
}
void
FormatterToDOM::setDocumentLocator(Locator* const /* locator */)
{
// No action for the moment.
}
void
FormatterToDOM::startDocument()
{
// No action for the moment.
}
void
FormatterToDOM::endDocument()
{
// No action for the moment.
}
void
FormatterToDOM::startElement(
const XMLCh* const name,
AttributeList& attrs)
{
DOM_Element elem = m_doc.createElement(name);
const int nAtts = attrs.getLength();
for(int i = 0; i < nAtts; i++)
{
elem.setAttribute(attrs.getName(i), attrs.getValue(i));
}
append(elem);
m_elemStack.push(elem);
m_currentElem = elem;
}
void
FormatterToDOM::endElement(
const XMLCh* const /* name */)
{
m_elemStack.pop();
if(m_elemStack.empty() == false)
{
m_currentElem = m_elemStack.top();
}
else
{
m_currentElem = 0;
}
}
void
FormatterToDOM::characters(
const XMLCh* const chars,
const unsigned int length)
{
append(m_doc.createTextNode(DOMString(chars, length)));
}
void
FormatterToDOM::charactersRaw(
const XMLCh* const chars,
const unsigned int length)
{
append(m_doc.createProcessingInstruction("xslt-next-is-raw",
"formatter-to-dom"));
append(m_doc.createTextNode(DOMString(chars, length)));
}
void
FormatterToDOM::entityReference(const XMLCh* const name)
{
append(m_doc.createEntityReference(name));
}
void
FormatterToDOM::ignorableWhitespace(
const XMLCh* const chars,
const unsigned int length)
{
append(m_doc.createTextNode(DOMString(chars, length)));
}
void
FormatterToDOM::processingInstruction(
const XMLCh* const target,
const XMLCh* const data)
{
append(m_doc.createProcessingInstruction(DOMString(target),
DOMString(data)));
}
void
FormatterToDOM::resetDocument()
{
}
void
FormatterToDOM::comment(const XMLCh* const data)
{
append(m_doc.createComment(DOMString(data)));
}
void
FormatterToDOM::cdata(
const XMLCh* const ch,
const unsigned int length)
{
append(m_doc.createCDATASection(DOMString(ch, length)));
}
void
FormatterToDOM::append(const DOM_Node& newNode)
{
if(0 != m_currentElem)
{
m_currentElem.appendChild(newNode);
}
else if(0 != m_docFrag)
{
m_docFrag.appendChild(newNode);
}
else
{
m_doc.appendChild(newNode);
}
}
1.1 xml-xalan/c/src/XMLSupport/FormatterToDOM.hpp
Index: FormatterToDOM.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FORMATTERTODOM_HEADER_GUARD_1357924680)
#define FORMATTERTODOM_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <stack>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_Document.hpp>
// Base class header file.
#include <XMLSupport/FormatterListener.hpp>
/**
* This class takes SAX events (in addition to some extra events
* that SAX doesn't handle yet) and adds the result to a document
* or document fragment.
*/
class XALAN_XMLSUPPORT_EXPORT FormatterToDOM : public FormatterListener
{
public:
/**
* FormatterToDOM instance constructor... it will add the DOM nodes
* to the document fragment.
*/
FormatterToDOM(
const DOM_Document& doc,
const DOM_DocumentFragment& docFrag =
DOM_DocumentFragment(),
const DOM_Element&
currentElement = DOM_Element());
FormatterToDOM(
const DOM_Document& doc,
const DOM_Element& elem);
virtual
~FormatterToDOM();
public:
/**
* Receive an object for locating the origin of SAX document events.
*
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.</p>
*
* <p>Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.</p>
*
* @param locator An object that can return the location of
* any SAX document event.
* @see org.xml.sax.Locator
*/
virtual void
setDocumentLocator(Locator* const locator);
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
startDocument();
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endDocument();
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param atts The attributes attached to the element, if any.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see org.xml.sax.AttributeList
*/
virtual void
startElement(
const XMLCh* const name,
AttributeList& attrs);
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endElement(const XMLCh* const name);
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
characters(
const XMLCh* const chars,
const unsigned int length);
/**
* If available, when the disable-output-escaping attribute is used,
* output raw text without escaping.
*/
virtual void
charactersRaw(
const XMLCh* const chars,
const unsigned int length);
/**
* Receive notivication of a entityReference.
*/
virtual void
entityReference(const XMLCh* const name);
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
virtual void
ignorableWhitespace(
const XMLCh* const chars,
const unsigned int length);
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
processingInstruction(
const XMLCh* const target,
const XMLCh* const data);
virtual void
resetDocument();
/**
* Called when a Comment is to be constructed.
* @param data The comment data.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
comment(const XMLCh* const data);
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
cdata(
const XMLCh* const ch,
const unsigned int length);
private:
/**
* Append a node to the current container.
*/
void
append(const DOM_Node& newNode);
// Data members...
DOM_DocumentFragment m_docFrag;
DOM_Document m_doc;
DOM_Element m_currentElem;
std::stack<DOM_Element> m_elemStack;
};
#endif // FORMATTERTODOM_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/FormatterToHTML.cpp
Index: FormatterToHTML.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: FormatterToHTML.cpp,v 1.1 1999/12/18 19:47:52 robweir Exp $
*
* $State: Exp $
*
* @author David N. Bertoni <[email protected]>
*/
// Class header file.
#include "FormatterToHTML.hpp"
#include <cassert>
#include <climits>
#include <sax/SaxException.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/Writer.hpp>
const FormatterToHTML::EmptiesSetType
FormatterToHTML::s_empties =
FormatterToHTML::createEmpties();
const FormatterToHTML::EmptiesSetType
FormatterToHTML::s_attrempties =
FormatterToHTML::createAttrEmpties();
const FormatterToHTML::HTMLAttributesVectorType
FormatterToHTML::s_HTMLlat1 =
FormatterToHTML::createAttributes();
const FormatterToHTML::HTMLSymbolsVectorType
FormatterToHTML::s_HTMLsymbol1 =
FormatterToHTML::createSymbols();
const FormatterToHTML::StringSetType FormatterToHTML::s_nonblockelems =
FormatterToHTML::createNonBlockElems();
const FormatterToHTML::StringSetType FormatterToHTML::s_escapetb =
FormatterToHTML::createEscapeElems();
const FormatterToHTML::AttributesMapType FormatterToHTML::s_attruris =
FormatterToHTML::createAttributesMap();
FormatterToHTML::FormatterToHTML(
Writer& writer,
const DOMString& version,
bool doIndent,
int indent,
const DOMString& encoding,
const DOMString& mediaType,
const DOMString& doctypeSystem,
const DOMString& doctypePublic,
bool xmlDecl,
const DOMString& standalone,
const QNameVectorType* const cdataSectionElems) :
FormatterToXML( writer, version, doIndent, indent,
encoding, mediaType, doctypeSystem, doctypePublic,
xmlDecl, standalone, cdataSectionElems),
m_currentElementName()
{
}
FormatterToHTML::~FormatterToHTML()
{
}
void
FormatterToHTML::endDocument()
{
try
{
m_writer.write("\n");
}
catch(...)
{
throw SAXException();
}
FormatterToXML::endDocument();
}
void
FormatterToHTML::startElement(
const XMLCh* const name,
AttributeList& attrs)
{
DOMString theName(name);
if(true == m_needToOutputDocTypeDecl)
{
try
{
if((! isEmpty(m_doctypeSystem)) || (!
isEmpty(m_doctypePublic)))
{
m_writer.write("<!DOCTYPE ");
m_writer.write(name);
if(! isEmpty(m_doctypePublic))
{
m_writer.write(" PUBLIC \"");
m_writer.write(m_doctypePublic);
m_writer.write("\"");
}
if(! isEmpty(m_doctypeSystem))
{
if(isEmpty(m_doctypePublic))
m_writer.write(" SYSTEM \"");
else
m_writer.write(" \"");
m_writer.write(m_doctypeSystem);
m_writer.write("\"");
}
m_writer.write(">");
m_writer.write(m_lineSep);
}
else
{
m_writer.write("<!DOCTYPE ");
if(equals(theName, "HTML"))
m_writer.write("html"); // match Clark
else
m_writer.write(name);
if(! isEmpty(m_version))
{
// Not totally sure about this.
m_writer.write(" PUBLIC \"-//W3C//DTD
"+m_version+" //EN\">");
m_writer.write(m_lineSep);
}
else
{
m_writer.write(" PUBLIC \"-//W3C//DTD
HTML 4.0 Transitional//EN\">");
m_writer.write(m_lineSep);
}
}
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
}
m_needToOutputDocTypeDecl = false;
bool savedDoIndent = m_doIndent;
// @@ JMD: What's this ??
bool noLineBreak;
// If the previous element is a non-block element or the next
// element is a non-block element, then do not indent.
m_doIndent =
((s_nonblockelems.end() != s_nonblockelems.find(toUpperCase(theName)))
||
((! isEmpty(m_currentElementName)) &&
(s_nonblockelems.end() !=
s_nonblockelems.find(toUpperCase(m_currentElementName)))))
? false : true;
m_currentElementName = name;
try
{
writeParentTagEnd();
m_ispreserve = false;
if (shouldIndent() && !m_elemStack.empty())
{
m_startNewLine = true;
indent(m_writer, m_currentIndent);
}
m_writer.write('<');
m_writer.write(name);
int nAttrs = attrs.getLength();
for (int i = 0; i < nAttrs ; i++)
{
processAttribute(attrs.getName(i), attrs.getValue(i));
}
// Flag the current element as not yet having any children.
openElementForChildren();
m_currentIndent += m_indent;
m_isprevtext = false;
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
m_doIndent = savedDoIndent;
}
void
FormatterToHTML::endElement(
const XMLCh* const name)
{
try
{
m_currentIndent -= m_indent;
// name = name.toUpperCase();
const bool hasChildNodes = childNodesWereAdded();
bool isWhitespaceSensitive
= (s_nonblockelems.end() != s_nonblockelems.find(toUpperCase(name)));
if (hasChildNodes == true)
{
if (shouldIndent() == true && ! isWhitespaceSensitive)
indent(m_writer, m_currentIndent);
m_writer.write("</");
m_writer.write(name);
m_writer.write(">");
}
else
{
if(s_empties.find(toUpperCase(name)) == s_empties.end())
{
m_writer.write("></");
m_writer.write(name);
m_writer.write(">");
}
else
{
m_writer.write(">");
}
}
if (hasChildNodes == true)
{
m_ispreserve = m_preserves.top();
m_preserves.pop();
}
m_isprevtext = false;
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToHTML::characters(
const XMLCh* const chars,
const unsigned int length)
{
if(0 == length) return;
std::basic_string<XMLCh> msg(L"Invalid UTF-16 surrogate detected: ");
XMLCh buffer[32]; // Should be big enough
if(m_nextIsRaw)
{
m_nextIsRaw = false;
charactersRaw (chars, length);
return;
}
if((! isEmpty(m_currentElementName)) &&
(equalsIgnoreCase(m_currentElementName, "SCRIPT") ||
equalsIgnoreCase(m_currentElementName, "STYLE")))
{
try
{
writeParentTagEnd();
m_ispreserve = true;
if (shouldIndent())
indent(m_writer, m_currentIndent);
// m_writer.write("<![CDATA[");
// m_writer.write(chars, 0, length);
writeNormalizedChars(chars, 0, length, false);
// m_writer.write("]]>");
return;
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
}
try
{
writeParentTagEnd();
m_ispreserve = true;
int pos = 0;
int end = length;
for (int i = 0; i < end; i ++)
{
int ch = chars[i];
int chNum = ch;
if ('\n' == ch)
{
/*
java:
for(int k = 0; k < m_lineSepLen; k++)
{
m_charBuf[pos++] = m_lineSep.charAt(k);
}
*/
m_charBuf[pos++] = m_lineSep;
}
else if ('<' == ch)
{
pos = copyEntityIntoBuf("lt", pos);
}
else if ('>' == ch)
{
pos = copyEntityIntoBuf("gt", pos);
}
else if ('&' == ch)
{
pos = copyEntityIntoBuf("amp", pos);
}
else if((chNum >= 9) && (chNum <= 126))
{
m_charBuf[pos++] = ch;
}
else if((chNum >= 160) && (chNum <= 255))
{
pos = copyEntityIntoBuf(s_HTMLlat1[ch-160],
pos);
}
else if((chNum >= 913) && (chNum <= 982))
{
pos = copyEntityIntoBuf(s_HTMLsymbol1[ch-913],
pos);
}
else if (402 == ch)
{
pos = copyEntityIntoBuf("fnof", pos);
}
else if (m_isUTF8 && (0xd800 <= chNum && chNum <
0xdc00))
{
// UTF-16 surrogate
copyUTF16IntoBuf( chars, i, pos, length);
}
else if((ch >= 0x7F) && (ch <= m_maxCharacter))
{
// Hope this is right...
m_charBuf[pos++] = ch;
}
else
{
DOMString ds;
m_charBuf[pos++] = '&';
m_charBuf[pos++] = '#';
ds = LongToDOMString(chNum);
const XMLCh* pb = c_wstr(ds);
int nIntStr = ds.length();
for(int k = 0; k < nIntStr; k++)
{
m_charBuf[pos++] = *(pb+k);
}
m_charBuf[pos++] = ';';
}
// Use 80 as a best guess safe buffer
if(pos > MAXSAFECHARBUF)
{
m_writer.write(m_charBuf, 0, pos);
pos = 0;
}
}
m_writer.write(m_charBuf, 0, pos);
m_isprevtext = true;
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
}
void
FormatterToHTML::entityReference(const XMLCh* const name)
{
try
{
m_writer.write("&");
m_writer.write(name);
m_writer.write(";");
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToHTML::cdata(
const XMLCh* const ch,
const unsigned int length)
{
if(equalsIgnoreCase(m_currentElementName, "SCRIPT") ||
equalsIgnoreCase(m_currentElementName, "STYLE"))
{
try
{
writeParentTagEnd();
m_ispreserve = true;
if (shouldIndent() == true)
{
indent(m_writer, m_currentIndent);
}
// was: m_writer.write(ch, 0, length);
writeNormalizedChars(ch, 0, length, true);
}
catch(...)
{
throw SAXException();
}
}
else if(m_stripCData == true)
{
try
{
writeParentTagEnd();
m_ispreserve = true;
if (shouldIndent() == true)
{
indent(m_writer, m_currentIndent);
}
// m_writer.write("<![CDATA[");
m_writer.write(ch, 0, length);
// m_writer.write("]]>");
}
catch(...)
{
throw SAXException();
}
}
else
{
characters(ch, length);
}
}
void
FormatterToHTML::processAttribute(
const DOMString& name,
const DOMString& value)
{
try
{
if(!name.equals("xmlns") && !startsWith(name, "xmlns:"))
{
DOMString pval;
DOMString aname = toLowerCase(name);
if (equals(aname, "xml:lang")) aname = "lang";
// qualify with an element??
AttributesMapType::const_iterator it =
(s_attruris.find(toLowerCase(m_currentElementName)));
if (it != s_attruris.end())
{
const StringSetType val = (*it).second;
// Determine if value is in the set of strings
if(val.find(aname) != val.end())
pval = prepAttrURI(value,
m_attrSpecialChars, m_encoding);
else
pval = prepAttrString(value,
m_attrSpecialChars, m_encoding);
}
else
pval = prepAttrString(value,
m_attrSpecialChars, m_encoding);
if(s_attrempties.find(toLowerCase(aname)) ==
s_attrempties.end())
{
m_writer.write(' ');
m_writer.write(aname);
m_writer.write("=\"");
m_writer.write(pval);
m_writer.write('\"');
}
else
{
m_writer.write(' ');
if((pval.length() == 0) ||
equalsIgnoreCase(pval, aname))
{
m_writer.write(aname);
}
else
{
m_writer.write(aname);
m_writer.write("=\"");
m_writer.write(pval);
m_writer.write('\"');
}
}
}
}
catch(...)
{
throw SAXException();
}
}
/**
* Returns the specified <var>string</var> after substituting non ASCII
characters,
* with <CODE>%HH</CODE>, where HH is the hex of the byte value.
*
* @param string String to convert to XML format.
* @param specials Characters, should be represented in character
references.
* @param encoding CURRENTLY NOT IMPLEMENTED.
* @return XML-formatted string.
* @see #backReference
* NOTE: return value destroyed on subsequent calls
*/
const DOMString& FormatterToHTML::prepAttrURI(
const DOMString& string,
const DOMString& specials,
const DOMString& encoding)
// java: throws SAXException
{
static DOMString sb;
sb = "";
for (int i = 0; i < string.length(); i ++)
{
XMLCh ch = charAt(string, i);
DOMString sch(&ch, 1);
int ich = ch;
if(((ch > 0x1F) && // X'00 - 1F' not valid
(ch < 0x7F)) && // X'7F' not valid
(s_escapetb.find(sch)== s_escapetb.end()) ) //
characters in the table
{
sb += ch; // valid character, append it
}
else
{
// need to escape the character
int mask1 = 0xFF00;
int mask2 = 0x00FF;
assert (ich < 0xFFFF);
int b1 = (int)(((ich) & mask1) >> 8);
int b2 = (int)((ich) & mask2);
// if first 8 bytes are 0, no need to append them.
if (b1 != 0)
{
sb += "%";
sb += LongToHexDOMString(b1);
}
sb += "%";
sb += LongToHexDOMString(b2);
}
}
return sb;
}
FormatterToHTML::EmptiesSetType
FormatterToHTML::createEmpties()
{
EmptiesSetType theEmpties;
theEmpties.insert("AREA");
theEmpties.insert("BASE");
theEmpties.insert("BR");
theEmpties.insert("COL");
theEmpties.insert("HR");
theEmpties.insert("IMG");
theEmpties.insert("INPUT");
theEmpties.insert("LINK");
theEmpties.insert("META");
theEmpties.insert("PARAM");
// HTML 4.0 loose DTD
theEmpties.insert("BASEFONT");
theEmpties.insert("FRAME");
theEmpties.insert("ISINDEX");
return theEmpties;
}
FormatterToHTML::EmptiesSetType
FormatterToHTML::createAttrEmpties()
{
EmptiesSetType theEmpties;
theEmpties.insert("checked");
theEmpties.insert("disabled");
theEmpties.insert("readonly");
theEmpties.insert("multiple");
theEmpties.insert("disabled");
theEmpties.insert("selected");
return theEmpties;
}
FormatterToHTML::StringSetType
FormatterToHTML::createNonBlockElems()
{
StringSetType theElems;
theElems.insert("FONT");
// s_nonblockelems.insert("A");
theElems.insert("TD");
theElems.insert("IMG");
theElems.insert("B");
theElems.insert("I");
return theElems;
}
FormatterToHTML::StringSetType
FormatterToHTML::createEscapeElems()
{
StringSetType theElems;
theElems.insert("%");
theElems.insert("<");
theElems.insert(">");
// theElems.insert(" ");
// theElems.insert("#");
theElems.insert("{");
theElems.insert("}");
theElems.insert("[");
theElems.insert("]");
// theElems.insert("\\");
theElems.insert("|");
theElems.insert("^");
theElems.insert("\"");
// theElems.insert("'");
return theElems;
}
FormatterToHTML::AttributesMapType
FormatterToHTML::createAttributesMap()
{
AttributesMapType theAtts;
StringSetType URLAttrsHREFSingle;
URLAttrsHREFSingle.insert(DOMString("href"));
StringSetType URLAttrsCITESingle;
URLAttrsCITESingle.insert(DOMString("cite"));
theAtts.insert(std::make_pair(DOMString("base"), URLAttrsHREFSingle));
theAtts.insert(std::make_pair(DOMString("link"), URLAttrsHREFSingle));
theAtts.insert(std::make_pair(DOMString("area"), URLAttrsHREFSingle));
// From the HTML 4.0 spec: Note. The same conversion based on UTF-8
// should be applied to values of the name attribute for the A element.
StringSetType URLAttrs_A;
URLAttrs_A.insert(DOMString("href"));
URLAttrs_A.insert(DOMString("name"));
theAtts.insert(std::make_pair(DOMString("a"), URLAttrs_A));
StringSetType URLAttrs_INPUT;
URLAttrs_A.insert(DOMString("src"));
URLAttrs_A.insert(DOMString("usemap"));
theAtts.insert(std::make_pair(DOMString("input"), URLAttrs_INPUT));
StringSetType URLAttrs_SCRIPT;
URLAttrs_A.insert(DOMString("src"));
URLAttrs_A.insert(DOMString("for"));
theAtts.insert(std::make_pair(DOMString("script"), URLAttrs_SCRIPT));
StringSetType URLAttrs_IMG;
URLAttrs_A.insert(DOMString("src"));
URLAttrs_A.insert(DOMString("longdesc"));
URLAttrs_A.insert(DOMString("usemap"));
theAtts.insert(std::make_pair(DOMString("img"), URLAttrs_IMG));
StringSetType URLAttrs_OBJECT;
URLAttrs_A.insert(DOMString("classid"));
URLAttrs_A.insert(DOMString("codebase"));
URLAttrs_A.insert(DOMString("data"));
URLAttrs_A.insert(DOMString("archive"));
URLAttrs_A.insert(DOMString("usemap"));
theAtts.insert(std::make_pair(DOMString("object"), URLAttrs_OBJECT));
theAtts.insert(std::make_pair(DOMString("q"), URLAttrsCITESingle));
theAtts.insert(std::make_pair(DOMString("blockquote"),
URLAttrsCITESingle));
theAtts.insert(std::make_pair(DOMString("ins"), URLAttrsCITESingle));
theAtts.insert(std::make_pair(DOMString("del"), URLAttrsCITESingle));
StringSetType URLAttrs_FORM;
URLAttrs_A.insert(DOMString("action"));
theAtts.insert(std::make_pair(DOMString("form"), URLAttrs_FORM));
StringSetType URLAttrs_HEAD;
URLAttrs_A.insert(DOMString("profile"));
theAtts.insert(std::make_pair(DOMString("head"), URLAttrs_HEAD));
return theAtts;
}
FormatterToHTML::HTMLAttributesVectorType
FormatterToHTML::createAttributes()
{
static const char* const theHTMLAttributes[] =
{
"nbsp", "iexcl", "cent", "pound",
"curren", "yen", "brvbar", "sect",
"uml", "copy", "ordf", "laquo",
"not", "shy", "reg", "macr", "deg",
"plusmn", "sup2", "sup3", "acute",
"micro", "para", "middot", "cedil",
"sup1", "ordm", "raquo", "frac14",
"frac12", "frac34", "iquest",
"Agrave", "Aacute", "Acirc",
"Atilde", "Auml", "Aring", "AElig",
"Ccedil", "Egrave", "Eacute", "Ecirc",
"Euml", "Igrave", "Iacute", "Icirc",
"Iuml", "ETH", "Ntilde", "Ograve",
"Oacute", "Ocirc", "Otilde", "Ouml",
"times", "Oslash", "Ugrave", "Uacute",
"Ucirc", "Uuml", "Yacute", "THORN",
"szlig", "agrave", "aacute", "acirc",
"atilde", "auml", "aring", "aelig",
"ccedil", "egrave", "eacute", "ecirc",
"euml", "igrave", "iacute", "icirc",
"iuml", "eth", "ntilde", "ograve",
"oacute", "ocirc", "otilde", "ouml",
"divide", "oslash", "ugrave", "uacute",
"ucirc", "uuml", "yacute", "thorn",
"yuml"
};
static const size_t theArraySize =
sizeof(theHTMLAttributes) /
sizeof(theHTMLAttributes[0]);
HTMLAttributesVectorType theAttributes;
theAttributes.reserve(theArraySize);
for(size_t i = 0; i < theArraySize; i++)
{
theAttributes.push_back(theHTMLAttributes[i]);
}
return theAttributes;
}
FormatterToHTML::HTMLSymbolsVectorType
FormatterToHTML::createSymbols()
{
static const char* const theHTMLSymbols[] =
{
"Alpha", "Beta",
"Gamma", "Delta", "Epsilon", "Zeta",
"Eta", "Theta", "Iota", "Kappa",
"Lambda", "Mu", "Nu", "Xi",
"Omicron", "Pi", "Rho", "Sigma",
"Tau", "Upsilon", "Phi", "Chi",
"Psi", "Omega", "alpha", "beta",
"gamma", "delta", "epsilon", "zeta",
"eta", "theta", "iota", "kappa",
"lambda", "mu", "nu", "xi",
"omicron", "pi", "rho", "sigmaf",
"sigma", "tau", "upsilon", "phi",
"chi", "psi", "omega", "thetasym",
"upsih", "piv"
};
static const size_t theArraySize =
sizeof(theHTMLSymbols) / sizeof(theHTMLSymbols[0]);
HTMLSymbolsVectorType theSymbols;
theSymbols.reserve(theArraySize);
for(size_t i = 0; i < theArraySize; i++)
{
theSymbols.push_back(theHTMLSymbols[i]);
}
return theSymbols;
}
1.1 xml-xalan/c/src/XMLSupport/FormatterToHTML.hpp
Index: FormatterToHTML.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FORMATTERTOHTML_HEADER_GUARD_1357924680)
#define FORMATTERTOHTML_HEADER_GUARD_1357924680
/**
* $Id: FormatterToHTML.hpp,v 1.1 1999/12/18 19:47:52 robweir Exp $
*
* $State: Exp $
*
* @author David N. Bertoni <[email protected]>
*/
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <set>
#include <map>
#include <vector>
// Base class header file.
#include <XMLSupport/FormatterToXML.hpp>
#include <XPath/QName.hpp>
typedef std::vector<QName> QNameVectorType;
/**
* FormatterToHTML formats SAX-style events into HTML.
*/
class XALAN_XMLSUPPORT_EXPORT FormatterToHTML : public FormatterToXML
{
public:
/**
* Constructor for customized encoding and doctype.
* @param writer The character output stream to use.
* @param encoding Java character encoding in use by
<VAR>writer</VAR>.
* @param doctype String to be printed at the top of the document.
* @param indent Number of spaces to indent at each nesting
level.
*/
FormatterToHTML(
Writer& writer,
const DOMString& version,
bool doIndent,
int indent,
const DOMString& encoding,
const DOMString& mediaType,
const DOMString& doctypeSystem,
const DOMString& doctypePublic,
bool xmlDecl,
const DOMString& standalone,
const QNameVectorType* const cdataSectionElems);
virtual
~FormatterToHTML();
/**
* Receive notification of the end of a document.
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endDocument();
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param atts The attributes attached to the element, if any.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see org.xml.sax.AttributeList
*/
virtual void
startElement(
const XMLCh* const name,
AttributeList& attrs);
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endElement(const XMLCh* const name);
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
characters(
const XMLCh* const chars,
const unsigned int length);
/**
* Receive notivication of a entityReference.
*/
virtual void
entityReference(const XMLCh* const name);
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
cdata(
const XMLCh* const ch,
const unsigned int length);
protected:
/**
* Process an attribute.
* @param name The name of the attribute.
* @param value The value of the attribute.
*/
virtual void
processAttribute(
const DOMString& name,
const DOMString& value);
/**
* Returns the specified <var>string</var> after substituting non ASCII
characters,
* with <CODE>%HH</CODE>, where HH is the hex of the byte value.
*
* @param string String to convert to XML format.
* @param specials Chracters, should be represeted in chracter
referenfces.
* @param encoding CURRENTLY NOT IMPLEMENTED.
* @return XML-formatted string.
* @see #backReference
* NOTE: return value destroyed on subsequent calls
*/
const DOMString& prepAttrURI(
const DOMString& string,
const DOMString& specials,
const DOMString& encoding);
// java: throws SAXException
public:
// Static tables.
typedef std::set<DOMString> EmptiesSetType;
typedef std::vector<DOMString> HTMLAttributesVectorType;
typedef std::vector<DOMString> HTMLSymbolsVectorType;
typedef std::set<DOMString> StringSetType;
// java: hashtable(map) to String vector
typedef std::map<DOMString, StringSetType> AttributesMapType;
static EmptiesSetType
createEmpties();
static EmptiesSetType
createAttrEmpties();
static HTMLAttributesVectorType
createAttributes();
static StringSetType
createNonBlockElems();
static StringSetType
createEscapeElems();
static AttributesMapType
createAttributesMap();
static HTMLSymbolsVectorType
createSymbols();
private:
static const EmptiesSetType s_empties;
static const EmptiesSetType s_attrempties;
static const HTMLAttributesVectorType s_HTMLlat1;
static const HTMLSymbolsVectorType s_HTMLsymbol1;
static const StringSetType
s_nonblockelems;
static const AttributesMapType s_attruris;
static const StringSetType
s_escapetb;
DOMString
m_currentElementName;
};
#endif // FORMATTERTOHTML_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/FormatterToText.cpp
Index: FormatterToText.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FormatterToText.hpp"
#include <sax\SAXException.hpp>
#include <PlatformSupport/Writer.hpp>
FormatterToText::FormatterToText(
Writer& pw) :
m_pw(pw)
{
}
FormatterToText::~FormatterToText()
{
}
void
FormatterToText::setDocumentLocator(Locator* /* locator */)
{
// No action for the moment.
}
void
FormatterToText::startDocument()
{
// No action for the moment.
}
void
FormatterToText::endDocument()
{
try
{
m_pw.close();
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToText::startElement(
const XMLCh* const /* name */,
AttributeList& /* attrs */)
{
// No action for the moment.
}
void
FormatterToText::endElement(
const XMLCh* const /* name */)
{
// No action for the moment.
}
void
FormatterToText::characters(
const XMLCh* const chars,
const unsigned int length)
{
try
{
m_pw.write(chars, 0, length);
m_pw.flush();
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToText::charactersRaw(
const XMLCh* const chars,
const unsigned int length)
{
characters(chars, length);
}
void
FormatterToText::entityReference(const XMLCh* const /* name */)
{
// No action for the moment.
}
void
FormatterToText::ignorableWhitespace(
const XMLCh* const /* chars */,
const unsigned int /* length */)
{
// No action for the moment.
}
void
FormatterToText::processingInstruction(
const XMLCh* const /* target */,
const XMLCh* const /* data */)
{
// No action for the moment.
}
void
FormatterToText::resetDocument()
{
// No action for the moment.
}
void
FormatterToText::comment(const XMLCh* const /* data */)
{
// No action for the moment.
}
void
FormatterToText::cdata(
const XMLCh* const ch,
const unsigned int length)
{
try
{
m_pw.write(ch, 0, length);
m_pw.flush();
}
catch(...)
{
throw SAXException();
}
}
1.1 xml-xalan/c/src/XMLSupport/FormatterToText.hpp
Index: FormatterToText.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FORMATTERTOTEXT_HEADER_GUARD_1357924680)
#define FORMATTERTOTEXT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
// Base class header file.
#include <XMLSupport/FormatterListener.hpp>
class Writer;
class Locator;
/**
* This class takes SAX events (in addition to some extra events
* that SAX doesn't handle yet) and produces simple text only.
*/
class XALAN_XMLSUPPORT_EXPORT FormatterToText : public FormatterListener
{
public:
/**
* FormatterToText instance constructor... it will add the DOM nodes
* to the document fragment.
*/
FormatterToText(Writer& pw);
virtual
~FormatterToText();
/**
* Receive an object for locating the origin of SAX document events.
*
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.</p>
*
* <p>Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.</p>
*
* @param locator An object that can return the location of
* any SAX document event.
* @see org.xml.sax.Locator
*/
virtual void
setDocumentLocator(Locator* const locator);
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
startDocument();
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endDocument();
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param atts The attributes attached to the element, if any.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see org.xml.sax.AttributeList
*/
virtual void
startElement(
const XMLCh* const name,
AttributeList& attrs);
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endElement(const XMLCh* const name);
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
characters(
const XMLCh* const chars,
const unsigned int length);
/**
* If available, when the disable-output-escaping attribute is used,
* output raw text without escaping.
*/
virtual void
charactersRaw(
const XMLCh* const chars,
const unsigned int length);
/**
* Receive notivication of a entityReference.
*/
virtual void
entityReference(const XMLCh* const name);
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
virtual void
ignorableWhitespace(
const XMLCh* const chars,
const unsigned int length);
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
processingInstruction(
const XMLCh* const target,
const XMLCh* const data);
virtual void
resetDocument();
/**
* Called when a Comment is to be constructed.
* @param data The comment data.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
comment(const XMLCh* const data);
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
cdata(
const XMLCh* const ch,
const unsigned int length);
private:
Writer& m_pw;
// These are not implemented.
FormatterToText(const FormatterToText&);
FormatterToText&
operator=(const FormatterToText&);
bool
operator==(const FormatterToText&) const;
};
#endif // FORMATTERTOTEXT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/FormatterToXML.cpp
Index: FormatterToXML.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FormatterToXML.hpp"
#include <sax/AttributeList.hpp>
#include <sax/SAXException.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/Writer.hpp>
#include <string>
namespace
{
const char* const theDefaultAttrSpecialChars = "<>&\"\'\r\n";
};
const DOMString FormatterToXML::DEFAULT_MIME_ENCODING = "UTF-8";
XMLCh FormatterToXML::m_charBuf[MAXCHARBUF];
// This should be OK on all platforms ??
XMLCh FormatterToXML::m_lineSep = '\n';
bool FormatterToXML::m_javaEncodingIsISO = false;
FormatterToXML::FormatterToXML(
Writer& writer,
const DOMString& /* version */,
bool doIndent,
int indent,
const DOMString& encoding,
const DOMString& /*mediaType */,
const DOMString& doctypeSystem,
const DOMString& doctypePublic,
bool xmlDecl,
const DOMString& /* standalone */,
const QNameVectorType* const /* cdataSectionElems */) :
FormatterListener(),
m_attrSpecialChars(theDefaultAttrSpecialChars),
m_currentIndent(0),
m_doctypePublic(doctypePublic),
m_doctypeSystem(doctypeSystem),
m_doIndent(doIndent),
m_elemStack(),
m_encoding(encoding),
m_escapeCData(false),
m_indent(indent),
m_ispreserve(false),
m_isprevtext(false),
m_level(0),
m_maxCharacter(0x007F),
m_needToOutputDocTypeDecl(true),
m_nextIsRaw(false),
m_preserves(),
m_shouldWriteXMLHeader(xmlDecl),
m_spaceBeforeClose(false),
m_startNewLine(true),
m_stripCData(false),
m_version(""),
m_writer(writer)
{
if(! isEmpty(m_doctypePublic))
{
if(startsWith(m_doctypePublic, "-//W3C//DTD XHTML"))
m_spaceBeforeClose = true;
}
// Determine the last printable character based on the output format
// @@ JMD: We don't have no OutputFormat class yet ...
// java: m_maxCharacter = format.getLastPrintable();
m_isUTF8 = equals(m_encoding, "UTF-8") || isEmpty(m_encoding);
if(isEmpty(m_encoding))
{
/*
@@ JMD: Not supported yet:
java:
encoding = System.getProperty("file.encoding");
encoding = (null != encoding) ?
FormatterToXML.convertJava2MimeEncoding(encoding ) :
DEFAULT_MIME_ENCODING;
*/
m_encoding = DEFAULT_MIME_ENCODING;
}
DOMString2IntMapType::const_iterator it;
it = s_revsize.find(toUpperCase(m_encoding));
if (it != s_revsize.end())
m_maxCharacter = (*it).second;
m_isUTF8 = equals(m_encoding, "UTF-8");
it = s_revsize.find(toUpperCase(m_encoding));
if (it != s_revsize.end())
{
m_maxCharacter = (*it).second;
}
}
FormatterToXML::~FormatterToXML()
{
}
void
FormatterToXML::setDocumentLocator(Locator* const /* locator */)
{
// I don't do anything with this yet.
}
void
FormatterToXML::startDocument()
{
try
{
m_needToOutputDocTypeDecl = true;
m_startNewLine = false;
if(m_shouldWriteXMLHeader)
{
DOMString encoding = m_encoding;
if(isEmpty(encoding))
{
/*
java:
try
{
encoding =
System.getProperty("file.encoding");
encoding =
FormatterToXML.convertJava2MimeEncoding( encoding );
}
catch(SecurityException se)
{
encoding = "ISO-8859-1";
}
*/
encoding = "ISO-8859-1";
}
DOMString version = (isEmpty(m_version)) ? "1.0" :
m_version;
m_writer.write("<?xml version=\""+version+"\"
encoding=\""+
encoding + "\"?>");
m_writer.write(m_lineSep);
}
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
}
void
FormatterToXML::endDocument()
{
try
{
m_writer.flush();
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToXML::startElement(
const XMLCh* const name,
AttributeList& attrs)
{
try
{
if((true == m_needToOutputDocTypeDecl) && (!
isEmpty(m_doctypeSystem)))
{
m_writer.write("<!DOCTYPE ");
m_writer.write(name);
if(! isEmpty(m_doctypePublic))
{
m_writer.write(" PUBLIC \"");
m_writer.write(m_doctypePublic);
m_writer.write("\"");
}
if(isEmpty(m_doctypePublic))
m_writer.write(" SYSTEM \"");
else
m_writer.write(" \"");
m_writer.write(m_doctypeSystem);
m_writer.write("\">");
m_writer.write(m_lineSep);
}
m_needToOutputDocTypeDecl = false;
writeParentTagEnd();
m_ispreserve = false;
if (shouldIndent() && !m_elemStack.empty())
{
m_startNewLine = true;
indent(m_writer, m_currentIndent);
}
m_writer.write('<');
m_writer.write(name);
int nAttrs = attrs.getLength();
for (int i = 0; i < nAttrs ; i++)
{
processAttribute(attrs.getName(i), attrs.getValue(i));
}
// Flag the current element as not yet having any children.
openElementForChildren();
m_currentIndent += m_indent;
m_isprevtext = false;
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
}
void
FormatterToXML::endElement(const XMLCh* const name)
{
try
{
m_currentIndent -= m_indent;
const bool hasChildNodes = childNodesWereAdded();
if (hasChildNodes == true)
{
if (shouldIndent() == true)
indent(m_writer, m_currentIndent);
m_writer.write(DOMString("</") + name + DOMString(">"));
}
else
{
if(m_spaceBeforeClose)
m_writer.write(" />");
else
m_writer.write("/>");
}
if (hasChildNodes == true)
{
if (m_preserves.size() == 0)
{
m_ispreserve = false;
}
else
{
m_ispreserve = m_preserves.top();
m_preserves.pop();
}
}
m_isprevtext = false;
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToXML::characters(
const XMLCh* const chars,
const unsigned int length)
{
if(0 == length)
return;
if(m_nextIsRaw)
{
m_nextIsRaw = false;
charactersRaw (chars, length);
return;
}
try
{
writeParentTagEnd();
m_ispreserve = true;
int pos = 0;
int end = length;
for (int i = 0; i < end; i ++)
{
char ch = chars[i];
int chNum = ch;
if ('\n' == ch)
{
/*
java:
for(int k = 0; k < m_lineSepLen; k++)
{
m_charBuf[pos++] = m_lineSep.charAt(k);
}
*/
m_charBuf[pos++] = m_lineSep;
}
else if ('<' == ch)
{
pos = copyEntityIntoBuf("lt", pos);
}
else if ('>' == ch)
{
pos = copyEntityIntoBuf("gt", pos);
}
else if ('&' == ch)
{
pos = copyEntityIntoBuf("amp", pos);
}
// Regular old ASCII character
else if((((chNum >= 20) && (chNum <= 126))
|| (chNum == 10)
|| (chNum == 13)
|| (chNum == 9)))
{
// System.out.println("ch: "+ch);
m_charBuf[pos++] = ch;
}
else if((chNum >= 20) && (ch <= m_maxCharacter))
{
// System.out.println("ch(2): "+ch);
// Hope this is right...
m_charBuf[pos++] = ch;
}
else
{
copyBigCharIntoBuf(chars, i, pos, length);
}
// Use 80 as a best guess safe buffer
if(pos > MAXSAFECHARBUF)
{
m_writer.write(m_charBuf, 0, pos);
pos = 0;
}
}
// System.out.println(new String(m_charBuf, 0, pos));
m_writer.write(m_charBuf, 0, pos);
m_isprevtext = true;
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
}
void
FormatterToXML::charactersRaw(
const XMLCh* const chars,
const unsigned int length)
{
try
{
writeParentTagEnd();
m_ispreserve = true;
m_writer.write(chars, 0, length);
m_writer.flush();
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException();
}
}
void FormatterToXML::copyBigCharIntoBuf(
const XMLCh* const chars, // Character
string to process
int& i,
// Index into 'chars'
int& pos,
// Index in m_charBuf
int length,
// Length of 'chars' string
XMLCh* theBuffer /* m_charBuf */ //
Buffer to write to
)
/*
* Processes a non-ASCII character either in hexadecimal format (&#Xnnn;) if
* the character is in the range 0xd800 to 0xdc00 or decimal format (&#nnn;),
* and places the result in member 'm_charBuf.' Side effect, indices 'i' and
* 'pos' are incremented. On exit, 'theBuffer' will contain a null terminated
* Unicode string.
*/
{
DOMString msg("Invalid UTF-16 surrogate detected: ");
DOMString ds;
int c = chars[i];
if (0xd800 <= c && c < 0xdc00)
{
// UTF-16 surrogate
int next;
if (i+1 >= length)
{
msg = append(msg, LongToHexDOMString(c));
msg = append(msg, " ?");
throw SAXException(c_wstr(msg));
}
else
{
next = chars[++i];
if (!(0xdc00 <= next && next < 0xe000))
{
msg = append(msg, LongToHexDOMString(c));
msg = append(msg, " ");
msg = append(msg, LongToHexDOMString(next));
throw SAXException(c_wstr(msg));
}
next = ((c-0xd800)<<10)+next-0xdc00+0x00010000;
}
theBuffer[pos++] = '&';
theBuffer[pos++] = '#';
theBuffer[pos++] = 'x';
ds = LongToHexDOMString(next);
const XMLCh* pb = c_wstr(ds);
int nIntStr = ds.length();
for(int k = 0; k < nIntStr; k++)
{
theBuffer[pos++] = *(pb+k);
}
theBuffer[pos++] = ';';
}
else
{
theBuffer[pos++] = '&';
theBuffer[pos++] = '#';
ds = LongToDOMString(c);
const XMLCh* pb = c_wstr(ds);
int nIntStr = ds.length();
for(int k = 0; k < nIntStr; k++)
{
theBuffer[pos++] = *(pb+k);
}
theBuffer[pos++] = ';';
}
theBuffer[pos] = 0; // null terminate
}
void FormatterToXML::writeBigChar(const XMLCh* const ch, int& i, int end)
/*
* Writes a non-ASCII character either in hexadecimal format (&#Xnnn;) if the
* character is in the range 0xd800 to 0xdc00 or decimal format (&#nnn;); as a
* side effect the current character index (i) is incremented
*/
{
XMLCh buffer[32]; // Should be big enough
int pos = 0;
copyBigCharIntoBuf(ch, i, pos, end, buffer);
m_writer.write(buffer);
}
void FormatterToXML::writeNormalizedChars(
const XMLCh* const ch,
int start, int length,
bool isCData)
{
int end = start+length;
for(int i = start; i < end; i++)
{
XMLCh c = ch[i];
if('\n' == c)
{
m_writer.write(m_lineSep);
}
else if(isCData && (c > m_maxCharacter))
{
if(i != 0)
m_writer.write("]]>");
writeBigChar(ch, i, end);
// @@ JMD: this differs from java
// java: if((i != 0) && (i < (end-1)))
if( (i < (end-1)))
m_writer.write("<![CDATA[");
}
else if(isCData && ((i < (end-2)) && (']' == c) &&
(']' == ch[i+1]) && ('>' == ch[i+2])))
{
m_writer.write("]]]]><![CDATA[>");
i+=2;
}
else
{
if(c <= m_maxCharacter)
{
m_writer.write(c);
}
else
writeBigChar(ch, i, end);
}
}
}
void
FormatterToXML::entityReference(const XMLCh* const name)
{
try
{
writeParentTagEnd();
if (shouldIndent() == true)
{
indent(m_writer, m_currentIndent);
}
m_writer.write("&");
m_writer.write(name);
m_writer.write(";");
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToXML::ignorableWhitespace(
const XMLCh* const chars,
const unsigned int length)
{
characters(chars, length);
}
void
FormatterToXML::processingInstruction(
const XMLCh* const target,
const XMLCh* const data)
{
try
{
writeParentTagEnd();
if (shouldIndent() == true)
{
indent(m_writer, m_currentIndent);
}
m_writer.write("<?");
m_writer.write(target);
if (length(data) > 0 && !isSpace(data[0]))
{
m_writer.write(" ");
}
m_writer.write(data);
m_writer.write("?>");
m_startNewLine = true;
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToXML::resetDocument()
{
// I don't do anything with this yet.
}
void
FormatterToXML::comment(const XMLCh* const data)
{
try
{
writeParentTagEnd();
if (shouldIndent() == true)
{
indent(m_writer, m_currentIndent);
}
m_writer.write("<!--");
m_writer.write(data);
m_writer.write("-->");
m_startNewLine = true;
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToXML::cdata(
const XMLCh* const ch,
const unsigned int length)
{
try
{
if(m_nextIsRaw)
{
m_nextIsRaw = false;
charactersRaw (ch, length);
return;
}
if(m_escapeCData) // Should normally always be false.
{
characters(ch, length);
}
else
{
writeParentTagEnd();
m_ispreserve = true;
if (shouldIndent())
indent(m_writer, m_currentIndent);
if(!m_stripCData)
{
if(((length >= 1) && (ch[0] <= m_maxCharacter)))
{
m_writer.write("<![CDATA[");
}
}
// m_writer.write(ch, 0, length);
writeNormalizedChars(ch, 0, length, !m_stripCData);
if(!m_stripCData)
{
if(((length >= 1) && (ch[(length)-1] <=
m_maxCharacter)))
{
m_writer.write("]]>");
}
}
}
}
// java: catch(IOException ioe)
catch(...)
{
throw SAXException("IO error");
}
}
void
FormatterToXML::writeParentTagEnd()
{
try
{
if(!m_elemStack.empty())
{
// See if the parent element has already been flagged
as having children.
if(false == m_elemStack.top())
{
m_writer.write(">");
m_elemStack.pop();
m_elemStack.push(true);
m_preserves.push(m_ispreserve);
}
}
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToXML::openElementForChildren()
{
m_elemStack.push(false);
}
bool
FormatterToXML::childNodesWereAdded()
{
bool fResult = false;
if (m_elemStack.size() > 0)
{
fResult = m_elemStack.top();
m_elemStack.pop();
}
return fResult;
}
void
FormatterToXML::processAttribute(
const DOMString& name,
const DOMString& value)
{
try
{
m_writer.write(" ");
m_writer.write(name);
m_writer.write("=\"");
m_writer.write(prepAttrString(value, m_attrSpecialChars,
m_encoding));
m_writer.write("\"");
}
catch(...)
{
throw SAXException();
}
}
DOMString
FormatterToXML::prepAttrString(
const DOMString& string,
const DOMString& specials,
const DOMString& /* encoding */)
{
const int theLength = string.length();
// we'll do the work into a buffer pre-allocated to
// twice the size of the original string, giving some
// room to grow without reallocating.
//
// Whem DOMString has gets a better += operator
// for XMLCh and XMLCh*, a more straightforward
// solution will give good performance
std::vector<XMLCh> vec;
vec.reserve(theLength*2);
for (int i = 0; i < theLength; i ++)
{
const XMLCh ch = charAt(string, i);
const int chNum = static_cast<int>(ch);
const int index = indexOf(specials, ch);
if (index >= 0)
{
vec.push_back('&');
vec.push_back('#');
vec.push_back(ch);
vec.push_back(';');
}
else if (0xd800 <= chNum && chNum < 0xdc00)
{
// UTF-16 surrogate
int next = 0;
if (i + 1 >= theLength)
{
throw SAXException();
// $$$ ToDo: Fix this!!!
// throw new SAXException("Invalid UTF-16
surrogate detected: "
// +Integer.toHexString(ch)+ " ?");
}
else
{
next = charAt(string, ++i);
if (!(0xdc00 <= next && next < 0xe000))
{
throw SAXException();
// $$$ ToDo: Fix this!!!
// throw new SAXException("Invalid UTF-16
surrogate detected: "
// +Integer.toHexString(ch)+"
"+Integer.toHexString(next));
}
next = ((ch-0xd800)<<10) + next - 0xdc00 +
0x00010000;
}
vec.push_back('&');
vec.push_back('#');
vec.push_back('x');
DOMString num = LongToHexDOMString(next);
for (int k=0; k<num.length(); k++)
vec.push_back(num.charAt(k));
vec.push_back(';');
}
/*
else if (null != ctbc && !ctbc.canConvert(ch))
{
sb.append("&#x");
sb.append(Integer.toString((int)ch, 16));
sb.append(";");
}
*/
else
{
vec.push_back(ch);
}
}
vec.push_back('\0');
return DOMString(vec.begin());
}
bool
FormatterToXML::shouldIndent() const
{
return m_doIndent && (!m_ispreserve && !m_isprevtext);
}
void
FormatterToXML::printSpace(
Writer& pw,
int n)
{
try
{
for (int i = 0; i < n; i++)
{
pw.write(' ');
}
}
catch(...)
{
throw SAXException();
}
}
void
FormatterToXML::indent(
Writer& pw,
int n)
{
try
{
if(m_startNewLine == true)
{
pw.write('\n');
}
if(m_doIndent == true)
{
printSpace(pw, n);
}
}
catch(...)
{
throw SAXException();
}
}
int FormatterToXML::copyEntityIntoBuf(
const DOMString& s,
int pos)
{
const int l = length(s);
m_charBuf[pos++] = '&';
for(int i = 0; i < l; i++)
{
m_charBuf[pos++] = charAt(s, i);
}
m_charBuf[pos++] = ';';
return pos;
}
int FormatterToXML::copyUTF16IntoBuf(
const XMLCh* const chars, // Character
string to process
int& i,
// Index into 'chars'
int& pos,
// Index in m_charBuf
int length
// Length of 'chars' string
)
/*
* Processes a UTF-16 surrogate character sequence, and places the result in
* member 'm_charBuf.' Side effect, indices 'i' and 'pos' are incremented.
* Method consumes two characters from the input buffer
*/
{
std::basic_string<XMLCh> msg(L"Invalid UTF-16 surrogate detected: ");
XMLCh buffer[32]; // Should be big enough
// UTF-16 surrogate
int next;
int ch = chars[i];
if (i+1 >= length)
{
msg += _itow(ch, buffer, 16);
msg += L" ?";
throw SAXException(msg.c_str());
}
else
{
next = chars[++i];
if (!(0xdc00 <= next && next < 0xe000))
{
msg += _itow(ch, buffer, 16);
msg += L" ";
msg += _itow( next, buffer, 16);
throw SAXException(msg.c_str());
}
next = ((ch-0xd800)<<10)+next-0xdc00+0x00010000;
}
m_charBuf[pos++] = '&';
m_charBuf[pos++] = '#';
DOMString ds;
ds = LongToDOMString(ch);
const XMLCh* pb = c_wstr(ds);
int nIntStr = ds.length();
for(int k = 0; k < nIntStr; k++)
{
m_charBuf[pos++] = pb[k];
}
m_charBuf[pos++] = ';';
return pos;
}
FormatterToXML::DOMStringMapType FormatterToXML::s_enchash;
FormatterToXML::DOMStringMapType FormatterToXML::s_revhash;
FormatterToXML::DOMString2IntMapType FormatterToXML::s_revsize;
const DOMString FormatterToXML::convertMime2JavaEncoding(
const DOMString& mimeCharsetName)
{
if (m_javaEncodingIsISO) return mimeCharsetName;
DOMStringMapType::const_iterator it =
s_enchash.find(toUpperCase(mimeCharsetName));
return (*it).second;
}
const DOMString FormatterToXML::convertJava2MimeEncoding(
const DOMString& encoding)
{
if (m_javaEncodingIsISO) return encoding;
DOMStringMapType::const_iterator it =
s_revhash.find(toUpperCase(encoding));
return (*it).second;
}
void FormatterToXML::initEncodings()
{
if(0 != s_enchash.size())
return;
bool useISOPrefix = false;
/*
java:
try
{
java.io.ByteArrayOutputStream os = new
java.io.ByteArrayOutputStream();
os.write(32);
String s = os.toString("ISO8859_1");
// Just in case it doesn't throw an exception...
if(null == s)
useISOPrefix = false;
else
useISOPrefix = true;
}
catch (java.io.UnsupportedEncodingException e)
{
useISOPrefix = false;
}
*/
// A bit of a hack for the blackdown VMs (and probably some others).
/*
java:
try
{
String encoding = System.getProperty("file.encoding");
int dashindex = (encoding != null ? encoding.indexOf('-') : -1);
if(3 == dashindex)
{
String ISOprefix = new String(encoding.toCharArray(),
0, 3);
if (ISOprefix.equals("ISO") == true)
javaEncodingIsISO = true;
}
}
catch(SecurityException se)
{
}
*/
// Make a table to maximum character sizes before we
// need to resort to escaping in the XML.
// TODO: To tell the truth, I'm guessing a bit here.
// s_revsize.insert(std::make_pair("CP1252", 0xFF)); //
Windows Latin-1
s_revsize.insert(std::make_pair(DOMString("WINDOWS-1250"), 0xFF));
// Windows 1250 Peter Smolik
s_revsize.insert(std::make_pair(DOMString("UTF-8"), 0xFFFF));
// Universal Transformation Format 8
s_revsize.insert(std::make_pair(DOMString("US-ASCII"), 0x7F));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-1"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-2"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-3"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-4"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-5"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-6"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-7"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-8"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-8859-9"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("ISO-2022-JP"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("SHIFT_JIS"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("EUC-JP"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("GB2312"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("BIG5"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("EUC-KR"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("ISO-2022-KR"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("KOI8-R"), 0xFFFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-US"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-CA"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-NL"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-DK"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-NO"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-FI"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-SE"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-IT"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-ES"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-GB"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-FR"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-AR1"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-HE"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-CH"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-ROECE"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-YU"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-IS"), 0xFF));
s_revsize.insert(std::make_pair(DOMString("EBCDIC-CP-AR2"), 0xFF));
// <preferred MIME name>, <Java encoding name>
// s_enchash.insert(std::make_pair("ISO 8859-1", "CP1252")); // Close
enough, I guess
s_enchash.insert(std::make_pair(DOMString("WINDOWS-1250"),
DOMString("CP1250"))); // Peter Smolik
s_enchash.insert(std::make_pair(DOMString("UTF-8"), DOMString("UTF8")));
if(useISOPrefix)
{
s_enchash.insert(std::make_pair(DOMString("US-ASCII"),
DOMString("ISO8859_1"))); // ?
s_enchash.insert(std::make_pair(DOMString("ISO-8859-1"),
DOMString("ISO8859_1")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-2"),
DOMString("ISO8859_2")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-3"),
DOMString("ISO8859_3")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-4"),
DOMString("ISO8859_4")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-5"),
DOMString("ISO8859_5")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-6"),
DOMString("ISO8859_6")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-7"),
DOMString("ISO8859_7")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-8"),
DOMString("ISO8859_8")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-9"),
DOMString("ISO8859_9")));
}
else
{
s_enchash.insert(std::make_pair(DOMString("US-ASCII"),
DOMString("8859_1"))); // ?
s_enchash.insert(std::make_pair(DOMString("ISO-8859-1"),
DOMString("8859_1")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-2"),
DOMString("8859_2")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-3"),
DOMString("8859_3")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-4"),
DOMString("8859_4")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-5"),
DOMString("8859_5")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-6"),
DOMString("8859_6")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-7"),
DOMString("8859_7")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-8"),
DOMString("8859_8")));
s_enchash.insert(std::make_pair(DOMString("ISO-8859-9"),
DOMString("8859_9")));
}
s_enchash.insert(std::make_pair(DOMString("ISO-2022-JP"),
DOMString("JIS")));
s_enchash.insert(std::make_pair(DOMString("SHIFT_JIS"),
DOMString("SJIS")));
s_enchash.insert(std::make_pair(DOMString("EUC-JP"),
DOMString("EUCJIS")));
s_enchash.insert(std::make_pair(DOMString("GB2312"),
DOMString("GB2312")));
s_enchash.insert(std::make_pair(DOMString("BIG5"),
DOMString("Big5")));
s_enchash.insert(std::make_pair(DOMString("EUC-KR"),
DOMString("KSC5601")));
s_enchash.insert(std::make_pair(DOMString("ISO-2022-KR"),
DOMString("ISO2022KR")));
s_enchash.insert(std::make_pair(DOMString("KOI8-R"),
DOMString("KOI8_R")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-US"),
DOMString("CP037")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-CA"),
DOMString("CP037")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-NL"),
DOMString("CP037")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-DK"),
DOMString("CP277")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-NO"),
DOMString("CP277")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-FI"),
DOMString("CP278")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-SE"),
DOMString("CP278")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-IT"),
DOMString("CP280")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-ES"),
DOMString("CP284")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-GB"),
DOMString("CP285")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-FR"),
DOMString("CP297")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-AR1"),
DOMString("CP420")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-HE"),
DOMString("CP424")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-CH"),
DOMString("CP500")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-ROECE"),
DOMString("CP870")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-YU"),
DOMString("CP870")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-IS"),
DOMString("CP871")));
s_enchash.insert(std::make_pair(DOMString("EBCDIC-CP-AR2"),
DOMString("CP918")));
// j:CNS11643 -> EUC-TW?
// ISO-2022-CN? ISO-2022-CN-EXT?
// <Java encoding name>, <preferred MIME name>
s_revhash.insert(std::make_pair(DOMString("CP1252"),
DOMString("ISO-8859-1"))); // Close enough, I guess
s_revhash.insert(std::make_pair(DOMString("CP1250"),
DOMString("windows-1250"))); // Peter Smolik
s_revhash.insert(std::make_pair(DOMString("UTF8"), DOMString("UTF-8")));
//s_revhash.insert(std::make_pair(DOMString("ISO8859_1"),
DOMString("US-ASCII"))); // ?
if(useISOPrefix)
{
s_revhash.insert(std::make_pair(DOMString("ISO8859_1"),
DOMString("ISO-8859-1")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_2"),
DOMString("ISO-8859-2")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_3"),
DOMString("ISO-8859-3")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_4"),
DOMString("ISO-8859-4")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_5"),
DOMString("ISO-8859-5")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_6"),
DOMString("ISO-8859-6")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_7"),
DOMString("ISO-8859-7")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_8"),
DOMString("ISO-8859-8")));
s_revhash.insert(std::make_pair(DOMString("ISO8859_9"),
DOMString("ISO-8859-9")));
}
else
{
s_revhash.insert(std::make_pair(DOMString("8859_1"),
DOMString("ISO-8859-1")));
s_revhash.insert(std::make_pair(DOMString("8859_2"),
DOMString("ISO-8859-2")));
s_revhash.insert(std::make_pair(DOMString("8859_3"),
DOMString("ISO-8859-3")));
s_revhash.insert(std::make_pair(DOMString("8859_4"),
DOMString("ISO-8859-4")));
s_revhash.insert(std::make_pair(DOMString("8859_5"),
DOMString("ISO-8859-5")));
s_revhash.insert(std::make_pair(DOMString("8859_6"),
DOMString("ISO-8859-6")));
s_revhash.insert(std::make_pair(DOMString("8859_7"),
DOMString("ISO-8859-7")));
s_revhash.insert(std::make_pair(DOMString("8859_8"),
DOMString("ISO-8859-8")));
s_revhash.insert(std::make_pair(DOMString("8859_9"),
DOMString("ISO-8859-9")));
}
s_revhash.insert(std::make_pair(DOMString("JIS"),
DOMString("ISO-2022-JP")));
s_revhash.insert(std::make_pair(DOMString("SJIS"),
DOMString("Shift_JIS")));
s_revhash.insert(std::make_pair(DOMString("EUCJIS"),
DOMString("EUC-JP")));
s_revhash.insert(std::make_pair(DOMString("GB2312"),
DOMString("GB2312")));
s_revhash.insert(std::make_pair(DOMString("BIG5"), DOMString("Big5")));
s_revhash.insert(std::make_pair(DOMString("KSC5601"),
DOMString("EUC-KR")));
s_revhash.insert(std::make_pair(DOMString("ISO2022KR"),
DOMString("ISO-2022-KR")));
s_revhash.insert(std::make_pair(DOMString("KOI8_R"),
DOMString("KOI8-R")));
s_revhash.insert(std::make_pair(DOMString("CP037"),
DOMString("EBCDIC-CP-US")));
s_revhash.insert(std::make_pair(DOMString("CP037"),
DOMString("EBCDIC-CP-CA")));
s_revhash.insert(std::make_pair(DOMString("CP037"),
DOMString("EBCDIC-CP-NL")));
s_revhash.insert(std::make_pair(DOMString("CP277"),
DOMString("EBCDIC-CP-DK")));
s_revhash.insert(std::make_pair(DOMString("CP277"),
DOMString("EBCDIC-CP-NO")));
s_revhash.insert(std::make_pair(DOMString("CP278"),
DOMString("EBCDIC-CP-FI")));
s_revhash.insert(std::make_pair(DOMString("CP278"),
DOMString("EBCDIC-CP-SE")));
s_revhash.insert(std::make_pair(DOMString("CP280"),
DOMString("EBCDIC-CP-IT")));
s_revhash.insert(std::make_pair(DOMString("CP284"),
DOMString("EBCDIC-CP-ES")));
s_revhash.insert(std::make_pair(DOMString("CP285"),
DOMString("EBCDIC-CP-GB")));
s_revhash.insert(std::make_pair(DOMString("CP297"),
DOMString("EBCDIC-CP-FR")));
s_revhash.insert(std::make_pair(DOMString("CP420"),
DOMString("EBCDIC-CP-AR1")));
s_revhash.insert(std::make_pair(DOMString("CP424"),
DOMString("EBCDIC-CP-HE")));
s_revhash.insert(std::make_pair(DOMString("CP500"),
DOMString("EBCDIC-CP-CH")));
s_revhash.insert(std::make_pair(DOMString("CP870"),
DOMString("EBCDIC-CP-ROECE")));
s_revhash.insert(std::make_pair(DOMString("CP870"),
DOMString("EBCDIC-CP-YU")));
s_revhash.insert(std::make_pair(DOMString("CP871"),
DOMString("EBCDIC-CP-IS")));
s_revhash.insert(std::make_pair(DOMString("CP918"),
DOMString("EBCDIC-CP-AR2")));
}
1.1 xml-xalan/c/src/XMLSupport/FormatterToXML.hpp
Index: FormatterToXML.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FORMATTERTOXML_HEADER_GUARD_1357924680)
#define FORMATTERTOXML_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <stack>
#include <vector>
#include <map>
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
// Base class header file.
#include <XMLSupport/FormatterListener.hpp>
#include <XPath/QName.hpp>
typedef std::vector<QName> QNameVectorType;
class Writer;
/**
* FormatterToXML formats SAX-style events into XML.
*/
class XALAN_XMLSUPPORT_EXPORT FormatterToXML : public FormatterListener
{
public:
typedef std::map<DOMString, DOMString> DOMStringMapType;
typedef std::map<DOMString, int> DOMString2IntMapType;
/**
* These are characters that will be escaped in the output.
*/
DOMString m_attrSpecialChars;
static const DOMString DEFAULT_MIME_ENCODING;
/**
* If true, cdata sections are simply stripped of their
* CDATA brackets, without escaping.
*/
bool m_stripCData;
/**
* If true, characters in cdata sections are
* escaped, instead of being writted out as
* cdata sections.
*/
bool m_escapeCData;
bool m_shouldWriteXMLHeader;
/**
*
* Number of spaces to indent. The default is 2
*/
int m_indent;
/**
* Tells the XML version, for writing out to the XML decl.
*/
DOMString m_version;
/**
* Constructor for customized encoding and doctype.
* @param writer The character output stream to use.
* @param encoding Java character encoding in use by
<VAR>writer</VAR>.
* @param doctype String to be printed at the top of the document.
* @param indent Number of spaces to indent at each nesting
level.
*/
FormatterToXML(
Writer& writer,
const DOMString& version,
bool doIndent,
int indent,
const DOMString& encoding,
const DOMString& mediaType,
const DOMString& doctypeSystem,
const DOMString& doctypePublic,
bool xmlDecl,
const DOMString& standalone,
const QNameVectorType* const cdataSectionElems);
virtual
~FormatterToXML();
/**
* Receive an object for locating the origin of SAX document events.
*
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.</p>
*
* <p>Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.</p>
*
* @param locator An object that can return the location of
* any SAX document event.
* @see org.xml.sax.Locator
*/
virtual void
setDocumentLocator(Locator* const locator);
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
startDocument();
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endDocument();
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param atts The attributes attached to the element, if any.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see org.xml.sax.AttributeList
*/
virtual void
startElement(
const XMLCh* const name,
AttributeList& attrs);
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
endElement(const XMLCh* const name);
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
characters(
const XMLCh* const chars,
const unsigned int length);
/**
* If available, when the disable-output-escaping attribute is used,
* output raw text without escaping.
*/
virtual void
charactersRaw(
const XMLCh* const chars,
const unsigned int length);
/**
* Normalize the characters, but don't escape.
*/
void writeNormalizedChars(
const XMLCh* const ch,
int start, int length,
bool isCData);
void FormatterToXML::copyBigCharIntoBuf(
const XMLCh* const chars, // Character
string to process
int& i,
// Index into 'chars'
int& pos,
// Index in m_charBuf
int length,
// Length of 'chars' string
XMLCh* buf = m_charBuf // Buffer to
write to
);
void writeBigChar(const XMLCh* const ch, int& i, int end);
/**
* Receive notification of a entityReference.
*/
virtual void
entityReference(const XMLCh* const name);
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
virtual void
ignorableWhitespace(
const XMLCh* const chars,
const unsigned int length);
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
processingInstruction(
const XMLCh* const target,
const XMLCh* const data);
virtual void
resetDocument();
/**
* Called when a Comment is to be constructed.
* @param data The comment data.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void
comment(const XMLCh* const data);
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void
cdata(
const XMLCh* const ch,
const unsigned int length);
protected:
void
writeParentTagEnd();
void
openElementForChildren();
bool
childNodesWereAdded();
/**
* Process an attribute.
* @param name The name of the attribute.
* @param value The value of the attribute.
*/
void
processAttribute(
const DOMString& name,
const DOMString& value);
/**
* Returns the specified <var>string</var> after substituting
<VAR>specials</VAR>,
* and UTF-16 surrogates for chracter references <CODE>&#xnn</CODE>.
*
* @param string String to convert to XML format.
* @param specials Chracters, should be represeted in chracter
referenfces.
* @param encoding CURRENTLY NOT IMPLEMENTED.
* @return XML-formatted string.
* @see #backReference
*/
static DOMString
prepAttrString(
const DOMString& string,
const DOMString& specials,
const DOMString& encoding);
virtual bool
shouldIndent() const;
/**
* Prints <var>n</var> spaces.
* @param pw The character output stream to use.
* @param n Number of spaces to print.
* @exception IOException Thrown if <var>pw</var> is invalid.
*/
static void
printSpace(
Writer& pw,
int n);
/**
* Prints a newline character and <var>n</var> spaces.
* @param pw The character output stream to use.
* @param n Number of spaces to print.
* @exception IOException Thrown if <var>pw</var> is invalid.
*/
void
indent(
Writer& pw,
int n);
/**
* Convert a MIME charset name, also known as an XML encoding name, to a
Java encoding name.
* @param mimeCharsetName Case insensitive MIME charset name:
<code>UTF-8, US-ASCII, ISO-8859-1,
* ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5,
ISO-8859-6,
* ISO-8859-7, ISO-8859-8, ISO-8859-9,
ISO-2022-JP, Shift_JIS,
* EUC-JP, GB2312, Big5, EUC-KR, ISO-2022-KR,
KOI8-R,
* EBCDIC-CP-US, EBCDIC-CP-CA, EBCDIC-CP-NL,
EBCDIC-CP-DK,
* EBCDIC-CP-NO, EBCDIC-CP-FI, EBCDIC-CP-SE,
EBCDIC-CP-IT,
* EBCDIC-CP-ES, EBCDIC-CP-GB, EBCDIC-CP-FR,
EBCDIC-CP-AR1,
* EBCDIC-CP-HE, EBCDIC-CP-CH, EBCDIC-CP-ROECE,
EBCDIC-CP-YU,
* EBCDIC-CP-IS and EBCDIC-CP-AR2</code>.
* @return Java encoding name, or <var>null</var> if
<var>mimeCharsetName</var>
* is unknown.
* @see #reverse
*/
static const DOMString convertMime2JavaEncoding(const DOMString&
mimeCharsetName);
static const DOMString convertJava2MimeEncoding(const DOMString&
encoding);
static void initEncodings();
protected:
enum { MAXCHARBUF = 4096, MAXSAFECHARBUF = MAXCHARBUF - 256 };
static XMLCh m_charBuf[MAXCHARBUF];
static XMLCh m_lineSep;
bool m_needToOutputDocTypeDecl;
Writer& m_writer;
/**
* The maximum character value before we have to resort
* to escaping.
*/
XMLCh m_maxCharacter;
/**
* The character encoding. Not currently used.
*/
DOMString m_encoding;
/**
* Tell if the next text should be raw.
*/
bool m_nextIsRaw;
/**
* A stack of Boolean objects that tell if the given element
* has children.
*/
std::stack<bool> m_elemStack;
bool m_ispreserve;
std::stack<bool> m_preserves;
bool m_isprevtext;
bool m_doIndent;
int m_currentIndent;
int m_level;
DOMString m_doctypeSystem;
DOMString m_doctypePublic;
bool m_startNewLine;
/**
* Assume java encoding names are the same as the ISO encoding names if
this is true.
*/
static bool m_javaEncodingIsISO;
/**
* Flag to quickly tell if the encoding is UTF8.
*/
bool m_isUTF8;
/**
* Add space before '/>' for XHTML.
*/
bool m_spaceBeforeClose;
static DOMStringMapType s_enchash;
static DOMStringMapType s_revhash;
static DOMString2IntMapType s_revsize;
int copyEntityIntoBuf(
const DOMString& s,
int pos);
int copyUTF16IntoBuf(
const XMLCh* const chars,
int& i,
// Index into 'chars'
int& pos,
// Index in m_charBuf
int length
// Length of 'chars' string
);
private:
// These are not implemented.
FormatterToXML(const FormatterToXML&);
FormatterToXML&
operator=(const FormatterToXML&);
bool
operator==(const FormatterToXML&) const;
};
#endif // FORMATTERTOXML_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/FormatterTreeWalker.cpp
Index: FormatterTreeWalker.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FormatterTreeWalker.hpp"
// Xerces header files...
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Comment.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_DocumentFragment.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOM_ProcessingInstruction.hpp>
#include <dom/DOM_Text.hpp>
// XSL4C header files.
#include <include/DOMHelper.hpp>
#include <PlatformSupport/AttributeListImpl.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/NamedNodeMapAttributeList.hpp>
#include "FormatterListener.hpp"
FormatterTreeWalker::FormatterTreeWalker(FormatterListener&
formatterListener) :
TreeWalker(),
m_formatterListener(formatterListener)
{
}
FormatterTreeWalker::~FormatterTreeWalker()
{
}
void
FormatterTreeWalker::startNode(const DOM_Node& node)
{
switch(node.getNodeType())
{
case DOM_Node::COMMENT_NODE:
{
const DOM_Comment& theCommentNode =
static_cast<const DOM_Comment&>(node);
m_formatterListener.comment(c_wstr(theCommentNode.getData()));
}
break;
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
// ??
break;
case DOM_Node::DOCUMENT_NODE:
m_formatterListener.startDocument();
break;
case DOM_Node::ELEMENT_NODE:
{
const DOM_Element& theElementNode =
static_cast<const DOM_Element&>(node);
DOM_NamedNodeMap atts =
theElementNode.getAttributes();
NamedNodeMapAttributeList theAttributeList(atts);
m_formatterListener.startElement(c_wstr(theElementNode.getNodeName()),
theAttributeList);
}
break;
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
{
const DOM_ProcessingInstruction& thePI =
static_cast<const
DOM_ProcessingInstruction&>(node);
m_formatterListener.processingInstruction(c_wstr(thePI.getNodeName()),
c_wstr(thePI.getData()));
}
break;
case DOM_Node::CDATA_SECTION_NODE:
{
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(node);
const DOMString data = theTextNode.getData();
m_formatterListener.cdata(c_wstr(data),
length(data));
}
break;
case DOM_Node::TEXT_NODE:
{
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(node);
const DOMString data = theTextNode.getData();
m_formatterListener.characters(c_wstr(data),
length(data));
}
break;
case DOM_Node::ENTITY_REFERENCE_NODE:
m_formatterListener.entityReference(c_wstr(node.getNodeName()));
break;
default:
// Do nothing...
break;
}
}
void
FormatterTreeWalker::endNode(const DOM_Node& node)
{
switch(node.getNodeType())
{
case DOM_Node::DOCUMENT_NODE:
m_formatterListener.endDocument();
break;
case DOM_Node::ELEMENT_NODE:
m_formatterListener.endElement(c_wstr(node.getNodeName()));
break;
default:
// Do nothing
break;
}
}
1.1 xml-xalan/c/src/XMLSupport/FormatterTreeWalker.hpp
Index: FormatterTreeWalker.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FORMATTERTREEWALKER_HEADER_GUARD_1357924680)
#define FORMATTERTREEWALKER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <DOMSupport/TreeWalker.hpp>
class DOM_Node;
class FormatterListener;
class XALAN_XMLSUPPORT_EXPORT FormatterTreeWalker : public TreeWalker
{
public:
/**
* Constructor.
* @param formatterListener The implemention of the
* FormatterListener operation (toXMLString, digest, ...)
*/
FormatterTreeWalker(FormatterListener& formatterListener);
virtual
~FormatterTreeWalker();
protected:
virtual void
startNode(const DOM_Node& node);
virtual void
endNode(const DOM_Node& node);
private:
FormatterListener& m_formatterListener;
};
#endif // FORMATTERTREEWALKER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/NSInfo.hpp
Index: NSInfo.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NSINFO_HEADER_GUARD_1357924680)
#define NSINFO_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Note that this call has no export definition, since everything is inline.
class NSInfo
{
public:
enum eHasXMLNSAttrs { ANCESTORXMLNSUNPROCESSED,
ANCESTORHASXMLNS,
ANCESTORNOXMLNS };
explicit
NSInfo(bool hasProcessedNS = false,
bool hasXMLNSAttrs = false) :
m_hasProcessedNS(hasProcessedNS),
m_hasXMLNSAttrs(hasXMLNSAttrs),
m_namespace(),
m_ancestorHasXMLNSAttrs(ANCESTORXMLNSUNPROCESSED)
{
};
// Unused at the moment
NSInfo(bool hasProcessedNS,
bool hasXMLNSAttrs,
eHasXMLNSAttrs ancestorHasXMLNSAttrs) :
m_hasProcessedNS(hasProcessedNS),
m_hasXMLNSAttrs(hasXMLNSAttrs),
m_ancestorHasXMLNSAttrs(ancestorHasXMLNSAttrs),
m_namespace()
{
};
NSInfo(DOMString theNamespace,
bool hasXMLNSAttrs) :
m_hasProcessedNS(true),
m_hasXMLNSAttrs(hasXMLNSAttrs),
m_namespace(theNamespace),
m_ancestorHasXMLNSAttrs(ANCESTORXMLNSUNPROCESSED)
{
};
~NSInfo()
{
}
bool
operator==(const NSInfo& theRHS) const
{
return equals(m_namespace, theRHS.m_namespace) &&
equals(m_hasXMLNSAttrs, theRHS.m_hasXMLNSAttrs) &&
equals(m_hasProcessedNS, theRHS.m_hasProcessedNS) &&
equals(m_ancestorHasXMLNSAttrs,
theRHS.m_ancestorHasXMLNSAttrs);
}
DOMString m_namespace;
bool m_hasXMLNSAttrs;
bool m_hasProcessedNS;
eHasXMLNSAttrs m_ancestorHasXMLNSAttrs;
};
#endif // NSINFO_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/XMLParserLiaison.cpp
Index: XMLParserLiaison.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XMLParserLiaison.hpp"
XMLParserLiaison::XMLParserLiaison()
{
}
XMLParserLiaison::~XMLParserLiaison()
{
}
1.1 xml-xalan/c/src/XMLSupport/XMLParserLiaison.hpp
Index: XMLParserLiaison.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XMLPARSERLIAISON_HEADER_GUARD_1357924680)
#define XMLPARSERLIAISON_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
// Xerces DOM header files
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/Resettable.hpp>
class DocumentHandler;
class FormatterListener;
class InputSource;
class URLInputSource;
class XALAN_XMLSUPPORT_EXPORT XMLParserLiaison : Resettable
{
public:
XMLParserLiaison();
virtual
~XMLParserLiaison();
// These interfaces are inherited from Resettable...
/**
* Reset for new run.
*/
virtual void
reset() = 0;
// These interfaces are new to XMLParserLiaison
/**
* Returns true if the liaison supports the SAX DocumentHandler
* interface.
*/
virtual bool
supportsSAX() const = 0;
/**
* Parse the text pointed at by the reader as XML, and return
* a DOM Document interface. May return null if not
* supported. It is recommended that you pass in some sort
* of recognizable name, such as the filename or URI, with
* which the reader can be recognized if the parse fails.
* @param reader A stream that should hold valid XML.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual DOM_Document
parseXMLStream(
InputSource& reader,
const DOMString& identifier = DOMString()) = 0;
/**
* Parse the text pointed at by the reader as XML, and return
* a DOM Document interface. May return null if not
* supported. It is recommended that you pass in some sort
* of recognizable name, such as the filename or URI, with
* which the reader can be recognized if the parse fails.
* @param reader A URL input source that should hold valid XML.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual DOM_Document
parseXMLStream(
URLInputSource& reader,
const DOMString& identifier = DOMString()) = 0;
/**
* Parse the text pointed at by the reader as XML.
*
* @param reader A URL input source that should hold valid XML.
* @param handler An instance of a DocumentHandler.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual void
parseXMLStream(
InputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& identifier = DOMString()) = 0;
/**
* Parse the text pointed at by the reader as XML.
*
* @param reader A URL input source that should hold valid XML.
* @param handler An instance of a DocumentHandler.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual void
parseXMLStream(
URLInputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& identifier = DOMString()) = 0;
/**
* Create an empty DOM Document. Mainly used for creating an
* output document.
*/
virtual DOM_Document
createDocument() = 0;
virtual DOM_Document
getDOMFactory() = 0;
/**
* Return the expanded element name.
*/
virtual DOMString
getExpandedElementName(const DOM_Element& elem) const = 0;
/**
* Returns the attribute name with the namespace expanded.
*/
virtual DOMString
getExpandedAttributeName(const DOM_Attr& attr) const = 0;
/**
* Set special characters for attributes that will be escaped.
*/
virtual void
setSpecialCharacters(const DOMString& str) = 0;
/**
* Get special characters for attributes that will be escaped.
*/
virtual DOMString
getSpecialCharacters() const = 0;
/**
* Get the amount to indent when indent-result="yes".
*/
virtual int
getIndent() const = 0;
/**
* Set the amount to indent when indent-result="yes".
*/
virtual void
setIndent(int i) = 0;
/**
* Get whether or not to expand all entity references in the
* source and style trees.
*/
virtual bool
getShouldExpandEntityRefs() const = 0;
/**
* Set whether or not to expand all entity references in the
* source and style trees.
*/
virtual void
SetShouldExpandEntityRefs(bool b) = 0;
/**
* Get whether or not validation will be performed. Validation is off
by default.
*/
virtual bool
getUseValidation() const = 0;
/**
* If set to true, validation will be performed. Validation is off by
default.
*/
virtual void
setUseValidation(bool b) = 0;
/**
* Return a string suitable for telling the user what parser is being
used.
*/
virtual const DOMString&
getParserDescription() const = 0;
private:
// Not implemented
XMLParserLiaison(const XMLParserLiaison&);
XMLParserLiaison&
operator=(const XMLParserLiaison&);
};
#endif // XMLPARSERLIAISON_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/XMLParserLiaisonDefault.cpp
Index: XMLParserLiaisonDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XMLParserLiaisonDefault.hpp"
// Standard header files
#include <cassert>
#include <cstring>
// Xerces header files
#include <dom/DOM_Attr.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
// XSL4C header files
#include <include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/PrintWriter.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "FormatterToHTML.hpp"
#include "FormatterToXML.hpp"
#include "FormatterTreeWalker.hpp"
#include "XMLSupportException.hpp"
namespace
{
static const char* const theDefaultSpecialCharacters = "<>&\"\'\r\n";
};
XMLParserLiaisonDefault::XMLParserLiaisonDefault(
DOMSupport& theDOMSupport,
const DOMString& theParserDescription) :
XMLParserLiaison(),
Formatter(),
m_DOMSupport(theDOMSupport),
m_SpecialCharacters(theDefaultSpecialCharacters),
m_Indent(-1),
m_fShouldExpandEntityRefs(false),
m_fUseValidation(false),
m_ParserDescription(theParserDescription),
m_FormatterListener(0),
m_fOwnListener(false)
{
}
XMLParserLiaisonDefault::~XMLParserLiaisonDefault()
{
if (m_fOwnListener == true)
{
delete m_FormatterListener;
}
}
void
XMLParserLiaisonDefault::reset()
{
if (m_fOwnListener == true)
{
delete m_FormatterListener;
m_fOwnListener = false;
}
m_FormatterListener = 0;
m_DOMSupport.reset();
}
bool
XMLParserLiaisonDefault::supportsSAX() const
{
return false;
}
DOM_Document
XMLParserLiaisonDefault::parseXMLStream(
InputSource& /* reader */,
const DOMString& /* identifier */)
{
throw XMLSupportException("parseXMLStream() not supported in
XMLParserLiaisonDefault!");
return DOM_Document();
}
DOM_Document
XMLParserLiaisonDefault::parseXMLStream(
URLInputSource& /* reader */,
const DOMString& /* identifier */)
{
throw XMLSupportException("parseXMLStream() not supported in
XMLParserLiaisonDefault!");
return DOM_Document();
}
void
XMLParserLiaisonDefault::parseXMLStream(
InputSource& /* urlInputSource */,
DocumentHandler& /* handler */,
const DOMString& /* identifier */)
{
throw XMLSupportException("parseXMLStream() not supported in
XMLParserLiaisonDefault!");
}
void
XMLParserLiaisonDefault::parseXMLStream(
URLInputSource& /* urlInputSource */,
DocumentHandler& /* handler */,
const DOMString& /* identifier */)
{
throw XMLSupportException("parseXMLStream() not supported in
XMLParserLiaisonDefault!");
}
DOM_Document
XMLParserLiaisonDefault::createDocument()
{
throw XMLSupportException("createDocument() not supported in
XMLParserLiaisonDefault!");
return DOM_Document();
}
DOM_Document
XMLParserLiaisonDefault::getDOMFactory()
{
return createDocument();
}
/**
* Returns the element name with the namespace expanded.
*/
DOMString
XMLParserLiaisonDefault::getExpandedElementName(const DOM_Element&
elem) const
{
return m_DOMSupport.getExpandedElementName(elem);
}
/**
* Returns the attribute name with the namespace expanded.
*/
DOMString
XMLParserLiaisonDefault::getExpandedAttributeName(const DOM_Attr& attr)
const
{
return m_DOMSupport.getExpandedAttributeName(attr);
}
void
XMLParserLiaisonDefault::toMarkup(
const DOM_Document& doc,
PrintWriter& pw,
const DOMString& resultns,
bool format)
{
using std::auto_ptr;
auto_ptr<FormatterListener> visitor;
if(equals(trim(resultns), "http://www.w3.org/TR/REC-html40") == true)
{
FormatterToHTML* const htmlFormatVisitor =
new FormatterToHTML(pw,
DOMString(),
format,
m_Indent,
DOMString(), // encoding
DOMString(), // media type
// @@ JMD: ??
// was: "<!DOCTYPE html PUBLIC
\"-//W3C//DTD HTML 4.0 Transitional//EN\">\n",
DOMString(), // doctypeSystem
DOMString(), // doctypePublic
false, // xmlDecl
DOMString(), // standalone,
0);
#if defined(XALAN_OLD_AUTO_PTR)
visitor = auto_ptr<FormatterListener>(htmlFormatVisitor);
#else
visitor.reset(htmlFormatVisitor);
#endif
htmlFormatVisitor->m_attrSpecialChars = m_SpecialCharacters;
}
else
{
FormatterToXML* const fToXML =
new FormatterToXML(pw,
DOMString(),
format,
m_Indent,
DOMString(), // encoding
DOMString(), // media type
DOMString(), // doctypeSystem
DOMString(), // doctypePublic
true,
// xmlDecl
DOMString(), // standalone,
0);
#if defined(XALAN_OLD_AUTO_PTR)
visitor = auto_ptr<FormatterListener>(fToXML);
#else
visitor.reset(fToXML);
#endif
fToXML->m_attrSpecialChars = m_SpecialCharacters;
}
if(visitor.get() != 0)
{
FormatterTreeWalker treeTraversal(*visitor);
treeTraversal.traverse(doc);
}
}
void
XMLParserLiaisonDefault::setFormatterListener(
PrintWriter& pw,
const DOMString& resultns,
bool format)
{
if(equals(trim(resultns), "http://www.w3.org/TR/REC-html40") == true)
{
FormatterToHTML* const htmlFormatVisitor =
new FormatterToHTML(pw,
DOMString(),
format,
m_Indent,
DOMString(), // encoding
DOMString(), // media type
// @@ JMD: ??
// was: "<!DOCTYPE html PUBLIC
\"-//W3C//DTD HTML 4.0 Transitional//EN\">\n",
DOMString(), // doctypeSystem
DOMString(), // doctypePublic
false, // xmlDecl
DOMString(), // standalone,
0);
if (m_fOwnListener == true)
{
delete m_FormatterListener;
}
m_FormatterListener = htmlFormatVisitor;
m_fOwnListener = true;
htmlFormatVisitor->m_attrSpecialChars = m_SpecialCharacters;
}
else if(0 == m_FormatterListener)
{
FormatterToXML* const fToXML =
new FormatterToXML(pw,
DOMString(),
format,
m_Indent,
DOMString(), // encoding
DOMString(), // media type
DOMString(), // doctypeSystem
DOMString(), // doctypePublic
true, //
xmlDecl
DOMString(), // standalone,
0);
fToXML->m_attrSpecialChars = m_SpecialCharacters;
m_FormatterListener = fToXML;
m_fOwnListener = true;
}
}
void
XMLParserLiaisonDefault::setFormatterListener(FormatterListener* fl)
{
if (m_fOwnListener == true)
{
delete m_FormatterListener;
}
m_fOwnListener = false;
m_FormatterListener = fl;
}
FormatterListener*
XMLParserLiaisonDefault::getFormatterListener() const
{
return m_FormatterListener;
}
1.1 xml-xalan/c/src/XMLSupport/XMLParserLiaisonDefault.hpp
Index: XMLParserLiaisonDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XMLPARSERLIAISONDEFAULT_HEADER_GUARD_1357924680)
#define XMLPARSERLIAISONDEFAULT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
// Xalan header files.
#include <DOMSupport/DOMSupportDefault.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include <XMLSupport/Formatter.hpp>
class DOM_Text;
class XALAN_XMLSUPPORT_EXPORT XMLParserLiaisonDefault : public
XMLParserLiaison, public Formatter
{
public:
XMLParserLiaisonDefault(
DOMSupport& theDOMSupport,
const DOMString& theParserDescription =
DOMString("(No parser - generic DOM)"));
virtual
~XMLParserLiaisonDefault();
// These interfaces are inherited from Resettable...
/**
* Reset for new run.
*/
virtual void
reset();
// These interfaces are inherited from XMLParserLiaison...
/**
* Returns true if the liaison supports the SAX DocumentHandler
* interface.
*/
virtual bool
supportsSAX() const;
/**
* Parse the text pointed at by the reader as XML, and return
* a DOM Document interface. May return null if not
* supported. It is recommended that you pass in some sort
* of recognizable name, such as the filename or URI, with
* which the reader can be recognized if the parse fails.
* @param reader A stream that should hold valid XML.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual DOM_Document
parseXMLStream(
InputSource& reader,
const DOMString& identifier = DOMString());
/**
* Parse the text pointed at by the reader as XML, and return
* a DOM Document interface. May return null if not
* supported. It is recommended that you pass in some sort
* of recognizable name, such as the filename or URI, with
* which the reader can be recognized if the parse fails.
* @param reader A URL input source that should hold valid XML.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual DOM_Document
parseXMLStream(
URLInputSource& reader,
const DOMString& identifier = DOMString());
/**
* Parse the text pointed at by the reader as XML.
*
* @param reader A URL input source that should hold valid XML.
* @param handler An instance of a DocumentHandler.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual void
parseXMLStream(
InputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& identifier = DOMString());
/**
* Parse the text pointed at by the reader as XML.
*
* @param reader A URL input source that should hold valid XML.
* @param handler An instance of a DocumentHandler.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual void
parseXMLStream(
URLInputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& identifier = DOMString());
/**
* Create an empty DOM Document. Mainly used for creating an
* output document.
*/
virtual DOM_Document
createDocument();
virtual DOM_Document
getDOMFactory();
/**
* Return the expanded element name.
*/
virtual DOMString
getExpandedElementName(const DOM_Element& elem) const;
/**
* Returns the attribute name with the namespace expanded.
*/
virtual DOMString
getExpandedAttributeName(const DOM_Attr& attr) const;
/**
* Set special characters for attributes that will be escaped.
*/
virtual void
setSpecialCharacters(const DOMString& str) { m_SpecialCharacters =
str; }
/**
* Get special characters for attributes that will be escaped.
*/
virtual DOMString
getSpecialCharacters() const { return m_SpecialCharacters; }
/**
* Get the amount to indent when indent-result="yes".
*/
virtual int
getIndent() const { return m_Indent; }
/**
* Set the amount to indent when indent-result="yes".
*/
virtual void
setIndent(int i) { m_Indent = i; }
/**
* Get whether or not to expand all entity references in the
* source and style trees.
*/
virtual bool
getShouldExpandEntityRefs() const { return m_fShouldExpandEntityRefs; }
/**
* Set whether or not to expand all entity references in the
* source and style trees.
*/
virtual void
SetShouldExpandEntityRefs(bool b) { m_fShouldExpandEntityRefs = b; }
/**
* Get whether or not validation will be performed. Validation is off
by default.
*/
virtual bool
getUseValidation() const { return m_fUseValidation; }
/**
* If set to true, validation will be performed. Validation is off by
default.
*/
virtual void
setUseValidation(bool b) { m_fUseValidation = b; }
/**
* Return a string suitable for telling the user what parser is being
used.
*/
virtual const DOMString&
getParserDescription() const { return m_ParserDescription; }
// These interfaces are inherited from Formatter...
/**
* Print the result tree.
* @param doc The result tree.
* @param pw The PrintWriter to print the contents to.
* @param resultns the value of the resultns attribute.
* @param format Tells if it should be pretty-printed.
* @exception Exception thrown if the result tree is corrupted.
*/
virtual void
toMarkup(
const DOM_Document& doc,
PrintWriter& pw,
const DOMString& resultns,
bool format);
/**
* Get an instance of the formatter listener that is associated
* with this formatter.
*/
virtual FormatterListener*
getFormatterListener() const;
/**
* Set an instance of the formatter listener that is associated
* with this formatter.
*/
virtual void
setFormatterListener(
PrintWriter& pw,
const DOMString& resultns,
bool format);
/**
* Set an instance of the formatter listener that is associated
* with this formatter.
*/
virtual void
setFormatterListener(FormatterListener* fl);
protected:
// Data members...
DOMSupport& m_DOMSupport;
private:
// Not implemented...
XMLParserLiaisonDefault(const XMLParserLiaisonDefault&);
XMLParserLiaisonDefault&
operator=(const XMLParserLiaisonDefault&);
// Data members...
DOMString m_SpecialCharacters;
int m_Indent;
bool m_fShouldExpandEntityRefs;
bool m_fUseValidation;
const DOMString m_ParserDescription;
FormatterListener* m_FormatterListener;
bool m_fOwnListener;
};
#endif // XMLPARSERLIAISONDEFAULT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/XMLSupportDefinitions.hpp
Index: XMLSupportDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XMLSUPPORT_DEFINITIONS_HEADER_GUARD_1357924680)
#define XMLSUPPORT_DEFINITIONS_HEADER_GUARD_1357924680
#include <include/PlatformDefinitions.hpp>
#if defined(XALAN_XMLSUPPORT_BUILD_DLL)
#define XALAN_XMLSUPPORT_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_XMLSUPPORT_EXPORT_FUNCTION(T) XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_XMLSUPPORT_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_XMLSUPPORT_EXPORT_FUNCTION(T) XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // XMLSUPPORT_DEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XMLSupport/XMLSupportException.cpp
Index: XMLSupportException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XMLSupportException.hpp"
XMLSupportException::XMLSupportException(const DOMString& message) :
XSLException(message)
{
}
XMLSupportException::~XMLSupportException()
{
}
1.1 xml-xalan/c/src/XMLSupport/XMLSupportException.hpp
Index: XMLSupportException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XMLSUPPORTEXCEPTION_HEADER_GUARD_1357924680)
#define XMLSUPPORTEXCEPTION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XMLSupport/XMLSupportDefinitions.hpp>
#include <dom/DOMString.hpp>
// Base class header file.
#include <PlatformSupport/XSLException.hpp>
class XALAN_XMLSUPPORT_EXPORT XMLSupportException : public XSLException
{
public:
explicit
XMLSupportException(
const DOMString& message = DOMString());
virtual
~XMLSupportException();
private:
};
#endif // XMLSUPPORTEXCEPTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/ElementPrefixResolverProxy.cpp
Index: ElementPrefixResolverProxy.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElementPrefixResolverProxy.hpp"
#include "XPathSupport.hpp"
ElementPrefixResolverProxy::ElementPrefixResolverProxy(
const DOM_Element& namespaceContext,
const XPathSupport& support) :
m_namespaceContext(namespaceContext),
m_support(support)
{
}
ElementPrefixResolverProxy::~ElementPrefixResolverProxy()
{
}
DOMString
ElementPrefixResolverProxy::getNamespaceForPrefix(const DOMString& prefix)
const
{
return m_support.getNamespaceForPrefix(prefix, m_namespaceContext);
}
1.1 xml-xalan/c/src/XPath/ElementPrefixResolverProxy.hpp
Index: ElementPrefixResolverProxy.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(ELEMENTPREFIXRESOLVERPROXY_HEADER_GUARD_1357924680)
#define ELEMENTPREFIXRESOLVERPROXY_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
// Base class header file...
#include <XPath/PrefixResolver.hpp>
class XPathSupport;
class XALAN_XPATH_EXPORT ElementPrefixResolverProxy : public PrefixResolver
{
public:
ElementPrefixResolverProxy(
const DOM_Element& namespaceContext,
const XPathSupport& support);
virtual
~ElementPrefixResolverProxy();
virtual DOMString
getNamespaceForPrefix(const DOMString& prefix) const;
private:
const DOM_Element m_namespaceContext;
const XPathSupport& m_support;
};
#endif // ELEMENTPREFIXRESOLVERPROXY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FoundIndex.cpp
Index: FoundIndex.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FoundIndex.hpp"
FoundIndex::FoundIndex() :
XPathException()
{
}
FoundIndex::~FoundIndex()
{
}
1.1 xml-xalan/c/src/XPath/FoundIndex.hpp
Index: FoundIndex.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FOUNDINDEX_HEADER_GUARD_1357924680)
#define FOUNDINDEX_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XPathException.hpp>
class XALAN_XPATH_EXPORT FoundIndex : public XPathException
{
public:
explicit
FoundIndex();
virtual
~FoundIndex();
};
#endif // FOUNDINDEX_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/Function.hpp
Index: Function.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTION_HEADER_GUARD_1357924680)
#define FUNCTION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
class DOM_Node;
class XObject;
class XPathExecutionContext;
// Base class for all XPath function classes.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT Function
{
public:
virtual
~Function()
{
}
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param executionContext The executing context.
* @param context The current context node.
* @param opPos The current op position.
* @param args A vector of pointers to XObject arguments.
* @return A pointer to the result XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
opPos,
const std::vector<XObject*>& args) = 0;
virtual Function*
clone() const = 0;
private:
// Not implemented...
Function&
operator=(const Function&);
bool
operator==(const Function&) const;
};
#endif // FUNCTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionBoolean.hpp
Index: FunctionBoolean.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONBOOLEAN_HEADER_GUARD_1357924680)
#define FUNCTIONBOOLEAN_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionBoolean implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionBoolean : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 1)
{
executionContext.error("The boolean() function takes
one argument!",
context);
}
return
executionContext.getXObjectFactory().createBoolean(args[0]->boolean());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionBoolean*
#endif
clone() const
{
return new FunctionBoolean(*this);
}
private:
// Not implemented...
FunctionBoolean&
operator=(const FunctionBoolean&);
bool
operator==(const FunctionBoolean&) const;
};
#endif // FUNCTIONBOOLEAN_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionCeiling.hpp
Index: FunctionCeiling.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONCEILING_HEADER_GUARD_1357924680)
#define FUNCTIONCEILING_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <cmath>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionCeiling implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionCeiling : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 1)
{
executionContext.error("The ceiling() function takes
one argument!",
context);
}
return
executionContext.getXObjectFactory().createNumber(ceil(args[0]->num()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionCeiling*
#endif
clone() const
{
return new FunctionCeiling(*this);
}
private:
// Not implemented...
FunctionCeiling&
operator=(const FunctionCeiling&);
bool
operator==(const FunctionCeiling&) const;
};
#endif // FUNCTIONCEILING_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionConcat.hpp
Index: FunctionConcat.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONCONCAT_HEADER_GUARD_1357924680)
#define FUNCTIONCONCAT_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionConcat implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionConcat : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
const std::vector<XObject*>::size_type theArgCount =
args.size();
if (theArgCount < 2)
{
executionContext.error("The concat() function takes at
least two arguments!",
context);
}
DOMString theResult;
for(std::vector<XObject*>::size_type i = 0; i < theArgCount;
i++)
{
theResult += args[i]->str();
}
return
executionContext.getXObjectFactory().createString(theResult);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionConcat*
#endif
clone() const
{
return new FunctionConcat(*this);
}
private:
// Not implemented...
FunctionConcat&
operator=(const FunctionConcat&);
bool
operator==(const FunctionConcat&) const;
};
#endif // FUNCTIONCONCAT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionContains.hpp
Index: FunctionContains.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONCONTAINS_HEADER_GUARD_1357924680)
#define FUNCTIONCONTAINS_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionContains implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionContains : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 2)
{
executionContext.error("The contains() function takes
two arguments!",
context);
}
const DOMString arg1 = args[0]->str();
const DOMString arg2 = args[1]->str();
const int theIndex = indexOf(arg1, arg2);
return
executionContext.getXObjectFactory().createBoolean(theIndex >= 0 ? true :
false);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionContains*
#endif
clone() const
{
return new FunctionContains(*this);
}
private:
// Not implemented...
FunctionContains&
operator=(const FunctionContains&);
bool
operator==(const FunctionContains&) const;
};
#endif // FUNCTIONCONTAINS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionCount.hpp
Index: FunctionCount.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONCOUNT_HEADER_GUARD_1357924680)
#define FUNCTIONCOUNT_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionCount implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionCount : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 1)
{
executionContext.error("The count() function takes one
argument!",
context);
}
const NodeRefListBase& theNodeList = args[0]->nodeset();
return
executionContext.getXObjectFactory().createNumber(theNodeList.getLength());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionCount*
#endif
clone() const
{
return new FunctionCount(*this);
}
private:
// Not implemented...
FunctionCount&
operator=(const FunctionCount&);
bool
operator==(const FunctionCount&) const;
};
#endif // FUNCTIONCOUNT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionDefaultStringArgument.hpp
Index: FunctionDefaultStringArgument.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONDEFAULTSTRINGARGUMENT_HEADER_GUARD_1357924680)
#define FUNCTIONDEFAULTSTRINGARGUMENT_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/FunctionString.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionDefaultStringArgument implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
//
// This is a base class for all string functions which have a default
// argument. It is _not_ a concrete class.
class XALAN_XPATH_EXPORT FunctionDefaultStringArgument : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args) = 0;
virtual Function*
clone() const = 0;
protected:
virtual DOMString
getDefaultStringArgument(
XPathExecutionContext& executionContext,
const DOM_Node& context,
int
opPos)
{
// This is complicated. The XPath standard says that if there
// are no arguments, the default is to turn the contextNode
// into a string-value, which really means using FunctionString.
//
// So we have to create a context for calling FunctionString
// with the context node. We shroud the temporary XObjects in
// XString in FactoryObjectAutoPointers because they can be
returned
// once we've converted the context node to an XObject.
// A vector for the args. The size will always be one.
std::vector<XObject*> theNewArgs(1);
// A node set that contains the context node.
FactoryObjectAutoPointer<XObject>
theArg(&executionContext.getXObjectFactory(),
executionContext.getXObjectFactory().createNodeSet(context));
// Put the argument into the vector...
theNewArgs[0] = theArg.get();
// This is our string functor.
FunctionString theStringFunctor;
// Get the result...
FactoryObjectAutoPointer<XObject>
theXString(&executionContext.getXObjectFactory(),
theStringFunctor.execute(executionContext,
context,
opPos,
theNewArgs));
// Now, get the string from the XObject.
return theXString->str();
}
private:
// Not implemented...
FunctionDefaultStringArgument&
operator=(const FunctionDefaultStringArgument&);
bool
operator==(const FunctionDefaultStringArgument&) const;
};
#endif // FUNCTIONDEFAULTSTRINGARGUMENT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionDoc.hpp
Index: FunctionDoc.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONDOC_HEADER_GUARD_1357924680)
#define FUNCTIONDOC_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionDoc implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XSLT class.
class XALAN_XSLT_EXPORT FunctionDoc : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
executionContext.error("Document() function
implementation has been replaced by xslt/FunctionDocument!",
context);
return executionContext.getXObjectFactory().createNull();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionDoc*
#endif
clone() const
{
return new FunctionDoc(*this);
}
private:
// Not implemented...
FunctionDoc&
operator=(const FunctionDoc&);
bool
operator==(const FunctionDoc&) const;
};
#endif // FUNCTIONDOC_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionFalse.hpp
Index: FunctionFalse.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONFALSE_HEADER_GUARD_1357924680)
#define FUNCTIONFALSE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionFalse implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionFalse : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() > 0)
{
executionContext.error("The false() function does not
accept arguments!",
context);
}
return
executionContext.getXObjectFactory().createBoolean(false);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionFalse*
#endif
clone() const
{
return new FunctionFalse(*this);
}
private:
// Not implemented...
FunctionFalse&
operator=(const FunctionFalse&);
bool
operator==(const FunctionFalse&) const;
};
#endif // FUNCTIONFALSE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionFloor.hpp
Index: FunctionFloor.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONFLOOR_HEADER_GUARD_1357924680)
#define FUNCTIONFLOOR_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <cmath>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionFloor implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionFloor : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 1)
{
executionContext.error("The floor() function takes one
argument!",
context);
}
return
executionContext.getXObjectFactory().createNumber(floor(args[0]->num()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionFloor*
#endif
clone() const
{
return new FunctionFloor(*this);
}
private:
// Not implemented...
FunctionFloor&
operator=(const FunctionFloor&);
bool
operator==(const FunctionFloor&) const;
};
#endif // FUNCTIONFLOOR_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionID.hpp
Index: FunctionID.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONID_HEADER_GUARD_1357924680)
#define FUNCTIONID_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <set>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
// Base class header files...
#include <XPath/Function.hpp>
#include <XPath/XObjectTypeCallback.hpp>
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionID implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionID : public Function, public
XObjectTypeCallback
{
public:
FunctionID() :
Function(),
XObjectTypeCallback(),
m_executionContext(0)
{
}
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 1)
{
executionContext.error("The id() function takes one
argument!",
context);
}
// OK, reset the data members...
m_executionContext = &executionContext;
m_resultString = 0;
// Do the callback to get the data.
args[0]->ProcessXObjectTypeCallback(*this);
// Get the context document, so we can search for nodes.
DOM_Document theDocContext = context.getNodeType()
== DOM_Node::DOCUMENT_NODE ?
reinterpret_cast<const DOM_Document&>(context) :
context.getOwnerDocument();
// This list will hold the nodes we find.
MutableNodeRefList theNodeList;
// If there is no context, we cannot continue.
if(0 == theDocContext)
{
executionContext.error("The context node does not have
an owner document!",
context);
}
else if (length(m_resultString) > 0)
{
// This set will hold tokens that we've previously
found, so
// we can avoid looking more than once.
std::set<DOMString> thePreviousTokens;
StringTokenizer theTokenizer(m_resultString);
// Parse the result string...
while(theTokenizer.hasMoreTokens() == true)
{
const DOMString theToken =
theTokenizer.nextToken();
if (length(theToken) > 0)
{
// See if we've already seen this one...
std::set<DOMString>::const_iterator
i =
thePreviousTokens.find(theToken);
if (i != thePreviousTokens.end())
{
thePreviousTokens.insert(theToken);
const DOM_Node theNode =
executionContext.getElementByID(theToken, theDocContext);
if (theNode != 0)
{
theNodeList.addNodeInDocOrder(theNode);
}
}
}
}
}
return
executionContext.getXObjectFactory().createNodeSet(theNodeList);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionID*
#endif
clone() const
{
return new FunctionID(*this);
}
virtual void
Number(const XObject& theXObject,
double /* theValue */)
{
m_resultString = theXObject.str();
}
virtual void
Boolean(const XObject& theXObject,
bool /* theValue */)
{
m_resultString = theXObject.str();
}
virtual void
String(const XObject& theXObject,
const DOMString& /* theValue */)
{
m_resultString = theXObject.str();
}
virtual void
ResultTreeFragment(const XObject&
theXObject,
const ResultTreeFragBase& /*
theValue */)
{
m_resultString = theXObject.str();
}
virtual void
ResultTreeFragment(const XObject& theXObject,
ResultTreeFragBase& /* theValue */)
{
m_resultString = theXObject.str();
}
virtual void
NodeSet(const XObject& /* theXObject */,
const NodeRefListBase& theValue)
{
assert(m_executionContext != 0);
const int theNodeCount = theValue.getLength();
for (int i = 0 ; i < theNodeCount; i++)
{
m_resultString +=
m_executionContext->getNodeData(theValue.item(i));
m_resultString += " ";
}
}
virtual void
Unknown(const XObject& /* theObject */,
const DOMString& /* theName */)
{
}
virtual void
Null(const XObject& /* theObject */)
{
}
private:
// Not implemented...
FunctionID&
operator=(const FunctionID&);
bool
operator==(const FunctionID&) const;
// Data members...
XPathExecutionContext* m_executionContext;
DOMString m_resultString;
};
#endif // FUNCTIONID_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionLang.hpp
Index: FunctionLang.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONLANG_HEADER_GUARD_1357924680)
#define FUNCTIONLANG_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionLang implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionLang : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 1)
{
executionContext.error("The lang() function takes one
argument!",
context);
}
DOM_Node parent = context;
bool fMatch = false;
const DOMString lang(args[0]->str());
while(0 != parent)
{
if(DOM_Node::ELEMENT_NODE == parent.getNodeType())
{
const DOM_Element& theElementNode =
reinterpret_cast<const
DOM_Element&>(parent);
const DOMString langVal =
theElementNode.getAttribute("xml:lang");
if(0 != length(langVal))
{
if(startsWith(toLowerCase(langVal),
toLowerCase(lang)))
{
int valLen = lang.length();
if(length(langVal) == valLen ||
charAt(langVal, valLen) ==
'-')
{
fMatch = true;
break;
}
}
}
}
parent = executionContext.getParentOfNode(parent);
}
return
executionContext.getXObjectFactory().createBoolean(fMatch);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionLang*
#endif
clone() const
{
return new FunctionLang(*this);
}
private:
// Not implemented...
FunctionLang&
operator=(const FunctionLang&);
bool
operator==(const FunctionLang&) const;
};
#endif // FUNCTIONLANG_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionLast.hpp
Index: FunctionLast.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONLAST_HEADER_GUARD_1357924680)
#define FUNCTIONLAST_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionLast implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionLast : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 0)
{
executionContext.error("The last() function takes no
arguments!",
context);
}
const int theValue =
executionContext.getContextNodeListLength();
return
executionContext.getXObjectFactory().createNumber(theValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionLast*
#endif
clone() const
{
return new FunctionLast(*this);
}
private:
// Not implemented...
FunctionLast&
operator=(const FunctionLast&);
bool
operator==(const FunctionLast&) const;
};
#endif // FUNCTIONLAST_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionLocalName.hpp
Index: FunctionLocalName.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONLOCALNAME_HEADER_GUARD_1357924680)
#define FUNCTIONLOCALNAME_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionLocalName implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionLocalName : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 1)
{
executionContext.error("The local-name() function takes
one argument!",
context);
}
const NodeRefListBase& theNodeList = args[0]->nodeset();
DOMString theData;
if (theNodeList.getLength() > 0)
{
theData =
executionContext.getLocalNameOfNode(theNodeList.item(0));
}
return
executionContext.getXObjectFactory().createString(theData);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionLocalName*
#endif
clone() const
{
return new FunctionLocalName(*this);
}
private:
// Not implemented...
FunctionLocalName&
operator=(const FunctionLocalName&);
bool
operator==(const FunctionLocalName&) const;
};
#endif // FUNCTIONLOCALNAME_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionName.hpp
Index: FunctionName.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONNAME_HEADER_GUARD_1357924680)
#define FUNCTIONNAME_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <cassert>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Attr.hpp>
#include <dom/DOMString.hpp>
#include <Include/DOMHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionName implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionName : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
const std::vector<XObject*>::size_type theSize = args.size();
DOMString
theResult;
if(theSize == 0)
{
// Make a temporary XObject from the context node.
XObjectFactory&
theFactory =
executionContext.getXObjectFactory();
FactoryObjectAutoPointer<XObject>
theXObject(&theFactory,
theFactory.createNodeSet(context));
theResult = getNameFromNodeList(theXObject->nodeset());
}
else if (theSize == 1)
{
theResult = getNameFromNodeList(args[0]->nodeset());
}
else
{
executionContext.error("The name() function takes
either zero arguments or one argument!",
context);
}
return
executionContext.getXObjectFactory().createString(theResult);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionName*
#endif
clone() const
{
return new FunctionName(*this);
}
virtual DOMString
getNameFromNodeList(const NodeRefListBase& theNodeList) const
{
DOMString theResult;
if (theNodeList.getLength() > 0)
{
DOM_Node theNode = theNodeList.item(0);
assert(theNode != 0);
if (DOM_Node::ATTRIBUTE_NODE == theNode.getNodeType())
{
const DOM_Attr& theAttributeNode =
reinterpret_cast<const
DOM_Attr&>(theNode);
theResult = theAttributeNode.getName();
}
else
{
theResult = theNode.getNodeName();
}
}
return theResult;
}
private:
// Not implemented...
FunctionName&
operator=(const FunctionName&);
bool
operator==(const FunctionName&) const;
};
#endif // FUNCTIONNAME_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionNamespaceURI.hpp
Index: FunctionNamespaceURI.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONNAMESPACEURI_HEADER_GUARD_1357924680)
#define FUNCTIONNAMESPACEURI_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionNamespaceURI implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionNamespaceURI : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
DOMString theNamespace;
if (args.size() > 1)
{
executionContext.error("The namespace-uri() function
takes zero arguments or one argument!",
context);
}
else if (args.size() == 1)
{
theNamespace = getNamespaceFromNodeSet(*args[0],
executionContext);
}
else
{
// The XPath standard says that if there are no
arguments,
// the argument defaults to a node set with the context
node
// as the only member.
// So we have to create an XObject with the context
node as
// the only member.
// We shroud the temporary getNamespaceFromNodeSet( in a
// FactoryObjectAutoPointer because it can be deleted
once
// we're done.
// An XObject that contains the context node.
FactoryObjectAutoPointer<XObject>
theXObject(&executionContext.getXObjectFactory(),
executionContext.getXObjectFactory().createNodeSet(context));
theNamespace =
getNamespaceFromNodeSet(*theXObject.get(),
executionContext);
}
return
executionContext.getXObjectFactory().createString(theNamespace);
}
virtual Function*
clone() const
{
return new FunctionNamespaceURI(*this);
}
private:
static DOMString
getNamespaceFromNodeSet(const XObject& theXObject,
XPathExecutionContext&
theContext)
{
DOMString theNamespace;
const NodeRefListBase& theList = theXObject.nodeset();
if (theList.getLength() > 0)
{
theNamespace =
theContext.getNamespaceOfNode(theList.item(0));
}
return theNamespace;
}
// Not implemented...
FunctionNamespaceURI&
operator=(const FunctionNamespaceURI&);
bool
operator==(const FunctionNamespaceURI&) const;
};
#endif // FUNCTIONNAMESPACEURI_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionNormalize.hpp
Index: FunctionNormalize.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONNORMALIZE_HEADER_GUARD_1357924680)
#define FUNCTIONNORMALIZE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/FunctionDefaultStringArgument.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath normalize-space() implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionNormalizeSpace : public
FunctionDefaultStringArgument
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
opPos,
const std::vector<XObject*>& args)
{
DOMString theSourceString;
if(args.size() > 2)
{
executionContext.error("The normalize-space() function
takes zero arguments or one argument!",
context);
}
else if (args.size() == 1)
{
theSourceString = args[0]->str();
}
else
{
theSourceString =
getDefaultStringArgument(executionContext,
context,
opPos);
}
const int theSourceStringLength =
length(theSourceString);
XMLCh thePreviousChar = 0;
// A vector to contain the new characters. We'll use it to
construct
// the result string.
std::vector<XMLCh> theVector;
// The result string can only be as large as the source string,
so
// just reserve the space now. Also reserve a space for the
// terminating 0.
theVector.reserve(theSourceStringLength + 1);
// OK, strip out any multiple spaces...
for (int i = 0; i < theSourceStringLength; i++)
{
const XMLCh theCurrentChar =
charAt(theSourceString, i);
if (isSpace(theCurrentChar) == true)
{
// If the previous character wasn't a space,
and we've
// encountered some non-space characters, then
push the
// space.
if (isSpace(thePreviousChar) == false &&
theVector.size() > 0)
{
theVector.push_back(XMLCh(' '));
}
}
else
{
theVector.push_back(theCurrentChar);
}
thePreviousChar = theCurrentChar;
}
if (isSpace(theVector.back()) == true)
{
// The last character is a space, so remove it
theVector.pop_back();
}
return
executionContext.getXObjectFactory().createString(DOMString(theVector.begin(),
theVector.size()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionNormalizeSpace*
#endif
clone() const
{
return new FunctionNormalizeSpace(*this);
}
private:
// Not implemented...
FunctionNormalizeSpace&
operator=(const FunctionNormalizeSpace&);
bool
operator==(const FunctionNormalizeSpace&) const;
};
#endif // FUNCTIONNORMALIZE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionNot.hpp
Index: FunctionNot.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONNOT_HEADER_GUARD_1357924680)
#define FUNCTIONNOT_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionNot implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionNot : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 1)
{
executionContext.error("The not() function takes one
argument!",
context);
}
return
executionContext.getXObjectFactory().createBoolean(!args[0]->boolean());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionNot*
#endif
clone() const
{
return new FunctionNot(*this);
}
private:
// Not implemented...
FunctionNot&
operator=(const FunctionNot&);
bool
operator==(const FunctionNot&) const;
};
#endif // FUNCTIONNOT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionNumber.hpp
Index: FunctionNumber.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONNUMBER_HEADER_GUARD_1357924680)
#define FUNCTIONNUMBER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionNumber implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionNumber : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
double theValue = 0.0L;
if (args.size() > 1)
{
executionContext.error("The number() function takes
zero arguments or one argument!",
context);
}
else if (args.size() == 1)
{
theValue = args[0]->num();
}
else
{
// The XPath standard says that if there are no
arguments,
// the argument defaults to a node set with the context
node
// as the only member.
// So we have to create an XNodeList with the context
node as
// the only member and call the num() function on it.
We shroud
// the temporary XNodeList in an XObjectGuard because
it can be
// deleted once we've converted the context node to a
number.
// An XObject that contains the context node.
FactoryObjectAutoPointer<XObject>
theXObject(&executionContext.getXObjectFactory(),
executionContext.getXObjectFactory().createNodeSet(context));
// Get the numeric value of the theXObject...
theValue = theXObject->num();
}
return
executionContext.getXObjectFactory().createNumber(theValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionNumber*
#endif
clone() const
{
return new FunctionNumber(*this);
}
private:
// Not implemented...
FunctionNumber&
operator=(const FunctionNumber&);
bool
operator==(const FunctionNumber&) const;
};
#endif // FUNCTIONNUMBER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionPosition.hpp
Index: FunctionPosition.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONPOSITION_HEADER_GUARD_1357924680)
#define FUNCTIONPOSITION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionPosition implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionPosition : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 0)
{
executionContext.error("The position() function takes
no arguments!",
context);
}
const int theValue =
executionContext.getContextNodeListPosition(context);
return
executionContext.getXObjectFactory().createNumber(theValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionPosition*
#endif
clone() const
{
return new FunctionPosition(*this);
}
private:
// Not implemented...
FunctionPosition&
operator=(const FunctionPosition&);
bool
operator==(const FunctionPosition&) const;
};
#endif // FUNCTIONPOSITION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionRound.hpp
Index: FunctionRound.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONROUND_HEADER_GUARD_1357924680)
#define FUNCTIONROUND_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionRound implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionRound : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 1)
{
executionContext.error("The round() function takes one
argument!",
context);
}
const double theValue = args[0]->num();
// $$$ ToDo: This is not really correct, but will do for now...
const long theRoundedValue = static_cast<long>(theValue <
0 ? theValue - 0.5 : theValue + 0.5);
return
executionContext.getXObjectFactory().createNumber(theRoundedValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionRound*
#endif
clone() const
{
return new FunctionRound(*this);
}
private:
// Not implemented...
FunctionRound&
operator=(const FunctionRound&);
bool
operator==(const FunctionRound&) const;
};
#endif // FUNCTIONROUND_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionStartsWith.hpp
Index: FunctionStartsWith.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSTARTSWITH_HEADER_GUARD_1357924680)
#define FUNCTIONSTARTSWITH_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionStartsWith implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionStartsWith : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 2)
{
executionContext.error("The startswith() function takes
one argument!",
context);
}
const bool fStartsWith = startsWith(args[0]->str(),
args[1]->str());
return
executionContext.getXObjectFactory().createBoolean(fStartsWith);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionStartsWith*
#endif
clone() const
{
return new FunctionStartsWith(*this);
}
private:
// Not implemented...
FunctionStartsWith&
operator=(const FunctionStartsWith&);
bool
operator==(const FunctionStartsWith&) const;
};
#endif // FUNCTIONSTARTSWITH_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionString.hpp
Index: FunctionString.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSTRING_HEADER_GUARD_1357924680)
#define FUNCTIONSTRING_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionString implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionString : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 1)
{
executionContext.error("The string() function takes one
argument!",
context);
}
return
executionContext.getXObjectFactory().createString(args[0]->str());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionString*
#endif
clone() const
{
return new FunctionString(*this);
}
private:
// Not implemented...
FunctionString&
operator=(const FunctionString&);
bool
operator==(const FunctionString&) const;
};
#endif // FUNCTIONSTRING_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionStringLength.hpp
Index: FunctionStringLength.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSTRINGLENGTH_HEADER_GUARD_1357924680)
#define FUNCTIONSTRINGLENGTH_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/FunctionDefaultStringArgument.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionStringLength implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionStringLength : public
FunctionDefaultStringArgument
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
opPos,
const std::vector<XObject*>& args)
{
const std::vector<XObject*>::size_type theSize = args.size();
DOMString theResult;
if(theSize == 0)
{
theResult = getDefaultStringArgument(executionContext,
context,
opPos);
}
else if (theSize == 1)
{
theResult = args[0]->str();
}
else
{
executionContext.error("The stringlength() function
takes either zero arguments or one argument!",
context);
}
return
executionContext.getXObjectFactory().createNumber(length(theResult));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionStringLength*
#endif
clone() const
{
return new FunctionStringLength(*this);
}
private:
// Not implemented...
FunctionStringLength&
operator=(const FunctionStringLength&);
bool
operator==(const FunctionStringLength&) const;
};
#endif // FUNCTIONSTRINGLENGTH_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionSubstring.hpp
Index: FunctionSubstring.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSUBSTRING_HEADER_GUARD_1357924680)
#define FUNCTIONSUBSTRING_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <cfloat>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionSubstring implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionSubstring : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
const std::vector<XObject*>::size_type theArgCount =
args.size();
if (theArgCount < 2 || theArgCount > 3)
{
executionContext.error("The substring() function takes
two or three arguments!",
context);
}
const DOMString theSourceString = args[0]->str();
const int theSourceStringLength =
length(theSourceString);
// This buffer will hold the output characters.
std::vector<XMLCh> theBuffer;
if (theSourceStringLength > 0)
{
// The substring can only be as long as the source
string,
// so reserve enough space now. Also reserve space for
// the terminating 0.
theBuffer.reserve(theSourceStringLength);
// $$$ ToDo: Add support for NaN.
// Get the value of the second argument...
const double theSecondArgValue =
args[1]->num();
// Now, total the second and third arguments. If
// the third argument is missing, make the total
// DBL_MAX.
const double theTotal =
theArgCount == 2 ?
DBL_MAX :
theSecondArgValue + args[2]->num();
// Start with 1, since strings are index from 1 in the
XPath spec,
for (int i = 1; i <= theSourceStringLength; i++)
{
// Is the index greater than or equal to the
second argument?
if (i >= theSecondArgValue)
{
// Is it less than the sum of the
second and
// third arguments?
if (i < theTotal)
{
// It is, so include the
character.
theBuffer.push_back(charAt(theSourceString, i - 1));
}
else
{
// It's not, so stop.
break;
}
}
}
}
return
executionContext.getXObjectFactory().createString(DOMString(theBuffer.begin(),
theBuffer.size()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionSubstring*
#endif
clone() const
{
return new FunctionSubstring(*this);
}
private:
// Not implemented...
FunctionSubstring&
operator=(const FunctionSubstring&);
bool
operator==(const FunctionSubstring&) const;
};
#endif // FUNCTIONSUBSTRING_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionSubstringAfter.hpp
Index: FunctionSubstringAfter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSUBSTRINGAFTER_HEADER_GUARD_1357924680)
#define FUNCTIONSUBSTRINGAFTER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionSubstringAfter implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionSubstringAfter : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 2)
{
executionContext.error("The substring-after() function
takes two arguments!",
context);
}
const DOMString theFirstString = args[0]->str();
const DOMString theSecondString = args[1]->str();
const int theIndex =
indexOf(theFirstString,
theSecondString);
// This buffer will hold the output characters.
std::vector<XMLCh> theBuffer;
if (theIndex != -1)
{
const int theFirstStringLength =
length(theFirstString);
int theStartIndex = theIndex +
length(theSecondString);
// The result string can only be as large as the source
string, so
// just reserve the space now. Also reserve a space
for the
// terminating 0.
theBuffer.reserve(theFirstStringLength - theStartIndex
+ 1);
for (; theStartIndex < theFirstStringLength;
theStartIndex++)
{
theBuffer.push_back(charAt(theFirstString,
theStartIndex));
}
}
return
executionContext.getXObjectFactory().createString(DOMString(theBuffer.begin(),
theBuffer.size()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionSubstringAfter*
#endif
clone() const
{
return new FunctionSubstringAfter(*this);
}
private:
// Not implemented...
FunctionSubstringAfter&
operator=(const FunctionSubstringAfter&);
bool
operator==(const FunctionSubstringAfter&) const;
};
#endif // FUNCTIONSUBSTRINGAFTER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionSubstringBefore.hpp
Index: FunctionSubstringBefore.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSUBSTRINGBEFORE_HEADER_GUARD_1357924680)
#define FUNCTIONSUBSTRINGBEFORE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionSubstringBefore implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionSubstringBefore : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 2)
{
executionContext.error("The substring-before() function
takes two arguments!",
context);
}
const DOMString theFirstString = args[0]->str();
const DOMString theSecondString = args[1]->str();
const int theIndex =
indexOf(theFirstString,
theSecondString);
// This buffer will hold the output characters.
std::vector<XMLCh> theBuffer;
if (theIndex != -1)
{
const int theFirstStringLength =
length(theFirstString);
// The result string can only be as large as the source
string, so
// just reserve the space now. Also reserve a space
for the
// terminating 0.
theBuffer.reserve(theFirstStringLength + 1);
// Stop with the last character before the index.
for (int i = 0; i < theIndex; i++)
{
theBuffer.push_back(charAt(theFirstString, i));
}
}
return
executionContext.getXObjectFactory().createString(DOMString(theBuffer.begin(),
theBuffer.size()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionSubstringBefore*
#endif
clone() const
{
return new FunctionSubstringBefore(*this);
}
private:
// Not implemented...
FunctionSubstringBefore&
operator=(const FunctionSubstringBefore&);
bool
operator==(const FunctionSubstringBefore&) const;
};
#endif // FUNCTIONSUBSTRINGBEFORE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionSum.hpp
Index: FunctionSum.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSUM_HEADER_GUARD_1357924680)
#define FUNCTIONSUM_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionSum implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionSum : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 1)
{
executionContext.error("The sum() function takes one
argument!",
context);
}
const NodeRefListBase& nl = args[0]->nodeset();
double sum = 0.0;
const int count = nl.getLength();
for (int i = 0; i < count; i++)
{
sum +=
DOMStringToDouble(executionContext.getNodeData(nl.item(i)));
}
return executionContext.getXObjectFactory().createNumber(sum);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionSum*
#endif
clone() const
{
return new FunctionSum(*this);
}
private:
// Not implemented...
FunctionSum&
operator=(const FunctionSum&);
bool
operator==(const FunctionSum&) const;
};
#endif // FUNCTIONSUM_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionTranslate.hpp
Index: FunctionTranslate.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONTRANSLATE_HEADER_GUARD_1357924680)
#define FUNCTIONTRANSLATE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionTranslate implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionTranslate : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 3)
{
executionContext.error("The translate() function takes
three arguments!",
context);
}
const DOMString theFirstString = args[0]->str();
const DOMString theSecondString = args[1]->str();
const DOMString theThirdString = args[2]->str();
const int theFirstStringLength =
length(theFirstString);
const int theThirdStringLength =
length(theThirdString);
// A vector to contain the new characters. We'll use it to
construct
// the result string.
std::vector<XMLCh> theVector;
// The result string can only be as large as the first string,
so
// just reserve the space now. Also reserve space for the
// terminating 0.
theVector.reserve(theFirstStringLength + 1);
for (int i = 0; i < theFirstStringLength; i++)
{
const XMLCh theCurrentChar =
charAt(theFirstString, i);
const int theIndex =
indexOf(theSecondString, theCurrentChar);
if (theIndex < 0)
{
// Didn't find the character in the second
string, so it
// is not translated.
theVector.push_back(theCurrentChar);
}
else if (theIndex < theThirdStringLength)
{
// OK, there's a corresponding character in the
// third string, so do the translation...
theVector.push_back(charAt(theThirdString,
theIndex));
}
else
{
// There's no corresponding character in the
// third string, since it's shorter than the
// second string. In this case, the character
// is removed from the output string, so don't
// do anything.
}
}
// Push a terminating 0.
theVector.push_back(0);
return
executionContext.getXObjectFactory().createString(DOMString(theVector.begin()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionTranslate*
#endif
clone() const
{
return new FunctionTranslate(*this);
}
private:
// Not implemented...
FunctionTranslate&
operator=(const FunctionTranslate&);
bool
operator==(const FunctionTranslate&) const;
};
#endif // FUNCTIONTRANSLATE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/FunctionTrue.hpp
Index: FunctionTrue.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONTRUE_HEADER_GUARD_1357924680)
#define FUNCTIONCURRENT_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionTrue implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XPATH_EXPORT FunctionTrue : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() > 0)
{
executionContext.error("The true() function does not
accept arguments!",
context);
}
return executionContext.getXObjectFactory().createBoolean(true);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionTrue*
#endif
clone() const
{
return new FunctionTrue(*this);
}
private:
// Not implemented...
FunctionTrue&
operator=(const FunctionTrue&);
bool
operator==(const FunctionTrue&) const;
};
#endif // FUNCTIONTRUE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/MutableNodeRefList.cpp
Index: MutableNodeRefList.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "MutableNodeRefList.hpp"
#include <cassert>
#include <algorithm>
#include <dom\DOM_NamedNodeMap.hpp>
#include <dom\DOM_NodeList.hpp>
#include <include/DOMHelper.hpp>
#include "XPathSupport.hpp"
MutableNodeRefList::MutableNodeRefList(XPathSupport* theSupport) :
NodeRefList(),
m_support(theSupport)
{
}
MutableNodeRefList::MutableNodeRefList(const MutableNodeRefList&
theSource) :
NodeRefList(theSource),
m_support(theSource.m_support)
{
}
MutableNodeRefList::MutableNodeRefList(const NodeRefListBase& theSource,
XPathSupport* theSupport) :
NodeRefList(theSource),
m_support(theSupport)
{
}
MutableNodeRefList::~MutableNodeRefList()
{
}
MutableNodeRefList&
MutableNodeRefList::operator=(const MutableNodeRefList& theRHS)
{
if (this != &theRHS)
{
// Chain up...
NodeRefList::operator=(theRHS);
m_support = theRHS.m_support;
}
return *this;
}
MutableNodeRefList&
MutableNodeRefList::operator=(const NodeRefList& theRHS)
{
if (this != &theRHS)
{
// Chain up...
NodeRefList::operator=(theRHS);
m_support = 0;
}
return *this;
}
MutableNodeRefList&
MutableNodeRefList::operator=(const NodeRefListBase& theRHS)
{
if (this != &theRHS)
{
// Chain up...
NodeRefList::operator=(theRHS);
m_support = 0;
}
return *this;
}
MutableNodeRefList&
MutableNodeRefList::operator=(const DOM_NodeList& theRHS)
{
clear();
addNodes(theRHS);
return *this;
}
void
MutableNodeRefList::addNode(const DOM_Node& n)
{
if (n != 0)
{
m_nodeList.push_back(n);
}
}
void
MutableNodeRefList::insertNode(
const DOM_Node& n,
int pos)
{
assert(getLength() >= pos);
if (n != 0)
{
m_nodeList.insert(&m_nodeList[pos], n);
}
}
void
MutableNodeRefList::removeNode(const DOM_Node& n)
{
using std::vector;
using std::find;
std::vector<DOM_Node>::iterator i =
find(m_nodeList.begin(),
m_nodeList.end(),
n);
if (i != m_nodeList.end())
{
m_nodeList.erase(i);
}
}
void
MutableNodeRefList::removeNode(int pos)
{
assert(pos < getLength());
m_nodeList.erase(&m_nodeList[pos]);
}
void
MutableNodeRefList::clear()
{
m_nodeList.clear();
}
void
MutableNodeRefList::setNode(
int pos,
const DOM_Node& theNode)
{
assert(pos < getLength());
if (theNode != 0)
{
m_nodeList[pos] = theNode;
}
}
void
MutableNodeRefList::addNodes(const DOM_NodeList& nodelist)
{
if (nodelist != 0)
{
const int theLength = nodelist.getLength();
for (int i = 0; i < theLength; i++)
{
addNode(nodelist.item(i));
}
}
}
void
MutableNodeRefList::addNodes(const NodeRefListBase& nodelist)
{
const int theLength = nodelist.getLength();
for (int i = 0; i < theLength; i++)
{
addNode(nodelist.item(i));
}
}
void
MutableNodeRefList::addNodesInDocOrder(const DOM_NodeList& nodelist)
{
const int nChildren = nodelist.getLength();
for(int i = 0; i < nChildren; i++)
{
addNodeInDocOrder(nodelist.item(i));
}
}
void
MutableNodeRefList::addNodesInDocOrder(const NodeRefListBase& nodelist)
{
const int nChildren = nodelist.getLength();
for(int i = 0; i < nChildren; i++)
{
addNodeInDocOrder(nodelist.item(i),
true);
}
}
void
MutableNodeRefList::addNodeInDocOrder(
const DOM_Node& node,
bool test)
{
if (node != 0)
{
if (test == false || m_support == 0)
{
addNode(node);
}
else
{
const int size = getLength();
int i = size - 1;
for(; i >= 0; i--)
{
const DOM_Node& child = m_nodeList[i];
if(child == node)
{
// Duplicate, don't insert...
i = -2;
break;
}
else if (isNodeAfter(node, child) == false)
{
break;
}
}
if (i != -2)
{
insertNode(node, i + 1);
}
}
}
}
bool
MutableNodeRefList::isNodeAfter(
const DOM_Node& node1,
const DOM_Node& node2) const
{
assert(m_support != 0);
assert(node1 != 0 && node2 != 0);
bool isNodeAfter = false;
DOM_Node parent1 = m_support->getParentOfNode(node1);
DOM_Node parent2 = m_support->getParentOfNode(node2);
// Optimize for most common case
if(parent1 == parent2) // then we know they are siblings
{
isNodeAfter = isNodeAfterSibling(parent1,
node1,
node2);
}
else
{
// General strategy: Figure out the lengths of the two
// ancestor chains, and walk up them looking for the
// first common ancestor, at which point we can do a
// sibling compare. Edge condition where one is the
// ancestor of the other.
// Count parents, so we can see if one of the chains
// needs to be equalized.
int nParents1 = 2;
int nParents2 = 2; // count node & parent obtained above
while(parent1 != 0)
{
nParents1++;
parent1 = m_support->getParentOfNode(parent1);
}
while(parent2 != 0)
{
nParents2++;
parent2 = m_support->getParentOfNode(parent2);
}
// adjustable starting points
DOM_Node startNode1 = node1;
DOM_Node startNode2 = node2;
// Do I have to adjust the start point in one of
// the ancesor chains?
if(nParents1 < nParents2)
{
// adjust startNode2
const int adjust = nParents2 - nParents1;
for(int i = 0; i < adjust; i++)
{
startNode2 =
m_support->getParentOfNode(startNode2);
}
}
else if(nParents1 > nParents2)
{
// adjust startNode1
const int adjust = nParents1 - nParents2;
for(int i = 0; i < adjust; i++)
{
startNode1 =
m_support->getParentOfNode(startNode1);
}
}
// so we can "back up"
DOM_Node prevChild1;
DOM_Node prevChild2;
// Loop up the ancestor chain looking for common parent.
while(0 != startNode1)
{
if(startNode1 == startNode2) // common parent?
{
if(0 == prevChild1) // first time in loop?
{
// Edge condition: one is the ancestor
of the other.
isNodeAfter = (nParents1 < nParents2) ?
true : false;
break; // from while loop
}
else
{
isNodeAfter =
isNodeAfterSibling(startNode1,
prevChild1,
prevChild2);
break; // from while loop
}
}
prevChild1 = startNode1;
startNode1 = m_support->getParentOfNode(startNode1);
prevChild2 = startNode2;
startNode2 = m_support->getParentOfNode(startNode2);
}
}
/* -- please do not remove... very useful for diagnostics --
System.out.println("node1 =
"+node1.getNodeName()+"("+node1.getNodeType()+")"+
", node2 = "+node2.getNodeName()
+"("+node2.getNodeType()+")"+
", isNodeAfter = "+isNodeAfter); */
return isNodeAfter;
}
bool
MutableNodeRefList::isNodeAfterSibling(
const DOM_Node& parent,
const DOM_Node& child1,
const DOM_Node& child2)
{
bool isNodeAfterSibling = false;
const int child1type = child1.getNodeType();
const int child2type = child2.getNodeType();
if(DOM_Node::ATTRIBUTE_NODE != child1type &&
DOM_Node::ATTRIBUTE_NODE == child2type)
{
// always sort attributes before non-attributes.
isNodeAfterSibling = false;
}
else if(DOM_Node::ATTRIBUTE_NODE == child1type &&
DOM_Node::ATTRIBUTE_NODE != child2type)
{
// always sort attributes before non-attributes.
isNodeAfterSibling = true;
}
else if(DOM_Node::ATTRIBUTE_NODE == child1type)
{
DOM_NamedNodeMap children = parent.getAttributes();
const int nNodes = children.getLength();
bool found1 = false;
bool found2 = false;
for(int i = 0; i < nNodes; i++)
{
const DOM_Node child = children.item(i);
if(child1 == child)
{
if(found2 == true)
{
isNodeAfterSibling = false;
break;
}
found1 = true;
}
else if(child2 == child)
{
if(found1 == true)
{
isNodeAfterSibling = true;
break;
}
found2 = true;
}
}
}
else
{
DOM_NodeList children = parent.getChildNodes();
const int nNodes = children.getLength();
bool found1 = false;
bool found2 = false;
for(int i = 0; i < nNodes; i++)
{
const DOM_Node child = children.item(i);
if(child1 == child)
{
if(found2 == true)
{
isNodeAfterSibling = false;
break;
}
found1 = true;
}
else if(child2 == child)
{
if(found1 == true)
{
isNodeAfterSibling = true;
break;
}
found2 = true;
}
}
}
return isNodeAfterSibling;
}
1.1 xml-xalan/c/src/XPath/MutableNodeRefList.hpp
Index: MutableNodeRefList.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(MUTABLENODEREFLIST_HEADER_GUARD_1357924680)
#define MUTABLENODEREFLIST_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/NodeRefList.hpp>
class DOM_NodeList;
/**
* Local implementation of MutableNodeRefList. This class is for internal
use only.
*/
class XPathSupport;
class XALAN_XPATH_EXPORT MutableNodeRefList : public NodeRefList
{
public:
explicit
MutableNodeRefList(XPathSupport* theSupport = 0);
MutableNodeRefList(const MutableNodeRefList& theSource);
explicit
MutableNodeRefList(const NodeRefListBase& theSource,
XPathSupport*
theSupport = 0);
virtual
~MutableNodeRefList();
MutableNodeRefList&
operator=(const MutableNodeRefList& theRHS);
MutableNodeRefList&
operator=(const NodeRefList& theRHS);
MutableNodeRefList&
operator=(const NodeRefListBase& theRHS);
MutableNodeRefList&
operator=(const DOM_NodeList& theRHS);
virtual void
addNode(const DOM_Node& n);
/**
* Insert a node at a given position.
*/
virtual void
insertNode(
const DOM_Node& n,
int pos);
/**
* Remove a node.
*/
virtual void
removeNode(const DOM_Node& n);
virtual void
removeNode(int pos);
/**
* Remove all nodes.
*/
virtual void
clear();
/**
* Set a item.
*/
virtual void
setNode(int pos,
const DOM_Node& n = DOM_Node());
/**
* Copy NodeList members into this nodelist, adding in
* document order. If a node is null, don't add it.
*/
virtual void
addNodes(const DOM_NodeList& nodelist);
/**
* Copy NodeList members into this nodelist, adding in
* document order. If a node is null, don't add it.
*/
virtual void
addNodes(const NodeRefListBase& nodelist);
/**
* Copy NodeList members into this nodelist, adding in
* document order.
*/
virtual void
addNodesInDocOrder(const DOM_NodeList& nodelist);
/**
* Copy NodeList members into this nodelist, adding in
* document order.
*/
virtual void
addNodesInDocOrder(const NodeRefListBase& nodelist);
/**
* Add the node into a vector of nodes where it should occur in
* document order.
* @param v Vector of nodes, presumably containing Nodes
* @param obj Node object.
* @param test true if we should test for doc order
*/
virtual void
addNodeInDocOrder(
const DOM_Node& node,
bool test = false);
protected:
virtual bool
isNodeAfter(
const DOM_Node& node1,
const DOM_Node& node2) const;
static bool
isNodeAfterSibling(
const DOM_Node& parent,
const DOM_Node& child1,
const DOM_Node& child2);
XPathSupport*
getSupport() const
{
return m_support;
}
private:
XPathSupport* m_support;
};
#endif // MUTABLENODEREFLIST_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/NameSpace.hpp
Index: NameSpace.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NAMESPACE_HEADER_GUARD_1357924680)
#define NAMESPACE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <memory>
#include <dom/DOMString.hpp>
/**
* A representation of a namespace. One of these will
* be pushed on the namespace stack for each
* element.
*/
class XALAN_XPATH_EXPORT NameSpace
{
public:
/**
* Construct a namespace for placement on the
* result tree namespace stack.
*/
NameSpace(
const DOMString& prefix = DOMString(),
const DOMString& uri = DOMString()) :
m_prefix(prefix),
m_uri(uri),
m_resultCandidate(true)
{
}
const DOMString&
getPrefix() const
{
return m_prefix;
}
const DOMString&
getURI() const
{
return m_uri;
}
bool
getResultCandidate() const
{
return m_resultCandidate;
}
void
setResultCandidate(bool fResultCandidate)
{
m_resultCandidate = fResultCandidate;
}
// Required for STL vector
NameSpace& operator=(const NameSpace& theRHS)
{
if (&theRHS != this)
{
m_prefix = theRHS.m_prefix;
m_uri = theRHS.m_uri;
m_resultCandidate = theRHS.m_resultCandidate;
}
return *this;
}
private:
DOMString m_prefix;
DOMString m_uri; // if length is 0, then
Element namespace is empty.
bool m_resultCandidate;
};
#endif // NAMESPACE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/NodeListImplSurrogate.cpp
Index: NodeListImplSurrogate.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NodeListImplSurrogate.hpp"
#include <include/DOMHelper.hpp>
#include "NodeRefListBase.hpp"
NodeListImplSurrogate::NodeListImplSurrogate(NodeRefListBase& theNodeRefList)
:
NodeListImpl(),
m_nodeRefList(theNodeRefList)
{
}
NodeListImplSurrogate::~NodeListImplSurrogate()
{
}
NodeImpl*
NodeListImplSurrogate::item(int index)
{
return
XALAN_DOM_NodeHack(m_nodeRefList.item(index)).getImplementationObject();
}
int
NodeListImplSurrogate::getLength()
{
return m_nodeRefList.getLength();
}
1.1 xml-xalan/c/src/XPath/NodeListImplSurrogate.hpp
Index: NodeListImplSurrogate.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NODELISTIMPLSURROGATE_HEADER_GUARD_1357924680)
#define NODELISTIMPLSURROGATE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/NodeListImpl.hpp>
class NodeImpl;
class NodeRefListBase;
class XALAN_XPATH_EXPORT NodeListImplSurrogate : public NodeListImpl
{
public:
/**
* Constructor.
*/
NodeListImplSurrogate(NodeRefListBase& theNodeRefList);
virtual
~NodeListImplSurrogate();
// These interfaces are inherited from NodeListImpl...
virtual NodeImpl*
item(int index);
virtual int
getLength();
private:
NodeRefListBase& m_nodeRefList;
};
#endif // NODELISTIMPLSURROGATE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/NodeRefList.cpp
Index: NodeRefList.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NodeRefList.hpp"
#include <cassert>
#include <algorithm>
NodeRefList::NodeRefList() :
NodeRefListBase(),
m_nodeList()
{
}
NodeRefList::NodeRefList(const NodeRefList& theSource) :
NodeRefListBase(theSource),
m_nodeList(theSource.m_nodeList)
{
}
NodeRefList::NodeRefList(const NodeRefListBase& theSource) :
NodeRefListBase(theSource),
m_nodeList()
{
*this = theSource;
}
NodeRefList::~NodeRefList()
{
}
NodeRefList&
NodeRefList::operator=(const NodeRefListBase& theRHS)
{
if (&theRHS != this)
{
m_nodeList.clear();
const int theLength = theRHS.getLength();
m_nodeList.reserve(theLength);
for(int i = 0; i < theLength; i++)
{
const DOM_Node theNode = theRHS.item(i);
if (theNode != 0)
{
m_nodeList.push_back(theNode);
}
}
// Chain up...
NodeRefListBase::operator=(theRHS);
}
return *this;
}
NodeRefList&
NodeRefList::operator=(const NodeRefList& theRHS)
{
if (&theRHS != this)
{
m_nodeList = theRHS.m_nodeList;
// Chain up...
NodeRefListBase::operator=(theRHS);
}
return *this;
}
DOM_Node
NodeRefList::item(int index) const
{
assert(index < m_nodeList.size());
return m_nodeList[index];
}
int
NodeRefList::getLength() const
{
return m_nodeList.size();
}
int
NodeRefList::indexOf(const DOM_Node& theNode) const
{
using std::vector;
using std::find;
// Look for the node in the list.
std::vector<DOM_Node>::const_iterator i =
find(m_nodeList.begin(),
m_nodeList.end(),
theNode);
// If not found, return -1. Otherwise, subtract the iterator
// from the first iterator to get the distance between them.
return i == m_nodeList.end() ? -1 : i - m_nodeList.begin();
}
1.1 xml-xalan/c/src/XPath/NodeRefList.hpp
Index: NodeRefList.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NODEREFLIST_HEADER_GUARD_1357924680)
#define NODEREFLIST_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <XPath/NodeRefListBase.hpp>
/**
* Local implementation of NodeRefList. This class is for internal use only.
*/
class XALAN_XPATH_EXPORT NodeRefList : public NodeRefListBase
{
public:
explicit
NodeRefList();
explicit
NodeRefList(const NodeRefList& theSource);
explicit
NodeRefList(const NodeRefListBase& theSource);
virtual
~NodeRefList();
NodeRefList&
operator=(const NodeRefListBase& theRHS);
NodeRefList&
operator=(const NodeRefList& theRHS);
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes
in
* the list, this returns <code>null</code>.
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
virtual DOM_Node
item(int index) const;
/**
* The number of nodes in the list. The range of valid child node
indices is
* 0 to <code>length-1</code> inclusive.
*/
virtual int
getLength() const;
virtual int
indexOf(const DOM_Node& theNode) const;
protected:
std::vector<DOM_Node> m_nodeList;
};
#endif // NODEREFLIST_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/NodeRefListBase.cpp
Index: NodeRefListBase.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NodeRefListBase.hpp"
NodeRefListBase::NodeRefListBase()
{
}
NodeRefListBase::~NodeRefListBase()
{
}
1.1 xml-xalan/c/src/XPath/NodeRefListBase.hpp
Index: NodeRefListBase.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NODEREFLISTBASE_HEADER_GUARD_1357924680)
#define NODEREFLISTBASE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOM_Node.hpp>
/**
* Local implementation of NodeRefList. This class is for internal use only.
*/
class XALAN_XPATH_EXPORT NodeRefListBase
{
public:
NodeRefListBase();
virtual
~NodeRefListBase();
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes
in
* the list, this returns <code>null</code>.
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
virtual DOM_Node
item(int index) const = 0;
/**
* The number of nodes in the list. The range of valid child node
indices is
* 0 to <code>length-1</code> inclusive.
*/
virtual int
getLength() const = 0;
virtual int
indexOf(const DOM_Node& theNode) const = 0;
protected:
NodeRefListBase(const NodeRefListBase&)
{
}
NodeRefListBase&
operator=(const NodeRefListBase&)
{
return *this;
}
};
#endif // NODEREFLISTBASE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/PrefixResolver.cpp
Index: PrefixResolver.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "PrefixResolver.hpp"
PrefixResolver::PrefixResolver()
{
}
PrefixResolver::~PrefixResolver()
{
}
1.1 xml-xalan/c/src/XPath/PrefixResolver.hpp
Index: PrefixResolver.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(PREFIXRESOLVER_HEADER_GUARD_1357924680)
#define PREFIXRESOLVER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOMString.hpp>
class XALAN_XPATH_EXPORT PrefixResolver
{
public:
explicit
PrefixResolver();
virtual
~PrefixResolver();
virtual DOMString
getNamespaceForPrefix(const DOMString& prefix) const = 0;
};
#endif // PREFIXRESOLVER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/QName.cpp
Index: QName.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "QName.hpp"
#include <include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include <PlatformSupport/XSLException.hpp>
#include <XSLT/Constants.hpp>
#include "NameSpace.hpp"
#include "ElementPrefixResolverProxy.hpp"
#include "PrefixResolver.hpp"
#include "XPathSupport.hpp"
const DOMString
QName::s_XMLNAMESPACEURI("http://www.w3.org/XML/1998/namespace");
QName::QName(
const DOMString& theNamespace,
const DOMString& theLocalPart) :
m_namespace(theNamespace),
m_localpart(theLocalPart)
{
}
QName::QName(
const DOMString& qname,
const NamespacesStackType& namespaces) :
m_namespace(),
m_localpart()
{
const int indexOfNSSep = indexOf(qname, ':');
if(indexOfNSSep > 0)
{
const DOMString prefix = substring(qname, 0,
indexOfNSSep);
if(prefix.equals("xmlns"))
return;
m_namespace = getNamespaceForPrefix(namespaces, prefix);
if(0 == length(m_namespace))
{
throw XSLException(DOMString("Prefix must resolve to a
namespace: ") + prefix);
}
m_localpart = substring(qname, indexOfNSSep + 1);
}
else
m_localpart = qname;
}
QName::QName(
const DOMString& qname,
const DOM_Element& namespaceContext,
const XPathSupport& support) :
m_namespace(),
m_localpart()
{
ElementPrefixResolverProxy theProxy(namespaceContext, support);
resolvePrefix(qname, theProxy);
}
QName::QName(
const DOMString& qname,
const PrefixResolver& theResolver) :
m_namespace(),
m_localpart()
{
resolvePrefix(qname, theResolver);
}
QName::~QName()
{
}
bool
QName::equals(const QName& theRHS) const
{
return ::equals(m_localpart, theRHS.m_localpart) &&
::equals(m_namespace, theRHS.m_namespace);
}
void
QName::resolvePrefix(
const DOMString& qname,
const PrefixResolver& theResolver)
{
const int indexOfNSSep = indexOf(qname, ':');
if(indexOfNSSep > 0)
{
const DOMString prefix = substring(qname, 0,
indexOfNSSep);
if(::equals(prefix, "xml"))
{
m_namespace = s_XMLNAMESPACEURI;
}
// The default namespace is not resolved.
else if(prefix.equals("xmlns"))
{
return;
}
else
{
m_namespace = theResolver.getNamespaceForPrefix(prefix);
}
if(0 == length(m_namespace))
{
throw XSLException(DOMString("Prefix must resolve to a
namespace: ") + prefix);
}
}
else
{
// $$$ ToDo: error or warning...
}
m_localpart = indexOfNSSep < 0 ? qname : substring(qname, indexOfNSSep
+ 1);
}
DOMString QName::getNamespaceForPrefix(const NamespaceVectorType& namespaces,
const DOMString& prefix, bool reverse /* true */)
{
DOMString nsURI;
if(prefix.equals("xml"))
nsURI = Constants::S_XMLNAMESPACEURI;
else
{
if (reverse)
{
for(int j = namespaces.size()-1; j >= 0; j--)
{
NameSpace ns = namespaces.at(j);
const DOMString& thisPrefix = ns.getPrefix();
if((0 != thisPrefix.length()) &&
prefix.equals(thisPrefix))
return ns.getURI();
}
}
else
{
for(int j = 0; j < namespaces.size(); j++)
{
NameSpace ns = namespaces.at(j);
const DOMString& thisPrefix = ns.getPrefix();
if((0 != thisPrefix.length()) &&
prefix.equals(thisPrefix))
return ns.getURI();
}
}
}
return nsURI;
}
DOMString QName::getNamespaceForPrefix(const NamespacesStackType& nsStack,
const DOMString& prefix, bool reverse /* true */)
{
DOMString nsURI;
int depth = nsStack.size();
for(int i = depth-1; i >= 0; i--)
{
NamespaceVectorType namespaces = nsStack.at(i);
nsURI = QName::getNamespaceForPrefix(namespaces, prefix,
reverse);
if (! ::isEmpty(nsURI))
return nsURI;
}
return nsURI;
}
DOMString QName::getPrefixForNamespace(const NamespaceVectorType& namespaces,
const DOMString& uri, bool reverse /* true */)
{
for(int j = namespaces.size()-1; j >= 0; j--)
{
NameSpace ns = namespaces.at(j);
const DOMString& thisPrefix = ns.getURI();
if((0 != thisPrefix.length()) && uri.equals(thisPrefix))
return ns.getPrefix();
}
return DOMString();
}
DOMString QName::getPrefixForNamespace(const NamespacesStackType& nsStack,
const DOMString& uri, bool reverse /* true */)
{
DOMString prefix;
int depth = nsStack.size();
if (reverse)
{
for(int i = depth-1; i >= 0; i--)
{
NamespaceVectorType namespaces = nsStack.at(i);
prefix = QName::getPrefixForNamespace(namespaces, uri,
reverse);
if (! ::isEmpty(prefix))
return prefix;
}
}
else
{
for(int i = 0; i < depth; i++)
{
NamespaceVectorType namespaces = nsStack.at(i);
prefix = QName::getPrefixForNamespace(namespaces, uri,
reverse);
if (! ::isEmpty(prefix))
return prefix;
}
}
return prefix;
}
1.1 xml-xalan/c/src/XPath/QName.hpp
Index: QName.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(QNAME_HEADER_GUARD_1357924680)
#define QNAME_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
class DOM_Element;
class NameSpace;
class PrefixResolver;
class XPathSupport;
/**
* Class to represent a qualified name: "The name of an internal XSLT object,
* specifically a named template (see [7 Named Templates]), a mode (see [6.7
Modes]),
* an attribute set (see [8.1.4 Named Attribute Sets]), a key (see [14.2
Keys]),
* a locale (see [14.3 Number Formatting]), a variable or a parameter (see
* [12 Variables and Parameters]) is specified as a QName. If it has a
prefix,
* then the prefix is expanded into a URI reference using the namespace
declarations
* in effect on the attribute in which the name occurs. The expanded name
* consisting of the local part of the name and the possibly null URI
reference
* is used as the name of the object. The default namespace is not used for
* unprefixed names."
*/
class XALAN_XPATH_EXPORT QName
{
public:
/**
* Construct a QName, with the supplied namespace and local part.
*/
QName(
const DOMString& theNamespace = DOMString(),
const DOMString& theLocalPart = DOMString());
typedef std::vector<NameSpace> NamespaceVectorType;
typedef std::vector<NamespaceVectorType>
NamespacesStackType;
/**
* Construct a QName from a string, resolving the prefix
* using the given namespace stack. The default namespace is
* not resolved.
*/
QName(
const DOMString& qname,
const NamespacesStackType& namespaces);
/**
* Construct a QName from a string, resolving the prefix
* using the given namespace stack. The default namespace is
* not resolved.
*/
QName(
const DOMString& qname,
const DOM_Element& namespaceContext,
const XPathSupport& support);
/**
* Construct a QName from a string, resolving the prefix
* using the given prefix resolver. The default namespace is
* not resolved.
*/
QName(
const DOMString& qname,
const PrefixResolver& theResolver);
~QName();
const DOMString&
getLocalPart() const
{
return m_localpart;
}
const DOMString&
getNamespace() const
{
return m_namespace;
}
bool isEmpty() const
{
return (::isEmpty(m_namespace) && ::isEmpty(m_localpart));
}
/**
* Override equals and agree that we're equal if
* the passed object is a string and it matches
* the name of the arg.
*/
bool
equals(const QName& theRHS) const;
bool
operator==(const QName& theRHS) const
{
return equals(theRHS);
}
/**
* Get the namespace from a prefix by searching a vector of namespaces,
of
* if reverse is true, search vector from last to first
*/
static DOMString getNamespaceForPrefix(const NamespaceVectorType&
namespaces,
const DOMString& prefix, bool reverse=true);
/**
* Get the namespace from a prefix by searching a vector of namespace
* vectors, if reverse is true, search vector from last to first
*/
static DOMString getNamespaceForPrefix(const NamespacesStackType&
nsStack,
const DOMString& prefix, bool reverse=true);
/**
* Get the prefix from a namespace by searching a vector of namespaces,
of
* if reverse is true, search vector from last to first
*/
static DOMString getPrefixForNamespace(const NamespaceVectorType&
namespaces,
const DOMString& uri, bool reverse=true);
/**
* Get the prefix from a namespace by searching a vector of namespace
* vectors, if reverse is true, search vector from last to first
*/
static DOMString getPrefixForNamespace(const NamespacesStackType&
nsStack,
const DOMString& uri, bool reverse=true);
private:
void
resolvePrefix(
const DOMString& qname,
const PrefixResolver& theResolver);
DOMString m_namespace;
DOMString m_localpart;
static const DOMString s_XMLNAMESPACEURI;
};
inline bool
operator<(
const QName& theLHS,
const QName& theRHS)
{
if (theLHS.getNamespace() < theRHS.getNamespace())
return true;
else if (equals( theLHS.getNamespace(), theRHS.getNamespace()))
{
return theLHS.getLocalPart() < theRHS.getLocalPart();
}
else
return false;
}
#endif // QNAME_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/ResultTreeFrag.cpp
Index: ResultTreeFrag.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ResultTreeFrag.hpp"
#include <cassert>
#include <include/DOMHelper.hpp>
ResultTreeFrag::ResultTreeFrag(
const DOM_Document& theFactory,
XPathSupport& theSupport) :
ResultTreeFragBase(theFactory),
m_document(theFactory),
m_children(&theSupport),
m_surrogate(m_children)
{
}
ResultTreeFrag::ResultTreeFrag(const ResultTreeFrag& theSource,
bool
deepClone) :
ResultTreeFragBase(theSource),
m_document(theSource.m_document),
m_children(deepClone == false ? theSource.m_children :
MutableNodeRefList()),
m_surrogate(m_children)
{
if (deepClone == true)
{
const int theLength = theSource.getLength();
for (int i = 0; i < theLength; i++)
{
m_children.addNode(theSource.item(i).cloneNode(true));
}
}
}
ResultTreeFrag::~ResultTreeFrag()
{
}
NodeImpl*
ResultTreeFrag::item(int index)
{
return
XALAN_DOM_NodeHack(m_children.item(index)).getImplementationObject();
};
int
ResultTreeFrag::getLength()
{
return m_children.getLength();
};
NodeImpl*
ResultTreeFrag::appendChild(NodeImpl* newChild)
{
XALAN_DOM_NodeHack theHack(newChild);
theHack = appendChild(theHack);
return theHack.getImplementationObject();
}
void
ResultTreeFrag::changed()
{
}
NodeImpl*
ResultTreeFrag::cloneNode(bool deep)
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return dynamic_cast<ResultTreeFrag*>(clone(deep));
#else
clone(deep);
#endif
}
NamedNodeMapImpl*
ResultTreeFrag::getAttributes()
{
return 0;
}
NodeListImpl*
ResultTreeFrag::getChildNodes()
{
return &m_surrogate;
}
NodeImpl*
ResultTreeFrag::getFirstChild()
{
return XALAN_DOM_NodeHack(m_children.item(0)).getImplementationObject();
}
NodeImpl*
ResultTreeFrag::getLastChild()
{
return XALAN_DOM_NodeHack(m_children.item(m_children.getLength() -
1)).getImplementationObject();
}
DocumentImpl*
ResultTreeFrag::getOwnerDocument()
{
XALAN_DOM_NodeHack theHack(m_document);
return dynamic_cast<DocumentImpl*>(theHack.getImplementationObject());
}
bool
ResultTreeFrag::hasChildNodes()
{
return const_cast<const ResultTreeFrag*>(this)->hasChildNodes();
}
NodeImpl*
ResultTreeFrag::insertBefore(
NodeImpl* newChild,
NodeImpl* refChild)
{
XALAN_DOM_NodeHack
theHack(insertBefore(XALAN_DOM_NodeHack(newChild),
XALAN_DOM_NodeHack(refChild)));
return theHack.getImplementationObject();
}
NodeImpl*
ResultTreeFrag::removeChild(NodeImpl* oldChild)
{
XALAN_DOM_NodeHack
theHack(removeChild(XALAN_DOM_NodeHack(oldChild)));
return theHack.getImplementationObject();
}
NodeImpl*
ResultTreeFrag::replaceChild(
NodeImpl* newChild,
NodeImpl* oldChild)
{
XALAN_DOM_NodeHack
theHack(replaceChild(XALAN_DOM_NodeHack(newChild),
XALAN_DOM_NodeHack(oldChild)));
return theHack.getImplementationObject();
}
void
ResultTreeFrag::setReadOnly(
bool /* readOnly */,
bool /* deep */)
{
}
DOMString
toString()
{
// $$$ ToTo: Fix this!!!
return DOMString();
}
DOM_Node
ResultTreeFrag::getFirstChild() const
{
return m_children.getLength() > 0 ? m_children.item(0) : DOM_Node();
}
DOM_Node
ResultTreeFrag::getLastChild() const
{
const int theLength = m_children.getLength();
return theLength > 0 ? m_children.item(theLength - 1) : DOM_Node();
}
DOM_Document
ResultTreeFrag::getOwnerDocument() const
{
return m_document;
}
DOM_Node
ResultTreeFrag::insertBefore(
const DOM_Node& newChild,
const DOM_Node& refChild)
{
const int refIndex = 0 == refChild ? m_children.getLength() :
m_children.indexOf(refChild);
assert(refIndex >= 0);
m_children.insertNode(newChild, refIndex);
return newChild;
}
DOM_Node
ResultTreeFrag::replaceChild(
const DOM_Node& newChild,
const DOM_Node& oldChild)
{
const int refIndex =
0 == oldChild ? -1 : m_children.indexOf(oldChild);
if(refIndex > -1)
{
const int newChildIndex = m_children.indexOf(newChild);
// Set the new child first, then erase it from
// the old position. if it's there.
m_children.setNode(refIndex, newChild);
if(newChildIndex > -1)
{
m_children.removeNode(newChildIndex);
}
}
return oldChild;
}
DOM_Node
ResultTreeFrag::removeChild(const DOM_Node& oldChild)
{
m_children.removeNode(oldChild);
return oldChild;
}
DOM_Node
ResultTreeFrag::appendChild(const DOM_Node& newChild)
{
m_children.addNode(newChild);
return newChild;
}
const NodeRefListBase&
ResultTreeFrag::getChildNodesAsNodeRefList() const
{
return m_children;
}
bool
ResultTreeFrag::hasChildNodes() const
{
return m_children.getLength() > 0 ? true : false;
}
int
ResultTreeFrag::getLength() const
{
return m_children.getLength();
};
DOM_Node
ResultTreeFrag::item(int index) const
{
return m_children.item(index);
};
DOM_Node
ResultTreeFrag::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return
DOM_ResultTreeFragBase(dynamic_cast<ResultTreeFrag*>(clone(deep)));
#else
return DOM_ResultTreeFragBase(clone(deep));
#endif
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Cloneable*
#else
ResultTreeFrag*
#endif
ResultTreeFrag::clone(bool deep) const
{
return new ResultTreeFrag(*this,
deep);
}
DOMString
ResultTreeFrag::toString()
{
return DOMString();
}
1.1 xml-xalan/c/src/XPath/ResultTreeFrag.hpp
Index: ResultTreeFrag.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(RESULTTREEFRAG_HEADER_GUARD_1357924680)
#define RESULTTREEFRAG_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOM_Document.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NodeListImplSurrogate.hpp>
#include <XPath/ResultTreeFragBase.hpp>
class XPathSupport;
/**
* The holder of result tree fragments.
*/
class XALAN_XPATH_EXPORT ResultTreeFrag : public ResultTreeFragBase
{
public:
ResultTreeFrag(
const DOM_Document& theFactory,
XPathSupport& theSupport);
ResultTreeFrag(const ResultTreeFrag& theSource,
bool
deepClone = true);
virtual
~ResultTreeFrag();
// these interfaces are inherited from Cloneable...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Cloneable*
#else
virtual ResultTreeFrag*
#endif
clone(bool deep) const;
// These interfaces are inherited from UnimplementedDocumentFragment...
// These interfaces are inherited from NodeListImpl...
virtual NodeImpl*
item(int index);
virtual int
getLength();
// These interfaces are inherited from NodeImpl...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual NodeImpl*
#else
virtual UnimplementedDocumentFragment*
#endif
cloneNode(bool deep);
virtual NodeImpl*
appendChild(NodeImpl* newChild);
virtual void
changed();
virtual NamedNodeMapImpl*
getAttributes();
virtual NodeListImpl*
getChildNodes();
virtual NodeImpl*
getFirstChild();
virtual NodeImpl*
getLastChild();
virtual DocumentImpl*
getOwnerDocument();
virtual bool
hasChildNodes();
virtual NodeImpl*
insertBefore(
NodeImpl* newChild,
NodeImpl* refChild);
virtual NodeImpl*
removeChild(NodeImpl* oldChild);
virtual NodeImpl*
replaceChild(
NodeImpl* newChild,
NodeImpl* oldChild);
virtual void
setReadOnly(
bool readOnly,
bool deep);
virtual DOMString
toString();
// These interfaces are inherited from ResultTreeFragBase
/**
* A <code>NodeList</code> that contains all children of this node. If
there
* are no children, this is a <code>NodeList</code> containing no
nodes.
* The content of the returned <code>NodeList</code> is "live" in the
sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned
by
* the <code>NodeList</code> accessors; it is not a static snapshot of
the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const NodeRefListBase&
getChildNodesAsNodeRefList() const;
virtual DOM_Node
item(int index) const;
virtual int
getLength() const;
/**
* The first child of this node. If there is no such node, this returns
* <code>null</code>.
*/
virtual DOM_Node
getFirstChild() const;
/**
* The last child of this node. If there is no such node, this returns
* <code>null</code>.
*/
virtual DOM_Node
getLastChild() const;
/**
* The <code>Document</code> object associated with this node. This is
also
* the <code>Document</code> object used to create new nodes. When this
* node is a <code>Document</code> this is <code>null</code>.
*/
virtual DOM_Document
getOwnerDocument() const;
/**
* Inserts the node <code>newChild</code> before the existing child
node
* <code>refChild</code>. If <code>refChild</code> is
<code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code>
object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in
the
* tree, it is first removed.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the
new
* node must be inserted.
* @return The node being inserted.
* @exception DOMException
* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not
* allow children of the type of the <code>newChild</code> node, or
if
* the node to insert is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was
created
* from a different document than the one that created this node.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child
of
* this node.
*/
virtual DOM_Node
insertBefore(
const DOM_Node& newChild,
const DOM_Node& refChild);
/**
* Replaces the child node <code>oldChild</code> with
<code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
If
* the <code>newChild</code> is already in the tree, it is first
removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
* @exception DOMException
* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not
* allow children of the type of the <code>newChild</code> node, or
it
* the node to put in is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was
created
* from a different document than the one that created this node.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child
of
* this node.
*/
virtual DOM_Node
replaceChild(
const DOM_Node& newChild,
const DOM_Node& oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the
list
* of children, and returns it.
* @param oldChild The node being removed.
* @return The node removed.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child
of
* this node.
*/
virtual DOM_Node
removeChild(const DOM_Node& oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of
children of
* this node. If the <code>newChild</code> is already in the tree, it
is
* first removed.
* @param newChild The node to add.If it is a
<code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved
into
* the child list of this node
* @return The node added.
* @exception DOMException
* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not
* allow children of the type of the <code>newChild</code> node, or
if
* the node to append is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was
created
* from a different document than the one that created this node.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual DOM_Node
appendChild(const DOM_Node& newChild);
/**
* This is a convenience method to allow easy determination of whether
a
* node has any children.
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
/**
* Returns a duplicate of this node, i.e., serves as a generic copy
* constructor for nodes. The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it
contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply
returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree
under the
* specified node; if <code>false</code>, clone only the node itself
(and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
virtual DOM_Node
cloneNode(bool deep) const;
ResultTreeFrag&
operator=(const ResultTreeFrag& theRHS)
{
if (&theRHS != this)
{
ResultTreeFragBase::operator==(theRHS);
m_document = theRHS.m_document;
m_children = m_children;
}
return *this;
}
private:
// Not defined
bool
operator==(const ResultTreeFrag& theRHS) const;
DOM_Document m_document;
MutableNodeRefList m_children;
NodeListImplSurrogate m_surrogate;
};
#endif // RESULTTREEFRAGBASE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/ResultTreeFragBase.cpp
Index: ResultTreeFragBase.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ResultTreeFragBase.hpp"
#include <include/DOMHelper.hpp>
ResultTreeFragBase::ResultTreeFragBase(const DOM_Document&
theOwnerDocument) :
Cloneable(),
#if defined(XALAN_XERCES_RTTI_AVAILABLE)
UnimplementedDocumentFragment(dynamic_cast<DocumentImpl*>(XALAN_DOM_NodeHack(theOwnerDocument).getImplementationObject()))
#else
UnimplementedDocumentFragment(static_cast<DocumentImpl*>(XALAN_DOM_NodeHack(theOwnerDocument).getImplementationObject()))
#endif
{
}
ResultTreeFragBase::ResultTreeFragBase(const ResultTreeFragBase&
theSource) :
Cloneable(theSource),
UnimplementedDocumentFragment(theSource)
{
}
ResultTreeFragBase::~ResultTreeFragBase()
{
}
DOMString
ResultTreeFragBase::getNodeValue()
{
return DOMString();
}
void
ResultTreeFragBase::setNodeValue(const DOMString&)
{
}
DOMString
ResultTreeFragBase::getNodeName()
{
return DOMString();
}
short
ResultTreeFragBase::getNodeType()
{
return DocumentFragmentImpl::getNodeType();
}
NodeImpl*
ResultTreeFragBase::getParentNode()
{
return 0;
}
NodeImpl*
ResultTreeFragBase::getNextSibling()
{
return 0;
}
NodeImpl*
ResultTreeFragBase::getPreviousSibling()
{
return 0;
}
DOM_ResultTreeFragBase::DOM_ResultTreeFragBase(ResultTreeFragBase*
theFragment) :
DOM_UnimplementedDocumentFragment(theFragment)
{
}
DOM_ResultTreeFragBase::DOM_ResultTreeFragBase() :
DOM_UnimplementedDocumentFragment()
{
}
DOM_ResultTreeFragBase::DOM_ResultTreeFragBase(const DOM_ResultTreeFragBase&
theDocument) :
DOM_UnimplementedDocumentFragment(theDocument)
{
}
DOM_ResultTreeFragBase::~DOM_ResultTreeFragBase()
{
}
1.1 xml-xalan/c/src/XPath/ResultTreeFragBase.hpp
Index: ResultTreeFragBase.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(RESULTTREEFRAGBASE_HEADER_GUARD_1357924680)
#define RESULTTREEFRAGBASE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/Cloneable.hpp>
#include <DOMSupport/UnimplementedDocumentFragment.hpp>
class DOM_Document;
class NodeRefListBase;
class XMLParserLiaison;
/**
* The holder of result tree fragments.
*/
class XALAN_XPATH_EXPORT ResultTreeFragBase : public Cloneable, public
UnimplementedDocumentFragment
{
public:
ResultTreeFragBase(const DOM_Document& theOwnerDocument);
ResultTreeFragBase(const ResultTreeFragBase&);
virtual
~ResultTreeFragBase();
// these interfaces are inherited from Cloneable...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Cloneable*
#else
virtual ResultTreeFragBase*
#endif
clone(bool deep) const = 0;
// These interfaces are inherited from UnimplementedDocumentFragment...
// These interfaces are inherited from NodeListImpl...
virtual NodeImpl*
item(int index) = 0;
virtual int
getLength() = 0;
// These interfaces are inherited from NodeImpl...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual NodeImpl*
#else
virtual ResultTreeFragBase*
#endif
cloneNode(bool deep) = 0;
virtual NodeImpl*
appendChild(NodeImpl* newChild) = 0;
virtual void
changed() = 0;
virtual NamedNodeMapImpl*
getAttributes() = 0;
virtual NodeListImpl*
getChildNodes() = 0;
virtual NodeImpl*
getFirstChild() = 0;
virtual NodeImpl*
getLastChild() = 0;
// Deriving classes do not need to override these next three
// interfaces, since ResultTreeFragments do not have these
// properties.
virtual DOMString
getNodeName();
virtual short
getNodeType();
virtual DOMString
getNodeValue();
// Deriving classes must implement these interfaces ...
virtual DocumentImpl*
getOwnerDocument() = 0;
// Deriving classes do not need to override these next three
// interfaces, since ResultTreeFragments do not have these
// properties.
virtual NodeImpl*
getParentNode();
virtual NodeImpl*
getNextSibling();
virtual NodeImpl*
getPreviousSibling();
// Deriving classes must implement these interfaces ...
virtual bool
hasChildNodes() = 0;
virtual NodeImpl*
insertBefore(
NodeImpl* newChild,
NodeImpl* refChild) = 0;
virtual NodeImpl*
removeChild(NodeImpl *oldChild) = 0;
virtual NodeImpl*
replaceChild(
NodeImpl* newChild,
NodeImpl* oldChild) = 0;
// Deriving classes do not need to override this, since
// ResultTreeFragments do not have this properties.
virtual void
setNodeValue(const DOMString& value);
// Deriving classes must implement these interfaces ...
virtual void
setReadOnly(
bool readOnly,
bool deep) = 0;
virtual DOMString
toString() = 0;
// These interfaces are new to ResultTreeFragBase
// Many of these interfaces duplicate ones that are inherited from the
Xerces DOM
// implementation classes. In general, they take and/or return
instances of the
// Xerces smart-pointer classes. Other are const, which many of the
Xerces functions
// are not.
/**
* A <code>NodeList</code> that contains all children of this node. If
there
* are no children, this is a <code>NodeList</code> containing no
nodes.
* The content of the returned <code>NodeList</code> is "live" in the
sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned
by
* the <code>NodeList</code> accessors; it is not a static snapshot of
the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const NodeRefListBase&
getChildNodesAsNodeRefList() const = 0;
virtual DOM_Node
item(int index) const = 0;
virtual int
getLength() const = 0;
/**
* The first child of this node. If there is no such node, this returns
* <code>null</code>.
*/
virtual DOM_Node
getFirstChild() const = 0;
/**
* The last child of this node. If there is no such node, this returns
* <code>null</code>.
*/
virtual DOM_Node
getLastChild() const = 0;
/**
* The <code>Document</code> object associated with this node. This is
also
* the <code>Document</code> object used to create new nodes. When this
* node is a <code>Document</code> this is <code>null</code>.
*/
virtual DOM_Document
getOwnerDocument() const = 0;
/**
* Inserts the node <code>newChild</code> before the existing child
node
* <code>refChild</code>. If <code>refChild</code> is
<code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code>
object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in
the
* tree, it is first removed.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the
new
* node must be inserted.
* @return The node being inserted.
* @exception DOMException
* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not
* allow children of the type of the <code>newChild</code> node, or
if
* the node to insert is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was
created
* from a different document than the one that created this node.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child
of
* this node.
*/
virtual DOM_Node
insertBefore(
const DOM_Node& newChild,
const DOM_Node& refChild) = 0;
/**
* Replaces the child node <code>oldChild</code> with
<code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
If
* the <code>newChild</code> is already in the tree, it is first
removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
* @exception DOMException
* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not
* allow children of the type of the <code>newChild</code> node, or
it
* the node to put in is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was
created
* from a different document than the one that created this node.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child
of
* this node.
*/
virtual DOM_Node
replaceChild(
const DOM_Node& newChild,
const DOM_Node& oldChild) = 0;
/**
* Removes the child node indicated by <code>oldChild</code> from the
list
* of children, and returns it.
* @param oldChild The node being removed.
* @return The node removed.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child
of
* this node.
*/
virtual DOM_Node
removeChild(const DOM_Node& oldChild) = 0;
/**
* Adds the node <code>newChild</code> to the end of the list of
children of
* this node. If the <code>newChild</code> is already in the tree, it
is
* first removed.
* @param newChild The node to add.If it is a
<code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved
into
* the child list of this node
* @return The node added.
* @exception DOMException
* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not
* allow children of the type of the <code>newChild</code> node, or
if
* the node to append is one of this node's ancestors.
* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was
created
* from a different document than the one that created this node.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual DOM_Node
appendChild(const DOM_Node& newChild) = 0;
/**
* This is a convenience method to allow easy determination of whether
a
* node has any children.
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const = 0;
/**
* Returns a duplicate of this node, i.e., serves as a generic copy
* constructor for nodes. The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it
contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply
returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree
under the
* specified node; if <code>false</code>, clone only the node itself
(and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
virtual DOM_Node
cloneNode(bool deep) const = 0;
protected:
ResultTreeFragBase&
operator=(const ResultTreeFragBase& theRHS)
{
Cloneable::operator=(theRHS);
UnimplementedDocumentFragment::operator=(theRHS);
return *this;
}
bool
operator==(const ResultTreeFragBase&) const
{
return true;
}
};
class XALAN_XPATH_EXPORT DOM_ResultTreeFragBase : public
DOM_UnimplementedDocumentFragment
{
public:
/**
* Constructors.
*/
DOM_ResultTreeFragBase(ResultTreeFragBase* theFragment);
DOM_ResultTreeFragBase();
DOM_ResultTreeFragBase(const DOM_ResultTreeFragBase& theNode);
/**
* Destructor.
*/
~DOM_ResultTreeFragBase();
/**
* Assignment operator.
*
* @param other The source to be assigned.
*/
DOM_ResultTreeFragBase&
operator=(const DOM_ResultTreeFragBase& other)
{
DOM_UnimplementedDocumentFragment::operator=(other);
return *this;
}
/**
* Assignment operator. This overloaded variant is provided for
* the sole purpose of setting a DOM_Node reference variable to
* zero. Nulling out a reference variable in this way will
decrement
* the reference count on the underlying Node object that the
variable
* formerly referenced. This effect is normally obtained when
reference
* variable goes out of scope, but zeroing them can be useful for
* global instances, or for local instances that will remain in
scope
* for an extended time, when the storage belonging to the
underlying
* node needs to be reclaimed.
*
* @param val. Only a value of 0, or null, is allowed.
*/
DOM_ResultTreeFragBase&
operator=(const DOM_NullPtr* val)
{
DOM_UnimplementedDocumentFragment::operator=(val);
return *this;
}
/**
* The equality operator. This compares to references to nodes, and
* returns true if they both refer to the same underlying node. It
* is exactly analogous to Java's operator == on object reference
* variables. This operator can not be used to compare the values
* of two different nodes in the document tree.
*
* @param other The object reference with which <code>this</code>
object is compared
* @returns True if both <code>DOM_Node</code>s refer to the same
* actual node, or are both null; return false otherwise.
*/
bool
operator==(const DOM_Node& other) const
{
return DOM_UnimplementedDocumentFragment::operator==(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator==(const DOM_NullPtr* other) const
{
return DOM_UnimplementedDocumentFragment::operator==(other);
}
/**
* The inequality operator. See operator ==.
*
*/
bool
operator!=(const DOM_Node& other) const
{
return DOM_UnimplementedDocumentFragment::operator!=(other);
}
/**
* Compare with a pointer. Intended only to allow a convenient
* comparison with null.
*
*/
bool
operator!=(const DOM_NullPtr* other) const
{
return DOM_UnimplementedDocumentFragment::operator!=(other);
}
};
#endif // RESULTTREEFRAGBASE_HEADER_GUARD
1.1 xml-xalan/c/src/XPath/SimpleNodeLocator.cpp
Index: SimpleNodeLocator.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "SimpleNodeLocator.hpp"
#include <include/DOMHelper.hpp>
#include <PlatformSupport/DirectoryEnumerator.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Attr.hpp>
#include <dom/DOM_Document.hpp>
#include "FoundIndex.hpp"
#include "NodeRefListBase.hpp"
#include "XObject.hpp"
#include "XObjectFactory.hpp"
#include "XPath.hpp"
SimpleNodeLocator SimpleNodeLocator::s_defaultInstance;
SimpleNodeLocator*
SimpleNodeLocator::getDefaultInstance()
{
return &s_defaultInstance;
}
SimpleNodeLocator::SimpleNodeLocator() :
XLocator()
{
}
SimpleNodeLocator::~SimpleNodeLocator()
{
}
XObject*
SimpleNodeLocator::connectToNodes(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& /* context */,
int opPos,
std::vector<XObject*> connectArgs)
{
assert(connectArgs.size() > 0 && connectArgs.size() < 3);
const XPathExpression& currentExpression =
xpath.getExpression();
XObjectFactory& theFactory =
executionContext.getXObjectFactory();
XObjectGuard results(theFactory,
theFactory.createNodeSet(MutableNodeRefList()));
const DOMString theFileSpec = connectArgs[0]->str();
const DOMString filterSpec = connectArgs.size() > 1 ?
connectArgs[0]->str() : "";
const int filterSpecLength = length(filterSpec);
DirectoryEnumeratorFunctor<std::vector<DOMString> > theEnumerator;
const std::vector<DOMString> theFiles =
theEnumerator(theFileSpec);
const int nFiles
= theFiles.size();
if (nFiles > 0)
{
MutableNodeRefList& theNodeList = results->mutableNodeset();
for(int i = 0; i < nFiles; ++i)
{
try
{
// If there's no filter spec, or the spec
matches the file, then
// parse the XML.
if (filterSpecLength == 0 ||
endsWith(theFiles[i], filterSpec) ==
true)
{
DOM_Document doc =
executionContext.parseXML(theFiles[i], theFileSpec);
if(0 != doc)
{
const int value =
currentExpression.getOpCodeMapValue(opPos);
if(XPathExpression::eOP_LOCATIONPATH == value)
{
XObject* const xnl =
xpath.locationPath(doc, opPos);
if(0 != xnl)
{
theNodeList.addNodes(xnl->nodeset());
executionContext.associateXLocatorToNode(doc, this);
}
}
else
{
theNodeList.addNode(doc);
executionContext.associateXLocatorToNode(doc, this);
}
}
}
}
catch(...)
{
executionContext.warn(DOMString("Couldn't parse
XML file: ") + theFiles[i]);
}
}
}
else
{
executionContext.warn("No files matched the file
specification!");
}
return results.release();
}
XObject*
SimpleNodeLocator::locationPath(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos)
{
MutableNodeRefList mnl = step(xpath, executionContext, context,
opPos + 2);
return executionContext.getXObjectFactory().createNodeSet(mnl);
}
double
SimpleNodeLocator::locationPathPattern(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos)
{
double score = xpath.s_MatchScoreNone;
stepPattern(xpath, executionContext, context, opPos + 2, score);
return score;
}
MutableNodeRefList
SimpleNodeLocator::step(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// int endStep = xpath.getNextOpPos(opPos);
const int stepType =
currentExpression.getOpCodeMapValue(opPos);
int argLen = 0;
MutableNodeRefList
subQueryResults(executionContext.createMutableNodeRefList());
MutableNodeRefList queryResults(subQueryResults);
bool shouldReorder = false;
bool continueStepRecursion = true;
switch(stepType)
{
case XPathExpression::eOP_VARIABLE:
case XPathExpression::eOP_EXTFUNCTION:
case XPathExpression::eOP_FUNCTION:
case XPathExpression::eOP_GROUP:
argLen = findNodeSet(xpath, executionContext, context, opPos,
stepType,
subQueryResults);
break;
case XPathExpression::eFROM_ROOT:
argLen = findRoot(xpath, executionContext, context, opPos,
stepType, subQueryResults);
break;
case XPathExpression::eFROM_PARENT:
argLen = findParent(xpath, executionContext, context, opPos,
stepType, subQueryResults);
break;
case XPathExpression::eFROM_SELF:
argLen = findSelf(xpath, executionContext, context, opPos,
stepType, subQueryResults);
break;
case XPathExpression::eFROM_ANCESTORS:
argLen = findAncestors(xpath, executionContext, context, opPos,
stepType, subQueryResults);
shouldReorder = true;
break;
case XPathExpression::eFROM_ANCESTORS_OR_SELF:
argLen = findAncestorsOrSelf(xpath, executionContext, context,
opPos, stepType, subQueryResults);
shouldReorder = true;
break;
case XPathExpression::eMATCH_ATTRIBUTE:
continueStepRecursion = false;
// fall-through on purpose.
case XPathExpression::eFROM_ATTRIBUTES:
argLen = findAttributes(xpath, executionContext, context,
opPos, stepType, subQueryResults);
break;
case XPathExpression::eMATCH_ANY_ANCESTOR:
case XPathExpression::eMATCH_IMMEDIATE_ANCESTOR:
case XPathExpression::eMATCH_ANY_ANCESTOR_WITH_PREDICATE:
continueStepRecursion = false;
// fall-through on purpose.
case XPathExpression::eFROM_CHILDREN:
argLen = findChildren(xpath, executionContext, context, opPos,
stepType, subQueryResults);
break;
case XPathExpression::eFROM_DESCENDANTS:
case XPathExpression::eFROM_DESCENDANTS_OR_SELF:
argLen = findDescendants(xpath, executionContext, context,
opPos, stepType, subQueryResults);
break;
case XPathExpression::eFROM_FOLLOWING:
argLen = findFollowing(xpath, executionContext, context, opPos,
stepType, subQueryResults);
break;
case XPathExpression::eFROM_FOLLOWING_SIBLINGS:
argLen = findFollowingSiblings(xpath, executionContext,
context, opPos, stepType, subQueryResults);
break;
case XPathExpression::eFROM_PRECEDING:
argLen = findPreceeding(xpath, executionContext, context,
opPos, stepType, subQueryResults);
shouldReorder = true;
break;
case XPathExpression::eFROM_PRECEDING_SIBLINGS:
argLen = findPreceedingSiblings(xpath, executionContext,
context, opPos, stepType, subQueryResults);
shouldReorder = true;
break;
case XPathExpression::eFROM_NAMESPACE:
argLen = findNamespace(xpath, executionContext, context, opPos,
stepType, subQueryResults);
break;
default:
argLen = findNodesOnUnknownAxis(xpath, executionContext,
context, opPos, stepType, subQueryResults);
break;
}
MutableNodeRefList savedContextNodeList =
executionContext.createMutableNodeRefList();
savedContextNodeList = xpath.getContextNodeList();
xpath.setContextNodeList(subQueryResults);
try
{
opPos += argLen;
int nextStepType =
currentExpression.getOpCodeMapValue(opPos);
if(XPathExpression::eOP_PREDICATE == nextStepType)
{
predicates(xpath,
executionContext,
context,
opPos,
subQueryResults,
opPos);
nextStepType =
currentExpression.getOpCodeMapValue(opPos);
}
if(XPathExpression::eENDOP != nextStepType &&
continueStepRecursion == true)
{
const int nContexts = subQueryResults.getLength();
for(int i = 0; i < nContexts; i++)
{
const DOM_Node node = subQueryResults.item(i);
if(0 != node)
{
MutableNodeRefList mnl =
step(xpath, executionContext, node, opPos);
if(queryResults.getLength() == 0)
{
queryResults = mnl;
}
else
{
queryResults.addNodesInDocOrder(mnl);
}
}
}
}
else
{
if(shouldReorder == true)
{
queryResults.addNodesInDocOrder(subQueryResults);
}
else
{
queryResults = subQueryResults;
}
}
}
catch(...)
{
xpath.setContextNodeList(savedContextNodeList);
throw;
}
xpath.setContextNodeList(savedContextNodeList);
return queryResults;
}
DOM_Node
SimpleNodeLocator:: stepPattern(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
double& score)
{
const XPathExpression& currentExpression =
xpath.getExpression();
const int startOpPos = opPos;
const int stepType = currentExpression.getOpCodeMapValue(opPos);
const int endStep =
currentExpression.getNextOpCodePosition(opPos);
int nextStepType =
currentExpression.getOpCodeMapValue(endStep);
DOM_Node localContext(context);
if(XPathExpression::eENDOP != nextStepType)
{
// Continue step via recursion...
localContext = stepPattern(xpath,
executionContext,
localContext,
endStep,
score);
if(0 == localContext)
{
score = xpath.s_MatchScoreNone;
// !!!!!!!!!!!!! Big ugly return here
!!!!!!!!!!!!!!!!!!!
return DOM_Node();
}
score = xpath.s_MatchScoreOther;
localContext = executionContext.getParentOfNode(localContext);
if(0 == localContext)
{
// !!!!!!!!!!!!! Big ugly return here
!!!!!!!!!!!!!!!!!!!
return DOM_Node();
}
}
int argLen = 0;
switch(stepType)
{
case XPathExpression::eOP_FUNCTION:
{
argLen = currentExpression.getOpCodeLength(opPos);
const XObject* const obj =
xpath.execute(localContext, opPos);
const NodeRefListBase& nl = obj->nodeset();
const int len =
nl.getLength();
score = xpath.s_MatchScoreNone;
for(int i = 0; i < len; i++)
{
const DOM_Node n = nl.item(i);
score = n == localContext ?
xpath.s_MatchScoreOther :
xpath.s_MatchScoreNone;
if(score == xpath.s_MatchScoreOther)
{
localContext = n;
break;
}
}
}
break;
case XPathExpression::eFROM_ROOT:
{
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
const DOM_Document docContext =
DOM_Node::DOCUMENT_NODE == localContext.getNodeType() ?
static_cast<const DOM_Document&>(localContext) :
localContext.getOwnerDocument();
score = docContext == localContext ?
xpath.s_MatchScoreOther : xpath.s_MatchScoreNone;
if(score == xpath.s_MatchScoreOther)
{
localContext = docContext;
}
}
break;
case XPathExpression::eMATCH_ATTRIBUTE:
{
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
score = nodeTest(xpath,
executionContext,
localContext,
opPos,
argLen,
XPathExpression::eFROM_ATTRIBUTES);
}
break;
case XPathExpression::eMATCH_ANY_ANCESTOR:
case XPathExpression::eMATCH_ANY_ANCESTOR_WITH_PREDICATE:
{
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
score = xpath.s_MatchScoreNone;
while(0 != localContext)
{
score = nodeTest(xpath, executionContext,
localContext, opPos, argLen, stepType);
if(xpath.s_MatchScoreNone != score)
break;
localContext =
executionContext.getParentOfNode(localContext);
}
}
break;
case XPathExpression::eMATCH_IMMEDIATE_ANCESTOR:
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
score = nodeTest(xpath, executionContext, localContext, opPos,
argLen, stepType);
break;
default:
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
score = xpath.s_MatchScoreNone;
executionContext.error("unknown match operation!",
localContext);
break;
}
opPos += argLen;
nextStepType = currentExpression.getOpCodeMapValue(opPos);
if(score != xpath.s_MatchScoreNone && XPathExpression::eOP_PREDICATE ==
nextStepType)
{
score = xpath.s_MatchScoreOther;
// Execute the xpath.predicates, but if we have an index, then
we have
// to start over and do a search from the parent. It would be
nice
// if I could sense this condition earlier...
try
{
xpath.setThrowFoundIndex(true);
// $$$ ToDo: Why is this variable introduced?
int startPredicates = opPos;
opPos = startPredicates;
while(XPathExpression::eOP_PREDICATE == nextStepType)
{
const XObject* const pred =
xpath.predicate(localContext, opPos);
if(XObject::eTypeNumber == pred->getType())
{
throw FoundIndex();
}
else if(pred->boolean() == false)
{
score = xpath.s_MatchScoreNone;
break; // from while(xpath.OP_PREDICATE
== nextStepType)
}
opPos =
currentExpression.getNextOpCodePosition(opPos);
nextStepType =
currentExpression.getOpCodeMapValue(opPos);
}
xpath.setThrowFoundIndex(false);
}
catch(const FoundIndex&)
{
// We have an index somewhere in our pattern. So, we
have
// to do a full search for our step, using the parent
as
// localContext, then see if the current localContext
is found in the
// node set. Seems crazy, but, so far, it seems like
the
// easiest way.
xpath.setThrowFoundIndex(false);
const DOM_Node parentContext =
executionContext.getParentOfNode(localContext);
MutableNodeRefList mnl = step(xpath,
executionContext, parentContext, startOpPos);
const int nNodes =
mnl.getLength();
score = xpath.s_MatchScoreNone;
for(int i = 0; i < nNodes; i++)
{
if(mnl.item(i) == localContext)
{
score = xpath.s_MatchScoreOther;
break;
}
}
}
}
return score == xpath.s_MatchScoreNone ? DOM_Node() : localContext;
}
int
SimpleNodeLocator::findNodeSet(
XPath& xpath,
XPathExecutionContext& /* executionContext */,
const DOM_Node& context,
int opPos,
int /* stepType */,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
const XObject* const obj = xpath.execute(context, opPos);
const NodeRefListBase& nl = obj->nodeset();
// Should this be adding in doc order?
// We can not simply assign the nl value to
// subQueryResults, because nl may be a ref to
// a variable or the like, and we may mutate
// below... which results in a hard-to-find bug!
subQueryResults.addNodes(nl);
return currentExpression.getOpCodeLength(opPos);
}
int
SimpleNodeLocator::findRoot(
XPath& xpath,
XPathExecutionContext& /* executionContext */,
const DOM_Node& context,
int opPos,
int /* stepType */,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
DOM_Document docContext = DOM_Node::DOCUMENT_NODE ==
context.getNodeType() ?
static_cast<const DOM_Document&>(context) :
context.getOwnerDocument();
subQueryResults.addNode(docContext);
return argLen + 3;
}
int
SimpleNodeLocator::findParent(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
const DOM_Node theParent = executionContext.getParentOfNode(context);
if(0 != theParent)
{
if(argLen > 0)
{
const double score = nodeTest(xpath,
executionContext,
theParent,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(theParent);
}
}
else
{
subQueryResults.addNode(theParent);
}
}
return argLen + 3;
}
int
SimpleNodeLocator::findSelf(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
if(argLen > 0)
{
const double score = nodeTest(xpath,
executionContext,
context,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(context);
}
}
else
{
subQueryResults.addNode(context);
}
return argLen + 3;
}
int
SimpleNodeLocator::findAncestors(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
DOM_Node contextNode =
executionContext.getParentOfNode(context);
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
while(0 != contextNode)
{
const double score = nodeTest(xpath,
executionContext,
contextNode,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(contextNode);
}
contextNode = executionContext.getParentOfNode(contextNode);
}
return argLen + 3;
}
int
SimpleNodeLocator::findAncestorsOrSelf(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
// $$ ToDO: Can this function be reduced to calling
// findSelf() and findAncestors()? I would think so...
const XPathExpression& currentExpression =
xpath.getExpression();
DOM_Node contextNode(context);
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
while(0 != contextNode)
{
const double score = nodeTest(xpath,
executionContext,
contextNode,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(contextNode);
}
contextNode = executionContext.getParentOfNode(contextNode);
}
return argLen + 3;
}
int
SimpleNodeLocator::findAttributes(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
if(0 != context && context.getNodeType() == DOM_Node::ELEMENT_NODE)
{
const DOM_Element& e =
static_cast<const DOM_Element&>(context);
DOM_NamedNodeMap attributeList = e.getAttributes();
if(attributeList != 0)
{
opPos += 3;
const int nAttrs = attributeList.getLength();
for(int j = 0; j < nAttrs; j++)
{
const DOM_Node theNode = attributeList.item(j);
assert(theNode.getNodeType() ==
DOM_Node::ATTRIBUTE_NODE);
const double score = nodeTest(xpath,
executionContext,
theNode,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(theNode);
}
}
}
}
return argLen + 3;
}
int
SimpleNodeLocator::findChildren(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
DOM_Node child = context.getFirstChild();
while(0 != child)
{
const double score = nodeTest(xpath,
executionContext,
child,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(child);
}
child = child.getNextSibling();
}
return argLen + 3;
}
int
SimpleNodeLocator::findDescendants(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
// Perform a pre-order traversal of descendents.
// Note that I would like to be able to do optimization here
// where if I have a simple tag name node test, I would
// like to be able to call
// ((Element)context).getElementsByTagName(m_token).
// One problem is that it would return a NodeList, not a
// NodeListImpl.
/*
if(lookahead('[', 1) || lookahead('(', 1)
|| (Node.ELEMENT_NODE != context.getNodeType()))
{
*/
DOM_Node pos = context;
while(0 != pos)
{
if(stepType == XPathExpression::eFROM_DESCENDANTS_OR_SELF ||
context != pos)
{
const double score = nodeTest(xpath,
executionContext,
pos,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(pos);
}
}
DOM_Node nextNode = pos.getFirstChild();
while(0 == nextNode)
{
if(context == pos)
break;
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
pos = pos.getParentNode();
if(context == pos || pos == 0)
{
nextNode = 0;
break;
}
}
}
pos = nextNode;
}
return argLen + 3;
}
int
SimpleNodeLocator::findFollowing(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
// What fun...
const DOM_Document doc = context.getOwnerDocument();
DOM_Node pos = context;
while(0 != pos)
{
DOM_Node nextNode;
if(pos != context)
{
const double score = nodeTest(xpath,
executionContext,
pos,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNodeInDocOrder(pos);
}
nextNode = pos.getFirstChild();
}
else
{
nextNode = 0;
}
while(0 == nextNode)
{
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
pos = pos.getParentNode();
if(doc == pos || 0 == pos)
{
nextNode = 0;
break;
}
}
}
pos = nextNode;
}
return argLen + 3;
}
int
SimpleNodeLocator::findFollowingSiblings(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
DOM_Node pos = context.getNextSibling();
while(0 != pos)
{
const double score = nodeTest(xpath,
executionContext,
pos,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(pos);
}
pos = pos.getNextSibling();
}
return argLen + 3;
}
int
SimpleNodeLocator::findPreceeding(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
// Ugh. Reverse document order, no parents, I guess.
const DOM_Document doc = context.getOwnerDocument();
DOM_Node pos = doc;
while(0 != pos)
{
if(context == pos)
break;
const double score = nodeTest(xpath,
executionContext,
pos,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
// Ugh. If I could think a little better tonight, I'm
// sure there's a better way to check for the parent.
bool isParent = false;
DOM_Node parent =
executionContext.getParentOfNode(context);
while(0 != parent)
{
if(parent == pos)
{
isParent = true;
break;
}
parent =
executionContext.getParentOfNode(parent);
}
if(isParent == false)
{
subQueryResults.insertNode(pos, 0);
}
}
DOM_Node nextNode = pos.getFirstChild();
while(0 == nextNode)
{
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
pos = pos.getParentNode();
if(doc == pos)
{
nextNode = 0;
break;
}
}
}
pos = nextNode;
}
return argLen + 3;
}
int
SimpleNodeLocator::findPreceedingSiblings(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
opPos += 3;
DOM_Node pos = context.getPreviousSibling();
while(0 != pos)
{
const double score = nodeTest(xpath,
executionContext,
pos,
opPos,
argLen,
stepType);
if(xpath.s_MatchScoreNone != score)
{
subQueryResults.addNode(pos);
}
pos = pos.getPreviousSibling();
}
return argLen + 3;
}
int
SimpleNodeLocator::findNamespace(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int /* stepType */,
MutableNodeRefList& /* subQueryResults */)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
executionContext.error("namespace axis not implemented yet!", context);
return argLen + 3;
}
int
SimpleNodeLocator::findNodesOnUnknownAxis(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& /* subQueryResults */)
{
const XPathExpression& currentExpression =
xpath.getExpression();
// $$ ToDO: Can we reduce this to some call on the
// XPathExpression interface?
const int argLen =
currentExpression.getOpCodeMapValue(opPos +
XPathExpression::s__opCodeMapLengthIndex + 1) - 3;
executionContext.error("unknown axis: " + stepType, context);
return argLen + 3;
}
double
SimpleNodeLocator::nodeTest(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int argLen,
int stepType)
{
const XPathExpression& currentExpression =
xpath.getExpression();
double score = 0.0L;
const int testType = currentExpression.getOpCodeMapValue(opPos);
const int nodeType = context.getNodeType();
opPos++;
switch(testType)
{
case XPathExpression::eNODETYPE_COMMENT:
score = DOM_Node::COMMENT_NODE == nodeType
? xpath.s_MatchScoreNodeTest : xpath.s_MatchScoreNone;
break;
case XPathExpression::eNODETYPE_TEXT:
score = (DOM_Node::CDATA_SECTION_NODE == nodeType ||
DOM_Node::TEXT_NODE == nodeType) &&
executionContext.shouldStripSourceNode(context) ==
false
? xpath.s_MatchScoreNodeTest : xpath.s_MatchScoreNone;
break;
case XPathExpression::eNODETYPE_PI:
if(DOM_Node::PROCESSING_INSTRUCTION_NODE != nodeType)
{
score = xpath.s_MatchScoreNone;
}
else
{
if(argLen == 1)
{
score = xpath.s_MatchScoreNodeTest;
}
else if(argLen == 2)
{
const int
tokenPosition =
currentExpression.getOpCodeMapValue(opPos);
const XObject* const name =
currentExpression.getToken(tokenPosition);
assert(name != 0);
const DOM_ProcessingInstruction& theNode
=
reinterpret_cast<const
DOM_ProcessingInstruction&>(context);
score = equals(theNode.getNodeName(),
name->str())
? xpath.s_MatchScoreQName :
xpath.s_MatchScoreNone;
}
else
{
score = xpath.s_MatchScoreNone;
executionContext.error("Arg length of
processing-instruction() node test is incorrect!");
}
}
break;
case XPathExpression::eNODETYPE_NODE:
if (nodeType == DOM_Node::CDATA_SECTION_NODE ||
nodeType == DOM_Node::TEXT_NODE)
{
if (executionContext.shouldStripSourceNode(context) ==
false)
{
score = xpath.s_MatchScoreNodeTest;
}
else
{
score = xpath.s_MatchScoreNone;
}
}
else
{
score = xpath.s_MatchScoreNodeTest;
}
break;
case XPathExpression::eNODETYPE_ROOT:
score = DOM_Node::DOCUMENT_FRAGMENT_NODE == nodeType ||
DOM_Node::DOCUMENT_NODE == nodeType ?
xpath.s_MatchScoreOther :
xpath.s_MatchScoreNone;
break;
case XPathExpression::eNODENAME:
{
bool test = false;
int queueIndex =
currentExpression.getOpCodeMapValue(opPos);
const DOMString targetNS = queueIndex >= 0 ?
currentExpression.getToken(queueIndex)->str() :
"";
opPos++;
// From the draft: "Two expanded names are equal if
they
// have the same local part, and either both have no
URI or
// both have the same URI."
// "A node test * is true for any node of the principal
node type.
// For example, child::* will select all element
children of the
// context node, and attribute::* will select all
attributes of
// the context node."
// "A node test can have the form NCName:*. In this
case, the prefix
// is expanded in the same way as with a QName using
the context
// namespace declarations. The node test will be true
for any node
// of the principal type whose expanded name has the
URI to which
// the prefix expands, regardless of the local part of
the name."
const bool isTotallyWild =
0 == length(targetNS) &&
currentExpression.getOpCodeMapValue(opPos) == XPathExpression::eELEMWILDCARD;
const bool processNamespaces =
executionContext.getProcessNamespaces();
bool didMatchNS = false;
if(isTotallyWild == false && processNamespaces == true)
{
const DOMString contextNS =
executionContext.getNamespaceOfNode(context);
if(0 != length(targetNS) && 0 !=
length(contextNS))
{
test = equals(contextNS, targetNS);
didMatchNS = true;
}
else
{
test = XPathExpression::eELEMWILDCARD
== queueIndex ||
0 == length(contextNS) || 0 ==
length(contextNS);
}
}
else
{
test = true;
}
queueIndex = currentExpression.getOpCodeMapValue(opPos);
const DOMString targetLocalName =
queueIndex >= 0 ?
currentExpression.getToken(queueIndex)->str() : "";
if(test == false)
{
score = XPath::s_MatchScoreNone;
}
else
{
switch(nodeType)
{
case DOM_Node::ATTRIBUTE_NODE:
if(stepType ==
XPathExpression::eFROM_ATTRIBUTES)
{
assert(context.getNodeType() ==
DOM_Node::ATTRIBUTE_NODE);
if(XPathExpression::eELEMWILDCARD == queueIndex)
{
if(processNamespaces ==
true)
{
const DOM_Attr&
theNode =
reinterpret_cast<const DOM_Attr&>(context);
const DOMString
attrName =
theNode.getNodeName();
score =
!(startsWith(attrName, "xmlns:") ||
equals(attrName, "xmlns"))
? xpath.s_MatchScoreNodeTest : xpath.s_MatchScoreNone;
}
else
{
score =
xpath.s_MatchScoreNodeTest;
}
}
else
{
const DOMString
localAttrName =
executionContext.getLocalNameOfNode(context);
score =
equals(localAttrName, targetLocalName) ?
xpath.s_MatchScoreQName : xpath.s_MatchScoreNone;
}
}
else
{
score = xpath.s_MatchScoreNone;
}
break;
case DOM_Node::ELEMENT_NODE:
if(stepType !=
XPathExpression::eFROM_ATTRIBUTES)
{
if(XPathExpression::eELEMWILDCARD == queueIndex)
{
score = didMatchNS ==
true ?
XPath::s_MatchScoreNSWild : XPath::s_MatchScoreNodeTest;
}
else
{
const DOM_Element&
theNode =
static_cast<const DOM_Element&>(context);
score =
equals(executionContext.getLocalNameOfNode(theNode), targetLocalName) ?
xpath.s_MatchScoreQName : xpath.s_MatchScoreNone;
}
}
else
{
score = xpath.s_MatchScoreNone;
}
break;
default:
// Trying to match on anything else
causes nasty bugs.
score = xpath.s_MatchScoreNone;
break;
} // end switch(nodeType)
} // end if(test)
} // end case XPathExpression::eNODENAME
break;
default:
score = xpath.s_MatchScoreNone;
break;
} // end switch(testType)
return score;
}
void
SimpleNodeLocator::predicates(
XPath& xpath,
XPathExecutionContext& /* executionContext */,
const DOM_Node& /* context */,
int opPos,
MutableNodeRefList& subQueryResults,
int&
endPredicatesPos)
{
const XPathExpression& currentExpression =
xpath.getExpression();
int nextStepType =
currentExpression.getOpCodeMapValue(opPos);
while(XPathExpression::eOP_PREDICATE == nextStepType)
{
int i = 0;
const int theLength = subQueryResults.getLength();
// We'll accumulate the entries that we want to remove
// here, then remove them all at once.
std::vector<int> theFailedEntries;
// Might as well reserve some space now, although it's
// probably bad to reserve the entire size of the
// list results.
theFailedEntries.reserve(theLength / 2);
while(i < theLength)
{
const DOM_Node theNode = subQueryResults.item(i);
XObject* const pred = xpath.predicate(theNode, opPos);
// Remove any node that doesn't satisfy the predicate.
if(XObject::eTypeNumber == pred->getType() &&
i + 1 != pred->num() ||
pred->boolean() == false)
{
theFailedEntries.push_back(i);
}
++i;
}
// Erase from the back to the front, to preserve the validity
// of the indesing, and so that we don't end up moving entries
// that we would already be erasing...
std::vector<int>::reverse_iterator theIterator =
theFailedEntries.rbegin();
while(theIterator != theFailedEntries.rend())
{
subQueryResults.removeNode(*theIterator);
theIterator++;
}
opPos = currentExpression.getNextOpCodePosition(opPos);
nextStepType = currentExpression.getOpCodeMapValue(opPos);
if(XPathExpression::eOP_PREDICATE == nextStepType)
{
xpath.setContextNodeList(subQueryResults);
// Don't break, loop 'till end so that opPos will be
set to end.
// if(0 == subQueryResults.getLength())
// break;
}
}
endPredicatesPos = opPos;
}
1.1 xml-xalan/c/src/XPath/SimpleNodeLocator.hpp
Index: SimpleNodeLocator.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(SIMPLENODELOCATOR_HEADER_GUARD_1357924680)
#define SIMPLENODELOCATOR_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file
#include <XPath/XLocator.hpp>
#include <XPath/MutableNodeRefList.hpp>
class XPathExpression;
/**
* SimpleNodeLocator implements a search of one or more DOM trees.
* By using the connect function as an extension, the user may
* specify a directory and a filter specification for XML files
* that will be searched.
* This is a singleton class.
*/
class XALAN_XPATH_EXPORT SimpleNodeLocator : public XLocator
{
public:
static SimpleNodeLocator*
getDefaultInstance();
/**
* Create a SimpleNodeLocator object.
*/
explicit
SimpleNodeLocator();
virtual
~SimpleNodeLocator();
virtual XObject*
connectToNodes(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
std::vector<XObject*> connectArgs);
/**
* Execute a location path. Normally, this method simply
* moves past the OP_LOCATIONPATH and it's length member,
* and calls the Step function, which will recursivly process
* the rest of the LocationPath, and then wraps the NodeList result
* in an XNodeSet object.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns the result of the query in an XNodeSet object.
*/
virtual XObject*
locationPath(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos);
/**
* Execute a a location path pattern. This will return a score
* of MATCH_SCORE_NONE, MATCH_SCORE_NODETEST,
* MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns score, one of MATCH_SCORE_NODETEST,
* MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
*/
virtual double
locationPathPattern(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos);
protected:
MutableNodeRefList
step(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos);
/**
* Execute a step in a location path.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns the last matched context node.
*/
DOM_Node
stepPattern(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
double& score);
int
findNodeSet(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findRoot(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findParent(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findSelf(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findAncestors(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findAncestorsOrSelf(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findAttributes(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findChildren(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findDescendants(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findFollowing(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findFollowingSiblings(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findPreceeding(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findPreceedingSiblings(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findNamespace(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
int
findNodesOnUnknownAxis(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int stepType,
MutableNodeRefList& subQueryResults);
double
nodeTest(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
int argLen,
int stepType);
void
predicates(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
MutableNodeRefList& subQueryResults,
int&
endPredicatesPos);
private:
static SimpleNodeLocator s_defaultInstance;
};
#if 0
/**
* The singleton instance of this class.
*/
private static SimpleNodeLocator m_locater = null;
/**
* The the default locator.
*/
public static SimpleNodeLocator getDefaultLocator()
{
m_locater = (null == m_locater) ? new SimpleNodeLocator() : m_locater;
return m_locater;
}
/**
* Execute the proprietary connect() function, which returns an
* instance of XLocator. When the XPath object sees a return type
* of XLocator, it will call the locationPath function that passes
* in the connectArgs. The opPos and args params are not used
* by this function. This really is just a factory function
* for the XLocator instance, but this fact is hidden from the
* user.
* @param opPos The current position in the xpath.m_opMap array.
* @param args The function args.
* @returns A node set of Document nodes.
*/
public static XLocator connect(String path, String fileSpec)
{
m_locater = (null == m_locater) ? new SimpleNodeLocator() : m_locater;
return m_locater;
}
/**
* Execute a connection (if it was not executed by the static
* connect method) and process the following LocationPath,
* if it is present. Normally, the connection functionality
* should be executed by this function and not the static connect
* function, which is really a factory method for the XLocator
* instance. The arguments to the static connect function
* are re-passed to this function.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param connectArgs The same arguments that were passed to the
* static connect function.
* @returns the result of the query in an XNodeSet object.
*/
public XNodeSet connectToNodes(XPath xpath, Node context,
int opPos, Vector
connectArgs)
{
String fileSpec = ((XObject)connectArgs.elementAt(0)).str();
FileFilter filter = null;
String filterSpec = null;
if(connectArgs.size() > 1)
{
filterSpec = ((XObject)connectArgs.elementAt(1)).str();
filter = new FileFilter(filterSpec);
}
File dir = new File(fileSpec);
XNodeSet results = new XNodeSet(xpath.m_callbacks);
MutableNodeList mnl = results.mutableNodeset();
if(null != dir)
{
String filenames[] = (filter != null) ? dir.list(filter) : dir.list();
if(null != filenames)
{
int nFiles = filenames.length;
for(int i = 0; i < nFiles; i++)
{
try
{
Document doc = xpath.m_callbacks.parseXML(filenames[i],
fileSpec);
if(null != doc)
{
if((xpath.OP_LOCATIONPATH == xpath.m_opMap[opPos]))
{
XNodeSet xnl = xpath.locationPath(doc, opPos);
if(null != xnl)
{
mnl.addNodes(xnl.nodeset());
xpath.m_callbacks.associateXLocatorToNode(doc, this);
}
}
else
{
mnl.addNode(doc);
xpath.m_callbacks.associateXLocatorToNode(doc,
this);
}
}
}
catch(Exception e)
{
System.out.println("Couldn't parse file:
"+e.getMessage());
}
}
}
else
{
System.out.println("Couldn't get a file list from filespec");
}
}
else
{
System.out.println("Filespec was bad in connect");
}
return results;
}
/**
* Execute a location path. Normally, this method simply
* moves past the OP_LOCATIONPATH and it's length member,
* and calls the Step function, which will recursivly process
* the rest of the LocationPath, and then wraps the NodeList result
* in an XNodeSet object.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns the result of the query in an XNodeSet object.
*/
public XNodeSet locationPath(XPath xpath, Node context, int opPos)
{
opPos+=2;
XNodeSet results;
MutableNodeList mnl = step(xpath, context, opPos);
if(null != mnl)
{
results = new XNodeSet(mnl, xpath.m_callbacks);
}
else
{
results = new XNodeSet(new MutableNodeListImpl(xpath.m_callbacks),
xpath.m_callbacks);
}
return results;
}
/**
* Execute a step and predicates in a location path. This recursivly
* executes each of the steps and predicates.
* The step can be oneof xpath.OP_VARIABLE, OP_EXTFUNCTION,
* OP_FUNCTION, OP_GROUP, FROM_ROOT, FROM_PARENT, FROM_SELF,
* FROM_ANCESTORS, FROM_ANCESTORS_OR_SELF, MATCH_ATTRIBUTE,
* FROM_ATTRIBUTES, MATCH_ANY_ANCESTOR, MATCH_IMMEDIATE_ANCESTOR,
* FROM_CHILDREN, FROM_DESCENDANTS,
* FROM_DESCENDANTS_OR_SELF, FROM_FOLLOWING, FROM_FOLLOWING_SIBLINGS,
* FROM_PRECEDING, FROM_PRECEDING_SIBLINGS, or FROM_NAMESPACE.
* Normally, this function should recurse to process the next
* step. However, it should not continue to process the location
* path if the step is oneof MATCH_ATTRIBUTE, MATCH_ANY_ANCESTOR, or
* match MATCH_IMMEDIATE_ANCESTOR.
* This method may be overridden to process the LocationPath as
* a whole, or the fromXXX methods may be overridden to process
* the steps as individual units.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns a node-set.
*/
protected MutableNodeList step(XPath xpath, Node context, int opPos)
{
// int endStep = xpath.getNextOpPos(opPos);
int stepType = xpath.m_opMap[opPos];
int argLen;
MutableNodeList subQueryResults = new
MutableNodeListImpl(xpath.m_callbacks);
MutableNodeList queryResults = null;
boolean shouldReorder = false;
boolean continueStepRecursion = true;
switch(stepType)
{
case xpath.OP_VARIABLE:
case xpath.OP_EXTFUNCTION:
case xpath.OP_FUNCTION:
case xpath.OP_GROUP:
argLen = findNodeSet(xpath, context, opPos,
stepType,
subQueryResults);
break;
case xpath.FROM_ROOT:
argLen = findRoot(xpath, context, opPos, stepType, subQueryResults);
break;
case xpath.FROM_PARENT:
argLen = findParent(xpath, context, opPos, stepType, subQueryResults);
break;
case xpath.FROM_SELF:
argLen = findSelf(xpath, context, opPos, stepType, subQueryResults);
break;
case xpath.FROM_ANCESTORS:
argLen = findAncestors(xpath, context, opPos, stepType,
subQueryResults);
shouldReorder = true;
break;
case xpath.FROM_ANCESTORS_OR_SELF:
argLen = findAncestorsOrSelf(xpath, context, opPos, stepType,
subQueryResults);
shouldReorder = true;
break;
case xpath.MATCH_ATTRIBUTE:
continueStepRecursion = false;
// fall-through on purpose.
case xpath.FROM_ATTRIBUTES:
argLen = findAttributes(xpath, context, opPos, stepType,
subQueryResults);
break;
case xpath.MATCH_ANY_ANCESTOR:
case xpath.MATCH_IMMEDIATE_ANCESTOR:
continueStepRecursion = false;
// fall-through on purpose.
case xpath.FROM_CHILDREN:
argLen = findChildren(xpath, context, opPos, stepType,
subQueryResults);
break;
case xpath.FROM_DESCENDANTS:
case xpath.FROM_DESCENDANTS_OR_SELF:
argLen = findDescendants(xpath, context, opPos, stepType,
subQueryResults);
break;
case xpath.FROM_FOLLOWING:
argLen = findFollowing(xpath, context, opPos, stepType,
subQueryResults);
break;
case xpath.FROM_FOLLOWING_SIBLINGS:
argLen = findFollowingSiblings(xpath, context, opPos, stepType,
subQueryResults);
break;
case xpath.FROM_PRECEDING:
argLen = findPreceding(xpath, context, opPos, stepType,
subQueryResults);
shouldReorder = true;
break;
case xpath.FROM_PRECEDING_SIBLINGS:
argLen = findPrecedingSiblings(xpath, context, opPos, stepType,
subQueryResults);
shouldReorder = true;
break;
case xpath.FROM_NAMESPACE:
argLen = findNamespace(xpath, context, opPos, stepType,
subQueryResults);
break;
default:
argLen = findNodesOnUnknownAxis(xpath, context, opPos, stepType,
subQueryResults);
break;
}
opPos += argLen;
int nextStepType = xpath.m_opMap[opPos];
NodeList savedContextNodeList = xpath.m_contextNodeList;
xpath.m_contextNodeList = subQueryResults;
if(xpath.OP_PREDICATE == nextStepType)
{
int[] endPredicatesPos = {-42};
subQueryResults = predicates(xpath, context, opPos,
subQueryResults, endPredicatesPos);
opPos = endPredicatesPos[0];
nextStepType = xpath.m_opMap[opPos];
}
if((xpath.ENDOP != nextStepType) && continueStepRecursion)
{
int nContexts = subQueryResults.getLength();
for(int i = 0; i < nContexts; i++)
{
Node node = subQueryResults.item(i);
if(null != node)
{
MutableNodeList mnl = step(xpath, node, opPos);
if(queryResults == null)
{
queryResults = mnl;
}
else
{
queryResults.addNodesInDocOrder(mnl);
}
}
}
if(null == queryResults)
{
queryResults = new MutableNodeListImpl(xpath.m_callbacks);
}
}
else
{
if(shouldReorder)
{
queryResults = new MutableNodeListImpl(xpath.m_callbacks);
queryResults.addNodesInDocOrder(subQueryResults);
}
else
{
queryResults = subQueryResults;
}
}
xpath.m_contextNodeList = savedContextNodeList;
return queryResults;
}
/**
* Execute a step that performs an OP_VARIABLE, OP_EXTFUNCTION,
* OP_FUNCTION, or OP_GROUP function.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType One of OP_VARIABLE, OP_EXTFUNCTION,
* OP_FUNCTION, or OP_GROUP.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findNodeSet(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
XObject obj = xpath.execute(context, opPos);
NodeList nl = obj.nodeset();
// Should this be adding in doc order?
// We can not simply assign the nl value to
// subQueryResults, because nl may be a ref to
// a variable or the like, and we may mutate
// below... which results in a hard-to-find bug!
subQueryResults.addNodes(nl);
return xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
}
/**
* Execute a step to the root.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_ROOT.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findRoot(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
Document docContext = (Node.DOCUMENT_NODE == context.getNodeType())
? (Document)context :
context.getOwnerDocument();
subQueryResults.addNode(docContext);
return argLen+3;
}
/**
* Add the parent to the list if it meets the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_PARENT.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findParent(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
context = xpath.m_callbacks.getParentOfNode(context);
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
if(null != context)
{
opPos += 3;
if(argLen > 0)
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, context, opPos,
argLen, stepType))
{
subQueryResults.addNode(context);
}
}
else
{
subQueryResults.addNode(context);
}
}
return argLen+3;
}
/**
* Add the context to the list if it meets the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_SELF.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findSelf(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
if(argLen > 0)
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, context, opPos, argLen,
stepType))
{
subQueryResults.addNode(context);
}
}
else
{
subQueryResults.addNode(context);
}
return argLen+3;
}
/**
* Add ancestors to the list if they meet the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_ANCESTORS.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findAncestors(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
context = xpath.m_callbacks.getParentOfNode(context);
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
while(null != context)
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, context, opPos, argLen,
stepType))
{
subQueryResults.addNode(context);
}
context = xpath.m_callbacks.getParentOfNode(context);
}
return argLen+3;
}
/**
* Add ancestors or the context to the list if they meet
* the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_ANCESTORS_OR_SELF.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findAncestorsOrSelf(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
while(null != context)
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, context, opPos, argLen,
stepType))
{
subQueryResults.addNode(context);
}
context = xpath.m_callbacks.getParentOfNode(context);
}
return argLen+3;
}
/**
* Add attributes to the list if they meet
* the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_ATTRIBUTES.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findAttributes(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
if( (null != context) && (context.getNodeType()==Node.ELEMENT_NODE) )
{
Element e = (Element)context;
NamedNodeMap attributeList = e.getAttributes();
if( attributeList != null )
{
int nAttrs = attributeList.getLength();
for( int j=0; j < nAttrs; j++ )
{
Attr attr = (Attr)attributeList.item(j);
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, attr, opPos,
argLen, stepType))
{
subQueryResults.addNode(attr);
}
}
}
}
return argLen+3;
}
/**
* Add children to the list if they meet
* the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_CHILDREN.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findChildren(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
Node c = context.getFirstChild();
while( null != c )
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, c, opPos, argLen,
stepType))
{
subQueryResults.addNode(c);
}
c = c.getNextSibling();
}
return argLen+3;
}
/**
* Add the descendants (and the context if the stepType is
* FROM_DESCENDANTS_OR_SELF) to the list if they meet
* the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_DESCENDANTS or
xpath.FROM_DESCENDANTS_OR_SELF.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findDescendants(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
// Perform a pre-order traversal of descendents.
// Note that I would like to be able to do optimization here
// where if I have a simple tag name node test, I would
// like to be able to call
// ((Element)context).getElementsByTagName(m_token).
// One problem is that it would return a NodeList, not a
// NodeListImpl.
/*
if(lookahead('[', 1) || lookahead('(', 1)
|| (Node.ELEMENT_NODE != context.getNodeType()))
{
*/
Node pos = context;
while(null != pos)
{
if((stepType == xpath.FROM_DESCENDANTS_OR_SELF) || (context != pos))
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, pos, opPos,
argLen, stepType))
{
subQueryResults.addNode(pos);
}
}
Node nextNode = pos.getFirstChild();
while(null == nextNode)
{
if(context == pos)
break;
nextNode = pos.getNextSibling();
if(null == nextNode)
{
pos = pos.getParentNode();
if((context == pos) || (pos == null))
{
nextNode = null;
break;
}
}
}
pos = nextNode;
}
return argLen+3;
}
/**
* Add the nodes following the context to the list if they meet
* the NodeTest qualification.
* The following axis contains all nodes in the same document as
* the context node that are after the context node in document
* order, excluding any descendants and excluding attribute nodes
* and namespace nodes; the nodes are ordered in document order.
* Note that the ancestor, descendant, following, preceding and
* self axes partition a document (ignoring attribute and namespace
* nodes): they do not overlap and together they contain all the
* nodes in the document.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_FOLLOWING.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findFollowing(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
// What fun...
Document doc = context.getOwnerDocument();
Node pos = context;
while(null != pos)
{
Node nextNode;
if(pos != context)
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, pos, opPos,
argLen, stepType))
{
subQueryResults.addNodeInDocOrder(pos);
}
nextNode = pos.getFirstChild();
}
else
{
nextNode = null;
}
while(null == nextNode)
{
nextNode = pos.getNextSibling();
if(null == nextNode)
{
pos = pos.getParentNode();
if((doc == pos) || (null == pos))
{
nextNode = null;
break;
}
}
}
pos = nextNode;
}
return argLen+3;
}
/**
* Add the sibling nodes following the context to the list if they meet
* the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_FOLLOWING_SIBLINGS.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findFollowingSiblings(XPath xpath, Node context, int opPos,
int
stepType, MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
Node pos = context.getNextSibling();
while(null != pos)
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, pos, opPos, argLen,
stepType))
{
subQueryResults.addNode(pos);
}
pos = pos.getNextSibling();
}
return argLen+3;
}
/**
* Add the nodes preceding the context to the list if they meet
* the NodeTest qualification.
* The preceding axis contains all nodes in the same document
* as the context node that are before the context node in document
* order, excluding any ancestors and excluding attribute nodes
* and namespace nodes; the nodes are ordered in reverse document order.
* Note that the ancestor, descendant, following, preceding and
* self axes partition a document (ignoring attribute and namespace
* nodes): they do not overlap and together they contain all the
* nodes in the document.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_PRECEDING.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findPreceding(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
// Ugh. Reverse document order, no parents, I guess.
Document doc = context.getOwnerDocument();
Node pos = doc;
while(null != pos)
{
if(context == pos)
break;
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, pos, opPos, argLen,
stepType))
{
// Ugh. If I could think a little better tonight, I'm
// sure there's a better way to check for the parent.
boolean isParent = false;
Node parent = xpath.m_callbacks.getParentOfNode(context);
while(null != parent)
{
if(parent == pos)
{
isParent = true;
break;
}
parent = xpath.m_callbacks.getParentOfNode(parent);
}
if(!isParent)
{
subQueryResults.insertNode(pos, 0);
}
}
Node nextNode = pos.getFirstChild();
while(null == nextNode)
{
nextNode = pos.getNextSibling();
if(null == nextNode)
{
pos = pos.getParentNode();
if(doc == pos)
{
nextNode = null;
break;
}
}
}
pos = nextNode;
}
return argLen+3;
}
/**
* Add the sibling nodes preceding the context to the list if they meet
* the NodeTest qualification.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_PRECEDING_SIBLINGS.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findPrecedingSiblings(XPath xpath, Node context, int opPos,
int
stepType, MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
Node pos = context.getPreviousSibling();
while(null != pos)
{
if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, pos, opPos, argLen,
stepType))
{
subQueryResults.addNode(pos);
}
pos = pos.getPreviousSibling();
}
return argLen+3;
}
/**
* Add the namespace node of the context.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_NAMESPACE.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findNamespace(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
xpath.error(context, "namespace axis not implemented yet!");
return argLen+3;
}
/**
* Add the namespace node of the context.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param stepType Value of xpath.FROM_NAMESPACE.
* @param subQueryResults Should be an empty node list where the
* results of the step will be put.
* @returns the length of the argument (i.e. amount to add to predicate pos
* or end of step).
*/
protected int findNodesOnUnknownAxis(XPath xpath, Node context, int opPos,
int stepType,
MutableNodeList subQueryResults)
{
int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
xpath.error(context, "unknown axis: "+stepType);
return argLen+3;
}
/**
* Qualify a node list by it's predicates.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param subQueryResults The list of nodes that need to be qualified.
* @param endPredicatesPos The end position in the xpath.m_opMap array will
be filled in.
* @returns the qualified subset of subQueryResults.
*/
protected MutableNodeList predicates(XPath xpath, Node context, int opPos,
MutableNodeList subQueryResults,
int[] endPredicatesPos)
{
boolean hasNulls = false;
int nextStepType = xpath.m_opMap[opPos];
while(xpath.OP_PREDICATE == nextStepType)
{
int nContexts = subQueryResults.getLength();
for(int i = 0; i < nContexts; i++)
{
XObject pred = xpath.predicate(subQueryResults.item(i), opPos);
if(XObject.CLASS_NUMBER == pred.getType())
{
if((i+1) != (int)pred.num())
{
hasNulls = true;
subQueryResults.setItemNull(i);
}
}
else if(!pred.bool())
{
hasNulls = true;
subQueryResults.setItemNull(i);
}
}
opPos = xpath.getNextOpPos(opPos);
nextStepType = xpath.m_opMap[opPos];
if(xpath.OP_PREDICATE == nextStepType)
{
// This will reconstruct the node list without the nulls.
subQueryResults = new MutableNodeListImpl(subQueryResults,
xpath.m_callbacks);
xpath.m_contextNodeList = subQueryResults;
// Don't break, loop 'till end so that opPos will be set to end.
// if(0 == subQueryResults.getLength())
// break;
}
}
endPredicatesPos[0] = opPos;
if(hasNulls)
{
subQueryResults = new MutableNodeListImpl(subQueryResults,
xpath.m_callbacks);
}
return subQueryResults;
}
/**
* Execute a a location path pattern. This will return a score
* of MATCH_SCORE_NONE, MATCH_SCORE_NODETEST,
* MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns score, one of MATCH_SCORE_NODETEST,
* MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
*/
public double locationPathPattern(XPath xpath, Node context, int opPos)
{
opPos+=2;
double[] scoreHolder = {xpath.MATCH_SCORE_NONE};
stepPattern(xpath, context, opPos, scoreHolder);
return scoreHolder[0];
}
/**
* Execute a step in a location path.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns the last matched context node.
*/
protected Node stepPattern(XPath xpath, Node context, int opPos, double
scoreHolder[])
{
int startOpPos = opPos;
int stepType = xpath.m_opMap[opPos];
int endStep = xpath.getNextOpPos(opPos);
int nextStepType = xpath.m_opMap[endStep];
double score;
if(xpath.ENDOP != nextStepType)
{
// Continue step via recursion...
context = stepPattern(xpath, context, endStep, scoreHolder);
if(null == context)
scoreHolder[0] = xpath.MATCH_SCORE_NONE;
if(scoreHolder[0] == xpath.MATCH_SCORE_NONE)
return null;
scoreHolder[0] = xpath.MATCH_SCORE_OTHER;
context = xpath.m_callbacks.getParentOfNode(context);
}
int argLen;
switch(stepType)
{
case xpath.OP_FUNCTION:
{
argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
XObject obj = xpath.execute(context, opPos);
NodeList nl = obj.nodeset();
int len = nl.getLength();
score = xpath.MATCH_SCORE_NONE;
for(int i = 0; i < len; i++)
{
Node n = nl.item(i);
score = (n == context) ? xpath.MATCH_SCORE_OTHER :
xpath.MATCH_SCORE_NONE;
if(score == xpath.MATCH_SCORE_OTHER)
{
context = n;
break;
}
}
}
break;
case xpath.FROM_ROOT:
{
argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
Document docContext = (Node.DOCUMENT_NODE ==
context.getNodeType())
? (Document)context :
context.getOwnerDocument();
score = (docContext == context) ? xpath.MATCH_SCORE_OTHER :
xpath.MATCH_SCORE_NONE;
if(score == xpath.MATCH_SCORE_OTHER)
{
context = docContext;
}
}
break;
case xpath.MATCH_ATTRIBUTE:
{
argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
score = nodeTest(xpath, context, opPos, argLen,
xpath.FROM_ATTRIBUTES);
break;
}
case xpath.MATCH_ANY_ANCESTOR:
{
argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
score = xpath.MATCH_SCORE_NONE;
while(null != context)
{
score = nodeTest(xpath, context, opPos, argLen, stepType);
if(xpath.MATCH_SCORE_NONE != score)
break;
context = xpath.m_callbacks.getParentOfNode(context);
}
}
break;
case xpath.MATCH_IMMEDIATE_ANCESTOR:
argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
score = nodeTest(xpath, context, opPos, argLen, stepType);
break;
default:
argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
opPos += 3;
score = xpath.MATCH_SCORE_NONE;
xpath.error(context, "unknown match operation!");
break;
}
opPos += argLen;
nextStepType = xpath.m_opMap[opPos];
if(((score != xpath.MATCH_SCORE_NONE)) && (xpath.OP_PREDICATE ==
nextStepType))
{
score = xpath.MATCH_SCORE_OTHER;
// Execute the xpath.predicates, but if we have an index, then we
have
// to start over and do a search from the parent. It would be nice
// if I could sense this condition earlier...
try
{
xpath.m_throwFoundIndex = true;
int startPredicates = opPos;
opPos = startPredicates;
nextStepType = xpath.m_opMap[opPos];
while(xpath.OP_PREDICATE == nextStepType)
{
XObject pred = xpath.predicate(context, opPos);
if(XObject.CLASS_NUMBER == pred.getType())
{
throw new FoundIndex();
}
else if(!pred.bool())
{
score = xpath.MATCH_SCORE_NONE;
break; // from while(xpath.OP_PREDICATE == nextStepType)
}
opPos = xpath.getNextOpPos(opPos);
nextStepType = xpath.m_opMap[opPos];
}
xpath.m_throwFoundIndex = false;
}
catch(FoundIndex fi)
{
// We have an index somewhere in our pattern. So, we have
// to do a full search for our step, using the parent as
// context, then see if the current context is found in the
// node set. Seems crazy, but, so far, it seems like the
// easiest way.
xpath.m_throwFoundIndex = false;
Node parentContext = xpath.m_callbacks.getParentOfNode(context);
MutableNodeList mnl = step(xpath, parentContext, startOpPos);
int nNodes = mnl.getLength();
score = xpath.MATCH_SCORE_NONE;
for(int i = 0; i < nNodes; i++)
{
if(mnl.item(i) == context)
{
score = xpath.MATCH_SCORE_OTHER;
break;
}
}
}
}
// If we haven't found a score yet, or the test was
// negative, assign the score.
if((scoreHolder[0] == xpath.MATCH_SCORE_NONE) ||
(score == xpath.MATCH_SCORE_NONE))
scoreHolder[0] = score;
return (score == xpath.MATCH_SCORE_NONE) ? null : context;
}
/**
* Test a node to see if it matches the given node test.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @param len The length of the argument.
* @param len The type of the step.
* @returns score in an XNumber, one of MATCH_SCORE_NODETEST,
* MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
*/
public double nodeTest(XPath xpath, Node context, int opPos, int argLen,
int stepType)
{
double score;
int testType = xpath.m_opMap[opPos];
int nodeType = context.getNodeType();
opPos++;
switch(testType)
{
case xpath.NODETYPE_COMMENT:
score = (Node.COMMENT_NODE == nodeType)
? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
break;
case xpath.NODETYPE_TEXT:
score = ((Node.CDATA_SECTION_NODE == nodeType)
|| (Node.TEXT_NODE == nodeType))
? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
break;
case xpath.NODETYPE_PI:
if( (Node.PROCESSING_INSTRUCTION_NODE == nodeType) && (argLen > 0) )
{
XString name =
(XString)xpath.m_tokenQueue[xpath.m_opMap[opPos]];
score =
((ProcessingInstruction)context).getNodeName().equals(name.str())
? xpath.MATCH_SCORE_QNAME :
xpath.MATCH_SCORE_NONE;
}
else
{
score = xpath.MATCH_SCORE_NONE;
}
break;
case xpath.NODETYPE_NODE:
score = xpath.MATCH_SCORE_NODETEST;
break;
case xpath.NODETYPE_ROOT:
score = ( (Node.DOCUMENT_FRAGMENT_NODE == nodeType)
|| (Node.DOCUMENT_NODE == nodeType))
? xpath.MATCH_SCORE_OTHER : xpath.MATCH_SCORE_NONE;
break;
case xpath.NODENAME:
{
boolean test;
int queueIndex = xpath.m_opMap[opPos];
String targetNS = (queueIndex >= 0) ?
(String)xpath.m_tokenQueue[xpath.m_opMap[opPos]]
: null;
opPos++;
// From the draft: "Two expanded names are equal if they
// have the same local part, and either both have no URI or
// both have the same URI."
// "A node test * is true for any node of the principal node
type.
// For example, child::* will select all element children of
the
// context node, and attribute::* will select all attributes of
// the context node."
// "A node test can have the form NCName:*. In this case, the
prefix
// is expanded in the same way as with a QName using the
context
// namespace declarations. The node test will be true for any
node
// of the principal type whose expanded name has the URI to
which
// the prefix expands, regardless of the local part of the
name."
boolean isTotallyWild = (null == targetNS) &&
(xpath.m_opMap[opPos] == xpath.ELEMWILDCARD);
boolean processNamespaces =
xpath.m_callbacks.getProcessNamespaces();
if(!isTotallyWild && processNamespaces)
{
String contextNS =
xpath.m_callbacks.getNamespaceOfNode(context);
if((null != targetNS) && (null != contextNS))
{
test = contextNS.equals(targetNS);
}
else
{
test = (xpath.ELEMWILDCARD == queueIndex) ||
((null == contextNS) || (contextNS.length()
== 0));
}
}
else
test = true;
queueIndex = xpath.m_opMap[opPos];
String targetLocalName = (queueIndex >= 0) ?
(String)xpath.m_tokenQueue[xpath.m_opMap[opPos]]
: null;
if(!test)
{
score = xpath.MATCH_SCORE_NONE;
}
else
{
switch(nodeType)
{
case Node.ATTRIBUTE_NODE:
if(stepType == xpath.FROM_ATTRIBUTES)
{
if(xpath.ELEMWILDCARD == queueIndex)
{
String attrName = ((Attr)context).getNodeName();
if(processNamespaces)
{
score = (!((attrName.startsWith("xmlns:")
||
attrName.equals("xmlns"))))
? xpath.MATCH_SCORE_NODETEST
: xpath.MATCH_SCORE_NONE;
}
else
{
score = xpath.MATCH_SCORE_NODETEST;
}
}
else
{
String localAttrName
=
xpath.m_callbacks.getLocalNameOfNode(context);
score = localAttrName.equals(targetLocalName)
? xpath.MATCH_SCORE_QNAME :
xpath.MATCH_SCORE_NONE;
}
}
else
{
score = xpath.MATCH_SCORE_NONE;
}
break;
case Node.ELEMENT_NODE:
if(stepType != xpath.FROM_ATTRIBUTES)
{
if(xpath.ELEMWILDCARD == queueIndex)
{
score = xpath.MATCH_SCORE_NODETEST;
}
else
{
score =
(xpath.m_callbacks.getLocalNameOfNode((Element)context).equals(targetLocalName))
? xpath.MATCH_SCORE_QNAME :
xpath.MATCH_SCORE_NONE;
}
}
else
{
score = xpath.MATCH_SCORE_NONE;
}
break;
default:
// Trying to match on anything else causes nasty bugs.
score = xpath.MATCH_SCORE_NONE;
break;
} // end switch(nodeType)
} // end if(test)
} // end case xpath.NODENAME
break;
default:
score = xpath.MATCH_SCORE_NONE;
} // end switch(testType)
return score;
}
public static XPathFactory factory()
{
return new SimpleNodeLocatorFactory();
}
/**
* Very crude file filter.
*/
class FileFilter implements FilenameFilter
{
private String m_filterSpec;
public FileFilter(String filter)
{
m_filterSpec = filter;
}
/**
* Tests if a specified file should be included in a file list.
*
* @param dir the directory in which the file was found.
* @param name the name of the file.
* @return <code>true</code> if the name should be included in the
file
* list; <code>false</code> otherwise.
* @since JDK1.0
*/
public boolean accept(File dir, String name)
{
return name.endsWith(m_filterSpec);
}
}
}
/**
* Override the createXLocatorHandler method.
*/
class DOMXPath extends XPath
{
public DOMXPath(XPathSupport callbacks)
{
super(callbacks);
}
/**
* getXLocatorHandler.
*/
XLocator createXLocatorHandler(XPath xpath)
{
return new SimpleNodeLocator();
}
}
/**
* Implement an XPath factory.
*/
class SimpleNodeLocatorFactory implements XPathFactory
{
public XPath create(XPathSupport callbacks)
{
return new DOMXPath(callbacks);
}
}
#endif
#endif // SIMPLENODELOCATOR_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XBoolean.cpp
Index: XBoolean.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XBoolean.hpp"
#include "XObjectTypeCallback.hpp"
XBoolean::XBoolean(
XPathEnvSupport& support,
bool val) :
XObject(&support),
m_value(val)
{
}
XBoolean::XBoolean(
XPathEnvSupport* support,
bool val) :
XObject(support),
m_value(val)
{
}
XBoolean::XBoolean(const XBoolean& source) :
XObject(source),
m_value(source.m_value)
{
}
XBoolean::~XBoolean()
{
}
XBoolean::eObjectType
XBoolean::getType() const
{
return eTypeBoolean;
}
DOMString
XBoolean::getTypeString() const
{
return "#BOOLEAN";
}
double
XBoolean::num() const
{
return m_value == true ? 1.0 : 0.0;
}
bool
XBoolean::boolean() const
{
return m_value;
}
DOMString
XBoolean::str() const
{
return m_value == true ? "true" : "false";
}
const ResultTreeFragBase&
XBoolean::rtree() const
{
error("Can't cast XBoolean to ResultTreeFragBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<ResultTreeFragBase*>(0);
}
ResultTreeFragBase&
XBoolean::rtree()
{
error("Can't cast XBoolean to ResultTreeFragBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<ResultTreeFragBase*>(0);
}
const NodeRefListBase&
XBoolean::nodeset() const
{
error("Can't cast XBoolean to NodeRefListBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<NodeRefListBase*>(0);
}
const MutableNodeRefList&
XBoolean::mutableNodeset() const
{
error("Can't cast XBoolean to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
MutableNodeRefList&
XBoolean::mutableNodeset()
{
error("Can't cast XBoolean to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
void
XBoolean::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject)
{
theCallbackObject.Boolean(*this,
boolean());
}
void
XBoolean::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const
{
theCallbackObject.Boolean(*this,
boolean());
}
bool
XBoolean::equals(const XObject& theRHS) const
{
return m_value == theRHS.boolean();
}
1.1 xml-xalan/c/src/XPath/XBoolean.hpp
Index: XBoolean.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XBOOLEAN_HEADER_GUARD_1357924680)
#define XBOOLEAN_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file.
#include <XPath/XObject.hpp>
#include <dom/DOMString.hpp>
class XALAN_XPATH_EXPORT XBoolean : public XObject
{
public:
XBoolean(XPathEnvSupport& support,
bool val);
XBoolean(const XBoolean& source);
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const;
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const;
/**
* Cast result object to a number.
*/
virtual double
num() const;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const;
virtual ResultTreeFragBase&
rtree();
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const;
/**
* Cast result object to a nodelist.
*/
virtual const MutableNodeRefList&
mutableNodeset() const;
virtual MutableNodeRefList&
mutableNodeset();
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const;
protected:
virtual
~XBoolean();
XBoolean(XPathEnvSupport* support,
bool val);
private:
bool m_value;
};
#endif // XBOOLEAN_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XBooleanStatic.cpp
Index: XBooleanStatic.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XBooleanStatic.hpp"
#include "XPathException.hpp"
XBooleanStatic::XBooleanStatic(bool val) :
XBoolean(0,
val)
{
}
XBooleanStatic::XBooleanStatic(const XBooleanStatic& source) :
XBoolean(source)
{
}
XBooleanStatic::~XBooleanStatic()
{
}
void
XBooleanStatic::error(const DOMString& msg) const
{
throw XPathException(msg);
}
1.1 xml-xalan/c/src/XPath/XBooleanStatic.hpp
Index: XBooleanStatic.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XBOOLEANSTATIC_HEADER_GUARD_1357924680)
#define XBOOLEANSTATIC_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file.
#include <XPath/XBoolean.hpp>
#include <dom/DOMString.hpp>
class XALAN_XPATH_EXPORT XBooleanStatic : public XBoolean
{
public:
XBooleanStatic(bool val);
XBooleanStatic(const XBooleanStatic& source);
virtual
~XBooleanStatic();
protected:
// We have to override this because there is not XPathEnvSupport
// for this class, so an error always throws an exception.
virtual void
error(const DOMString& msg) const;
private:
};
#endif // XBOOLEANSTATIC_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XLocator.cpp
Index: XLocator.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XLocator.hpp"
XLocator::XLocator()
{
}
XLocator::~XLocator()
{
}
1.1 xml-xalan/c/src/XPath/XLocator.hpp
Index: XLocator.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XLOCATOR_HEADER_GUARD_1357924680)
#define XLOCATOR_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
class DOM_Node;
class XObject;
class XPath;
class XPathExecutionContext;
class XNodeSet;
class XALAN_XPATH_EXPORT XLocator
{
public:
XLocator();
virtual
~XLocator();
virtual XObject*
connectToNodes(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos,
std::vector<XObject*> connectArgs) = 0;
/**
* Execute a location path. Normally, this method simply
* moves past the OP_LOCATIONPATH and it's length member,
* and calls the Step function, which will recursivly process
* the rest of the LocationPath, and then wraps the NodeList result
* in an XNodeSet object.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns the result of the query in an XNodeSet object.
*/
virtual XObject*
locationPath(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos) = 0;
/**
* Execute a a location path pattern. This will return a score
* of MATCH_SCORE_NONE, MATCH_SCORE_NODETEST,
* MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
* @param xpath The xpath that is executing.
* @param context The current source tree context node.
* @param opPos The current position in the xpath.m_opMap array.
* @returns score, one of MATCH_SCORE_NODETEST,
* MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
*/
virtual double
locationPathPattern(
XPath& xpath,
XPathExecutionContext& executionContext,
const DOM_Node& context,
int opPos) = 0;
};
#endif // XLOCATOR_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XNodeSet.cpp
Index: XNodeSet.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XNodeSet.hpp"
#include <limits>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
#include "ResultTreeFrag.hpp"
#include "XObjectTypeCallback.hpp"
#include "XPathEnvSupport.hpp"
#include "XPathSupport.hpp"
XNodeSet::XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
const NodeRefListBase& value) :
XObject(&envSupport),
m_support(support),
m_value(value),
m_resultTreeFrag()
{
}
XNodeSet::XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
const MutableNodeRefList& value) :
XObject(&envSupport),
m_support(support),
m_value(value),
m_resultTreeFrag()
{
}
XNodeSet::XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
const DOM_Node& value) :
XObject(&envSupport),
m_support(support),
m_value(),
m_resultTreeFrag()
{
m_value.addNode(value);
}
XNodeSet::XNodeSet(const XNodeSet& source,
bool deepClone) :
XObject(source),
m_support(source.m_support),
m_value(source.m_value),
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
0 :
dynamic_cast<ResultTreeFragBase*>(source.m_resultTreeFrag->clone(deepClone)))
#else
m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
0 :
source.m_resultTreeFrag->clone(deepClone))
#endif
{
}
XNodeSet::~XNodeSet()
{
}
XNodeSet::eObjectType
XNodeSet::getType() const
{
return eTypeNodeSet;
}
DOMString
XNodeSet::getTypeString() const
{
return "#NODESET";
}
double
XNodeSet::num() const
{
double result = DoubleSupport::getNaN();
if(m_value.getLength() > 0)
{
const DOMString s =
m_support.getNodeData(m_value.item(0));
if(0 == length(s))
{
result = 0;
}
else
{
result = DOMStringToDouble(s);
}
}
return result;
}
bool
XNodeSet::boolean() const
{
return m_value.getLength() > 0 ? true : false;
}
DOMString
XNodeSet::str() const
{
DOMString theResult;
if (m_value.getLength() > 0)
{
const DOM_Node theNode = m_value.item(0);
const int theType = theNode.getNodeType();
if (theType == DOM_Node::COMMENT_NODE ||
theType == DOM_Node::PROCESSING_INSTRUCTION_NODE)
{
theResult = theNode.getNodeValue();
}
else
{
theResult = m_support.getNodeData(theNode);
}
}
return theResult;
}
const ResultTreeFragBase&
XNodeSet::rtree() const
{
assert(m_envSupport != 0);
if (m_resultTreeFrag.get() == 0)
{
ResultTreeFrag* const theFrag =
new ResultTreeFrag(m_envSupport->getDOMFactory(),
m_support);
#if defined(XALAN_OLD_AUTO_PTR)
m_resultTreeFrag = std::auto_ptr<ResultTreeFragBase>(theFrag);
#else
m_resultTreeFrag.reset(theFrag);
#endif
const int nNodes = m_value.getLength();
for(int i = 0; i < nNodes; i++)
{
m_resultTreeFrag->appendChild(m_value.item(i).cloneNode(true));
}
}
return *m_resultTreeFrag.get();
}
ResultTreeFragBase&
XNodeSet::rtree()
{
assert(m_envSupport != 0);
if (m_resultTreeFrag.get() == 0)
{
ResultTreeFrag* const theFrag =
new ResultTreeFrag(m_envSupport->getDOMFactory(),
m_support);
#if defined(XALAN_OLD_AUTO_PTR)
m_resultTreeFrag = std::auto_ptr<ResultTreeFragBase>(theFrag);
#else
m_resultTreeFrag.reset(theFrag);
#endif
const int nNodes = m_value.getLength();
for(int i = 0; i < nNodes; i++)
{
m_resultTreeFrag->appendChild(m_value.item(i).cloneNode(true));
}
}
return *m_resultTreeFrag.get();
}
const NodeRefListBase&
XNodeSet::nodeset() const
{
return m_value;
}
const MutableNodeRefList&
XNodeSet::mutableNodeset() const
{
return m_value;
}
MutableNodeRefList&
XNodeSet::mutableNodeset()
{
return m_value;
}
void
XNodeSet::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject)
{
theCallbackObject.NodeSet(*this,
nodeset());
}
void
XNodeSet::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const
{
theCallbackObject.NodeSet(*this,
nodeset());
}
bool
XNodeSet::equals(const XObject& theRHS) const
{
bool fResult = false;
const XNodeSet::eObjectType theType =
theRHS.getType();
if (XObject::eTypeNodeSet == theType)
{
// See the XPath spec., section 3.4 for an explanation of this
lunacy...
const int theLHSLength =
m_value.getLength();
if (theLHSLength > 0)
{
const XNodeSet& theRHSNodeSet =
static_cast<const XNodeSet&>(theRHS);
const int theRHSLength =
theRHSNodeSet.m_value.getLength();
// See if there's at least one pair of nodes in the two
nodes sets
// whose "string" values are equal...
for(int i = 0; i < theLHSLength && fResult == false;
i++)
{
const DOM_Node theCurrent(m_value.item(i));
for (int j = 0; j < theRHSLength && fResult ==
false; j++)
{
if
(::equals(m_support.getNodeData(theCurrent),
m_support.getNodeData(theRHSNodeSet.m_value.item(j))) == true)
{
fResult = true;
}
}
}
}
}
else if(XObject::eTypeString == theType ||
XObject::eTypeResultTreeFrag == theType)
{
if (::equals(str(), theRHS.str()) == true)
{
fResult = true;
}
}
else if(XObject::eTypeBoolean == theType)
{
if (boolean() == theRHS.boolean())
{
fResult = true;
}
}
else if(XObject::eTypeNumber == theType)
{
if (num() == theRHS.num())
{
fResult = true;
}
}
return fResult;
}
1.1 xml-xalan/c/src/XPath/XNodeSet.hpp
Index: XNodeSet.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XNODESET_HEADER_GUARD_1357924680)
#define XNODESET_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <memory>
// Base class header file.
#include <XPath/XObject.hpp>
#include <dom/DOM_DocumentFragment.hpp>
#include <dom/DOMString.hpp>
#include <XPath/ResultTreeFragBase.hpp>
#include <XPath/MutableNodeRefList.hpp>
class NodeRefListBase;
class XPathSupport;
/**
* Class to hold XPath return types.
*/
class XALAN_XPATH_EXPORT XNodeSet : public XObject
{
public:
/**
* Create an XNodeSet.
*/
XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
const NodeRefListBase& value = MutableNodeRefList());
XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
const MutableNodeRefList& value =
MutableNodeRefList());
XNodeSet(
XPathEnvSupport& envSupport,
XPathSupport& support,
const DOM_Node& value);
XNodeSet(
const XNodeSet& source,
bool deepClone = true);
virtual
~XNodeSet();
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const;
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const;
/**
* Cast result object to a number.
*/
virtual double
num() const;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const;
virtual ResultTreeFragBase&
rtree();
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const;
/**
* Cast result object to a nodelist that is mutable.
*/
virtual const MutableNodeRefList&
mutableNodeset() const;
virtual MutableNodeRefList&
mutableNodeset();
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const;
private:
// Not implemented...
XNodeSet&
operator=(const XNodeSet&);
// Data members...
XPathSupport&
m_support;
MutableNodeRefList
m_value;
mutable std::auto_ptr<ResultTreeFragBase> m_resultTreeFrag;
};
#endif // XNODESET_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XNull.cpp
Index: XNull.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XNull.hpp"
#include "ResultTreeFrag.hpp"
#include "XObjectTypeCallback.hpp"
#include "XPathEnvSupport.hpp"
XNull::XNull(
XPathEnvSupport& envSupport,
XPathSupport& support) :
XObject(&envSupport),
m_resultTreeFrag(new ResultTreeFrag(envSupport.getDOMFactory(),
support))
{
}
XNull::XNull(
const XNull& source,
bool deepClone) :
XObject(source),
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
m_resultTreeFrag(dynamic_cast<ResultTreeFragBase*>(source.m_resultTreeFrag->clone(deepClone)))
#else
m_resultTreeFrag(source.m_resultTreeFrag->clone(deepClone))
#endif
{
}
XNull::~XNull()
{
}
XNull::eObjectType
XNull::getType() const
{
return eTypeNull;
}
DOMString
XNull::getTypeString() const
{
return "#NULL";
}
double
XNull::num() const
{
return 0.0;
}
bool
XNull::boolean() const
{
return false;
}
DOMString
XNull::str() const
{
return "";
}
const ResultTreeFragBase&
XNull::rtree() const
{
return *m_resultTreeFrag.get();
}
ResultTreeFragBase&
XNull::rtree()
{
return *m_resultTreeFrag.get();
}
const NodeRefListBase&
XNull::nodeset() const
{
error("Can't cast XNull to NodeRefListBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<NodeRefListBase*>(0);
}
const MutableNodeRefList&
XNull::mutableNodeset() const
{
error("Can't cast XNull to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
MutableNodeRefList&
XNull::mutableNodeset()
{
error("Can't cast XNull to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
void
XNull::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject)
{
theCallbackObject.Null(*this);
}
void
XNull::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const
{
theCallbackObject.Null(*this);
}
bool
XNull::equals(const XObject& theRHS) const
{
return theRHS.getType() == eTypeNull;
}
1.1 xml-xalan/c/src/XPath/XNull.hpp
Index: XNull.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XNULL_HEADER_GUARD_1357924680)
#define XNULL_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <memory>
#include <dom/DOMString.hpp>
// Base class header file.
#include <XPath/XObject.hpp>
#include <XPath/ResultTreeFragBase.hpp>
class XPathSupport;
class XALAN_XPATH_EXPORT XNull : public XObject
{
public:
XNull(
XPathEnvSupport& envSupport,
XPathSupport& support);
XNull(
const XNull& source,
bool deepClone = true);
virtual
~XNull();
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const;
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const;
/**
* Cast result object to a number.
*/
virtual double
num() const;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const;
virtual ResultTreeFragBase&
rtree();
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const;
/**
* Cast result object to a nodelist.
*/
virtual const MutableNodeRefList&
mutableNodeset() const;
virtual MutableNodeRefList&
mutableNodeset();
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const;
private:
const std::auto_ptr<ResultTreeFragBase> m_resultTreeFrag;
// not implemented
XNull& operator=(const XNull &);
};
#endif // XNULL_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XNumber.cpp
Index: XNumber.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XNumber.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
#include "XObjectTypeCallback.hpp"
XNumber::XNumber(
XPathEnvSupport& envSupport,
double val) :
XObject(&envSupport),
m_value(val)
{
}
XNumber::XNumber(const XNumber& source) :
XObject(source),
m_value(source.m_value)
{
}
XNumber::~XNumber()
{
}
XNumber::eObjectType
XNumber::getType() const
{
return eTypeNumber;
}
DOMString
XNumber::getTypeString() const
{
return "#NUMBER";
}
double
XNumber::num() const
{
return m_value;
}
bool
XNumber::boolean() const
{
return m_value == 0.0 ? false : true;
}
DOMString
XNumber::str() const
{
return DoubleToDOMString(m_value);
}
const ResultTreeFragBase&
XNumber::rtree() const
{
error("Can't cast XNumber to ResultTreeFragBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<ResultTreeFragBase*>(0);
}
ResultTreeFragBase&
XNumber::rtree()
{
error("Can't cast XNumber to ResultTreeFragBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<ResultTreeFragBase*>(0);
}
const NodeRefListBase&
XNumber::nodeset() const
{
error("Can't cast XNumber to NodeRefListBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<NodeRefListBase*>(0);
}
const MutableNodeRefList&
XNumber::mutableNodeset() const
{
error("Can't cast XNumber to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
MutableNodeRefList&
XNumber::mutableNodeset()
{
error("Can't cast XNumber to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
void
XNumber::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject)
{
theCallbackObject.Number(*this,
num());
}
void
XNumber::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const
{
theCallbackObject.Number(*this,
num());
}
bool
XNumber::equals(const XObject& theRHS) const
{
bool fResult = false;
if (DoubleSupport::isNaN(m_value) == false)
{
const double theRHSNumber = theRHS.num();
if (DoubleSupport::isNaN(theRHSNumber) == false &&
m_value == theRHSNumber)
{
fResult = true;
}
}
return fResult;
}
1.1 xml-xalan/c/src/XPath/XNumber.hpp
Index: XNumber.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XNUMBER_HEADER_GUARD_1357924680)
#define XNUMBER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOMString.hpp>
// Base class header file.
#include <XPath/XObject.hpp>
class XALAN_XPATH_EXPORT XNumber : public XObject
{
public:
XNumber(
XPathEnvSupport& envSupport,
double val);
XNumber(const XNumber& source);
virtual
~XNumber();
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const;
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const;
/**
* Cast result object to a number.
*/
virtual double
num() const;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const;
virtual ResultTreeFragBase&
rtree();
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const;
/**
* Cast result object to a nodelist.
*/
virtual const MutableNodeRefList&
mutableNodeset() const;
virtual MutableNodeRefList&
mutableNodeset();
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const;
private:
// Value of the number being represented.
double m_value;
};
#endif // XNUMBER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XObject.cpp
Index: XObject.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XObject.hpp"
#include <stdexcept>
#include "XPathEnvSupport.hpp"
#include "XPathException.hpp"
XObject::XObject(XPathEnvSupport* envSupport) :
FactoryObject(),
m_envSupport(envSupport)
{
}
XObject::XObject(const XObject& source) :
FactoryObject(),
m_envSupport(source.m_envSupport)
{
}
XObject::~XObject()
{
}
void
XObject::error(const DOMString& msg) const
{
const bool shouldThrow =
m_envSupport->problem(XPathEnvSupport::eXPATHProcessor,
XPathEnvSupport::eError,
DOM_Node(),
DOM_Node(),
msg,
0,
0);
if(shouldThrow == true)
{
throw XPathException(msg);
}
}
1.1 xml-xalan/c/src/XPath/XObject.hpp
Index: XObject.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XOBJECT_HEADER_GUARD_1357924680)
#define XOBJECT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOM_DocumentFragment.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/FactoryObject.hpp>
class MutableNodeRefList;
class NodeRefListBase;
class ResultTreeFragBase;
class XObjectTypeCallback;
class XPathEnvSupport;
/**
* Class to hold XPath return types.
*/
class XALAN_XPATH_EXPORT XObject : public FactoryObject
{
public:
/**
* Create an XObject.
*/
explicit
XObject(XPathEnvSupport* envSupport = 0);
XObject(const XObject& source);
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const = 0;
/**
* Cast result object to a number.
*/
virtual double
num() const = 0;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const = 0;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const = 0;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const = 0;
virtual ResultTreeFragBase&
rtree() = 0;
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const = 0;
/**
* Cast result object to a nodelist that is mutable.
*/
virtual const MutableNodeRefList&
mutableNodeset() const = 0;
virtual MutableNodeRefList&
mutableNodeset() = 0;
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) = 0;
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const = 0;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const = 0;
enum eObjectType { eTypeNull = -1,
eTypeUnknown = 0,
eTypeBoolean = 1,
eTypeNumber = 2,
eTypeString = 3,
eTypeNodeSet = 4,
eTypeResultTreeFrag = 5,
eUnknown = 6};
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const = 0;
protected:
virtual
~XObject();
/**
* Tell the user of an error, and probably throw an
* exception.
*/
virtual void
error(const DOMString& msg) const;
// Data member...
XPathEnvSupport* const m_envSupport;
private:
// Not implemented...
XObject&
operator=(const XObject&);
};
#endif // XOBJECT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XObjectFactory.cpp
Index: XObjectFactory.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XObjectFactory.hpp"
XObjectFactory::XObjectFactory()
{
}
XObjectFactory::~XObjectFactory()
{
}
1.1 xml-xalan/c/src/XPath/XObjectFactory.hpp
Index: XObjectFactory.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XOBJECTFACTORY_HEADER_GUARD_1357924680)
#define XOBJECTFACTORY_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <cassert>
#include <set>
// Base class header file...
#include <PlatformSupport/Factory.hpp>
#include <XPath/XObject.hpp>
class DOM_Node;
class DOMString;
class MutableNodeRefList;
class NodeRefListBase;
class ResultTreeFragBase;
class XObject;
class XALAN_XPATH_EXPORT XObjectFactory : public Factory
{
public:
XObjectFactory();
virtual
~XObjectFactory();
// These interfaces are inherited from Resetable...
/**
* Reset the instance. This invalidates all existing FactoryObject
* instances created with this Factory.
*/
virtual void
reset() = 0;
// These interfaces are inherited from Factory...
/*
* Return an object to the factory.
*
*/
virtual bool
returnObject(const FactoryObject* theFactoryObject) = 0;
// These interfaces are new to XObjectFactory...
virtual XObject*
createBoolean(
bool theValue,
bool fOptimize = true) = 0;
virtual XObject*
createNodeSet(
const NodeRefListBase& value,
bool fOptimize =
true) = 0;
virtual XObject*
createNodeSet(
const MutableNodeRefList& value,
bool
fOptimize = true) = 0;
virtual XObject*
createNodeSet(
const DOM_Node& value,
bool fOptimize = true) = 0;
virtual XObject*
createNull(bool fOptimize = true) = 0;
virtual XObject*
createNumber(
double theValue,
bool fOptimize = true) = 0;
virtual XObject*
createString(
const DOMString& theValue,
bool fOptimize = true) = 0;
virtual XObject*
createUnknown(
const DOMString& theValue,
bool fOptimize = true) = 0;
virtual XObject*
createResultTreeFrag(
const ResultTreeFragBase& theValue,
bool
fOptimize = true) = 0;
virtual XObject*
createSpan(
const NodeRefListBase& value,
bool fOptimize =
true) = 0;
virtual XObject*
createSpan(
const MutableNodeRefList& value,
bool
fOptimize = true) = 0;
virtual XObject*
createSpan(
const DOM_Node& value,
bool fOptimize = true) = 0;
private:
// Not implemented...
XObjectFactory(const XObjectFactory&);
XObjectFactory&
operator=(const XObjectFactory&);
bool
operator==(const XObjectFactory&) const;
};
class XObjectGuard
{
public:
XObjectGuard(XObjectFactory& theFactory,
XObject* theXObject) :
m_factory(&theFactory),
m_object(theXObject)
{
}
// Note that copy construction transfers ownership, just
// as std::auto_ptr.
XObjectGuard(XObjectGuard& theRHS)
{
// Release the current object...
release();
// Copy the factory and object pointers...
m_factory = theRHS.m_factory;
m_object = theRHS.m_object;
// The source object no longer points to
// the object...
theRHS.m_factory = 0;
theRHS.m_object = 0;
}
~XObjectGuard()
{
reset();
}
XObject*
operator->() const
{
assert(m_object != 0);
return m_object;
}
XObject*
get() const
{
return m_object;
}
void
reset()
{
if (m_object != 0)
{
assert(m_factory != 0);
m_factory->returnObject(m_object);
m_object = 0;
}
m_factory = 0;
}
XObject*
release()
{
XObject* const theTemp = m_object;
m_object = 0;
return theTemp;
}
private:
XObjectGuard&
operator=(const XObjectGuard&);
bool
operator==(const XObjectGuard&) const;
// Data members...
XObjectFactory* m_factory;
XObject* m_object;
};
#endif // XOBJECTFACTORY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XObjectFactoryDefault.cpp
Index: XObjectFactoryDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XObjectFactoryDefault.hpp"
#include <algorithm>
#include <memory>
#include <PlatformSupport/STLHelper.hpp>
#include "XBoolean.hpp"
#include "XBooleanStatic.hpp"
#include "XNodeSet.hpp"
#include "XNull.hpp"
#include "XNumber.hpp"
#include "XPathEnvSupport.hpp"
#include "XPathSupport.hpp"
#include "XResultTreeFrag.hpp"
#include "XSpan.hpp"
#include "XString.hpp"
#include "XUnknown.hpp"
namespace
{
XBooleanStatic theTrueBoolean(true);
XBooleanStatic theFalseBoolean(false);
};
namespace
{
template<class ValueType, class CollectionType>
void
InsertObjectIntoCollection(
CollectionType& theCollection,
const ValueType& theObject)
{
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
theCollection.insert(theObject);
#else
theCollection.push_back(theObject);
#endif
}
template<class ValueType, class CollectionType>
bool
RemoveObjectFromCollection(
CollectionType& theCollection,
const ValueType& theObject)
{
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
return theCollection.erase(theObject) > 0 ? true : false;
#else
CollectionType::iterator i =
std::find(theCollection.begin(),
theCollection.end(),
theObject);
if (i == theCollection.end())
{
return false;
}
else
{
theCollection.erase(i);
return true;
}
#endif
}
};
XObjectFactoryDefault::XObjectFactoryDefault(
XPathEnvSupport& theEnvSupport,
XPathSupport& theSupport) :
m_envSupport(theEnvSupport),
m_support(theSupport),
m_xobjects(),
m_XNull(this,
new XNull(m_envSupport, m_support))
{
}
XObjectFactoryDefault::~XObjectFactoryDefault()
{
reset();
}
bool
XObjectFactoryDefault::returnObject(const FactoryObject*
theFactoryObject)
{
if (theFactoryObject == &theTrueBoolean ||
theFactoryObject == &theFalseBoolean ||
theFactoryObject == m_XNull.get())
{
return true;
}
else
{
if (RemoveObjectFromCollection(m_xobjects,
theFactoryObject) == true)
{
return deleteObject(theFactoryObject);
}
else
{
return false;
}
}
}
XObject*
XObjectFactoryDefault::createBoolean(
bool theValue,
bool fOptimize)
{
if (fOptimize == true)
{
return theValue == true ? &theTrueBoolean : &theFalseBoolean;
}
else
{
XBoolean* const theBoolean = new XBoolean(m_envSupport,
theValue);
InsertObjectIntoCollection(m_xobjects,
theBoolean);
return theBoolean;
}
}
XObject*
XObjectFactoryDefault::createNodeSet(
const NodeRefListBase& value,
bool /* fOptimize */)
{
XNodeSet* const theXNodeSet = new XNodeSet(m_envSupport,
m_support, value);
InsertObjectIntoCollection(m_xobjects,
theXNodeSet);
return theXNodeSet;
}
XObject*
XObjectFactoryDefault::createNodeSet(
const MutableNodeRefList& value,
bool /* fOptimize */)
{
XNodeSet* const theXNodeSet = new XNodeSet(m_envSupport,
m_support, value);
InsertObjectIntoCollection(m_xobjects,
theXNodeSet);
return theXNodeSet;
}
XObject*
XObjectFactoryDefault::createNodeSet(
const DOM_Node& value,
bool /* fOptimize */)
{
XNodeSet* const theXNodeSet = new XNodeSet(m_envSupport,
m_support, value);
InsertObjectIntoCollection(m_xobjects,
theXNodeSet);
return theXNodeSet;
}
XObject*
XObjectFactoryDefault::createNull(bool fOptimize)
{
if (fOptimize == true)
{
return m_XNull.get();
}
else
{
XNull* const theXNull = new XNull(m_envSupport, m_support);
InsertObjectIntoCollection(m_xobjects,
theXNull);
return theXNull;
}
}
XObject*
XObjectFactoryDefault::createNumber(
double theValue,
bool /* fOptimize */)
{
XNumber* theXNumber = new XNumber(m_envSupport, theValue);
InsertObjectIntoCollection(m_xobjects,
theXNumber);
return theXNumber;
}
XObject*
XObjectFactoryDefault::createString(
const DOMString& theValue,
bool /* fOptimize */)
{
XString* const theXString = new XString(m_envSupport, m_support,
theValue);
InsertObjectIntoCollection(m_xobjects,
theXString);
return theXString;
}
XObject*
XObjectFactoryDefault::createUnknown(
const DOMString& theValue,
bool /* fOptimize */)
{
XUnknown* const theXUnknown = new XUnknown(m_envSupport, theValue);
InsertObjectIntoCollection(m_xobjects,
theXUnknown);
return theXUnknown;
}
XObject*
XObjectFactoryDefault::createResultTreeFrag(
const ResultTreeFragBase& theValue,
bool /*
fOptimize */)
{
XResultTreeFrag* const theResultTreeFrag = new
XResultTreeFrag(m_envSupport, m_support, theValue);
InsertObjectIntoCollection(m_xobjects,
theResultTreeFrag);
return theResultTreeFrag;
}
XObject*
XObjectFactoryDefault::createSpan(
const NodeRefListBase& theValue,
bool /* fOptimize */)
{
XSpan* const theXSpan = new XSpan(m_envSupport, m_support, theValue);
InsertObjectIntoCollection(m_xobjects,
theXSpan);
return theXSpan;
}
XObject*
XObjectFactoryDefault::createSpan(
const MutableNodeRefList& theValue,
bool
fOptimize)
{
XSpan* const theXSpan = new XSpan(m_envSupport, m_support, theValue);
InsertObjectIntoCollection(m_xobjects,
theXSpan);
return theXSpan;
}
XObject*
XObjectFactoryDefault::createSpan(
const DOM_Node& theValue,
bool /* fOptimize */)
{
XSpan* const theXSpan = new XSpan(m_envSupport, m_support, theValue);
InsertObjectIntoCollection(m_xobjects,
theXSpan);
return theXSpan;
}
void
XObjectFactoryDefault::reset()
{
std::for_each(m_xobjects.begin(),
m_xobjects.end(),
DeleteFactoryObjectFunctor(*this));
m_xobjects.clear();
}
1.1 xml-xalan/c/src/XPath/XObjectFactoryDefault.hpp
Index: XObjectFactoryDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XOBJECTFACTORYDEFAULT_HEADER_GUARD_1357924680)
#define XOBJECTFACTORYDEFAULT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
#include <hash_set>
#elif !defined(XALAN_XTREE_BUG)
#include <slist>
#else
#include <vector>
#endif
// Base class header file...
#include <XPath/XObjectFactory.hpp>
class XPathEnvSupport;
class XPathSupport;
class XALAN_XPATH_EXPORT XObjectFactoryDefault : public XObjectFactory
{
public:
XObjectFactoryDefault(
XPathEnvSupport& theEnvSupport,
XPathSupport& theSupport);
virtual
~XObjectFactoryDefault();
// Inherited from Factory...
/**
* Reset the factory, deleting all objects that it owns.
*/
virtual void
reset();
/*
* Return an object to the factory.
*
*/
virtual bool
returnObject(const FactoryObject* theFactoryObject);
// Inherited from XObjectFactory...
virtual XObject*
createBoolean(
bool theValue,
bool fOptimize = true);
virtual XObject*
createNodeSet(
const NodeRefListBase& value,
bool fOptimize =
true);
virtual XObject*
createNodeSet(
const MutableNodeRefList& value,
bool
fOptimize = true);
virtual XObject*
createNodeSet(
const DOM_Node& value,
bool fOptimize = true);
virtual XObject*
createNull(bool fOptimize = true);
virtual XObject*
createNumber(
double theValue,
bool fOptimize = true);
virtual XObject*
createString(
const DOMString& theValue,
bool fOptimize = true);
virtual XObject*
createUnknown(
const DOMString& theValue,
bool fOptimize = true);
virtual XObject*
createResultTreeFrag(
const ResultTreeFragBase& theValue,
bool
fOptimize = true);
virtual XObject*
createSpan(
const NodeRefListBase& value,
bool fOptimize =
true);
virtual XObject*
createSpan(
const MutableNodeRefList& value,
bool
fOptimize = true);
virtual XObject*
createSpan(
const DOM_Node& value,
bool fOptimize = true);
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef std::hash_set<const FactoryObject*> CollectionType;
#elif !defined(XALAN_XTREE_BUG)
typedef std::slist<const FactoryObject*> CollectionType;
#else
typedef std::vector<const FactoryObject*> CollectionType;
#endif
CollectionType::size_type
instanceCount() const
{
return m_xobjects.size();
}
private:
// Not implemented...
XObjectFactoryDefault(const XObjectFactoryDefault&);
XObjectFactoryDefault&
operator=(const XObjectFactoryDefault&);
bool
operator==(const XObjectFactoryDefault&) const;
// Data members...
XPathEnvSupport&
m_envSupport;
XPathSupport&
m_support;
CollectionType
m_xobjects;
const FactoryObjectAutoPointer<XObject> m_XNull;
};
#endif // XOBJECTFACTORYDEFAULT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XObjectTypeCallback.cpp
Index: XObjectTypeCallback.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XObjectTypeCallback.hpp"
XObjectTypeCallback::XObjectTypeCallback()
{
}
XObjectTypeCallback::~XObjectTypeCallback()
{
}
1.1 xml-xalan/c/src/XPath/XObjectTypeCallback.hpp
Index: XObjectTypeCallback.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XOBJECT_TYPE_CALLBACK_HEADER_GUARD_1357924680)
#define XOBJECT_TYPE_CALLBACK_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
class DOMString;
class MutableNodeRefList;
class NodeRefListBase;
class ResultTreeFragBase;
class XObject;
// The purpose of this class is to provide a way to get the "preferred" or
closest-
// matching type for XObject-derived classes. The idea is to pass a
reference to
// an instance of this class to an XObject instance. It will then call back
to the
// member function that most closely matches its type. This makes it
possible to
// get preferred typing information without doing RTTI or other such type
// introspections.
class XALAN_XPATH_EXPORT XObjectTypeCallback
{
public:
XObjectTypeCallback();
virtual
~XObjectTypeCallback();
virtual void
Number(const XObject& theXObject,
double theValue) = 0;
virtual void
Boolean(const XObject& theXObject,
bool theValue) = 0;
virtual void
String(const XObject& theXObject,
const DOMString& theValue) = 0;
virtual void
ResultTreeFragment(const XObject&
theXObject,
const ResultTreeFragBase&
theValue) = 0;
virtual void
ResultTreeFragment(const XObject& theXObject,
ResultTreeFragBase& theValue) = 0;
virtual void
NodeSet(const XObject& theXObject,
const NodeRefListBase& theValue) = 0;
virtual void
Unknown(const XObject& theObject,
const DOMString& theName) = 0;
virtual void
Null(const XObject& theObject) = 0;
};
#endif // XOBJECT_TYPE_CALLBACK_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPath.cpp
Index: XPath.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPath.hpp"
#include <cassert>
#include <cfloat>
#include <include/DOMHelper.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include "FoundIndex.hpp"
#include "MutableNodeRefList.hpp"
#include "QName.hpp"
#include "PrefixResolver.hpp"
#include "SimpleNodeLocator.hpp"
#include "XLocator.hpp"
#include "XPathException.hpp"
#include "XObject.hpp"
#include "XObjectFactory.hpp"
#include "XPathEnvSupport.hpp"
#include "XPathSupport.hpp"
#if !defined(XALAN_INLINE_INITIALIZATION)
const char* const XPath::PSEUDONAME_ANY = "*";
const char* const XPath::PSEUDONAME_ROOT = "/";
const char* const XPath::PSEUDONAME_TEXT =
"#text";
const char* const XPath::PSEUDONAME_COMMENT =
"#comment";
const char* const XPath::PSEUDONAME_PI = "#pi";
const char* const XPath::PSEUDONAME_OTHER = "*";
const double XPath::s_MatchScoreNone =
-9999999999999;
const double XPath::s_MatchScoreQName = 0.0;
const double XPath::s_MatchScoreNSWild =
-0.25;
const double XPath::s_MatchScoreNodeTest =
-0.5;
const double XPath::s_MatchScoreOther = 0.5;
#endif
XPath::FunctionTableType XPath::s_functions;
XPath::XPath(
XObjectFactory& theXObjectFactory,
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport) :
XPathExecutionContext(),
m_xobjectFactory(theXObjectFactory),
m_XPathEnvSupport(theXPathEnvSupport),
m_XPathSupport(theXPathSupport),
m_defaultXLocator(createXLocatorHandler()),
m_currentNode(),
m_prefixResolver(0),
m_contextNodeList(),
m_throwFoundIndex(false),
m_expression()
{
}
XPath::XPath(
XObjectFactory& theXObjectFactory,
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport,
bool createDefaultLocator) :
XPathExecutionContext(),
m_xobjectFactory(theXObjectFactory),
m_XPathEnvSupport(theXPathEnvSupport),
m_XPathSupport(theXPathSupport),
m_defaultXLocator(createDefaultLocator == false ? 0 :
createXLocatorHandler()),
m_currentNode(),
m_prefixResolver(0),
m_contextNodeList(),
m_throwFoundIndex(false),
m_expression()
{
}
XPath::~XPath()
{
m_defaultXLocator = 0;
m_prefixResolver = 0;
}
void
XPath::shrink()
{
m_expression.shrink();
}
DOM_Node
XPath::getCurrentNode() const
{
return m_currentNode;
}
void
XPath::setCurrentNode(const DOM_Node& theCurrentNode)
{
m_currentNode = theCurrentNode;
}
XObjectFactory&
XPath::getXObjectFactory() const
{
return m_xobjectFactory;
}
DOMString
XPath::getNamespaceOfNode(const DOM_Node& n) const
{
return m_XPathSupport.getNamespaceOfNode(n);
}
DOMString
XPath::getLocalNameOfNode(const DOM_Node& n) const
{
return m_XPathSupport.getLocalNameOfNode(n);
}
DOM_Node
XPath::getParentOfNode(const DOM_Node& n) const
{
return m_XPathSupport.getParentOfNode(n);
}
DOMString
XPath::getNodeData(const DOM_Node& n) const
{
return m_XPathSupport.getNodeData(n);
}
DOM_Element
XPath::getElementByID(
const DOMString& id,
const DOM_Document& doc) const
{
return m_XPathSupport.getElementByID(id, doc);
}
const NodeRefListBase&
XPath::getContextNodeList() const
{
return m_contextNodeList;
}
void
XPath::setContextNodeList(const NodeRefListBase& theList)
{
m_contextNodeList = theList;
}
int
XPath::getContextNodeListLength() const
{
if (m_throwFoundIndex == true)
{
throw FoundIndex();
}
return m_contextNodeList.getLength();
}
int
XPath::getContextNodeListPosition(const DOM_Node& contextNode) const
{
assert(0 != contextNode);
if (m_throwFoundIndex == true)
{
throw FoundIndex();
}
int pos = 0;
const int nNodes = m_contextNodeList.getLength();
for(int i = 0; i < nNodes; i++)
{
if(m_contextNodeList.item(i) == contextNode)
{
pos = i + 1; // for 1-based XSL count.
break;
}
}
return pos;
}
void
XPath::associateXLocatorToNode(
const DOM_Node& node,
XLocator* xlocator) const
{
m_XPathEnvSupport.associateXLocatorToNode(node, xlocator);
}
DOM_Document
XPath::parseXML(
const DOMString& urlString,
const DOMString& base) const
{
return m_XPathSupport.parseXML(urlString, base);
}
MutableNodeRefList
XPath::createMutableNodeRefList() const
{
return MutableNodeRefList(&m_XPathSupport);
}
bool
XPath::getProcessNamespaces() const
{
return m_XPathSupport.getProcessNamespaces();
}
const NodeRefListBase*
XPath::getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const
{
return m_XPathEnvSupport.getNodeSetByKey(doc,
name,
ref,
resolver);
}
const PrefixResolver&
XPath::getPrefixResolver() const
{
return *m_prefixResolver;
}
void
XPath::setPrefixResolver(const PrefixResolver& thePrefixResolver)
{
m_prefixResolver = &thePrefixResolver;
}
DOMString
XPath::getNamespaceForPrefix(const DOMString& prefix) const
{
assert(m_prefixResolver != 0);
return m_prefixResolver->getNamespaceForPrefix(prefix);
}
DOMString
XPath::findURIFromDoc(const DOM_Document& owner) const
{
return m_XPathEnvSupport.findURIFromDoc(owner);
}
DOMString
XPath::getUnparsedEntityURI(
const DOMString& theName,
const DOM_Document& theDocument) const
{
return m_XPathSupport.getUnparsedEntityURI(theName, theDocument);
}
bool
XPath::shouldStripSourceNode(const DOM_Node& node) const
{
return m_XPathEnvSupport.shouldStripSourceNode(node);
}
void
XPath::error(
const DOMString& msg,
const DOM_Node& sourceNode) const
{
assert(m_prefixResolver != 0);
DOMString emsg;
const DOMString& theCurrentPattern =
m_expression.getCurrentPattern();
if (length(theCurrentPattern) != 0)
{
emsg = DOMString("pattern = '") +
theCurrentPattern +
DOMString("'\n");
}
emsg += msg;
if (m_XPathEnvSupport.problem(XPathEnvSupport::eXPATHProcessor,
XPathEnvSupport::eError,
*m_prefixResolver,
sourceNode,
emsg,
0,
0) == true)
{
// $$$ ToDo: Do something with the PrefixResolver here...
throw XPathException(msg, DOM_Node());
}
}
void
XPath::warn(
const DOMString& msg,
const DOM_Node& sourceNode) const
{
assert(m_prefixResolver != 0);
DOMString emsg;
const DOMString& theCurrentPattern =
m_expression.getCurrentPattern();
if (length(theCurrentPattern) != 0)
{
emsg = DOMString("pattern = '") +
theCurrentPattern +
DOMString("'\n");
}
emsg += msg;
if (m_XPathEnvSupport.problem(XPathEnvSupport::eXPATHProcessor,
XPathEnvSupport::eWarning,
*m_prefixResolver,
sourceNode,
emsg,
0,
0) == true)
{
// $$$ ToDo: Do something with the PrefixResolver here...
throw XPathException(msg, DOM_Node());
}
}
XObject*
XPath::execute(
const DOM_Node& contextNode,
const PrefixResolver& resolver,
const NodeRefListBase& contextNodeList)
{
m_prefixResolver = &resolver;
m_contextNodeList = contextNodeList;
m_currentNode = contextNode;
XObject* const xobj = execute(contextNode, 0);
m_currentNode = 0;
m_contextNodeList.clear();
m_prefixResolver = 0;
return xobj;
}
void
XPath::installFunction(
const DOMString& funcName,
const Function& func)
{
s_functions.InstallFunction(funcName,
func);
}
XLocator*
XPath::createXLocatorHandler() const
{
return SimpleNodeLocator::getDefaultInstance();
}
XObject*
XPath::execute(
const DOM_Node& context,
int opPos)
{
XObject* result = 0;
switch(m_expression.m_opMap[opPos])
{
case XPathExpression::eOP_XPATH:
result = execute(context, opPos + 2);
break;
case XPathExpression::eOP_MATCHPATTERN:
result = matchPattern(context, opPos + 2);
break;
case XPathExpression::eEMPTY:
opPos++;
break;
case XPathExpression::eOP_OR:
result = or(context, opPos);
break;
case XPathExpression::eOP_AND:
result = and(context, opPos);
break;
case XPathExpression::eOP_NOTEQUALS:
result = notequals(context, opPos);
break;
case XPathExpression::eOP_EQUALS:
result = equals(context, opPos);
break;
case XPathExpression::eOP_LTE:
result = lte(context, opPos);
break;
case XPathExpression::eOP_LT:
result = lt(context, opPos);
break;
case XPathExpression::eOP_GTE:
result = gte(context, opPos);
break;
case XPathExpression::eOP_GT:
result = gt(context, opPos);
break;
case XPathExpression::eOP_PLUS:
result = plus(context, opPos);
break;
case XPathExpression::eOP_MINUS:
result = minus(context, opPos);
break;
case XPathExpression::eOP_MULT:
result = mult(context, opPos);
break;
case XPathExpression::eOP_DIV:
result = div(context, opPos);
break;
case XPathExpression::eOP_MOD:
result = mod(context, opPos);
break;
case XPathExpression::eOP_QUO:
result = quo(context, opPos);
break;
case XPathExpression::eOP_NEG:
result = neg(context, opPos);
break;
case XPathExpression::eOP_STRING:
result = string(context, opPos);
break;
case XPathExpression::eOP_BOOL:
result = boolean(context, opPos);
break;
case XPathExpression::eOP_NUMBER:
result = number(context, opPos);
break;
case XPathExpression::eOP_UNION:
result = Union(context, opPos);
break;
case XPathExpression::eOP_LITERAL:
result = literal(context, opPos);
break;
case XPathExpression::eOP_VARIABLE:
result = variable(context, opPos);
break;
case XPathExpression::eOP_GROUP:
result = group(context, opPos);
break;
case XPathExpression::eOP_NUMBERLIT:
result = numberlit(context, opPos);
break;
case XPathExpression::eOP_ARGUMENT:
result = arg(context, opPos);
break;
case XPathExpression::eOP_EXTFUNCTION:
result = runExtFunction(context, opPos);
break;
case XPathExpression::eOP_FUNCTION:
result = runFunction(context, opPos);
break;
case XPathExpression::eOP_LOCATIONPATH:
result = locationPath(context, opPos);
break;
case XPathExpression::eOP_LOCATIONPATHPATTERN:
result = locationPathPattern(context, opPos);
break;
/*
case XPathExpression::eOP_PREDICATE:
break;
case XPathExpression::XPathExpression::eFROM_ANCESTORS:
break;
case XPathExpression::eFROM_ANCESTORS_OR_SELF:
break;
case XPathExpression::eFROM_ATTRIBUTES:
break;
case XPathExpression::eFROM_CHILDREN:
break;
case XPathExpression::eFROM_DESCENDANTS:
break;
case XPathExpression::eFROM_DESCENDANTS_OR_SELF:
break;
case XPathExpression::eFROM_FOLLOWING:
break;
case XPathExpression::eFROM_FOLLOWING_SIBLINGS:
break;
case XPathExpression::eFROM_PARENT:
break;
case XPathExpression::eFROM_PRECEDING:
break;
case XPathExpression::eFROM_PRECEDING_SIBLINGS:
break;
case XPathExpression::eFROM_SELF:
break;
case XPathExpression::eFROM_NAMESPACE:
break;
case XPathExpression::eFROM_ATTRIBUTE:
break;
case XPathExpression::eFROM_DOC:
break;
case XPathExpression::eFROM_DOCREF:
break;
case XPathExpression::eFROM_ID:
break;
case XPathExpression::eFROM_IDREF:
break;
case XPathExpression::eFROM_ROOT:
break;
case eNODETYPE_COMMENT:
break;
case eNODETYPE_TEXT:
break;
case eNODETYPE_PI:
break;
case eNODETYPE_NODE:
break;
case eNODETYPE_ROOT:
break;
case eNODETYPE_ANYELEMENT:
break;
case eNODENAME:
break;
*/
default:
error(DOMString("ERROR! Unknown op code: ") +
static_cast<int>(m_expression.m_opMap[opPos]),
context);
break;
}
return result;
}
double
XPath::getMatchScore(const DOM_Node& context)
{
double score = s_MatchScoreNone;
int opPos = 0;
if(m_expression.m_opMap[opPos] == XPathExpression::eOP_MATCHPATTERN)
{
opPos += 2;
XLocator* locator =
m_XPathEnvSupport.getXLocatorFromNode(context);
if(0 == locator)
{
locator = m_defaultXLocator;
}
assert(locator != 0);
while(m_expression.m_opMap[opPos] ==
XPathExpression::eOP_LOCATIONPATHPATTERN &&
score == s_MatchScoreNone)
{
const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
// opPos+=2;
score = locator->locationPathPattern(*this, *this,
context, opPos);
if(score == s_MatchScoreNone)
{
opPos = nextOpPos;
}
}
}
else
{
error("Expected match pattern in getMatchScore!",
context);
}
return score;
}
double
XPath::nodeTest(
const DOM_Node& context,
int /* opPos */,
int /* argLen */,
int /* stepType */)
{
warn("XPath needs a derived object to implement nodeTest!",
context);
return s_MatchScoreNone;
}
void
XPath::getTargetElementStrings(TargetElementStringsVectorType&
targetStrings)
{
int opPos = 2;
while(m_expression.m_opMap[opPos] ==
XPathExpression::eOP_LOCATIONPATHPATTERN)
{
const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
opPos += 2;
while(m_expression.m_opMap[opPos] != XPathExpression::eENDOP)
{
const int nextStepPos =
m_expression.getNextOpCodePosition(opPos);
const int nextOp =
m_expression.m_opMap[nextStepPos];
if(nextOp == XPathExpression::eOP_PREDICATE ||
nextOp == XPathExpression::eENDOP)
{
const int stepType =
m_expression.m_opMap[opPos];
opPos += 3;
switch(stepType)
{
case XPathExpression::eOP_FUNCTION:
targetStrings.push_back(PSEUDONAME_ANY);
break;
case XPathExpression::eFROM_ROOT:
targetStrings.push_back(PSEUDONAME_ROOT);
break;
case XPathExpression::eMATCH_ATTRIBUTE:
case XPathExpression::eMATCH_ANY_ANCESTOR:
case XPathExpression::eMATCH_IMMEDIATE_ANCESTOR:
{
const int tok =
m_expression.m_opMap[opPos];
opPos++;
switch(tok)
{
case
XPathExpression::eNODETYPE_COMMENT:
targetStrings.push_back(PSEUDONAME_COMMENT);
break;
case
XPathExpression::eNODETYPE_TEXT:
targetStrings.push_back(PSEUDONAME_TEXT);
break;
case
XPathExpression::eNODETYPE_NODE:
targetStrings.push_back(PSEUDONAME_ANY);
break;
case
XPathExpression::eNODETYPE_ROOT:
targetStrings.push_back(PSEUDONAME_ROOT);
break;
case
XPathExpression::eNODETYPE_ANYELEMENT:
targetStrings.push_back(PSEUDONAME_ANY);
break;
case
XPathExpression::eNODETYPE_PI:
targetStrings.push_back(PSEUDONAME_ANY);
break;
case XPathExpression::eNODENAME:
{
// Skip the
namespace
const int
tokenIndex = m_expression.m_opMap[opPos + 1];
if(tokenIndex
>= 0)
{
const
DOMString targetName =
m_expression.m_tokenQueue[tokenIndex]->str();
if(::equals(targetName, "*") == true)
{
targetStrings.push_back(PSEUDONAME_ANY);
}
else
{
targetStrings.push_back(targetName);
}
}
else
{
targetStrings.push_back(PSEUDONAME_ANY);
}
}
break;
default:
targetStrings.push_back(PSEUDONAME_ANY);
break;
}
}
break;
}
}
opPos = nextStepPos;
}
opPos = nextOpPos;
}
}
XObject*
XPath::xpath(
const DOM_Node& context,
int opPos)
{
return execute(context, opPos + 2);
}
XObject*
XPath::matchPattern(
const DOM_Node& context,
int opPos)
{
XObject* score = 0;
while(m_expression.m_opMap[opPos] ==
XPathExpression::eOP_LOCATIONPATHPATTERN)
{
const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
score = execute(context, opPos);
if(score->num() != s_MatchScoreNone)
{
break;
}
opPos = nextOpPos;
}
if(0 == score)
{
score = m_xobjectFactory.createNumber(s_MatchScoreNone);
}
return score;
}
MutableNodeRefList*
XPath::step(
const DOM_Node& context,
int /* opPos */)
{
warn("XPath needs a derived object to implement step!",
context);
return 0;
}
XObject*
XPath::or(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
bool fResult = expr1->boolean();
if(fResult == false)
{
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
fResult = expr2->boolean();
}
return m_xobjectFactory.createBoolean(fResult);
}
XObject*
XPath::and(
const DOM_Node& context,
int opPos)
{
bool fResult = false;
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
if (expr1->boolean() == true)
{
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
if (expr2->boolean() == true)
{
fResult = true;
}
}
return m_xobjectFactory.createBoolean(fResult);
}
XObject*
XPath::notequals(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
return m_xobjectFactory.createBoolean(!expr1->equals(*expr2));
}
XObject*
XPath::equals(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
return m_xobjectFactory.createBoolean(expr1->equals(*expr2));
}
XObject*
XPath::lte(
const DOM_Node& context,
int opPos)
{
bool fResult = false;
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const double expr1Value = expr1->num();
if (DoubleSupport::isNaN(expr1Value) == false)
{
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
const double expr2Value = expr2->num();
if (DoubleSupport::isNaN(expr2Value) == false)
{
if (expr1Value <= expr2Value)
{
fResult = true;
}
}
}
return m_xobjectFactory.createBoolean(fResult);
}
XObject*
XPath::lt(
const DOM_Node& context,
int opPos)
{
bool fResult = false;
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const double expr1Value = expr1->num();
if (DoubleSupport::isNaN(expr1Value) == false)
{
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
const double expr2Value = expr2->num();
if (DoubleSupport::isNaN(expr2Value) == false)
{
if (expr1Value < expr2Value)
{
fResult = true;
}
}
}
return m_xobjectFactory.createBoolean(fResult);
}
XObject*
XPath::gte(
const DOM_Node& context,
int opPos)
{
bool fResult = false;
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const double expr1Value = expr1->num();
if (DoubleSupport::isNaN(expr1Value) == false)
{
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
const double expr2Value = expr2->num();
if (DoubleSupport::isNaN(expr2Value) == false)
{
if (expr1Value >= expr2Value)
{
fResult = true;
}
}
}
return m_xobjectFactory.createBoolean(fResult);
}
XObject*
XPath::gt(
const DOM_Node& context,
int opPos)
{
bool fResult = false;
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const double expr1Value = expr1->num();
if (DoubleSupport::isNaN(expr1Value) == false)
{
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
const double expr2Value = expr2->num();
if (DoubleSupport::isNaN(expr2Value) == false)
{
if (expr1Value > expr2Value)
{
fResult = true;
}
}
}
return m_xobjectFactory.createBoolean(fResult);
}
XObject*
XPath::plus(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
return m_xobjectFactory.createNumber(expr1->num() + expr2->num());
}
XObject*
XPath::minus(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
return m_xobjectFactory.createNumber(expr1->num() - expr2->num());
}
XObject*
XPath::mult(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
return m_xobjectFactory.createNumber(expr1->num() * expr2->num());
}
XObject*
XPath::div(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
return m_xobjectFactory.createNumber(expr1->num() / expr2->num());
}
XObject*
XPath::mod(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* const expr1 = execute(context, opPos);
assert(expr1 != 0);
const int expr2Pos =
m_expression.getNextOpCodePosition(opPos);
XObject* const expr2 = execute(context, expr2Pos);
assert(expr2 != 0);
return m_xobjectFactory.createNumber(static_cast<int>(expr1->num()) %
static_cast<int>(expr2->num()));
}
XObject*
XPath::quo(
const DOM_Node& context,
int opPos)
{
// Actually, this is no longer supported by xpath...
warn("Old syntax: quo(...) is no longer defined in XPath.");
return div(context, opPos);
}
XObject*
XPath::neg(
const DOM_Node& context,
int opPos)
{
XObject* const expr1 = execute(context, opPos + 2);
assert(expr1 != 0);
return m_xobjectFactory.createNumber(-expr1->num());
}
XObject*
XPath::string(
const DOM_Node& context,
int opPos)
{
XObject* const expr1 = execute(context, opPos + 2);
assert(expr1 != 0);
return m_xobjectFactory.createString(expr1->str());
}
XObject*
XPath::boolean(
const DOM_Node& context,
int opPos)
{
XObject* const expr1 = execute(context, opPos + 2);
assert(expr1 != 0);
return m_xobjectFactory.createBoolean(expr1->boolean());
}
XObject*
XPath::number(
const DOM_Node& context,
int opPos)
{
XObject* const expr1 = execute(context, opPos + 2);
assert(expr1 != 0);
return m_xobjectFactory.createNumber(expr1->num());
}
XObject*
XPath::Union(
const DOM_Node& context,
int opPos)
{
opPos += 2;
XObject* resultNodeSet = 0;
while(m_expression.m_opMap[opPos] == XPathExpression::eOP_LOCATIONPATH)
{
const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
XObject* expr = execute(context, opPos);
if(0 == resultNodeSet)
{
resultNodeSet = expr;
}
else
{
MutableNodeRefList& nl =
resultNodeSet->mutableNodeset();
nl.addNodesInDocOrder(expr->nodeset());
}
opPos = nextOpPos;
}
return resultNodeSet;
}
XObject*
XPath::literal(
const DOM_Node& /* context */,
int opPos)
{
assert(m_expression.m_opMap.size() > static_cast<unsigned>(opPos + 2));
assert(m_expression.m_tokenQueue.size() >
static_cast<unsigned>(m_expression.m_opMap[opPos + 2]));
return
m_xobjectFactory.createString(m_expression.m_tokenQueue[m_expression.m_opMap[opPos
+ 2]]->str());
}
XObject*
XPath::variable(
const DOM_Node& context,
int opPos)
{
assert(m_prefixResolver != 0);
XObject* const varName =
m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
// $$$ ToDo: I don't this will be parsed right in the first place...
const QName qname(varName->str(),
*m_prefixResolver);
XObject* result = 0;
try
{
result = m_XPathEnvSupport.getVariable(*this, qname);
}
catch(...)
{
error(DOMString("Could not get variable named ") +
varName->str());
}
if(0 == result)
{
warn(DOMString("VariableReference given for variable out ") +
DOMString("of context or without definition!
Name = ") +
varName->str(),
context);
}
return result;
}
XObject*
XPath::group(
const DOM_Node& context,
int opPos)
{
return execute(context, opPos + 2);
}
XObject*
XPath::numberlit(
const DOM_Node& /* context */,
int opPos)
{
assert(m_expression.m_opMap.size() > static_cast<unsigned>(opPos + 2));
assert(m_expression.m_tokenQueue.size() >
static_cast<unsigned>(m_expression.m_opMap[opPos + 2]));
return
m_xobjectFactory.createNumber(m_expression.m_tokenQueue[m_expression.m_opMap[opPos
+ 2]]->num());
}
XObject*
XPath::arg(
const DOM_Node& context,
int opPos)
{
return execute(context, opPos + 2);
}
XObject*
XPath::locationPath(
const DOM_Node& context,
int opPos)
{
/*
const int stepType = m_expression.m_opMap[opPos + 2];
XLocator xlocator = null;
if(OP_VARIABLE == stepType)
{
// Bit of a hack here...
XObject obj = execute(context, opPos+2);
NodeList nl = obj.nodeset();
if(nl.getLength() > 0)
{
// Use the xlocator of the first node...
// I guess we should really loop through the contexts, but
things
// will get very nasty quick, so just do this for now.
xlocator = m_callbacks.getXLocatorFromNode(nl.item(0));
}
else
{
xlocator = m_callbacks.getXLocatorFromNode(context);
}
}
else
{
xlocator = m_callbacks.getXLocatorFromNode(context);
}
*/
XLocator* xlocator =
m_XPathEnvSupport.getXLocatorFromNode(context);
if(0 == xlocator)
{
xlocator = m_defaultXLocator;
}
return xlocator->locationPath(*this, *this, context, opPos);
}
XObject*
XPath::predicate(
const DOM_Node& context,
int opPos)
{
XObject* const expr1 = execute(context, opPos + 2);
// $$$ ToDo: This appears to be just an optimization, but is it really?
/*
int objType = expr1.getType();
if((XObject.CLASS_NUMBER != objType) && (XObject.CLASS_BOOLEAN !=
objType))
{
expr1 = expr1.bool() ? m_true : m_false;
}
*/
return expr1;
}
XObject*
XPath::locationPathPattern(
const DOM_Node& context,
int opPos)
{
XLocator* locator =
m_XPathEnvSupport.getXLocatorFromNode(context);
if(0 == locator)
{
locator = m_defaultXLocator;
}
const double result = locator->locationPathPattern(*this, *this,
context, opPos);
return m_xobjectFactory.createNumber(result);
}
XObject*
XPath::runExtFunction(
const DOM_Node& context,
int opPos)
{
const int endExtFunc = opPos + m_expression.m_opMap[opPos + 1] -
1;
opPos += 2;
const XObject* const ns =
m_expression.m_tokenQueue[m_expression.m_opMap[opPos]];
opPos++;
const XObject* const funcName =
m_expression.m_tokenQueue[m_expression.m_opMap[opPos]];
opPos++;
std::vector<XObject*> args;
while(opPos < endExtFunc)
{
const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
args.push_back(execute(context, opPos));
opPos = nextOpPos;
}
return extfunction(context, opPos, ns->str(), funcName->str(), args);
}
XObject*
XPath::extfunction(
const DOM_Node& /*
context */,
int
/* opPos */,
const DOMString&
theNamespace,
const DOMString&
extensionName,
const std::vector<XObject*>& argVec)
{
return m_XPathEnvSupport.extFunction(*this,
theNamespace,
extensionName,
argVec);
}
XObject*
XPath::runFunction(
const DOM_Node& context,
int opPos)
{
const int endFunc = opPos + m_expression.m_opMap[opPos + 1] - 1;
opPos += 2;
// This is actually the position in the token queue of the
// string that contains the name of the function.
const int funcID = m_expression.m_opMap[opPos];
opPos++;
std::vector<XObject*> args;
while(opPos < endFunc)
{
const int nextOpPos =
m_expression.getNextOpCodePosition(opPos);
args.push_back(execute(context, opPos));
opPos = nextOpPos;
}
return function(context, opPos, funcID, args);
}
XObject*
XPath::function(
const DOM_Node& context,
int
opPos,
int
funcID,
const std::vector<XObject*>& argVec)
{
assert(m_expression.getToken(funcID) != 0);
const DOMString
theFunctionName(m_expression.getToken(funcID)->str());
return s_functions[theFunctionName].execute(*this, context, opPos,
argVec);
}
1.1 xml-xalan/c/src/XPath/XPath.hpp
Index: XPath.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATH_HEADER_GUARD_1357924680)
#define XPATH_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <map>
#include <memory>
#include <vector>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/FactoryObject.hpp>
#include <PlatformSupport/STLHelper.hpp>
// Base class header files...
#include <XPath/XPathExecutionContext.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/XPathExpression.hpp>
#include <XPath/XPathFunctionTable.hpp>
class PrefixResolver;
class XLocator;
class XObject;
class XObjectFactory;
class XPathEnvSupport;
class XPathSupport;
/**
* The XPath class represents the semantic parse tree of the XPath pattern.
* It is the representation of the grammar which filters out
* the choice for replacement order of the production rules.
* In order to conserve memory and reduce object creation, the
* tree is represented as an array of integers:
* [op code][length][...]
* where strings are represented within the array as
* indexes into the token tree.
*/
// $$$ ToDo: I'm only having XPath derive from XPathExecutionContext for
convenience,
// and because we really haven't broken XPath into an abstract base class,
and an
// implementation class. But for now, XPathProcessorImpl has intimate
knowledge of
// XPath, so this is necessary.
class XALAN_XPATH_EXPORT XPath : public FactoryObject, public
XPathExecutionContext
{
public:
#if defined(XALAN_INLINE_INITIALIZATION)
const char* const PSEUDONAME_ANY = "*";
const char* const PSEUDONAME_ROOT = "/";
const char* const PSEUDONAME_TEXT = "#text";
const char* const PSEUDONAME_COMMENT = "#comment";
const char* const PSEUDONAME_PI = "#pi";
const char* const PSEUDONAME_OTHER = "*";
#else
static const char* const PSEUDONAME_ANY;
static const char* const PSEUDONAME_ROOT;
static const char* const PSEUDONAME_TEXT;
static const char* const PSEUDONAME_COMMENT;
static const char* const PSEUDONAME_PI;
static const char* const PSEUDONAME_OTHER;
#endif
XPath(
XObjectFactory& theXObjectFactory,
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport);
// These interfaces are inherited from XPathExecutionContext
virtual DOM_Node
getCurrentNode() const;
virtual void
setCurrentNode(const DOM_Node& theCurrentNode);
virtual XObjectFactory&
getXObjectFactory() const;
/**
* Returns the namespace of the given node.
*/
virtual DOMString
getNamespaceOfNode(const DOM_Node& n) const;
/**
* Returns the local name of the given node.
*/
virtual DOMString
getLocalNameOfNode(const DOM_Node& n) const;
/**
* Returns the parent of the given node.
*/
virtual DOM_Node
getParentOfNode(const DOM_Node& n) const;
/**
* Get node data recursively.
* (Note whitespace issues.)
*/
virtual DOMString
getNodeData(const DOM_Node& n) const;
/**
* Get an element from an ID.
*/
virtual DOM_Element
getElementByID(
const DOMString& id,
const DOM_Document& doc) const;
/*
* Get the current context node list.
*
*/
virtual const NodeRefListBase&
getContextNodeList() const;
/*
* Set the current context node list.
*
*/
virtual void
setContextNodeList(const NodeRefListBase& theList);
/*
* Get the count of nodes in the current context node list.
*
*/
virtual int
getContextNodeListLength() const;
/*
* Get the current position in the current context node list.
*
*/
virtual int
getContextNodeListPosition(const DOM_Node& contextNode) const;
virtual void
associateXLocatorToNode(
const DOM_Node& node,
XLocator* xlocator) const;
/**
* Provides support for XML parsing service.
*/
virtual DOM_Document
parseXML(
const DOMString& urlString,
const DOMString& base) const;
/**
* Create a MutableNodeRefList with the appropriate context.
*/
virtual MutableNodeRefList
createMutableNodeRefList() const;
/**
* Tells if namespaces should be supported. For optimization purposes.
*/
virtual bool
getProcessNamespaces() const;
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const;
virtual const PrefixResolver&
getPrefixResolver() const;
virtual void
setPrefixResolver(const PrefixResolver& thePrefixResolver);
virtual DOMString
getNamespaceForPrefix(const DOMString& prefix) const;
/**
* Given a DOM Document, tell what URI was used to parse it.
* Needed for relative resolution.
*/
virtual DOMString
findURIFromDoc(const DOM_Document& owner) const;
/**
* The getUnparsedEntityURI function returns the URI of the unparsed
* entity with the specified name in the same document as the context
* node (see [3.3 Unparsed Entities]). It returns the empty string if
* there is no such entity.
*/
virtual DOMString
getUnparsedEntityURI(
const DOMString& theName,
const DOM_Document& theDocument) const;
/**
* Tells, through the combination of the default-space attribute
* on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the
* xml:space attribute, whether or not extra whitespace should be
stripped
* from the node. Literal elements from template elements should
* <em>not</em> be tested with this function.
* @param textNode A text node from the source tree.
* @return true if the text node should be stripped of extra whitespace.
*/
virtual bool
shouldStripSourceNode(const DOM_Node& node) const;
/**
* Tell the user of an error, and probably throw an
* exception.
*/
virtual void
error(
const DOMString& msg,
const DOM_Node& sourceNode = DOM_Node()) const;
/**
* Tell the user of an warning, and probably throw an
* exception.
*/
virtual void
warn(
const DOMString& msg,
const DOM_Node& sourceNode = DOM_Node()) const;
// These interfaces are new...
virtual void
shrink();
bool
getThrowFoundIndex() const
{
return m_throwFoundIndex;
}
void
setThrowFoundIndex(bool fThrow)
{
m_throwFoundIndex = fThrow;
}
/**
* Given an expression and a context, return the result.
* @param expression The expression.
* @param node The node that "." expresses.
* @param namespaceContext The context in which namespaces in the
* queries are supposed to be expanded.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual XObject*
execute(
const DOM_Node& contextNode,
const PrefixResolver& resolver,
const NodeRefListBase& contextNodeList);
/**
* Execute the XPath from the provided context.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns the union of node-set operands.
*/
virtual XObject*
execute(
const DOM_Node& context,
int opPos);
/**
* Execute a location path.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns a node-set.
*/
virtual XObject*
locationPath(
const DOM_Node& context,
int opPos);
// Get a reference to the current expression.
XPathExpression&
getExpression()
{
return m_expression;
}
#if defined(XALAN_INLINE_INITIALIZATION)
/**
* The match score if no match is made.
*/
const double s_MatchScoreNone =
-9999999999999;
/**
* The match score if the pattern has the form
* of a QName optionally preceded by an @ character.
*/
const double s_MatchScoreQName = 0.0;
/**
* The match score if the pattern has the form NCName:*.
*/
const double s_MatchScoreNSWild =
-0.25;
/**
* The match score if the pattern consists of just a NodeTest.
*/
const double s_MatchScoreNodeTest =
-0.5;
/**
* The match score if the pattern consists of something
* other than just a NodeTest or just a qname.
*/
const double s_MatchScoreOther = 0.5;
#else
/**
* The match score if no match is made.
*/
static const double
s_MatchScoreNone;
/**
* The match score if the pattern has the form
* of a QName optionally preceded by an @ character.
*/
static const double
s_MatchScoreQName;
/**
* The match score if the pattern has the form NCName:*.
*/
static const double
s_MatchScoreNSWild;
/**
* The match score if the pattern consists of just a NodeTest.
*/
static const double
s_MatchScoreNodeTest;
/**
* The match score if the pattern consists of something
* other than just a NodeTest or just a qname.
*/
static const double
s_MatchScoreOther;
#endif
/**
* Computes the union of its operands which must be node-sets.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns the union of node-set operands.
*/
virtual double
getMatchScore(const DOM_Node& context);
/**
* Test a node. This should be implemented by a derived class.
* The default just returns s_MatchScoreNone.
* @return one of s_MatchScoreNone, s_MatchScoreNodeTest,
s_MatchScoreQName
*/
virtual double
nodeTest(
const DOM_Node& context,
int opPos,
int argLen,
int stepType);
/**
* Evaluate a predicate.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns either a boolean or a number.
*/
virtual XObject*
predicate(
const DOM_Node& context,
int opPos);
typedef std::vector<DOMString> TargetElementStringsVectorType;
virtual void
getTargetElementStrings(TargetElementStringsVectorType&
targetStrings);
/**
* Install a built-in function.
* @param funcName The unqualified name of the function.
* @param func An instance of an XPath function object.
* @return Nothing.
*/
static void
installFunction(
const DOMString& funcName,
const Function& func);
static bool
isInstalledFunction(const DOMString& theFunctionName)
{
return s_functions.isInstalledFunction(theFunctionName);
}
typedef XPathFunctionTable FunctionTableType;
static const FunctionTableType&
getFunctionTable()
{
return s_functions;
}
#if defined(XALAN_NO_MEMBER_TEMPLATES)
typedef XPathFunctionTable::InstalledFunctionNameVectorType
InstalledFunctionNameVectorType;
static void
getInstalledFunctionNames(InstalledFunctionNameVectorType&
theVector)
{
s_functions.getInstalledFunctionNames(theVector);
}
#else
template<class OutputIteratorType>
static void
getInstalledFunctionNames(OutputIteratorType theIterator)
{
s_functions.getInstalledFunctionNames(theIterator);
}
#endif
protected:
XPath(
XObjectFactory& theXObjectFactory,
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport,
bool createDefaultLocator);
virtual
~XPath();
/**
* createXLocatorHandler.
*/
virtual XLocator*
createXLocatorHandler() const;
/**
* Execute from the beginning of the xpath.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns The result of the expression.
*/
virtual XObject*
xpath(
const DOM_Node& context,
int opPos);
/**
* Computes the union of its operands which must be node-sets.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns the match score in the form of an XObject.
*/
virtual XObject*
matchPattern(
const DOM_Node& context,
int opPos);
/**
* Execute a step in a location path. This must be implemented
* by a derived class of XPath (or don't call at all
* from the derived implementation of locationPath()).
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns a node-set.
*/
MutableNodeRefList*
step(
const DOM_Node& context,
int opPos);
/**
* OR two expressions and return the boolean result.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if the one of the two arguments are
true.
*/
virtual XObject*
or(
const DOM_Node& context,
int opPos);
/**
* OR two expressions and return the boolean result.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if the two arguments are both true.
*/
virtual XObject*
and(
const DOM_Node& context,
int opPos);
/**
* Tell if two expressions are functionally not equal.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if the two arguments are not equal.
*/
virtual XObject*
notequals(
const DOM_Node& context,
int opPos);
/**
* Tell if two expressions are functionally equal.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if the two arguments are equal.
*/
virtual XObject*
equals(
const DOM_Node& context,
int opPos);
/**
* Tell if one argument is less than or equal to the other argument.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if arg 1 is less than or equal to arg
2.
*/
virtual XObject*
lte(
const DOM_Node& context,
int opPos);
/**
* Tell if one argument is less than the other argument.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if arg 1 is less than arg 2.
*/
virtual XObject*
lt(
const DOM_Node& context,
int opPos);
/**
* Tell if one argument is greater than or equal to the other argument.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if arg 1 is greater than or equal to
arg 2.
*/
virtual XObject*
gte(
const DOM_Node& context,
int opPos);
/**
* Tell if one argument is greater than the other argument.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns XBoolean set to true if arg 1 is greater than arg 2.
*/
virtual XObject*
gt(
const DOM_Node& context,
int opPos);
/**
* Give the sum of two arguments.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns sum of arg1 and arg2.
*/
virtual XObject*
plus(
const DOM_Node& context,
int opPos);
/**
* Give the difference of two arguments.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns difference of arg1 and arg2.
*/
virtual XObject*
minus(
const DOM_Node& context,
int opPos);
/**
* Multiply two arguments.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg1 * arg2.
*/
virtual XObject*
mult(
const DOM_Node& context,
int opPos);
/**
* Divide a number.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg1 / arg2.
*/
virtual XObject*
div(
const DOM_Node& context,
int opPos);
/**
* Return the remainder from a truncating division.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg1 mod arg2.
*/
virtual XObject*
mod(
const DOM_Node& context,
int opPos);
/**
* Return the remainder from a truncating division.
* (Quo is no longer supported by xpath).
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg1 mod arg2.
*/
virtual XObject*
quo(
const DOM_Node& context,
int opPos);
/**
* Return the negation of a number.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns -arg.
*/
virtual XObject*
neg(
const DOM_Node& context,
int opPos);
/**
* Cast an expression to a string.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg cast to a string.
*/
virtual XObject*
string(
const DOM_Node& context,
int opPos);
/**
* Cast an expression to a boolean.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg cast to a boolean.
*/
virtual XObject*
boolean(
const DOM_Node& context,
int opPos);
/**
* Cast an expression to a number.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg cast to a number.
*/
virtual XObject*
number(
const DOM_Node& context,
int opPos);
/**
* Computes the union of its operands which must be node-sets.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns the union of node-set operands.
*/
virtual XObject*
Union(
const DOM_Node& context,
int opPos);
/**
* Get a literal value.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns an XObject object.
*/
virtual XObject*
literal(
const DOM_Node& context,
int opPos);
/**
* Get a literal value.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns an XObject object.
*/
virtual XObject*
variable(
const DOM_Node& context,
int opPos);
/**
* Execute an expression as a group.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns arg.
*/
virtual XObject*
group(
const DOM_Node& context,
int opPos);
/**
* Get a literal value.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns an XObject object.
*/
virtual XObject*
numberlit(
const DOM_Node& context,
int opPos);
/**
* Execute a function argument.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns the result of the argument expression.
*/
virtual XObject*
arg(
const DOM_Node& context,
int opPos);
/**
* Execute a location path.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @returns score in an XNumber, one of MATCH_SCORE_NODETEST,
* MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
*/
virtual XObject*
locationPathPattern(
const DOM_Node& context,
int opPos);
/**
* Setup for and run an extension function.
*/
virtual XObject*
runExtFunction(
const DOM_Node& context,
int opPos);
/**
* Handle an extension function.
*/
virtual XObject*
extfunction(
const DOM_Node& context,
int
opPos,
const DOMString&
theNamespace,
const DOMString&
extensionName,
const std::vector<XObject*>& argVec);
/**
* Setup for and run a function.
*/
virtual XObject*
runFunction(
const DOM_Node& context,
int opPos);
/**
* Handle a built-in function.
*/
virtual XObject*
function(
const DOM_Node& context,
int
opPos,
int
funcID,
const std::vector<XObject*>& argVec);
#if 0
public Vector getTargetElementStrings()
{
Vector targetStrings = new Vector();
int opPos = 2;
while(m_opMap[opPos] == OP_LOCATIONPATHPATTERN)
{
int nextOpPos = getNextOpPos(opPos);
opPos+=2;
while( m_opMap[opPos] != ENDOP )
{
int nextStepPos = getNextOpPos(opPos);
int nextOp = m_opMap[nextStepPos];
if((nextOp == OP_PREDICATE) || (nextOp == ENDOP))
{
int stepType = m_opMap[opPos];
opPos += 3;
switch(stepType)
{
case OP_FUNCTION:
targetStrings.addElement(PSEUDONAME_ANY);
break;
case FROM_ROOT:
targetStrings.addElement(PSEUDONAME_ROOT);
break;
case MATCH_ATTRIBUTE:
case MATCH_ANY_ANCESTOR:
case MATCH_IMMEDIATE_ANCESTOR:
int tok = m_opMap[opPos];
opPos++;
switch(tok)
{
case NODETYPE_COMMENT:
targetStrings.addElement(PSEUDONAME_COMMENT);
break;
case NODETYPE_TEXT:
targetStrings.addElement(PSEUDONAME_TEXT);
break;
case NODETYPE_NODE:
targetStrings.addElement(PSEUDONAME_ANY);
break;
case NODETYPE_ROOT:
targetStrings.addElement(PSEUDONAME_ROOT);
break;
case NODETYPE_ANYELEMENT:
targetStrings.addElement(PSEUDONAME_ANY);
break;
case NODETYPE_PI:
targetStrings.addElement(PSEUDONAME_ANY);
break;
case NODENAME:
// Skip the namespace
int tokenIndex = m_opMap[opPos+1];
if(tokenIndex >= 0)
{
String targetName =
(String)m_tokenQueue[tokenIndex];
if(targetName.equals("*"))
{
targetStrings.addElement(PSEUDONAME_ANY);
}
else
{
targetStrings.addElement(targetName);
}
}
else
{
targetStrings.addElement(PSEUDONAME_ANY);
}
break;
default:
targetStrings.addElement(PSEUDONAME_ANY);
break;
}
break;
}
}
opPos = nextStepPos;
}
opPos = nextOpPos;
}
return targetStrings;
}
// ============= DIAGNOSTIC & ERROR HANDLINING =================
private void ____DIAGNOSTICS_AND_ERRORS____(){}
private final void trace(String s)
{
System.out.println(s);
}
/**
* Tell the user of an assertion error, and probably throw an
* exception.
*/
private void assert(boolean b, String msg)
{
if(!b)
error(null, "Programmer assertion is incorrect! - "+msg);
}
#endif
private:
// Not implemented...
XPath(const XPath&);
// Data members...
XObjectFactory&
m_xobjectFactory;
XPathEnvSupport&
m_XPathEnvSupport;
XPathSupport& m_XPathSupport;
XLocator*
m_defaultXLocator;
/**
* The current node at the beginning of the pattern, in other words,
* the value returned by the current() function.
*/
DOM_Node
m_currentNode;
/**
* The PrefixResolver that determines which namespaces in the
* queries are supposed to be expanded.
*/
const PrefixResolver* m_prefixResolver;
/**
* The current step node. This and m_stepMark can be
* used to call Step(...) in order to arrive at the
* current context list.
*/
MutableNodeRefList
m_contextNodeList;
/**
* Tells if FoundIndex should be thrown if index is found.
* This is an optimization for match patterns.
*/
bool
m_throwFoundIndex;
/**
*
* Holds information about the current expression.
*
*/
XPathExpression m_expression;
/**
*
* This is the table of functions. It's range starts where
* the opcodes end.
*/
static FunctionTableType s_functions;
};
#endif // XPATH_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathDefinitions.hpp
Index: XPathDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHDEFINITIONS_HEADER_GUARD_1357924680)
#define XPATHDEFINITIONS_HEADER_GUARD_1357924680
#include <include/PlatformDefinitions.hpp>
#if defined(XALAN_XPATH_BUILD_DLL)
#define XALAN_XPATH_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_XPATH_EXPORT_FUNCTION(T) XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_XPATH_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_XPATH_EXPORT_FUNCTION(T) XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // XPATHDEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathEnvSupport.cpp
Index: XPathEnvSupport.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathEnvSupport.hpp"
XPathEnvSupport::XPathEnvSupport() :
Resettable()
{
}
XPathEnvSupport::~XPathEnvSupport()
{
}
1.1 xml-xalan/c/src/XPath/XPathEnvSupport.hpp
Index: XPathEnvSupport.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHENVSUPPORT_HEADER_GUARD_1357924680)
#define XPATHENVSUPPORT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <map>
#include <vector>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NodeList.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/Resettable.hpp>
class NodeRefListBase;
class PrefixResolver;
class XLocator;
class XObject;
class XPathExecutionContext;
class QName;
class XALAN_XPATH_EXPORT XPathEnvSupport : public Resettable
{
public:
XPathEnvSupport();
virtual
~XPathEnvSupport();
// These interfaces are inherited from Resettable...
/**
* Reset the instance.
*/
virtual void
reset() = 0;
// These interfaces are new to XPathEnvSupport...
/**
* Given a valid element key, return the corresponding node list.
*/
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const DOM_Element& nscontext) const = 0;
/**
* Given a valid element key, return the corresponding node list.
*/
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& nscontext) const = 0;
/**
* Given a name, locate a variable in the current context, and return
* the Object.
*/
virtual XObject*
getVariable(
XPathExecutionContext& executionContext,
const QName& name) const = 0;
// Table for storing source tree documents, which are keyed by
// URL.
typedef std::map<DOMString, DOM_Document, DOMStringEqualsFunction>
SourceDocsTableType;
/**
* Get table of source tree documents.
* Document objects are keyed by URL string.
*/
virtual SourceDocsTableType&
getSourceDocsTable() = 0;
/**
* Given a DOM Document, tell what URI was used to parse it.
* Needed for relative resolution.
*/
virtual DOMString
findURIFromDoc(const DOM_Document& owner) const = 0;
/**
* Get a DOM document, primarily for creating result
* tree fragments.
*/
virtual DOM_Document
getDOMFactory() const = 0;
/**
* Execute the function-available() function.
*/
virtual bool
functionAvailable(
const DOMString& theNamespace,
const DOMString& extensionName) const = 0;
/**
* Handle an extension function.
*/
virtual XObject*
extFunction(
XPathExecutionContext&
executionContext,
const DOMString&
theNamespace,
const DOMString&
extensionName,
const std::vector<XObject*>& argVec) const = 0;
virtual XLocator*
getXLocatorFromNode(const DOM_Node& node) const = 0;
virtual void
associateXLocatorToNode(
const DOM_Node& node,
XLocator* xlocator) const = 0;
/**
* Tells, through the combination of the default-space attribute
* on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the
* xml:space attribute, whether or not extra whitespace should be
stripped
* from the node. Literal elements from template elements should
* <em>not</em> be tested with this function.
* @param textNode A text node from the source tree.
* @return true if the text node should be stripped of extra whitespace.
*/
virtual bool
shouldStripSourceNode(const DOM_Node& node) const = 0;
/**
* Function that is called when a problem event occurs.
*
* @param where Either eXMLParser,
eXSLTProcessor,
* eXPATHParser,
eXPATHProcessor, or
* eDataSource.
* @param classification Either eWarning, or eError
* @param styleNode The style tree node where the problem
* occurred. May
be null.
* @param sourceNode The source tree node where the problem
* occurred. May
be null.
* @param msg A string message explaining the
problem.
* @param lineNo The line number where the
problem occurred,
* if it is known.
May be zero.
* @param charOffset The character offset where the problem,
* occurred if it
is known. May be zero.
*
* @return true if the return is an ERROR, in which case
* exception will be thrown. Otherwise the processor
will
* continue to process.
*/
enum eSource { eXMLParser = 1,
eXSLTProcessor = 2,
eXPATHParser = 3,
eXPATHProcessor = 4,
eDataSource = 5 };
enum eClassification { eWarning = 1,
eError = 2 };
virtual bool
problem(
eSource where,
eClassification classification,
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int charOffset)
const = 0;
virtual bool
problem(
eSource where,
eClassification classification,
const PrefixResolver& resolver,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int
charOffset) const = 0;
/**
* Query the value of the extend support instance.
*
* @return A pointer to the extended support instance. May be 0.
*/
virtual XPathEnvSupport*
GetExtendedEnvSupport() const = 0;
/**
* This call is intended to allow extending via delegation.
*
* @param theExtendedSupport A pointer to another
XPathEnvSupport
*
instance to delegate to. This may be
*
0.
*
* @return A pointer to the previous extended instance. May be 0.
*/
virtual XPathEnvSupport*
SetExtendedEnvSupport(XPathEnvSupport* theExtendedSupport) = 0;
private:
// These are not implemented...
XPathEnvSupport(const XPathEnvSupport&);
XPathEnvSupport&
operator=(const XPathEnvSupport&);
bool
operator==(const XPathEnvSupport&) const;
};
#endif // XPATHENVSUPPORT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathEnvSupportDefault.cpp
Index: XPathEnvSupportDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathEnvSupportDefault.hpp"
#include <algorithm>
#include <util/StdOut.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include "QName.hpp"
#include "SimpleNodeLocator.hpp"
#include "XObject.hpp"
#include "XObjectFactory.hpp"
#include "XPathExecutionContext.hpp"
XPathEnvSupportDefault::XPathEnvSupportDefault() :
XPathEnvSupport(),
m_extendedSupport(0),
m_sourceDocs()
{
}
XPathEnvSupportDefault::~XPathEnvSupportDefault()
{
}
void
XPathEnvSupportDefault::reset()
{
if (m_extendedSupport != 0)
{
m_extendedSupport->reset();
}
}
const NodeRefListBase*
XPathEnvSupportDefault::getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const DOM_Element& nscontext) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->getNodeSetByKey(doc,
name,
ref,
nscontext);
}
else
{
return 0;
}
}
const NodeRefListBase*
XPathEnvSupportDefault::getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->getNodeSetByKey(doc,
name,
ref,
resolver);
}
else
{
return 0;
}
}
XObject*
XPathEnvSupportDefault::getVariable(
XPathExecutionContext& executionContext,
const QName& name) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->getVariable(executionContext,
name);
}
else
{
return
executionContext.getXObjectFactory().createUnknown(name.getLocalPart());
}
}
XPathEnvSupportDefault::SourceDocsTableType&
XPathEnvSupportDefault::getSourceDocsTable()
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->getSourceDocsTable();
}
else
{
return m_sourceDocs;
}
}
DOMString
XPathEnvSupportDefault::findURIFromDoc(const DOM_Document& owner) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->findURIFromDoc(owner);
}
else
{
return "Unknown";
}
}
DOM_Document
XPathEnvSupportDefault::getDOMFactory() const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->getDOMFactory();
}
else
{
return DOM_Document();
}
}
bool
XPathEnvSupportDefault::functionAvailable(
const DOMString& theNamespace,
const DOMString& extensionName) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->functionAvailable(theNamespace,
extensionName);
}
else
{
return false;
}
}
XObject*
XPathEnvSupportDefault::extFunction(
XPathExecutionContext&
executionContext,
const DOMString&
theNamespace,
const DOMString&
extensionName,
const std::vector<XObject*>& argVec) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->extFunction(executionContext,
theNamespace,
extensionName,
argVec);
}
else
{
return executionContext.getXObjectFactory().createNull();
}
}
XLocator*
XPathEnvSupportDefault::getXLocatorFromNode(const DOM_Node& node) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->getXLocatorFromNode(node);
}
else
{
return SimpleNodeLocator::getDefaultInstance();
}
}
void
XPathEnvSupportDefault::associateXLocatorToNode(
const DOM_Node& node,
XLocator* xlocator) const
{
if (m_extendedSupport != 0)
{
m_extendedSupport->associateXLocatorToNode(node,
xlocator);
}
}
bool
XPathEnvSupportDefault::shouldStripSourceNode(const DOM_Node& node) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->shouldStripSourceNode(node);
}
else
{
return false;
}
}
bool
XPathEnvSupportDefault::problem(
eSource where,
eClassification classification,
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int charOffset)
const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->problem(where,
classification,
styleNode,
sourceNode,
msg,
lineNo,
charOffset);
}
else
{
#if 0
// $$$ ToDo: Xerces-specific code!
XMLStdErr theStdErr;
theStdErr << msg
<< ", at line number "
<< static_cast<long>(lineNo)
<< " at offset "
<< static_cast<long>(charOffset)
<< XMLStdErr::EndLine;
#endif
return classification == XPathEnvSupport::eWarning ? false :
true;
}
}
bool
XPathEnvSupportDefault::problem(
eSource where,
eClassification classification,
const PrefixResolver& resolver,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int
charOffset) const
{
if (m_extendedSupport != 0)
{
return m_extendedSupport->problem(where,
classification,
resolver,
sourceNode,
msg,
lineNo,
charOffset);
}
else
{
return classification == XPathEnvSupport::eWarning ? false :
true;
}
}
XPathEnvSupport*
XPathEnvSupportDefault::GetExtendedEnvSupport() const
{
return m_extendedSupport;
}
XPathEnvSupport*
XPathEnvSupportDefault::SetExtendedEnvSupport(XPathEnvSupport*
theExtendedSupport)
{
XPathEnvSupport* const theOldSupport = m_extendedSupport;
m_extendedSupport = theExtendedSupport;
return theOldSupport;
}
1.1 xml-xalan/c/src/XPath/XPathEnvSupportDefault.hpp
Index: XPathEnvSupportDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680)
#define XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <vector>
#include <XPath/XPathEnvSupport.hpp>
class XUnknown;
/**
* Dummy class in order to make the XPath object happy
* for diagnostic purposes.
*/
class XALAN_XPATH_EXPORT XPathEnvSupportDefault : public XPathEnvSupport
{
public:
XPathEnvSupportDefault();
virtual
~XPathEnvSupportDefault();
// These interfaces are inherited from Resettable...
/**
* Reset the instance.
*/
virtual void
reset();
// These interfaces are inherited from XPathEnvSupport...
/**
* Given a valid element key, return the corresponding node list.
*/
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const DOM_Element& nscontext) const;
/**
* Given a valid element key, return the corresponding node list.
*/
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& nscontext) const;
/**
* Given a name, locate a variable in the current context, and return
* the Object.
*/
XObject*
getVariable(
XPathExecutionContext& executionContext,
const QName& name) const;
/**
* Get table of source tree documents.
* Document objects are keyed by URL string.
*/
virtual SourceDocsTableType&
getSourceDocsTable();
/**
* Given a DOM Document, tell what URI was used to parse it.
* Needed for relative resolution.
*/
virtual DOMString
findURIFromDoc(const DOM_Document& owner) const;
/**
* Get a DOM document, primarily for creating result
* tree fragments.
*/
virtual DOM_Document
getDOMFactory() const;
/**
* Execute the function-available() function.
*/
virtual bool
functionAvailable(
const DOMString& theNamespace,
const DOMString& extensionName) const;
// $$$ ToDo: How do we implement this?
/**
* Handle an extension function.
*/
virtual XObject*
extFunction(
XPathExecutionContext&
executionContext,
const DOMString&
theNamespace,
const DOMString&
extensionName,
const std::vector<XObject*>& argVec) const;
virtual XLocator*
getXLocatorFromNode(const DOM_Node& node) const;
virtual void
associateXLocatorToNode(
const DOM_Node& node,
XLocator* xlocator) const;
/**
* Tells, through the combination of the default-space attribute
* on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the
* xml:space attribute, whether or not extra whitespace should be
stripped
* from the node. Literal elements from template elements should
* <em>not</em> be tested with this function.
* @param textNode A text node from the source tree.
* @return true if the text node should be stripped of extra whitespace.
*/
virtual bool
shouldStripSourceNode(const DOM_Node& node) const;
/**
* Function that is called when a problem event occurs.
*
* @param where Either eXMLParser,
eXSLTProcessor,
* eXPATHParser,
eXPATHProcessor, or
* eDataSource.
* @param classification Either eWarning, or eError
* @param styleNode The style tree node where the problem
* occurred. May
be null.
* @param sourceNode The source tree node where the problem
* occurred. May
be null.
* @param msg A string message explaining the
problem.
* @param lineNo The line number where the
problem occurred,
* if it is known.
May be zero.
* @param charOffset The character offset where the problem,
* occurred if it
is known. May be zero.
*
* @return true if the return is an ERROR, in which case
* exception will be thrown. Otherwise the processor
will
* continue to process.
*/
virtual bool
problem(
eSource where,
eClassification classification,
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int charOffset)
const;
virtual bool
problem(
eSource where,
eClassification classification,
const PrefixResolver& resolver,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int
charOffset) const;
/**
* Query the value of the extend support instance.
*
* @return A pointer to the extended support instance. May be 0.
*/
virtual XPathEnvSupport*
GetExtendedEnvSupport() const;
/**
* This call is intended to allow extending via delegation.
*
* @param theExtendedSupport A pointer to another
XPathEnvSupport
*
instance to delegate to. This may be
*
0.
*
* @return A pointer to the previous extended instance. May be 0.
*/
virtual XPathEnvSupport*
SetExtendedEnvSupport(XPathEnvSupport* theExtendedSupport);
private:
// These are not implemented...
XPathEnvSupportDefault(const XPathEnvSupportDefault&);
XPathEnvSupportDefault&
operator=(const XPathEnvSupportDefault&);
bool
operator==(const XPathEnvSupportDefault&) const;
// Data members...
XPathEnvSupport* m_extendedSupport;
SourceDocsTableType m_sourceDocs;
};
#endif // XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathException.cpp
Index: XPathException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathException.hpp"
XPathException::XPathException(
const DOMString& message,
const DOM_Node& styleNode) :
XSLException(message),
m_styleNode(styleNode)
{
}
XPathException::~XPathException()
{
}
1.1 xml-xalan/c/src/XPath/XPathException.hpp
Index: XPathException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHEXCEPTION_HEADER_GUARD_1357924680)
#define XPATHEXCEPTION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
// Base class header file.
#include <PlatformSupport/XSLException.hpp>
class XALAN_XPATH_EXPORT XPathException : public XSLException
{
public:
explicit
XPathException(
const DOMString& message = DOMString(),
const DOM_Node& styleNode = DOM_Node());
virtual
~XPathException();
private:
const DOM_Node m_styleNode;
};
#endif // XPATHEXCEPTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathExecutionContext.cpp
Index: XPathExecutionContext.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathExecutionContext.hpp"
XPathExecutionContext::XPathExecutionContext()
{
}
XPathExecutionContext::~XPathExecutionContext()
{
}
1.1 xml-xalan/c/src/XPath/XPathExecutionContext.hpp
Index: XPathExecutionContext.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680)
#define XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
#include <XPath/MutableNodeRefList.hpp>
class XLocator;
class NodeRefListBase;
class PrefixResolver;
class XObjectFactory;
class XPathSupport;
//
// An abstract class which provides support for executing XPath functions
// and extension functions.
//
class XALAN_XPATH_EXPORT XPathExecutionContext
{
public:
explicit
XPathExecutionContext();
virtual
~XPathExecutionContext();
virtual DOM_Node
getCurrentNode() const = 0;
virtual void
setCurrentNode(const DOM_Node& theCurrentNode) = 0;
virtual XObjectFactory&
getXObjectFactory() const = 0;
/**
* Returns the namespace of the given node.
*/
virtual DOMString
getNamespaceOfNode(const DOM_Node& n) const = 0;
/**
* Returns the local name of the given node.
*/
virtual DOMString
getLocalNameOfNode(const DOM_Node& n) const = 0;
/**
* Returns the parent of the given node.
*/
virtual DOM_Node
getParentOfNode(const DOM_Node& n) const = 0;
/**
* Get node data recursively.
* (Note whitespace issues.)
*/
virtual DOMString
getNodeData(const DOM_Node& n) const = 0;
/**
* Get an element from an ID.
*/
virtual DOM_Element
getElementByID(
const DOMString& id,
const DOM_Document& doc) const = 0;
virtual const NodeRefListBase&
getContextNodeList() const = 0;
/*
* Set the current context node list.
*
*/
virtual void
setContextNodeList(const NodeRefListBase& theList) = 0;
/*
* Get the count of nodes in the current context node list.
*
*/
virtual int
getContextNodeListLength() const = 0;
/*
* Get the position of the node in the current context node list.
*
*/
virtual int
getContextNodeListPosition(const DOM_Node& contextNode) const = 0;
virtual void
associateXLocatorToNode(
const DOM_Node& node,
XLocator* xlocator) const = 0;
/**
* Provides support for XML parsing service.
*/
virtual DOM_Document
parseXML(
const DOMString& urlString,
const DOMString& base) const = 0;
/**
* Create a MutableNodeRefList with the appropriate context.
*/
virtual MutableNodeRefList
createMutableNodeRefList() const = 0;
/**
* Tells if namespaces should be supported. For optimization purposes.
*/
virtual bool
getProcessNamespaces() const = 0;
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const = 0;
virtual const PrefixResolver&
getPrefixResolver() const = 0;
virtual void
setPrefixResolver(const PrefixResolver& thePrefixResolver) = 0;
virtual DOMString
getNamespaceForPrefix(const DOMString& prefix) const = 0;
/**
* Given a DOM Document, tell what URI was used to parse it.
* Needed for relative resolution.
*/
virtual DOMString
findURIFromDoc(const DOM_Document& owner) const = 0;
/**
* The getUnparsedEntityURI function returns the URI of the unparsed
* entity with the specified name in the same document as the context
* node (see [3.3 Unparsed Entities]). It returns the empty string if
* there is no such entity.
*/
virtual DOMString
getUnparsedEntityURI(
const DOMString& theName,
const DOM_Document& theDocument) const = 0;
/**
* Tells, through the combination of the default-space attribute
* on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the
* xml:space attribute, whether or not extra whitespace should be
stripped
* from the node. Literal elements from template elements should
* <em>not</em> be tested with this function.
* @param textNode A text node from the source tree.
* @return true if the text node should be stripped of extra whitespace.
*/
virtual bool
shouldStripSourceNode(const DOM_Node& node) const = 0;
/**
* Tell the user of an error, and probably throw an
* exception.
*/
virtual void
error(
const DOMString& msg,
const DOM_Node& sourceNode = DOM_Node()) const
= 0;
/**
* Tell the user of an warning, and probably throw an
* exception.
*/
virtual void
warn(
const DOMString& msg,
const DOM_Node& sourceNode = DOM_Node()) const
= 0;
};
#endif // XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathExpression.cpp
Index: XPathExpression.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathExpression.hpp"
#include <cstdio>
const XPathExpression::OpCodeLengthMapType
XPathExpression::s_opCodeLengths =
XPathExpression::IntializeOpCodeLengthMap();
const XPathExpression::NodeTestSetType
XPathExpression::s_NodeTestOpCodes =
XPathExpression::InitializeNodeTestSet();
XPathExpression::XPathExpressionException::XPathExpressionException(const
std::string& theMessage) :
XPathException(theMessage.c_str())
{
}
XPathExpression::XPathExpressionException::~XPathExpressionException()
{
}
XPathExpression::InvalidOpCodeException::InvalidOpCodeException(int
theOpCode) :
XPathExpressionException(FormatErrorMessage(theOpCode))
{
}
XPathExpression::InvalidOpCodeException::~InvalidOpCodeException()
{
}
std::string
XPathExpression::InvalidOpCodeException::FormatErrorMessage(int
theOpCode)
{
// $$$ ToDo: This can be changed to C++-style
// formatting with a stringstream if we can
// get the Microsoft library and the SGI STL to
// coexist.
char theBuffer[256];
const char* theMessage =
"Invalid op code %d was detected.";
sprintf(theBuffer,
theMessage,
theOpCode);
return theBuffer;
}
XPathExpression::InvalidArgumentCountException::InvalidArgumentCountException(
int theOpCode,
int theExpectedCount,
int theSuppliedCount) :
XPathExpressionException(FormatErrorMessage(theOpCode,
theExpectedCount, theSuppliedCount))
{
}
XPathExpression::InvalidArgumentCountException::~InvalidArgumentCountException()
{
}
std::string
XPathExpression::InvalidArgumentCountException::FormatErrorMessage(
int theOpCode,
int theExpectedCount,
int theSuppliedCount)
{
// $$$ ToDo: This can be changed to C++-style
// formatting with a stringstream if we can
// get the Microsoft library and the SGI STL to
// coexist.
char theBuffer[256];
const char* theMessage =
"An invalid number of arguments for op code %d
was detected. "
"The required number of argument(s) is %d, but
%d arguments(s) were "
"supplied.";
sprintf(theBuffer,
theMessage,
theOpCode,
theExpectedCount,
theSuppliedCount);
return theBuffer;
}
XPathExpression::InvalidArgumentException::InvalidArgumentException(
int theOpCode,
int theValue) :
XPathExpressionException(FormatErrorMessage(theOpCode, theValue))
{
}
XPathExpression::InvalidArgumentException::~InvalidArgumentException()
{
}
std::string
XPathExpression::InvalidArgumentException::FormatErrorMessage(
int theOpCode,
int theValue)
{
// $$$ ToDo: This can be changed to C++-style
// formatting with a stringstream if we can
// get the Microsoft library and the SGI STL to
// coexist.
char theBuffer[256];
const char* theMessage =
"An invalid argument of %d was supplied for op
code %d.";
sprintf(theBuffer,
theMessage,
theValue,
theOpCode);
return theBuffer;
}
XPathExpression::XPathExpression() :
m_opMap(),
m_lastOpCodeIndex(0),
m_tokenQueue(),
m_currentPosition(0),
m_patternMap(200),
m_currentPattern()
{
}
XPathExpression::~XPathExpression()
{
}
void
XPathExpression::reset()
{
m_opMap.clear();
m_tokenQueue.clear();
m_patternMap.clear();
}
void
XPathExpression::shrink()
{
m_opMap = OpCodeMapType(m_opMap);
m_patternMap = PatternMapType(m_patternMap);
}
XPathExpression::OpCodeMapValueType
XPathExpression::getOpCodeLength(OpCodeMapSizeType opPos) const
{
OpCodeMapValueType theResult = 0;
if (opPos >= opCodeMapSize())
{
throw InvalidOpCodeException(-1);
}
else
{
// Is there a valid opcode?
OpCodeLengthMapType::const_iterator i =
s_opCodeLengths.find(m_opMap[opPos]);
if (i == s_opCodeLengths.end())
{
throw InvalidOpCodeException(-1);
}
else
{
// Does the Op code have a length > 1?
if ((*i).second > 1)
{
// Yes, so get the length.
theResult = m_opMap[opPos +
s__opCodeMapLengthIndex];
}
}
}
return theResult;
}
void
XPathExpression::setOpCodeArgs(
eOpCodes
theOpCode,
OpCodeMapSizeType
theIndex,
const std::vector<OpCodeMapValueType>& theArgs)
{
// There must be at least enough space to hold the OpCode
// and the length indicator.
assert(opCodeMapSize() > theIndex + 1);
OpCodeLengthMapType::const_iterator i =
s_opCodeLengths.find(theOpCode);
// Make sure it's a valid op code and that it
// matches the op code at supplied index.
if (i == s_opCodeLengths.end() ||
m_opMap[theIndex] != theOpCode)
{
throw InvalidOpCodeException(theOpCode);
}
else
{
assert((*i).second > 0);
const OpCodeMapSizeType theArgCount =
(*i).second - 1 - s__opCodeMapLengthIndex;
if (theArgCount != theArgs.size())
{
throw InvalidArgumentCountException(theOpCode,
(*i).second,
theArgCount);
}
else
{
assert(opCodeMapSize() > theIndex + theArgCount);
for (OpCodeMapSizeType i = 0; i < theArgCount; ++i)
{
if (theArgs[i] < 0)
{
throw
InvalidArgumentException(theOpCode,
theArgs[i]);
}
else
{
m_opMap[i + theIndex +
s__opCodeMapLengthIndex + 1] =
theArgs[i];
}
}
}
}
}
void
XPathExpression::appendOpCode(eOpCodes theOpCode)
{
OpCodeLengthMapType::const_iterator i =
s_opCodeLengths.find(theOpCode);
if (i == s_opCodeLengths.end())
{
throw InvalidOpCodeException(theOpCode);
}
else
{
assert((*i).second > 0);
// Set the current index before pushing, by
// getting the size, which will be correct
// after the push.
m_lastOpCodeIndex = opCodeMapSize();
m_opMap.push_back(theOpCode);
assert(s__opCodeMapLengthIndex == 1);
const OpCodeMapSizeType theSize =
(*i).second;
if (theSize > 1)
{
m_opMap.push_back(theSize);
for (OpCodeMapSizeType i = 2;
i < theSize;
i++)
{
m_opMap.push_back(eENDOP);
}
}
if (m_lastOpCodeIndex != 0)
{
m_opMap[s__opCodeMapLengthIndex] += theSize;
}
}
assert(opCodeMapSize() ==
static_cast<OpCodeMapSizeType>(opCodeMapLength()));
}
XPathExpression::OpCodeMapValueType
XPathExpression::insertOpCode(
eOpCodes theOpCode,
OpCodeMapSizeType theIndex)
{
OpCodeLengthMapType::const_iterator i =
s_opCodeLengths.find(theOpCode);
if (i == s_opCodeLengths.end())
{
throw InvalidOpCodeException(theOpCode);
}
else
{
assert((*i).second > 0);
// Insert -1 for each element of the opcode.
m_opMap.insert(&m_opMap[theIndex], (*i).second, -1);
// Set the member that contains the last insert/appended
// index.
m_lastOpCodeIndex = theIndex;
// Assign the opcode.
m_opMap[theIndex] = theOpCode;
// Update the entire expression length.
m_opMap[s__opCodeMapLengthIndex] += (*i).second;
}
return (*i).second;
}
void
XPathExpression::updateShiftedOpCodeLength(
OpCodeMapValueType theOpCode,
OpCodeMapSizeType theOriginalIndex,
OpCodeMapSizeType theNewIndex)
{
// There must be some other expressions in
// the buffer...
assert(opCodeMapSize() > theNewIndex + 1);
assert(theNewIndex > theOriginalIndex);
OpCodeLengthMapType::const_iterator i =
s_opCodeLengths.find(theOpCode);
// Make sure it's a valid op code and that it
// matches the op code at supplied index.
if (i == s_opCodeLengths.end() ||
m_opMap[theNewIndex] != theOpCode)
{
throw InvalidOpCodeException(theOpCode);
}
else
{
assert((*i).second > 0);
// Determine where the length position of the op code
// is.
const OpCodeMapSizeType theLengthIndex =
theNewIndex +
s__opCodeMapLengthIndex;
// Too long, then throw an exception.
if (theLengthIndex >= opCodeMapSize())
{
throw InvalidOpCodeException(theOpCode);
}
else
{
// Look ahead to where the new operand is.
const OpCodeMapSizeType theNextOpCodePosition =
getNextOpCodePosition(theNewIndex);
// If it's there, then update our size by
// adding that size in.
if (theNextOpCodePosition < opCodeMapSize())
{
m_opMap[theLengthIndex] +=
getOpCodeLength(theNextOpCodePosition);
}
}
}
}
void
XPathExpression::updateOpCodeLength(
OpCodeMapValueType theOpCode,
OpCodeMapSizeType theIndex)
{
// There must be some other expressions in
// the buffer...
assert(opCodeMapSize() > theIndex + 1);
OpCodeLengthMapType::const_iterator i =
s_opCodeLengths.find(theOpCode);
// Make sure it's a valid op code and that it
// matches the op code at supplied index.
if (i == s_opCodeLengths.end() ||
m_opMap[theIndex] != theOpCode)
{
throw InvalidOpCodeException(theOpCode);
}
else
{
assert((*i).second > 0);
// This presumes that the other opcodes
// have been appended to the expression,
// and that the specified op code's length
// needs to be set. The size includes the
// normal length of the opcode, plus the
// length of its subexpressions.
m_opMap[theIndex + s__opCodeMapLengthIndex] =
opCodeMapLength() -
theIndex;
}
}
bool
XPathExpression::isNodeTestOpCode(OpCodeMapValueType theOpCode)
{
const NodeTestSetType::const_iterator i =
s_NodeTestOpCodes.find(theOpCode);
if (i != s_NodeTestOpCodes.end())
{
return true;
}
else
{
return false;
}
}
void
XPathExpression::updateOpCodeLengthAfterNodeTest(OpCodeMapSizeType
theIndex)
{
// There must be some other expressions in
// the buffer...
assert(opCodeMapSize() > theIndex + 1);
const OpCodeMapValueType theOpCode =
m_opMap[theIndex];
OpCodeLengthMapType::const_iterator i =
s_opCodeLengths.find(theOpCode);
// Make sure it's a valid op code and that it
// is a node test op code.
if (i == s_opCodeLengths.end() ||
isNodeTestOpCode(theOpCode) == false)
{
throw InvalidOpCodeException(theOpCode);
}
else
{
assert((*i).second > 0);
m_opMap[theIndex + s__opCodeMapLengthIndex + 1] =
opCodeMapLength() -
theIndex;
}
}
void
XPathExpression::dumpOpCodeMap(
PrintWriter& thePrintWriter,
OpCodeMapSizeType theStartPosition) const
{
for (OpCodeMapSizeType i = theStartPosition;
i < opCodeMapSize(); i++)
{
thePrintWriter.print(" '");
thePrintWriter.print(m_opMap[i]);
thePrintWriter.print("'");
}
}
void
XPathExpression::dumpTokenQueue(
PrintWriter& thePrintWriter,
TokenQueueSizeType theStartPosition) const
{
for (TokenQueueSizeType i = theStartPosition;
i < tokenQueueSize(); i++)
{
assert(getToken(i) != 0);
thePrintWriter.print(" '");
thePrintWriter.print(getToken(i)->str());
thePrintWriter.print("'");
}
}
void
XPathExpression::dumpRemainingTokenQueue(PrintWriter& thePrintWriter) const
{
thePrintWriter.print("Remaining tokens: (");
dumpTokenQueue(thePrintWriter,
m_currentPosition);
thePrintWriter.print(")");
}
void
XPathExpression::pushArgumentOnOpCodeMap(XObject* theToken)
{
assert(theToken != 0);
assert(m_currentPosition != 0);
const TokenQueueSizeType thePosition = m_currentPosition - 1;
assert(thePosition < tokenQueueSize());
// Set the entry in the token queue to the XObject.
m_tokenQueue[thePosition] = theToken;
// Push the index onto the op map.
m_opMap.push_back(thePosition);
// Update the op map length.
m_opMap[s__opCodeMapLengthIndex]++;
}
void
XPathExpression::pushCurrentTokenOnOpCodeMap()
{
assert(m_currentPosition != 0);
const TokenQueueSizeType thePosition = m_currentPosition - 1;
assert(thePosition < tokenQueueSize());
// Push the index onto the op map.
m_opMap.push_back(thePosition);
// Update the op map length.
m_opMap[s__opCodeMapLengthIndex]++;
}
XPathExpression::OpCodeLengthMapType
XPathExpression::IntializeOpCodeLengthMap()
{
OpCodeLengthMapType theMap;
theMap[eENDOP] = 1;
theMap[eEMPTY] = 1;
theMap[eELEMWILDCARD] = 1;
theMap[eOP_XPATH] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_OR] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_AND] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_NOTEQUALS] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_EQUALS] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_LTE] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_LT] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_GTE] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_GT] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_PLUS] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_MINUS] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_MULT] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_DIV] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_MOD] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_QUO] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_NEG] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_STRING] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_BOOL] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_NUMBER] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_UNION] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_LITERAL] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_VARIABLE] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_GROUP] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_NUMBERLIT] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_ARGUMENT] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_EXTFUNCTION] = 3 + s__opCodeMapLengthIndex;
theMap[eOP_FUNCTION] = 2 + s__opCodeMapLengthIndex;
theMap[eOP_LOCATIONPATH] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_PREDICATE] = 1 + s__opCodeMapLengthIndex;
theMap[eNODETYPE_COMMENT] = 1;
theMap[eNODETYPE_TEXT] = 1;
theMap[eNODETYPE_PI] = 1;
theMap[eNODETYPE_NODE] = 1;
theMap[eNODENAME] = 1;
theMap[eNODETYPE_ROOT] = 1;
theMap[eNODETYPE_ANYELEMENT] = 1;
theMap[eFROM_ANCESTORS] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_ANCESTORS_OR_SELF] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_ATTRIBUTES] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_CHILDREN] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_DESCENDANTS] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_DESCENDANTS_OR_SELF] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_FOLLOWING] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_FOLLOWING_SIBLINGS] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_PARENT] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_PRECEDING] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_PRECEDING_SIBLINGS] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_SELF] = 2 + s__opCodeMapLengthIndex;
theMap[eFROM_NAMESPACE] = 1 + s__opCodeMapLengthIndex;
// theMap[eFROM_ATTRIBUTE] = -1;
// theMap[eFROM_DOC] = -1;
// theMap[eFROM_DOCREF] = -1;
// theMap[eFROM_ID] = -1;
// theMap[eFROM_IDREF] = -1;
theMap[eFROM_ROOT] = 2 + s__opCodeMapLengthIndex;
theMap[eOP_MATCHPATTERN] = 1 + s__opCodeMapLengthIndex;
theMap[eOP_LOCATIONPATHPATTERN] = 1 + s__opCodeMapLengthIndex;
theMap[eMATCH_ATTRIBUTE] = 1 + s__opCodeMapLengthIndex;
theMap[eMATCH_ANY_ANCESTOR] = 1 + s__opCodeMapLengthIndex;
theMap[eMATCH_IMMEDIATE_ANCESTOR] = 1 + s__opCodeMapLengthIndex;
theMap[eMATCH_ANY_ANCESTOR_WITH_PREDICATE] = 2 +
s__opCodeMapLengthIndex;
return theMap;
}
XPathExpression::NodeTestSetType
XPathExpression::InitializeNodeTestSet()
{
NodeTestSetType theSet;
theSet.insert(eMATCH_ANY_ANCESTOR);
theSet.insert(eMATCH_IMMEDIATE_ANCESTOR);
theSet.insert(eMATCH_ATTRIBUTE);
theSet.insert(eFROM_ATTRIBUTES);
theSet.insert(eFROM_DESCENDANTS_OR_SELF);
theSet.insert(eFROM_CHILDREN);
theSet.insert(eFROM_ANCESTORS);
theSet.insert(eFROM_ANCESTORS_OR_SELF);
theSet.insert(eFROM_ATTRIBUTES);
theSet.insert(eFROM_CHILDREN);
theSet.insert(eFROM_DESCENDANTS);
theSet.insert(eFROM_DESCENDANTS_OR_SELF);
theSet.insert(eFROM_FOLLOWING);
theSet.insert(eFROM_FOLLOWING_SIBLINGS);
theSet.insert(eFROM_PARENT);
theSet.insert(eFROM_PRECEDING);
theSet.insert(eFROM_PRECEDING_SIBLINGS);
theSet.insert(eFROM_SELF);
theSet.insert(eFROM_NAMESPACE);
// theSet.insert(eFROM_ATTRIBUTE);
// theSet.insert(eFROM_DOC);
// theSet.insert(eFROM_DOCREF);
// theSet.insert(eFROM_ID);
// theSet.insert(eFROM_IDREF);
theSet.insert(eFROM_ROOT);
theSet.insert(eOP_OR);
return theSet;
}
1.1 xml-xalan/c/src/XPath/XPathExpression.hpp
Index: XPathExpression.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHEXPRESSION_HEADER_GUARD_1357924680)
#define XPATHEXPRESSION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <map>
#include <set>
#include <vector>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/PrintWriter.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPathException.hpp>
class XObject;
class XALAN_XPATH_EXPORT XPathExpression
{
public:
// List of operations codes.
//
// Code for the descriptions of the operations codes:
// [UPPER CASE] indicates a literal value,
// [lower case] is a description of a value,
// ([length] always indicates the length of the operation,
// including the operations code and the length integer.)
// {UPPER CASE} indicates the given production,
// {description} is the description of a new production,
// (For instance, {boolean expression} means some
expression
// that should be resolved to a boolean.)
// * means that it occurs zero or more times,
// + means that it occurs one or more times,
// ? means that it is optional.
//
// returns: indicates what the production should return.
enum eOpCodes
{
/**
* [ENDOP]
* Some operators may like to have a terminator.
*/
eENDOP = -1,
/**
* [EMPTY]
* Empty slot to indicate NULL.
*/
eEMPTY = -2,
/**
* [ELEMWILDCARD]
* Means ELEMWILDCARD ("*"), used instead
* of string index in some places.
*/
eELEMWILDCARD = -3,
/**
* [OP_XPATH]
* [length]
* {expression}
*
* returns:
* XNodeSet
* XNumber
* XString
* XBoolean
* XRTree
* XObject
*/
eOP_XPATH = 1,
/**
* [OP_OR]
* [length]
* {boolean expression}
* {boolean expression}
*
* returns:
* XBoolean
*/
eOP_OR = 2,
/**
* [OP_AND]
* [length]
* {boolean expression}
* {boolean expression}
*
* returns:
* XBoolean
*/
eOP_AND = 3,
/**
* [OP_NOTEQUALS]
* [length]
* {expression}
* {expression}
*
* returns:
* XBoolean
*/
eOP_NOTEQUALS = 4,
/**
* [OP_EQUALS]
* [length]
* {expression}
* {expression}
*
* returns:
* XBoolean
*/
eOP_EQUALS = 5,
/**
* [OP_LTE] (less-than-or-equals)
* [length]
* {number expression}
* {number expression}
*
* returns:
* XBoolean
*/
eOP_LTE = 6,
/**
* [OP_LT] (less-than)
* [length]
* {number expression}
* {number expression}
*
* returns:
* XBoolean
*/
eOP_LT = 7,
/**
* [OP_GTE] (greater-than-or-equals)
* [length]
* {number expression}
* {number expression}
*
* returns:
* XBoolean
*/
eOP_GTE = 8,
/**
* [OP_GT] (greater-than)
* [length]
* {number expression}
* {number expression}
*
* returns:
* XBoolean
*/
eOP_GT = 9,
/**
* [OP_PLUS]
* [length]
* {number expression}
* {number expression}
*
* returns:
* XNumber
*/
eOP_PLUS = 10,
/**
* [OP_MINUS]
* [length]
* {number expression}
* {number expression}
*
* returns:
* XNumber
*/
eOP_MINUS = 11,
/**
* [OP_MULT]
* [length]
* {number expression}
* {number expression}
*
* returns:
* XNumber
*/
eOP_MULT = 12,
/**
* [OP_DIV]
* [length]
* {number expression}
* {number expression}
*
* returns:
* XNumber
*/
eOP_DIV = 13,
/**
* [OP_MOD]
* [length]
* {number expression}
* {number expression}
*
* returns:
* XNumber
*/
eOP_MOD = 14,
/**
* [OP_QUO]
* [length]
* {number expression}
* {number expression}
*
* returns:
* XNumber
*/
eOP_QUO = 15,
/**
* [OP_NEG]
* [length]
* {number expression}
*
* returns:
* XNumber
*/
eOP_NEG = 16,
/**
* [OP_STRING] (cast operation)
* [length]
* {expression}
*
* returns:
* XString
*/
eOP_STRING = 17,
/**
* [OP_BOOL] (cast operation)
* [length]
* {expression}
*
* returns:
* XBoolean
*/
eOP_BOOL = 18,
/**
* [OP_NUMBER] (cast operation)
* [length]
* {expression}
*
* returns:
* XBoolean
*/
eOP_NUMBER = 19,
/**
* [OP_UNION]
* [length]
* {PathExpr}+
*
* returns:
* XNodeSet
*/
eOP_UNION = 20,
/**
* [OP_LITERAL]
* [3]
* [index to token]
*
* returns:
* XString
*/
eOP_LITERAL = 21,
/**
* [OP_VARIABLE]
* [3]
* [index to token]
*
* returns:
* XString
*/
eOP_VARIABLE = 22,
/**
* [OP_GROUP]
* [length]
* {expression}
*
* returns:
* XNodeSet
* XNumber
* XString
* XBoolean
* XRTree
* XObject
*/
eOP_GROUP = 23,
/**
* [OP_NUMBERLIT] (Number literal.)
* [3]
* [index to token]
*
* returns:
* XString
*/
eOP_NUMBERLIT = 24,
/**
* [OP_ARGUMENT] (Function argument.)
* [length]
* {expression}
*
* returns:
* XNodeSet
* XNumber
* XString
* XBoolean
* XRTree
* XObject
*/
eOP_ARGUMENT = 25,
/**
* [OP_EXTFUNCTION] (Extension function.)
* [length]
* [index to namespace token]
* [index to function name token]
* {OP_ARGUMENT}*
*
* returns:
* XNodeSet
* XNumber
* XString
* XBoolean
* XRTree
* XObject
*/
eOP_EXTFUNCTION = 26,
/**
* [OP_FUNCTION]
* [length]
* [FUNC_name]
* {OP_ARGUMENT}*
* [ENDOP]
*
* returns:
* XNodeSet
* XNumber
* XString
* XBoolean
* XRTree
* XObject
*/
eOP_FUNCTION = 27,
/**
* [OP_LOCATIONPATH]
* [length]
* {FROM_stepType}
* | {function}{predicate}*
* [ENDOP]
*
* (Note that element and attribute namespaces and
* names can be wildcarded '*'.)
*
* returns:
* XNodeSet
*/
eOP_LOCATIONPATH = 28,
/**
* [OP_PREDICATE]
* [length]
* {expression}
* [ENDOP] (For safety)
*
* returns:
* XBoolean or XNumber
*/
eOP_PREDICATE = 29,
/**
* [NODETYPE_COMMENT]
* No size or arguments.
*
* returns:
* XBoolean
*/
eNODETYPE_COMMENT = 1030,
/**
* [NODETYPE_TEXT]
* No size or arguments.
*
* returns:
* XBoolean
*/
eNODETYPE_TEXT = 1031,
/**
* [NODETYPE_PI]
* [index to token]
*
* returns:
* XBoolean
*/
eNODETYPE_PI = 1032,
/**
* [NODETYPE_NODE]
* No size or arguments.
*
* returns:
* XBoolean
*/
eNODETYPE_NODE = 1033,
/**
* [NODENAME]
* [index to ns token or EMPTY]
* [index to name token]
*
* returns:
* XBoolean
*/
eNODENAME = 34,
/**
* [NODETYPE_ROOT]
* No size or arguments.
*
* returns:
* XBoolean
*/
eNODETYPE_ROOT = 35,
/**
* [NODETYPE_ANY]
* No size or arguments.
*
* returns:
* XBoolean
*/
eNODETYPE_ANYELEMENT = 36,
/**
* [FROM_stepType]
* [length, including predicates]
* [length of just the step, without the predicates]
* {node test}
* {predicates}?
*
* returns:
* XBoolean
*/
eFROM_ANCESTORS = 37,
eFROM_ANCESTORS_OR_SELF = 38,
eFROM_ATTRIBUTES = 39,
eFROM_CHILDREN = 40,
eFROM_DESCENDANTS = 41,
eFROM_DESCENDANTS_OR_SELF = 42,
eFROM_FOLLOWING = 43,
eFROM_FOLLOWING_SIBLINGS = 44,
eFROM_PARENT = 45,
eFROM_PRECEDING = 46,
eFROM_PRECEDING_SIBLINGS = 47,
eFROM_SELF = 48,
eFROM_NAMESPACE = 49,
// eFROM_ATTRIBUTE = 50,
// eFROM_DOC = 51,
// eFROM_DOCREF = 52,
// eFROM_ID = 53,
// eFROM_IDREF = 54,
eFROM_ROOT = 55,
/**
* [OP_UNION]
* [length]
* {PathExpr}+
*
* returns:
* XNodeSet
*/
eOP_MATCHPATTERN = 92,
/**
* [OP_UNION]
* [length]
* {PathExpr}+
*
* returns:
* XNodeSet
*/
eOP_LOCATIONPATHPATTERN = 93,
// For match patterns
eMATCH_ATTRIBUTE = 94,
eMATCH_ANY_ANCESTOR = 95,
eMATCH_IMMEDIATE_ANCESTOR = 96,
eMATCH_ANY_ANCESTOR_WITH_PREDICATE = 97,
// Always add _before_ this one.
// $$$ ToDo: Determine if these specific numbers mean
// anything vis-a-vis the parser and xpath code.
eOpCodeNextAvailable
}; // enum eOpCodes
/**
* The length is always the opcode position + 1.
* Length is always expressed as the opcode+length bytes,
* so it is always 2 or greater. This is the offset
* from the op code where the length is stored. It will
* always remain one.
*/
#if defined(XALAN_INLINE_INITIALIZATION)
const int s__opCodeMapLengthIndex = 1;
#else
enum eDummy
{
s__opCodeMapLengthIndex = 1
};
#endif
class XALAN_XPATH_EXPORT XPathExpressionException : public
XPathException
{
public:
XPathExpressionException(const std::string&
theMessage);
virtual~
XPathExpressionException();
};
class XALAN_XPATH_EXPORT InvalidOpCodeException : public
XPathExpressionException
{
public:
InvalidOpCodeException(int theOpCode);
virtual~
InvalidOpCodeException();
private:
static std::string
FormatErrorMessage(int theOpCode);
};
class XALAN_XPATH_EXPORT InvalidArgumentCountException : public
XPathExpressionException
{
public:
InvalidArgumentCountException(
int theOpCode,
int theExpectedCount,
int theSuppliedCount);
virtual~
InvalidArgumentCountException();
private:
static std::string
FormatErrorMessage(
int theOpCode,
int theExpectedCount,
int theSuppliedCount);
};
class XALAN_XPATH_EXPORT InvalidArgumentException : public
XPathExpressionException
{
public:
InvalidArgumentException(
int theOpCode,
int theValue);
virtual~
InvalidArgumentException();
private:
static std::string
FormatErrorMessage(
int theOpCode,
int theValue);
};
typedef std::vector<int> OpCodeMapType;
typedef std::vector<XObject*> TokenQueueType;
typedef std::vector<int> PatternMapType;
typedef std::map<int, int>
OpCodeLengthMapType;
typedef OpCodeMapType::value_type OpCodeMapValueType;
typedef OpCodeMapType::size_type OpCodeMapSizeType;
typedef TokenQueueType::value_type TokenQueueValueType;
typedef TokenQueueType::size_type TokenQueueSizeType;
typedef PatternMapType::value_type PatternMapValueType;
typedef PatternMapType::size_type PatternMapSizeType;
typedef std::set<OpCodeMapValueType> NodeTestSetType;
explicit
XPathExpression();
~XPathExpression();
void
reset();
void
shrink();
OpCodeMapSizeType
opCodeMapSize() const
{
return m_opMap.size();
}
OpCodeMapValueType
opCodeMapLength() const
{
// The length of the entire map is stored after
// the first op code. That offset is determined
// by this const static member. Note that as
// expressions are defined recursively, this is
// really just the length of the first expression
// in the map, which is the top of the parse tree.
// Any subexpression will also have a length entry
// at the same offset from the beginning of the
// subexpression.
const OpCodeMapSizeType theSize = opCodeMapSize();
if (theSize > s__opCodeMapLengthIndex)
{
assert(theSize ==
static_cast<OpCodeMapSizeType>(m_opMap[s__opCodeMapLengthIndex]));
return m_opMap[s__opCodeMapLengthIndex];
}
else
{
return theSize;
}
}
TokenQueueSizeType
tokenQueueSize() const
{
return m_tokenQueue.size();
}
PatternMapSizeType
patternMapSize() const
{
return m_patternMap.size();
}
OpCodeMapValueType
getOpCodeMapValue(OpCodeMapSizeType opPos) const
{
return m_opMap[opPos];
}
OpCodeMapValueType
getOpCodeLength(OpCodeMapSizeType opPos) const;
OpCodeMapValueType
getNextOpCodePosition(OpCodeMapSizeType opPos) const
{
assert(opPos < opCodeMapSize());
return opPos + m_opMap[opPos + s__opCodeMapLengthIndex];
}
void
setOpCodeArgs(
eOpCodes
theOpCode,
OpCodeMapSizeType
theIndex,
const std::vector<OpCodeMapValueType>& theArgs);
void
appendOpCode(eOpCodes theOpCode);
void
appendOpCode(eOpCodes
theOpCode,
const std::vector<OpCodeMapValueType>&
theArgs)
{
appendOpCode(theOpCode);
setOpCodeArgs(theOpCode,
m_lastOpCodeIndex,
theArgs);
}
OpCodeMapValueType
insertOpCode(
eOpCodes theOpCode,
OpCodeMapSizeType theIndex);
void
updateOpCodeLength(OpCodeMapSizeType theIndex)
{
assert(theIndex < opCodeMapSize());
// This presumes that the other opcodes
// have been appended to the expression,
// and that the specified op code's length
// needs to be set. The size includes the
// normal length of the opcode, plus the
// length of its subexpressions.
updateOpCodeLength(m_opMap[theIndex], theIndex);
}
void
updateShiftedOpCodeLength(
OpCodeMapValueType theOpCode,
OpCodeMapSizeType theOriginalIndex,
OpCodeMapSizeType theNewIndex);
void
updateOpCodeLength(
OpCodeMapValueType theOpCode,
OpCodeMapSizeType theIndex);
static bool
isNodeTestOpCode(OpCodeMapValueType theOpCode);
void
updateOpCodeLengthAfterNodeTest(OpCodeMapSizeType theIndex);
bool
hasMoreTokens() const
{
return tokenQueueSize() - m_currentPosition > 0 ? true : false;
}
TokenQueueSizeType
getTokenPosition() const
{
return m_currentPosition;
}
void
resetTokenPosition()
{
m_currentPosition = 0;
}
void
setTokenPosition(TokenQueueSizeType thePosition)
{
const TokenQueueSizeType theSize = tokenQueueSize();
m_currentPosition = thePosition > theSize ? theSize :
thePosition;
}
void
setTokenPosition(int thePosition)
{
setTokenPosition(thePosition > 0 ?
static_cast<TokenQueueSizeType>(thePosition) : 0);
}
XObject*
getToken(TokenQueueSizeType thePosition) const
{
assert(thePosition < tokenQueueSize());
return m_tokenQueue[thePosition];
}
XObject*
getNextToken()
{
if (hasMoreTokens() == true)
{
return getToken(m_currentPosition++);
}
else
{
return 0;
}
}
XObject*
getPreviousToken()
{
if (m_currentPosition > 0)
{
return getToken(--m_currentPosition);
}
else
{
return 0;
}
}
XObject*
getRelativeToken(int theOffset) const
{
const int thePosition =
static_cast<int>(m_currentPosition) + theOffset;
if (thePosition < 0 ||
thePosition >= static_cast<int>(tokenQueueSize()))
{
return 0;
}
else
{
return getToken(thePosition);
}
}
void
pushToken(XObject* theToken)
{
assert(theToken != 0);
m_tokenQueue.push_back(theToken);
}
void
dumpOpCodeMap(PrintWriter& thePrintWriter,
OpCodeMapSizeType
theStartPosition = 0) const;
void
dumpTokenQueue(PrintWriter& thePrintWriter,
TokenQueueSizeType theStartPosition = 0)
const;
void
dumpRemainingTokenQueue(PrintWriter& thePrintWriter) const;
void
pushArgumentOnOpCodeMap(XObject* theToken);
void
pushCurrentTokenOnOpCodeMap();
PatternMapValueType
getPattern(int thePatternPosition) const
{
assert(static_cast<int>(patternMapSize()) > thePatternPosition);
return m_patternMap[thePatternPosition];
}
PatternMapValueType
getPattern(PatternMapSizeType thePatternPosition) const
{
assert(patternMapSize() > thePatternPosition);
return m_patternMap[thePatternPosition];
}
void
pushPattern(PatternMapValueType thePattern)
{
m_patternMap.push_back(thePattern);
}
void
adjustPattern(
OpCodeMapSizeType theIndex,
PatternMapValueType theAdjustment)
{
m_patternMap[theIndex] += theAdjustment;
}
void
setCurrentPattern(const DOMString& thePattern)
{
m_currentPattern = thePattern;
}
const DOMString&
getCurrentPattern() const
{
return m_currentPattern;
}
/**
* An operations map is used instead of a proper parse tree. It
contains
* operations codes and indexes into the m_tokenQueue.
* We use an array instead of a full parse tree in order to cut down
* on the number of objects created.
*/
OpCodeMapType m_opMap;
/**
* This is the index of the last opcode that was appended or inserted.
*
*/
OpCodeMapSizeType m_lastOpCodeIndex;
/**
* This is the queue of used tokens. The current token is the token at
the
* end of the m_tokenQueue. The idea is that the queue can be marked
and a
* sequence of tokens can be reused.
*/
TokenQueueType m_tokenQueue;
/**
* This is the current position in the token queue.
*/
TokenQueueSizeType m_currentPosition;
/**
* Ignore this, it is going away.
* This holds a map to the m_tokenQueue that tells where the top-level
elements are.
* It is used for pattern matching so the m_tokenQueue can be walked
backwards.
* Each element that is a 'target', (right-most top level element name)
has
* TARGETEXTRA added to it.
*
*/
PatternMapType m_patternMap;
/**
* The current pattern string, for diagnostics purposes
*/
DOMString m_currentPattern;
private:
// A map of Op codes to op code lengths.
const static OpCodeLengthMapType s_opCodeLengths;
static OpCodeLengthMapType
IntializeOpCodeLengthMap();
// A static set of Op codes that are node tests.
const static NodeTestSetType s_NodeTestOpCodes;
static NodeTestSetType
InitializeNodeTestSet();
};
#endif // XPATHEXPRESSION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathFactory.cpp
Index: XPathFactory.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathFactory.hpp"
XPathFactory::XPathFactory()
{
}
XPathFactory::~XPathFactory()
{
}
1.1 xml-xalan/c/src/XPath/XPathFactory.hpp
Index: XPathFactory.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHFACTORY_HEADER_GUARD_1357924680)
#define XPATHFACTORY_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file...
#include <PlatformSupport/Factory.hpp>
class DOM_Element;
class DOMString;
class XPath;
class XALAN_XPATH_EXPORT XPathFactory : public Factory
{
public:
explicit
XPathFactory();
virtual
~XPathFactory();
// Inherited from Factory...
virtual void
reset() = 0;
/*
* Return an object to the factory.
*
*/
virtual bool
returnObject(const FactoryObject* theFactoryObject) = 0;
// New to XPathFactory...
/**
* Create an XPath. The XPath instance is owned by the
* factory, and should not be deleted. The factory will
* manage the lifetime.
*/
virtual XPath*
create(bool fOptimize = true) = 0;
};
#endif // XPATHFACTORY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathFactoryDefault.cpp
Index: XPathFactoryDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathFactoryDefault.hpp"
#include <algorithm>
#include "XPath.hpp"
#include "XPathEnvSupport.hpp"
#include "XPathSupport.hpp"
XPathFactoryDefault::XPathFactoryDefault(
XObjectFactory& theXObjectFactory,
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport) :
XPathFactory(),
m_XObjectFactory(theXObjectFactory),
m_XPathEnvSupport(theXPathEnvSupport),
m_XPathSupport(theXPathSupport),
m_xpaths()
{
}
XPathFactoryDefault::~XPathFactoryDefault()
{
reset();
}
void
XPathFactoryDefault::reset()
{
std::for_each(m_xpaths.begin(),
m_xpaths.end(),
DeleteFactoryObjectFunctor(*this));
m_xpaths.clear();
}
bool
XPathFactoryDefault::returnObject(const FactoryObject*
theFactoryObject)
{
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
if(m_xpaths.erase(theObject) > 0)
{
#else
CollectionType::iterator i =
std::find(m_xpaths.begin(),
m_xpaths.end(),
theFactoryObject);
if (i != m_xpaths.end())
{
m_xpaths.erase(i);
#endif
return deleteObject(theFactoryObject);
}
else
{
return false;
}
}
XPath*
XPathFactoryDefault::create(bool /* fOptimize */)
{
XPath* const theXPath = new XPath(m_XObjectFactory,
m_XPathEnvSupport,
m_XPathSupport);
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
m_xpaths.insert(theXPath);
#else
m_xpaths.push_back(theXPath);
#endif
return theXPath;
}
1.1 xml-xalan/c/src/XPath/XPathFactoryDefault.hpp
Index: XPathFactoryDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHFACTORYDEFAULT_HEADER_GUARD_1357924680)
#define XPATHFACTORYDEFAULT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
#include <hash_set>
#elif !defined(XALAN_XTREE_BUG)
#include <slist>
#else
#include <vector>
#endif
// Base class header file...
#include <XPath/XPathFactory.hpp>
class XObjectFactory;
class XPathEnvSupport;
class XPathSupport;
class XALAN_XPATH_EXPORT XPathFactoryDefault : public XPathFactory
{
public:
XPathFactoryDefault(
XObjectFactory& theXObjectFactory,
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport);
virtual
~XPathFactoryDefault();
// Inherited from Factory...
virtual void
reset();
/*
* Return an object to the factory.
*
*/
virtual bool
returnObject(const FactoryObject* theFactoryObject);
// Inherited from XPathFactory...
/**
* Create an XPath. The XPath instance is owned by the
* factory, and should not be deleted. The factory will
* manage the lifetime.
*/
virtual XPath*
create(bool fOptimize = true);
private:
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef std::hash_set<const FactoryObject*> CollectionType;
#elif !defined(XALAN_XTREE_BUG)
typedef std::slist<const FactoryObject*> CollectionType;
#else
typedef std::vector<const FactoryObject*> CollectionType;
#endif
XObjectFactory& m_XObjectFactory;
XPathEnvSupport& m_XPathEnvSupport;
XPathSupport& m_XPathSupport;
CollectionType m_xpaths;
};
#endif // XPATHFACTORYDEFAULT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathFunctionTable.cpp
Index: XPathFunctionTable.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Base class header file
#include "XPathFunctionTable.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
#include "FunctionBoolean.hpp"
#include "FunctionCeiling.hpp"
#include "FunctionConcat.hpp"
#include "FunctionContains.hpp"
#include "FunctionCount.hpp"
#include "FunctionFalse.hpp"
#include "FunctionFloor.hpp"
#include "FunctionID.hpp"
#include "FunctionLang.hpp"
#include "FunctionLast.hpp"
#include "FunctionLocalName.hpp"
#include "FunctionName.hpp"
#include "FunctionNamespaceURI.hpp"
#include "FunctionNormalize.hpp"
#include "FunctionNot.hpp"
#include "FunctionNumber.hpp"
#include "FunctionPosition.hpp"
#include "FunctionRound.hpp"
#include "FunctionStartsWith.hpp"
#include "FunctionString.hpp"
#include "FunctionStringLength.hpp"
#include "FunctionSubstring.hpp"
#include "FunctionSubstringAfter.hpp"
#include "FunctionSubstringBefore.hpp"
#include "FunctionSum.hpp"
#include "FunctionTranslate.hpp"
#include "FunctionTrue.hpp"
XPathFunctionTable::XPathFunctionTable() :
m_FunctionCollection()
{
CreateTable();
}
XPathFunctionTable::~XPathFunctionTable()
{
DestroyTable();
}
void
XPathFunctionTable::InstallFunction(
const DOMString& theFunctionName,
const Function& theFunction)
{
assert(length(theFunctionName) != 0);
// Delete the currently installed function, if there is
// one
delete m_FunctionCollection[theFunctionName];
// Clone the function and add it to the collection.
m_FunctionCollection[theFunctionName] = theFunction.clone();
}
void
XPathFunctionTable::CreateTable()
{
try
{
InstallFunction("last",
FunctionLast());
InstallFunction("position",
FunctionPosition());
InstallFunction("count",
FunctionCount());
InstallFunction("id",
FunctionID());
InstallFunction("local-name",
FunctionLocalName());
InstallFunction("namespace-uri",
FunctionNamespaceURI());
InstallFunction("name",
FunctionName());
InstallFunction("string",
FunctionString());
InstallFunction("concat",
FunctionConcat());
InstallFunction("starts-with",
FunctionStartsWith());
InstallFunction("contains",
FunctionContains());
InstallFunction("substring-before",
FunctionSubstringBefore());
InstallFunction("substring-after",
FunctionSubstringAfter());
InstallFunction("substring",
FunctionSubstring());
InstallFunction("string-length",
FunctionStringLength());
InstallFunction("normalize-space",
FunctionNormalizeSpace());
InstallFunction("translate",
FunctionTranslate());
InstallFunction("boolean",
FunctionBoolean());
InstallFunction("not",
FunctionNot());
InstallFunction("true",
FunctionTrue());
InstallFunction("false",
FunctionFalse());
InstallFunction("lang",
FunctionLang());
InstallFunction("number",
FunctionNumber());
InstallFunction("sum",
FunctionSum());
InstallFunction("floor",
FunctionFloor());
InstallFunction("ceiling",
FunctionCeiling());
InstallFunction("round",
FunctionRound());
}
catch(...)
{
DestroyTable();
throw;
}
}
void
XPathFunctionTable::DestroyTable()
{
try
{
std::for_each(m_FunctionCollection.begin(),
m_FunctionCollection.end(),
DeleteFunctorType());
}
catch(...)
{
}
}
XPathFunctionTableException::XPathFunctionTableException(const DOMString&
theMessage) :
XPathException(theMessage)
{
}
XPathFunctionTableException::~XPathFunctionTableException()
{
}
XPathFunctionTableInvalidFunctionException::XPathFunctionTableInvalidFunctionException(const
DOMString& theFunctionName) :
XPathFunctionTableException(FormatMessage(theFunctionName))
{
}
XPathFunctionTableInvalidFunctionException::~XPathFunctionTableInvalidFunctionException()
{
}
DOMString
XPathFunctionTableInvalidFunctionException::FormatMessage(const DOMString&
theFunctionName)
{
const char* theMessage =
"Invalid function name detected: ";
return DOMString(theMessage) + theFunctionName;
}
1.1 xml-xalan/c/src/XPath/XPathFunctionTable.hpp
Index: XPathFunctionTable.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680)
#define XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <algorithm>
#include <map>
#include <dom/DOMString.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include <XPath/Function.hpp>
#include <XPath/XPathException.hpp>
class XALAN_XPATH_EXPORT XPathFunctionTableException : public XPathException
{
public:
virtual
~XPathFunctionTableException();
protected:
XPathFunctionTableException(const DOMString& theMessage);
};
class XALAN_XPATH_EXPORT XPathFunctionTableInvalidFunctionException : public
XPathFunctionTableException
{
public:
XPathFunctionTableInvalidFunctionException(const DOMString&
theFunctionName);
virtual
~XPathFunctionTableInvalidFunctionException();
private:
static DOMString
FormatMessage(const DOMString& theFunctionName);
};
class XALAN_XPATH_EXPORT XPathFunctionTable
{
public:
typedef std::map<DOMString, Function*> CollectionType;
typedef MapValueDeleteFunctor<CollectionType> DeleteFunctorType;
XPathFunctionTable();
~XPathFunctionTable();
Function&
operator[](const DOMString& theFunctionName) const
{
CollectionType::const_iterator i =
m_FunctionCollection.find(theFunctionName);
if (i != m_FunctionCollection.end())
{
return *(*i).second;
}
else
{
throw
XPathFunctionTableInvalidFunctionException(theFunctionName);
}
}
void
InstallFunction(
const DOMString& theFunctionName,
const Function& theFunction);
bool
isInstalledFunction(const DOMString& theFunctionName) const
{
if (m_FunctionCollection.find(theFunctionName) !=
m_FunctionCollection.end())
{
return true;
}
else
{
return false;
}
}
#if defined(XALAN_NO_MEMBER_TEMPLATES)
typedef vector<DOMString> InstalledFunctionNameVectorType;
void
getInstalledFunctionNames(InstalledFunctionNameVectorType&
theVector) const
{
CollectionType::const_iterator i =
m_FunctionCollection.begin();
while(i != m_FunctionCollection.end())
{
theVector.push_back((*i).first);
++i;
}
}
#else
template<class OutputIteratorType>
void
getInstalledFunctionNames(OutputIteratorType theIterator) const
{
copy(m_FunctionCollection.begin(),
m_FunctionCollection.end(),
PairIsolatorOutputIterator<OutputIteratorType,
PairFirstIsolator<CollectionType::value_type> >(theIterator,
PairFirstIsolator<CollectionType::value_type>()));
}
#endif
protected:
void
CreateTable();
void
DestroyTable();
private:
CollectionType
m_FunctionCollection;
};
#endif // XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathParserException.cpp
Index: XPathParserException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Base class header file.
#include "XPathParserException.hpp"
XPathParserException::XPathParserException(
const DOMString& message,
const DOM_Node& styleNode) :
XPathException(message,
styleNode)
{
}
XPathParserException::~XPathParserException()
{
}
1.1 xml-xalan/c/src/XPath/XPathParserException.hpp
Index: XPathParserException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHPARSEREXCEPTION_HEADER_GUARD_1357924680)
#define XPATHPARSEREXCEPTION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XPathException.hpp>
class XALAN_XPATH_EXPORT XPathParserException : public XPathException
{
public:
explicit
XPathParserException(
const DOMString& message = DOMString(),
const DOM_Node& styleNode = DOM_Node());
virtual
~XPathParserException();
};
#endif // XPATHPARSEREXCEPTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathProcessor.cpp
Index: XPathProcessor.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathProcessor.hpp"
#include "XPath.hpp"
XPathProcessor::XPathProcessor()
{
}
XPathProcessor::~XPathProcessor()
{
}
void
XPathProcessor::installFunction(
const DOMString& theFunctionName,
const Function& theFunction)
{
XPath::installFunction(theFunctionName,
theFunction);
}
1.1 xml-xalan/c/src/XPath/XPathProcessor.hpp
Index: XPathProcessor.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHPROCESSOR_HEADER_GUARD_1357924680)
#define XPATHPROCESSOR_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
class PrefixResolver;
class DOMString;
class Function;
class XPath;
class XALAN_XPATH_EXPORT XPathProcessor
{
public:
explicit
XPathProcessor();
virtual
~XPathProcessor();
/**
* Given a string, make an XPath object, in order that a parse doesn't
* have to be done each time the expression is executed.
*/
virtual void
initXPath(
XPath& pathObj,
const DOMString& expression,
const PrefixResolver& resolver) = 0;
/**
* Given a string, make an XSLT Match Pattern object.
*/
virtual void
initMatchPattern(
XPath& pathObj,
const DOMString& expression,
const PrefixResolver& resolver) = 0;
/**
* Given a string, and a reference to a function object, install
* the function with the given name.
*/
static void
installFunction(
const DOMString& theFunctionName,
const Function& theFunction);
};
#endif // XPATHPROCESSOR_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
Index: XPathProcessorImpl.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathProcessorImpl.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/DOMStringPrintWriter.hpp>
#include "PrefixResolver.hpp"
#include "XObjectFactory.hpp"
#include "XPathEnvSupport.hpp"
#include "XPathParserException.hpp"
#include "XPathSupport.hpp"
namespace
{
const char* const FROM_ANCESTORS_STRING = "ancestor";
const char* const FROM_ANCESTORS_OR_SELF_STRING = "ancestor-or-self";
const char* const FROM_ATTRIBUTES_STRING = "attribute";
const char* const FROM_CHILDREN_STRING = "child";
const char* const FROM_DESCENDANTS_STRING = "descendant";
const char* const FROM_DESCENDANTS_OR_SELF_STRING = "descendant-or-self";
const char* const FROM_FOLLOWING_STRING = "following";
const char* const FROM_FOLLOWING_SIBLINGS_STRING = "following-sibling";
const char* const FROM_PARENT_STRING = "parent";
const char* const FROM_PRECEDING_STRING = "preceding";
const char* const FROM_PRECEDING_SIBLINGS_STRING = "preceding-sibling";
const char* const FROM_SELF_STRING = "self";
const char* const FROM_SELF_ABBREVIATED_STRING = ".";
const char* const FROM_NAMESPACE_STRING = "namespace";
// This shouldn't really be here, since it duplicates a string that is part
// of the information that is maintained by the class XPathFunctionTable,
// but this is a reasonable optimization.
const char* const FUNC_ID_STRING = "id";
// These shouldn't really be here, since they are not part of the XPath
standard,
// but rather a part ofthe XSLT standard.
const char* const FUNC_KEY_STRING = "key";
const char* const FUNC_DOC_STRING = "doc";
const char* const FUNC_DOCUMENT_STRING = "document";
const char* const NODETYPE_COMMENT_STRING = "comment";
const char* const NODETYPE_TEXT_STRING = "text";
const char* const NODETYPE_PI_STRING = "processing-instruction";
const char* const NODETYPE_NODE_STRING = "node";
const char* const NODETYPE_ANYELEMENT_STRING = "*";
#if 0
const string XPathProcessorImpl::FROM_SELF_ABBREVIATED_STRING = ".";
const string XPathProcessorImpl::FROM_ATTRIBUTE_STRING = "@";
const string XPathProcessorImpl::FROM_DOC_STRING = "document";
const string XPathProcessorImpl::FROM_DOCREF_STRING = "document";
const string XPathProcessorImpl::FROM_ID_STRING = "id";
const string XPathProcessorImpl::FROM_IDREF_STRING = "idref";
const string XPathProcessorImpl::FUNC_CURRENT_STRING = "current";
const string XPathProcessorImpl::FUNC_LAST_STRING = "last";
const string XPathProcessorImpl::FUNC_POSITION_STRING = "position";
const string XPathProcessorImpl::FUNC_COUNT_STRING = "count";
const string XPathProcessorImpl::FUNC_ID_STRING = "id";
const string XPathProcessorImpl::FUNC_IDREF_STRING = "idref";
const string XPathProcessorImpl::FUNC_KEY_STRING = "key";
const string XPathProcessorImpl::FUNC_KEYREF_STRING = "keyref";
const string XPathProcessorImpl::FUNC_DOCUMENT_STRING = "document";
const string XPathProcessorImpl::FUNC_DOCREF_STRING = "docref";
const string XPathProcessorImpl::FUNC_LOCAL_PART_STRING = "local-name";
const string XPathProcessorImpl::FUNC_NAMESPACE_STRING = "namespace-uri";
const string XPathProcessorImpl::FUNC_NAME_STRING = "name";
const string XPathProcessorImpl::FUNC_GENERATE_ID_STRING = "generate-id";
const string XPathProcessorImpl::FUNC_NOT_STRING = "not";
const string XPathProcessorImpl::FUNC_TRUE_STRING = "true";
const string XPathProcessorImpl::FUNC_FALSE_STRING = "false";
const string XPathProcessorImpl::FUNC_BOOLEAN_STRING = "boolean";
const string XPathProcessorImpl::FUNC_LANG_STRING = "lang";
const string XPathProcessorImpl::FUNC_NUMBER_STRING = "number";
const string XPathProcessorImpl::FUNC_FLOOR_STRING = "floor";
const string XPathProcessorImpl::FUNC_CEILING_STRING = "ceiling";
const string XPathProcessorImpl::FUNC_ROUND_STRING = "round";
const string XPathProcessorImpl::FUNC_SUM_STRING = "sum";
const string XPathProcessorImpl::FUNC_STRING_STRING = "string";
const string XPathProcessorImpl::FUNC_STARTS_WITH_STRING = "starts-with";
const string XPathProcessorImpl::FUNC_CONTAINS_STRING = "contains";
const string XPathProcessorImpl::FUNC_SUBSTRING_BEFORE_STRING =
"substring-before";
const string XPathProcessorImpl::FUNC_SUBSTRING_AFTER_STRING =
"substring-after";
const string XPathProcessorImpl::FUNC_NORMALIZE_STRING = "normalize";
const string XPathProcessorImpl::FUNC_TRANSLATE_STRING = "translate";
const string XPathProcessorImpl::FUNC_CONCAT_STRING = "concat";
const string XPathProcessorImpl::FUNC_FORMAT_NUMBER_STRING = "format-number";
const string XPathProcessorImpl::FUNC_SYSTEM_PROPERTY_STRING =
"system-property";
const string XPathProcessorImpl::FUNC_EXT_FUNCTION_AVAILABLE_STRING =
"extension-function-available";
const string XPathProcessorImpl::FUNC_EXT_ELEM_AVAILABLE_STRING =
"extension-element-available";
const string XPathProcessorImpl::FUNC_SUBSTRING_STRING = "substring";
const string XPathProcessorImpl::FUNC_STRING_LENGTH_STRING = "string-length";
const string XPathProcessorImpl::FUNC_DOCLOCATION_STRING =
"document-location";
#endif
};
XPathProcessorImpl::KeywordsMapType
XPathProcessorImpl::s_keywords;
XPathProcessorImpl::FunctionNameMapType
XPathProcessorImpl::s_functions;
XPathProcessorImpl::AxisNamesMapType
XPathProcessorImpl::s_axisNames;
XPathProcessorImpl::NodeTypesMapType
XPathProcessorImpl::s_nodeTypes;
XPathProcessorImpl::XPathProcessorImpl(
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport) :
m_envSupport(theXPathEnvSupport),
m_support(theXPathSupport),
m_xpath(0),
m_token(),
m_tokenChar(0),
m_expression(0)
{
// $$$ ToDo: This is not thread-safe!!!
static StaticInitializer theInitializer;
}
XPathProcessorImpl::~XPathProcessorImpl()
{
m_expression = 0;
m_xpath = 0;
}
void
XPathProcessorImpl::initXPath(
XPath& pathObj,
const DOMString& expression,
const PrefixResolver& resolver)
{
m_xpath = &pathObj;
m_expression = &m_xpath->getExpression();
m_xpath->setPrefixResolver(resolver);
tokenize(expression);
m_expression->appendOpCode(XPathExpression::eOP_XPATH);
nextToken();
Expr();
m_xpath = 0;
m_expression = 0;
}
void
XPathProcessorImpl::initMatchPattern(
XPath& pathObj,
const DOMString& expression,
const PrefixResolver& resolver)
{
m_xpath = &pathObj;
m_expression = &m_xpath->getExpression();
m_expression->reset();
m_xpath->setPrefixResolver(resolver);
tokenize(expression);
m_expression->appendOpCode(XPathExpression::eOP_MATCHPATTERN);
nextToken();
Pattern();
// Terminate for safety.
m_expression->appendOpCode(XPathExpression::eENDOP);
m_expression->shrink();
m_xpath = 0;
m_expression = 0;
}
void
XPathProcessorImpl::tokenize(
const DOMString& pat,
std::vector<DOMString>* targetStrings)
{
m_expression->setCurrentPattern(pat);
const int nChars = length(pat);
int startSubstring = -1;
int posOfNSSep = -1;
bool isStartOfPat = true;
bool isAttrName = false;
bool isNum = false;
// Nesting of '[' so we can know if the given element should be
// counted inside the m_patternMap.
int nesting = 0;
// char[] chars = pat.toCharArray();
for(int i = 0; i < nChars; i++)
{
XMLCh c = charAt(pat, i);
switch(c)
{
case '\"':
{
if(startSubstring != -1)
{
isNum = false;
isStartOfPat =
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
isAttrName = false;
if(-1 != posOfNSSep)
{
posOfNSSep = mapNSTokens(pat,
startSubstring, posOfNSSep, i);
}
else
{
addToTokenQueue(substring(pat,
startSubstring, i));
}
}
startSubstring = i;
for(i++; i < nChars && (c = charAt(pat, i)) !=
'\"'; i++);
if(c == '\"')
{
addToTokenQueue(substring(pat,
startSubstring, i + 1));
startSubstring = -1;
}
else
{
error("misquoted literal... expected
double quote!");
}
}
break;
case '\'':
{
if(startSubstring != -1)
{
isNum = false;
isStartOfPat =
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
isAttrName = false;
if(-1 != posOfNSSep)
{
posOfNSSep = mapNSTokens(pat,
startSubstring, posOfNSSep, i);
}
else
{
addToTokenQueue(substring(pat,
startSubstring, i));
}
}
startSubstring = i;
for(i++; i < nChars && (c = charAt(pat, i)) !=
'\''; i++);
if(c == '\'')
{
addToTokenQueue(substring(pat,
startSubstring, i + 1));
startSubstring = -1;
}
else
{
error("misquoted literal... expected
single quote!");
}
}
break;
case 0x0A:
case 0x0D:
case ' ':
case '\t':
{
if(startSubstring != -1)
{
isNum = false;
isStartOfPat =
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
isAttrName = false;
if(-1 != posOfNSSep)
{
posOfNSSep = mapNSTokens(pat,
startSubstring, posOfNSSep, i);
}
else
{
addToTokenQueue(substring(pat,
startSubstring, i));
}
startSubstring = -1;
}
}
break;
case '@':
isAttrName = true;
// fall-through on purpose
case '-':
{
if('-' == c)
{
if(!(isNum || (startSubstring == -1)))
{
break;
}
isNum = false;
}
}
// fall-through on purpose
case '(':
case '[':
case ')':
case ']':
case '|':
case '/':
case '*':
case '+':
case '=':
case ',':
case '\\': // Unused at the moment
case '^': // Unused at the moment
case '!': // Unused at the moment
case '$':
case '<':
case '>':
{
if(startSubstring != -1)
{
isNum = false;
isStartOfPat =
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
isAttrName = false;
if(-1 != posOfNSSep)
{
posOfNSSep = mapNSTokens(pat,
startSubstring, posOfNSSep, i);
}
else
{
addToTokenQueue(substring(pat,
startSubstring, i));
}
startSubstring = -1;
}
else if('/' == c && isStartOfPat == true)
{
isStartOfPat =
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
}
else if('*' == c)
{
isStartOfPat =
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
isAttrName = false;
}
if(0 == nesting)
{
if('|' == c)
{
if(0 != targetStrings)
{
recordTokenString(*targetStrings);
}
isStartOfPat = true;
}
}
if(')' == c || ']' == c)
{
nesting--;
}
else if('(' == c || '[' == c)
{
nesting++;
}
addToTokenQueue(substring(pat, i, i + 1));
}
break;
case ':':
{
if(posOfNSSep == (i - 1))
{
if(startSubstring != -1)
{
addToTokenQueue(substring(pat,
startSubstring, i - 1));
}
isNum = false;
isAttrName = false;
startSubstring = -1;
posOfNSSep = -1;
addToTokenQueue(substring(pat, i - 1, i
+ 1));
break;
}
else
{
posOfNSSep = i;
}
}
// fall through on purpose
default:
{
if(-1 == startSubstring)
{
startSubstring = i;
isNum = isDigit(c);
}
else if(isNum == true)
{
isNum = isDigit(c);
}
}
}
}
if(startSubstring != -1)
{
isNum = false;
isStartOfPat = mapPatternElemPos(nesting, isStartOfPat,
isAttrName);
if(-1 != posOfNSSep)
{
posOfNSSep = mapNSTokens(pat, startSubstring,
posOfNSSep, nChars);
}
else
{
addToTokenQueue(substring(pat, startSubstring, nChars));
}
}
if(0 == m_expression->tokenQueueSize())
{
error("Empty expression!");
}
else if(0 != targetStrings)
{
recordTokenString(*targetStrings);
}
m_expression->setTokenPosition(0);
}
bool
XPathProcessorImpl::mapPatternElemPos(
int nesting,
bool isStart,
bool isAttrName) const
{
if(0 == nesting)
{
if(!isStart)
{
m_expression->adjustPattern(m_expression->patternMapSize(),
-TARGETEXTRA);
}
const int theValue =
m_expression->tokenQueueSize() - (isAttrName ? 1 : 0) +
TARGETEXTRA;
m_expression->pushPattern(theValue);
isStart = false;
}
return isStart;
}
void
XPathProcessorImpl::recordTokenString(std::vector<DOMString>& targetStrings)
{
assert(m_expression != 0);
int tokPos = getTokenQueuePosFromMap(m_expression->patternMapSize() -
1);
resetTokenMark(tokPos + 1);
if(lookahead('(', 1) == true)
{
const int tok = getKeywordToken(m_token);
switch(tok)
{
case XPathExpression::eNODETYPE_COMMENT:
targetStrings.push_back(m_xpath->PSEUDONAME_COMMENT);
break;
case XPathExpression::eNODETYPE_TEXT:
targetStrings.push_back(m_xpath->PSEUDONAME_TEXT);
break;
case XPathExpression::eNODETYPE_NODE:
targetStrings.push_back(m_xpath->PSEUDONAME_ANY);
break;
case XPathExpression::eNODETYPE_ROOT:
targetStrings.push_back(m_xpath->PSEUDONAME_ROOT);
break;
case XPathExpression::eNODETYPE_ANYELEMENT:
targetStrings.push_back(m_xpath->PSEUDONAME_ANY);
break;
case XPathExpression::eNODETYPE_PI:
targetStrings.push_back(m_xpath->PSEUDONAME_ANY);
break;
default:
targetStrings.push_back(m_xpath->PSEUDONAME_ANY);
break;
}
}
else
{
if(tokenIs('@') == true)
{
tokPos++;
resetTokenMark(tokPos + 1);
}
if(lookahead(':', 1) == true)
{
tokPos += 2;
}
assert(m_expression->getToken(tokPos) != 0);
targetStrings.push_back(m_expression->getToken(tokPos)->str());
}
}
void
XPathProcessorImpl::addToTokenQueue(const DOMString& s) const
{
assert(m_xpath != 0);
assert(m_expression != 0);
m_expression->pushToken(m_xpath->getXObjectFactory().createString(s));
}
int
XPathProcessorImpl::mapNSTokens(
const DOMString& pat,
int startSubstring,
int posOfNSSep,
int posOfScan) const
{
assert(m_xpath != 0);
const DOMString prefix = substring(pat, startSubstring,
posOfNSSep);
const DOMString uName =
m_xpath->getPrefixResolver().getNamespaceForPrefix(prefix);
if(length(uName) > 0)
{
addToTokenQueue(uName);
addToTokenQueue(":");
const DOMString s = substring(pat, posOfNSSep + 1,
posOfScan);
if(length(s) > 0)
{
addToTokenQueue(s);
}
}
else
{
// error(DOMString("Could not locate namespace for prefix: ") +
prefix);
addToTokenQueue(prefix);
addToTokenQueue(":");
const DOMString s = substring(pat, posOfNSSep + 1,
posOfScan);
if(s.length() > 0)
{
addToTokenQueue(s);
}
}
return -1;
}
int
XPathProcessorImpl::getTokenQueuePosFromMap(int i) const
{
assert(m_expression != 0);
const int pos = m_expression->getPattern(i);
return pos >= TARGETEXTRA ? pos - TARGETEXTRA : pos;
}
bool
XPathProcessorImpl::tokenIs(const char* s) const
{
return equals(m_token, s);
}
bool
XPathProcessorImpl::tokenIs(char c) const
{
return m_tokenChar == static_cast<XMLCh>(c) ? true : false;
}
bool
XPathProcessorImpl::lookahead(
char c,
int n) const
{
const DOMString tok =
getTokenRelative(n - 1);
if (length(tok) == 1 &&
charAt(tok, 0) == c)
{
return true;
}
else
{
return false;
}
}
bool
XPathProcessorImpl::lookahead(
const char* s,
int n) const
{
const DOMString tok =
getTokenRelative(n - 1);
return equals(tok, s);
}
bool
XPathProcessorImpl::lookbehind(
char c,
int n) const
{
const DOMString tok =
getTokenRelative(-(n + 1));
if (length(tok) == 1 &&
charAt(tok, 0) == c)
{
return true;
}
else
{
return false;
}
}
bool
XPathProcessorImpl::lookbehindHasToken(int n) const
{
const DOMString tok =
getTokenRelative(-(n + 1));
const XMLCh c0 = length(tok) == 0 ? '|' : charAt(tok, 0);
return c0 == '|' ? false : true;
}
void
XPathProcessorImpl::nextToken()
{
assert(m_expression != 0);
const XObject* const theNextToken =
m_expression->getNextToken();
m_token = theNextToken == 0 ? "" : theNextToken->str();
if(length(m_token) > 0)
{
m_tokenChar = charAt(m_token, 0);
}
else
{
m_tokenChar = 0;
}
}
void
XPathProcessorImpl::prevToken()
{
assert(m_expression != 0);
const XObject* const thePreviousToken =
m_expression->getPreviousToken();
m_token = thePreviousToken == 0 ? "" : thePreviousToken->str();
if(length(m_token) > 0)
{
m_tokenChar = charAt(m_token, 0);
}
else
{
m_tokenChar = 0;
}
}
DOMString
XPathProcessorImpl::getTokenRelative(int theOffset) const
{
assert(m_expression != 0);
const XObject* const theToken =
m_expression->getRelativeToken(theOffset);
return theToken == 0 ? DOMString() : theToken->str();
}
void
XPathProcessorImpl::resetTokenMark(int mark)
{
m_expression->setTokenPosition(mark);
nextToken();
}
void
XPathProcessorImpl::consumeExpected(const char* expected)
{
if(tokenIs(expected) == true)
{
nextToken();
}
else
{
error(DOMString("Expected ") +
DOMString(expected) +
DOMString(", but found: ") +
m_token);
}
}
void
XPathProcessorImpl::consumeExpected(char expected)
{
if(tokenIs(expected) == true)
{
nextToken();
}
else
{
DOMString theMsg("Expected ");
theMsg += expected;
theMsg += ", but found: ";
theMsg += m_token;
error(theMsg);
}
}
void
XPathProcessorImpl::warn(
const DOMString& msg,
const DOM_Node& sourceNode) const
{
assert(m_xpath != 0);
const bool shouldThrow =
m_envSupport.problem(XPathEnvSupport::eXPATHParser,
XPathEnvSupport::eWarning,
m_xpath->getPrefixResolver(),
sourceNode,
msg,
0,
0);
if(shouldThrow == true)
{
throw XPathParserException(msg);
}
}
void
XPathProcessorImpl::error(
const DOMString& msg,
const DOM_Node& sourceNode) const
{
DOMString emsg;
if (m_expression == 0)
{
emsg = msg;
}
else
{
const DOMString& theCurrentPattern =
m_expression->getCurrentPattern();
DOMStringPrintWriter thePrintWriter;
if (length(theCurrentPattern) != 0)
{
thePrintWriter.print("pattern = '");
thePrintWriter.println(theCurrentPattern);
}
thePrintWriter.print(msg);
m_expression->dumpRemainingTokenQueue(thePrintWriter);
emsg = thePrintWriter.getString();
}
assert(m_xpath != 0);
const bool shouldThrow =
m_envSupport.problem(XPathEnvSupport::eXPATHParser,
XPathEnvSupport::eError,
m_xpath->getPrefixResolver(),
sourceNode,
emsg,
0,
0);
if(shouldThrow == true)
{
throw XPathParserException(emsg);
}
}
#if 0
private static Hashtable m_keywords = new Hashtable();
private static Hashtable m_axisnames = new Hashtable();
static Hashtable m_functions = new Hashtable();
private static Hashtable m_nodetypes = new Hashtable();
private static final String FROM_ANCESTORS_STRING = "ancestor";
private static final String FROM_ANCESTORS_OR_SELF_STRING =
"ancestor-or-self";
private static final String FROM_ATTRIBUTES_STRING = "attribute";
private static final String FROM_CHILDREN_STRING = "child";
private static final String FROM_DESCENDANTS_STRING = "descendant";
private static final String FROM_DESCENDANTS_OR_SELF_STRING =
"descendant-or-self";
private static final String FROM_FOLLOWING_STRING = "following";
private static final String FROM_FOLLOWING_SIBLINGS_STRING =
"following-sibling";
private static final String FROM_PARENT_STRING = "parent";
private static final String FROM_PRECEDING_STRING = "preceding";
private static final String FROM_PRECEDING_SIBLINGS_STRING =
"preceding-sibling";
private static final String FROM_SELF_STRING = "self";
private static final String FROM_NAMESPACE_STRING = "namespace";
private static final String FROM_SELF_ABBREVIATED_STRING = ".";
private static final String NODETYPE_COMMENT_STRING = "comment";
private static final String NODETYPE_TEXT_STRING = "text";
private static final String NODETYPE_PI_STRING = "processing-instruction";
private static final String NODETYPE_NODE_STRING = "node";
private static final String FROM_ATTRIBUTE_STRING = "@";
private static final String FROM_DOC_STRING = "document";
private static final String FROM_DOCREF_STRING = "document";
private static final String FROM_ID_STRING = "id";
private static final String FROM_IDREF_STRING = "idref";
private static final String NODETYPE_ANYELEMENT_STRING = "*";
private static final String FUNC_CURRENT_STRING = "current";
private static final String FUNC_LAST_STRING = "last";
private static final String FUNC_POSITION_STRING = "position";
private static final String FUNC_COUNT_STRING = "count";
private static final String FUNC_ID_STRING = "id";
private static final String FUNC_IDREF_STRING = "idref";
private static final String FUNC_KEY_STRING = "key";
private static final String FUNC_KEYREF_STRING = "keyref";
private static final String FUNC_DOC_STRING = "doc";
private static final String FUNC_DOCUMENT_STRING = "document";
private static final String FUNC_DOCREF_STRING = "docref";
private static final String FUNC_LOCAL_PART_STRING = "local-name";
private static final String FUNC_NAMESPACE_STRING = "namespace-uri";
private static final String FUNC_NAME_STRING = "name";
private static final String FUNC_GENERATE_ID_STRING = "generate-id";
private static final String FUNC_NOT_STRING = "not";
private static final String FUNC_TRUE_STRING = "true";
private static final String FUNC_FALSE_STRING = "false";
private static final String FUNC_BOOLEAN_STRING = "boolean";
private static final String FUNC_LANG_STRING = "lang";
private static final String FUNC_NUMBER_STRING = "number";
private static final String FUNC_FLOOR_STRING = "floor";
private static final String FUNC_CEILING_STRING = "ceiling";
private static final String FUNC_ROUND_STRING = "round";
private static final String FUNC_SUM_STRING = "sum";
private static final String FUNC_STRING_STRING = "string";
private static final String FUNC_STARTS_WITH_STRING = "starts-with";
private static final String FUNC_CONTAINS_STRING = "contains";
private static final String FUNC_SUBSTRING_BEFORE_STRING =
"substring-before";
private static final String FUNC_SUBSTRING_AFTER_STRING = "substring-after";
private static final String FUNC_NORMALIZE_STRING = "normalize";
private static final String FUNC_TRANSLATE_STRING = "translate";
private static final String FUNC_CONCAT_STRING = "concat";
private static final String FUNC_FORMAT_NUMBER_STRING = "format-number";
private static final String FUNC_SYSTEM_PROPERTY_STRING = "system-property";
private static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING =
"extension-function-available";
private static final String FUNC_EXT_ELEM_AVAILABLE_STRING =
"extension-element-available";
private static final String FUNC_SUBSTRING_STRING = "substring";
private static final String FUNC_STRING_LENGTH_STRING = "string-length";
// Proprietary, built in functions
private static final String FUNC_DOCLOCATION_STRING = "document-location";
static
{
m_axisnames.put((FROM_ANCESTORS_STRING).intern(), new
Integer(XPath.FROM_ANCESTORS));
m_axisnames.put((FROM_ANCESTORS_OR_SELF_STRING).intern(), new
Integer(XPath.FROM_ANCESTORS_OR_SELF));
m_axisnames.put((FROM_ATTRIBUTES_STRING).intern(), new
Integer(XPath.FROM_ATTRIBUTES));
m_axisnames.put((FROM_CHILDREN_STRING).intern(), new
Integer(XPath.FROM_CHILDREN));
m_axisnames.put((FROM_DESCENDANTS_STRING).intern(), new
Integer(XPath.FROM_DESCENDANTS));
m_axisnames.put((FROM_DESCENDANTS_OR_SELF_STRING).intern(), new
Integer(XPath.FROM_DESCENDANTS_OR_SELF));
m_axisnames.put((FROM_FOLLOWING_STRING).intern(), new
Integer(XPath.FROM_FOLLOWING));
m_axisnames.put((FROM_FOLLOWING_SIBLINGS_STRING).intern(), new
Integer(XPath.FROM_FOLLOWING_SIBLINGS));
m_axisnames.put((FROM_PARENT_STRING).intern(), new
Integer(XPath.FROM_PARENT));
m_axisnames.put((FROM_PRECEDING_STRING).intern(), new
Integer(XPath.FROM_PRECEDING));
m_axisnames.put((FROM_PRECEDING_SIBLINGS_STRING).intern(), new
Integer(XPath.FROM_PRECEDING_SIBLINGS));
m_axisnames.put((FROM_SELF_STRING).intern(), new
Integer(XPath.FROM_SELF));
m_axisnames.put((FROM_NAMESPACE_STRING).intern(), new
Integer(XPath.FROM_NAMESPACE));
m_nodetypes.put((NODETYPE_COMMENT_STRING).intern(), new
Integer(XPath.NODETYPE_COMMENT));
m_nodetypes.put((NODETYPE_TEXT_STRING).intern(), new
Integer(XPath.NODETYPE_TEXT));
m_nodetypes.put((NODETYPE_PI_STRING).intern(), new
Integer(XPath.NODETYPE_PI));
m_nodetypes.put((NODETYPE_NODE_STRING).intern(), new
Integer(XPath.NODETYPE_NODE));
m_nodetypes.put((NODETYPE_ANYELEMENT_STRING).intern(), new
Integer(XPath.NODETYPE_ANYELEMENT));
m_keywords.put((FROM_SELF_ABBREVIATED_STRING).intern(), new
Integer(XPath.FROM_SELF));
// m_keywords.put((FROM_ATTRIBUTE_STRING).intern(), new
Integer(XPath.FROM_ATTRIBUTE));
// m_keywords.put((FROM_DOC_STRING).intern(), new
Integer(XPath.FROM_DOC));
// m_keywords.put((FROM_DOCREF_STRING).intern(), new
Integer(XPath.FROM_DOCREF));
// m_keywords.put((FROM_ID_STRING).intern(), new
Integer(XPath.FROM_ID));
// m_keywords.put((FROM_IDREF_STRING).intern(), new
Integer(XPath.FROM_IDREF));
m_keywords.put((FUNC_ID_STRING).intern(), new Integer(XPath.FUNC_ID));
m_keywords.put((FUNC_KEY_STRING).intern(), new Integer(XPath.FUNC_KEY));
m_keywords.put((FUNC_DOCUMENT_STRING).intern(), new
Integer(XPath.FUNC_DOC));
m_functions.put((FUNC_CURRENT_STRING).intern(), new
Integer(XPath.FUNC_CURRENT));
m_functions.put((FUNC_LAST_STRING).intern(), new
Integer(XPath.FUNC_LAST));
m_functions.put((FUNC_POSITION_STRING).intern(), new
Integer(XPath.FUNC_POSITION));
m_functions.put((FUNC_COUNT_STRING).intern(), new
Integer(XPath.FUNC_COUNT));
m_functions.put((FUNC_ID_STRING).intern(), new Integer(XPath.FUNC_ID));
m_functions.put((FUNC_KEY_STRING).intern(), new
Integer(XPath.FUNC_KEY));
m_functions.put((FUNC_DOCUMENT_STRING).intern(), new
Integer(XPath.FUNC_DOC));
m_functions.put((FUNC_LOCAL_PART_STRING).intern(), new
Integer(XPath.FUNC_LOCAL_PART));
m_functions.put((FUNC_NAMESPACE_STRING).intern(), new
Integer(XPath.FUNC_NAMESPACE));
m_functions.put((FUNC_NAME_STRING).intern(), new
Integer(XPath.FUNC_QNAME));
m_functions.put((FUNC_GENERATE_ID_STRING).intern(), new
Integer(XPath.FUNC_GENERATE_ID));
m_functions.put((FUNC_NOT_STRING).intern(), new
Integer(XPath.FUNC_NOT));
m_functions.put((FUNC_TRUE_STRING).intern(), new
Integer(XPath.FUNC_TRUE));
m_functions.put((FUNC_FALSE_STRING).intern(), new
Integer(XPath.FUNC_FALSE));
m_functions.put((FUNC_BOOLEAN_STRING).intern(), new
Integer(XPath.FUNC_BOOLEAN));
m_functions.put((FUNC_LANG_STRING).intern(), new
Integer(XPath.FUNC_LANG));
m_functions.put((FUNC_NUMBER_STRING).intern(), new
Integer(XPath.FUNC_NUMBER));
m_functions.put((FUNC_FLOOR_STRING).intern(), new
Integer(XPath.FUNC_FLOOR));
m_functions.put((FUNC_CEILING_STRING).intern(), new
Integer(XPath.FUNC_CEILING));
m_functions.put((FUNC_ROUND_STRING).intern(), new
Integer(XPath.FUNC_ROUND));
m_functions.put((FUNC_SUM_STRING).intern(), new
Integer(XPath.FUNC_SUM));
m_functions.put((FUNC_STRING_STRING).intern(), new
Integer(XPath.FUNC_STRING));
m_functions.put((FUNC_STARTS_WITH_STRING).intern(), new
Integer(XPath.FUNC_STARTS_WITH));
m_functions.put((FUNC_CONTAINS_STRING).intern(), new
Integer(XPath.FUNC_CONTAINS));
m_functions.put((FUNC_SUBSTRING_BEFORE_STRING).intern(), new
Integer(XPath.FUNC_SUBSTRING_BEFORE));
m_functions.put((FUNC_SUBSTRING_AFTER_STRING).intern(), new
Integer(XPath.FUNC_SUBSTRING_AFTER));
m_functions.put((FUNC_NORMALIZE_STRING).intern(), new
Integer(XPath.FUNC_NORMALIZE));
m_functions.put((FUNC_TRANSLATE_STRING).intern(), new
Integer(XPath.FUNC_TRANSLATE));
m_functions.put((FUNC_CONCAT_STRING).intern(), new
Integer(XPath.FUNC_CONCAT));
m_functions.put((FUNC_FORMAT_NUMBER_STRING).intern(), new
Integer(XPath.FUNC_FORMAT_NUMBER));
m_functions.put((FUNC_SYSTEM_PROPERTY_STRING).intern(), new
Integer(XPath.FUNC_SYSTEM_PROPERTY));
m_functions.put((FUNC_EXT_FUNCTION_AVAILABLE_STRING).intern(), new
Integer(XPath.FUNC_EXT_FUNCTION_AVAILABLE));
m_functions.put((FUNC_EXT_ELEM_AVAILABLE_STRING).intern(), new
Integer(XPath.FUNC_EXT_ELEM_AVAILABLE));
m_functions.put((FUNC_SUBSTRING_STRING).intern(), new
Integer(XPath.FUNC_SUBSTRING));
m_functions.put((FUNC_STRING_LENGTH_STRING).intern(), new
Integer(XPath.FUNC_STRING_LENGTH));
// These aren't really functions.
m_functions.put((NODETYPE_COMMENT_STRING).intern(), new
Integer(XPath.NODETYPE_COMMENT));
m_functions.put((NODETYPE_TEXT_STRING).intern(), new
Integer(XPath.NODETYPE_TEXT));
m_functions.put((NODETYPE_PI_STRING).intern(), new
Integer(XPath.NODETYPE_PI));
m_functions.put((NODETYPE_NODE_STRING).intern(), new
Integer(XPath.NODETYPE_NODE));
m_functions.put((FUNC_DOCLOCATION_STRING).intern(), new
Integer(XPath.FUNC_DOCLOCATION));
}
#endif
int
XPathProcessorImpl::getKeywordToken(const DOMString& key) const
{
KeywordsMapType::const_iterator i =
s_keywords.find(key);
if (i == s_keywords.end())
{
return 0;
}
else
{
return (*i).second;
}
}
int
XPathProcessorImpl::getFunctionToken(const DOMString& key) const
{
FunctionNameMapType::const_iterator i = s_functions.find(key);
if (i != s_functions.end())
{
return (*i).second;
}
else
{
return 0;
}
}
void
XPathProcessorImpl::Expr()
{
OrExpr();
}
void
XPathProcessorImpl::OrExpr()
{
const int opPos = m_expression->opCodeMapLength();
AndExpr();
if(tokenIs("or") == true)
{
nextToken();
m_expression->insertOpCode(XPathExpression::eOP_OR,
opPos);
OrExpr();
m_expression->updateOpCodeLength(XPathExpression::eOP_OR,
opPos);
}
}
void
XPathProcessorImpl::AndExpr()
{
const int opPos = m_expression->opCodeMapLength();
EqualityExpr();
if(tokenIs("and") == true)
{
nextToken();
m_expression->insertOpCode(XPathExpression::eOP_AND,
opPos);
AndExpr();
m_expression->updateOpCodeLength(XPathExpression::eOP_AND,
opPos);
}
}
int
XPathProcessorImpl::EqualityExpr(int opCodePos)
{
int theOpDisplacement = 0;
const int opPos = opCodePos != -1 ? opCodePos :
m_expression->opCodeMapLength();
RelationalExpr();
XPathExpression::eOpCodes theOpCode =
XPathExpression::eENDOP;
if(tokenIs('!') && lookahead('=', 1))
{
nextToken();
nextToken();
theOpCode = XPathExpression::eOP_NOTEQUALS;
}
else if(tokenIs('='))
{
nextToken();
theOpCode = XPathExpression::eOP_EQUALS;
}
if (theOpCode != XPathExpression::eENDOP)
{
// Save the number of bytes we inserted
// into the map.
const int theLocalDisplacement =
m_expression->insertOpCode(theOpCode,
opPos);
// Update the length
m_expression->updateOpCodeLength(theOpCode,
opPos);
// Do the right term of the expression.
theOpDisplacement += EqualityExpr(opPos);
// If there's any displacement from the right
// term, update the length for a shift. Otherwise,
// just update the length.
if (theOpDisplacement > 0)
{
m_expression->updateShiftedOpCodeLength(theOpCode,
opPos,
opPos + theOpDisplacement);
}
else
{
m_expression->updateOpCodeLength(theOpCode,
opPos);
}
// Accumulate the displacement.
theOpDisplacement += theLocalDisplacement;
}
return theOpDisplacement;
}
int
XPathProcessorImpl::RelationalExpr(int opCodePos)
{
int theOpDisplacement = 0;
const int opPos = opCodePos != -1 ? opCodePos :
m_expression->opCodeMapLength();
AdditiveExpr();
if(0 != length(m_token))
{
XPathExpression::eOpCodes theOpCode =
XPathExpression::eENDOP;
if(tokenIs('<') == true)
{
nextToken();
if(tokenIs('=') == true)
{
nextToken();
theOpCode = XPathExpression::eOP_LTE;
}
else
{
theOpCode = XPathExpression::eOP_LT;
}
}
else if(tokenIs('>') == true)
{
nextToken();
if(tokenIs('=') == true)
{
nextToken();
theOpCode = XPathExpression::eOP_GTE;
}
else
{
theOpCode = XPathExpression::eOP_GT;
}
}
if (theOpCode != XPathExpression::eENDOP)
{
// Save the number of bytes we inserted
// into the map.
const int theLocalDisplacement =
m_expression->insertOpCode(theOpCode,
opPos);
// Update the length
m_expression->updateOpCodeLength(theOpCode,
opPos);
// Do the right term of the expression.
theOpDisplacement += RelationalExpr(opPos);
// If there's any displacement from the right
// term, update the length for a shift. Otherwise,
// just update the length.
if (theOpDisplacement > 0)
{
m_expression->updateShiftedOpCodeLength(theOpCode,
opPos,
opPos + theOpDisplacement);
}
else
{
m_expression->updateOpCodeLength(theOpCode,
opPos);
}
// Accumulate the displacement.
theOpDisplacement += theLocalDisplacement;
}
}
return theOpDisplacement;
}
int
XPathProcessorImpl::AdditiveExpr(int opCodePos)
{
int theOpDisplacement = 0;
const int opPos = opCodePos != -1 ? opCodePos :
m_expression->opCodeMapLength();
MultiplicativeExpr();
if(0 != length(m_token))
{
XPathExpression::eOpCodes theOpCode =
XPathExpression::eENDOP;
if(tokenIs('+') == true)
{
theOpCode = XPathExpression::eOP_PLUS;
}
else if(tokenIs('-') == true)
{
theOpCode = XPathExpression::eOP_MINUS;
}
if (theOpCode != XPathExpression::eENDOP)
{
nextToken();
// Save the number of bytes we inserted
// into the map.
const int theLocalDisplacement =
m_expression->insertOpCode(theOpCode,
opPos);
// Update the length
m_expression->updateOpCodeLength(theOpCode,
opPos);
// Do the right term of the expression.
theOpDisplacement += AdditiveExpr(opPos);
// If there's any displacement from the right
// term, update the length for a shift. Otherwise,
// just update the length.
if (theOpDisplacement > 0)
{
m_expression->updateShiftedOpCodeLength(theOpCode,
opPos,
opPos + theOpDisplacement);
}
else
{
m_expression->updateOpCodeLength(theOpCode,
opPos);
}
// Accumulate the displacement.
theOpDisplacement += theLocalDisplacement;
}
}
return theOpDisplacement;
}
int
XPathProcessorImpl::MultiplicativeExpr(int opCodePos)
{
int theOpDisplacement = 0;
const int opPos = opCodePos != -1 ? opCodePos :
m_expression->opCodeMapLength();
UnaryExpr();
if(0 != length(m_token))
{
XPathExpression::eOpCodes theOpCode =
XPathExpression::eENDOP;
if(tokenIs('*') == true)
{
theOpCode = XPathExpression::eOP_MULT;
}
else if(tokenIs("div") == true)
{
theOpCode = XPathExpression::eOP_DIV;
}
else if(tokenIs("mod") == true)
{
theOpCode = XPathExpression::eOP_MOD;
}
else if(tokenIs("quo") == true)
{
theOpCode = XPathExpression::eOP_QUO;
}
if (theOpCode != XPathExpression::eENDOP)
{
nextToken();
// Save the number of bytes we inserted
// into the map.
const int theLocalDisplacement =
m_expression->insertOpCode(theOpCode,
opPos);
// Update the length
m_expression->updateOpCodeLength(theOpCode,
opPos);
// Do the right term of the expression.
theOpDisplacement += MultiplicativeExpr(opPos);
// If there's any displacement from the right
// term, update the length for a shift. Otherwise,
// just update the length.
if (theOpDisplacement > 0)
{
m_expression->updateShiftedOpCodeLength(theOpCode,
opPos,
opPos + theOpDisplacement);
}
else
{
m_expression->updateOpCodeLength(theOpCode,
opPos);
}
// Accumulate the displacement.
theOpDisplacement += theLocalDisplacement;
}
}
return theOpDisplacement;
}
void
XPathProcessorImpl::UnaryExpr()
{
const int opPos = m_expression->opCodeMapLength();
bool isNeg = false;
if(m_tokenChar == '-')
{
nextToken();
m_expression->insertOpCode(XPathExpression::eOP_NEG,
opPos);
isNeg = true;
}
UnionExpr();
if(isNeg == true)
{
m_expression->updateOpCodeLength(XPathExpression::eOP_NEG,
opPos);
}
}
void
XPathProcessorImpl::StringExpr()
{
const int opPos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eOP_STRING);
Expr();
// $$$ ToDo: Is this really necessary?
m_expression->updateOpCodeLength(XPathExpression::eOP_STRING,
opPos);
}
void
XPathProcessorImpl::BooleanExpr()
{
const int opPos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eOP_BOOL);
Expr();
const int opLen = m_expression->opCodeMapLength() - opPos;
if(opLen == 2)
{
error("boolean(...) argument is no longer optional with
19990709 XPath draft.");
}
m_expression->updateOpCodeLength(XPathExpression::eOP_BOOL,
opPos);
}
void
XPathProcessorImpl::NumberExpr()
{
const int opPos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eOP_NUMBER);
Expr();
m_expression->updateOpCodeLength(XPathExpression::eOP_NUMBER,
opPos);
}
void
XPathProcessorImpl::UnionExpr()
{
const int opPos = m_expression->opCodeMapLength();
bool continueOrLoop = true;
bool foundUnion = false;
do
{
PathExpr();
if(tokenIs('|') == true)
{
if(false == foundUnion)
{
foundUnion = true;
m_expression->insertOpCode(XPathExpression::eOP_UNION,
opPos);
}
nextToken();
}
else
{
break;
}
// this.m_testForDocOrder = true;
}
while(continueOrLoop == true);
m_expression->updateOpCodeLength(opPos);
}
void
XPathProcessorImpl::PathExpr()
{
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
FilterExpr();
if(tokenIs('/') == true)
{
nextToken();
m_expression->insertOpCode(XPathExpression::eOP_LOCATIONPATH,
opPos);
RelativeLocationPath();
m_expression->appendOpCode(XPathExpression::eENDOP);
m_expression->updateOpCodeLength(XPathExpression::eOP_LOCATIONPATH,
opPos);
}
}
void
XPathProcessorImpl::FilterExpr()
{
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
// const bool isFunc = lookahead('(', 1);
PrimaryExpr();
if(tokenIs('[') == true)
{
m_expression->insertOpCode(XPathExpression::eOP_LOCATIONPATH,
opPos);
while(tokenIs('[') == true)
{
Predicate();
}
if(tokenIs('/') == true)
{
nextToken();
RelativeLocationPath();
}
// Terminate for safety.
m_expression->appendOpCode(XPathExpression::eENDOP);
m_expression->updateOpCodeLength(XPathExpression::eOP_LOCATIONPATH,
opPos);
}
/*
if(tokenIs('[') == true)
{
Predicate();
m_expression->updateOpCodeLength(XPathExpression::eOP_LOCATIONPATH,
opPos);
}
*/
}
void
XPathProcessorImpl::PrimaryExpr()
{
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
if(m_tokenChar == '\'' || m_tokenChar == '"')
{
m_expression->appendOpCode(XPathExpression::eOP_LITERAL);
Literal();
m_expression->updateOpCodeLength(XPathExpression::eOP_LITERAL,
opPos);
}
else if(m_tokenChar == '$')
{
nextToken(); // consume '$'
m_expression->appendOpCode(XPathExpression::eOP_VARIABLE);
NCName();
m_expression->updateOpCodeLength(XPathExpression::eOP_VARIABLE,
opPos);
}
else if(m_tokenChar == '(')
{
nextToken();
m_expression->appendOpCode(XPathExpression::eOP_GROUP);
Expr();
consumeExpected(')');
m_expression->updateOpCodeLength(XPathExpression::eOP_GROUP,
opPos);
}
else if(('.' == m_tokenChar && m_token.length() > 1 &&
isDigit(charAt(m_token, 1)) == true)
|| isDigit(m_tokenChar) == true)
{
m_expression->appendOpCode(XPathExpression::eOP_NUMBERLIT);
Number();
m_expression->updateOpCodeLength(XPathExpression::eOP_NUMBERLIT,
opPos);
}
else if(lookahead('(', 1) == true ||
(lookahead(':', 1) == true && lookahead('(', 3) ==
true))
{
FunctionCall();
}
else
{
LocationPath();
}
}
void
XPathProcessorImpl::Argument()
{
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eOP_ARGUMENT);
Expr();
m_expression->updateOpCodeLength(XPathExpression::eOP_ARGUMENT,
opPos);
}
void
XPathProcessorImpl::FunctionCall()
{
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
if(lookahead(':', 1) == true)
{
m_expression->appendOpCode(XPathExpression::eOP_EXTFUNCTION);
std::vector<XPathExpression::OpCodeMapValueType>
theArgs(2);
theArgs[0] = m_expression->getTokenPosition();
nextToken();
consumeExpected(':');
theArgs[1] = m_expression->getTokenPosition();
nextToken();
m_expression->setOpCodeArgs(XPathExpression::eOP_EXTFUNCTION,
opPos,
theArgs);
}
else
{
if (isValidFunction(m_token) == false)
{
warn(DOMString("Could not find function: ") +
m_token +
DOMString("()"));
}
// $$$ ToDo: I believe that this is XSLT functionality. We
// need to figure out how to do the extensions for this stuff.
const int funcTok = getFunctionToken(m_token);
switch(funcTok)
{
case XPathExpression::eNODETYPE_PI:
case XPathExpression::eNODETYPE_COMMENT:
case XPathExpression::eNODETYPE_TEXT:
case XPathExpression::eNODETYPE_NODE:
LocationPath();
// ************** Nasty return here!!!
*********************** //
return;
break;
default:
{
// The position must be at least zero, since
// we've looked at a token.
assert(m_expression->getTokenPosition() > 0);
XPathExpression::OpCodeMapValueType
thePosition =
static_cast<XPathExpression::OpCodeMapValueType>(m_expression->getTokenPosition())
- 1;
assert(m_expression->getToken(thePosition) != 0
&&
equals(m_expression->getToken(thePosition)->str(), m_token));
std::vector<XPathExpression::OpCodeMapValueType> theArgs(1, thePosition);
m_expression->appendOpCode(XPathExpression::eOP_FUNCTION,
theArgs);
}
}
nextToken();
}
consumeExpected('(');
while(tokenIs(')') == false)
{
if(tokenIs(',') == true)
{
error("Found ',' but no preceding argument!");
}
Argument();
if(tokenIs(')') == false)
{
consumeExpected(',');
if(tokenIs(')') == true)
{
error("Found ',' but no following argument!");
}
}
}
consumeExpected(')');
// Terminate for safety.
m_expression->appendOpCode(XPathExpression::eENDOP);
m_expression->updateOpCodeLength(opPos);
}
void
XPathProcessorImpl::LocationPath()
{
const int opPos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eOP_LOCATIONPATH);
if(tokenIs('/') == true)
{
const int newOpPos = m_expression->opCodeMapLength();
std::vector<XPathExpression::OpCodeMapValueType>
theArgs(1);
// Tell how long the step is without the predicate
theArgs[0] = 4;
m_expression->appendOpCode(XPathExpression::eFROM_ROOT,
theArgs);
m_expression->appendOpCode(XPathExpression::eNODETYPE_ROOT);
// Tell how long the entire step is.
m_expression->updateOpCodeLength(newOpPos);
nextToken();
}
if(length(m_token) != 0)
{
RelativeLocationPath();
}
// Terminate for safety.
m_expression->appendOpCode(XPathExpression::eENDOP);
m_expression->updateOpCodeLength(XPathExpression::eOP_LOCATIONPATH,
opPos);
}
void
XPathProcessorImpl::RelativeLocationPath()
{
Step();
while(tokenIs('/') == true)
{
nextToken();
Step();
}
}
void
XPathProcessorImpl::Step()
{
const int opPos = m_expression->opCodeMapLength();
if(tokenIs(".") == true)
{
nextToken();
if(tokenIs('[') == true)
{
error("'..[predicate]' or '.[predicate]' is illegal
syntax. Use 'self::node()[predicate]' instead.");
}
std::vector<XPathExpression::OpCodeMapValueType>
theArgs(1);
// Tell how long the step is without the predicate
theArgs[0] = 4;
m_expression->appendOpCode(XPathExpression::eFROM_SELF,
theArgs);
m_expression->appendOpCode(XPathExpression::eNODETYPE_NODE);
}
else if(tokenIs("..") == true)
{
nextToken();
std::vector<XPathExpression::OpCodeMapValueType>
theArgs(1);
// Tell how long the step is without the predicate
theArgs[0] = 4;
m_expression->appendOpCode(XPathExpression::eFROM_PARENT,
theArgs);
m_expression->appendOpCode(XPathExpression::eNODETYPE_NODE);
}
else
{
Basis();
while(tokenIs('[') == true)
{
Predicate();
}
}
// Tell how long the entire step is.
m_expression->updateOpCodeLength(opPos);
}
void
XPathProcessorImpl::Basis()
{
assert(m_xpath != 0);
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
// The next blocks guarantee that a FROM_XXX will be added.
if(lookahead("::", 1) == true)
{
AxisName();
nextToken();
nextToken();
}
else if(tokenIs('@') == true)
{
m_expression->appendOpCode(XPathExpression::eFROM_ATTRIBUTES);
nextToken();
}
else if(tokenIs('/') == true)
{
// Have to fix up for patterns such as '//@foo' or
'//attribute::foo',
// which translate to
'descendant-or-self::node()/attribute::foo'.
// notice I leave the '/' on the queue, so the next will be
processed
// by a regular step pattern.
// if(lookahead('@', 1) == true || lookahead("::", 2) == true)
{
std::vector<XPathExpression::OpCodeMapValueType>
theArgs(1);
// Tell how long the step is without the predicate
theArgs[0] = 4;
m_expression->appendOpCode(XPathExpression::eFROM_DESCENDANTS_OR_SELF,
theArgs);
m_expression->appendOpCode(XPathExpression::eNODETYPE_NODE);
// Tell how long the step is without the predicate
m_expression->updateOpCodeLengthAfterNodeTest(opPos);
return; // make a quick exit...
}
//else
//{
// nextToken();
//}
}
else
{
m_expression->appendOpCode(XPathExpression::eFROM_CHILDREN);
}
NodeTest();
// Tell how long the step is without the predicate
m_expression->updateOpCodeLengthAfterNodeTest(opPos);
}
void
XPathProcessorImpl::AxisName()
{
assert(m_xpath != 0);
assert(m_expression != 0);
AxisNamesMapType::const_iterator i =
s_axisNames.find(m_token);
if (i == s_axisNames.end())
{
error(DOMString("illegal axis name: ") +
m_token);
}
else
{
m_expression->appendOpCode((*i).second);
}
}
void
XPathProcessorImpl::NodeTest()
{
assert(m_xpath != 0);
assert(m_expression != 0);
if(lookahead('(', 1) == true)
{
NodeTypesMapType::const_iterator i =
s_nodeTypes.find(m_token);
if (i == s_nodeTypes.end())
{
error(DOMString("Unknown nodetype: ") +
m_token);
}
else
{
nextToken();
m_expression->appendOpCode((*i).second);
consumeExpected('(');
if(XPathExpression::eNODETYPE_PI == (*i).second)
{
if(tokenIs(')') == false)
{
Literal();
}
}
consumeExpected(')');
}
}
else
{
// Assume name of attribute or element.
m_expression->appendOpCode(XPathExpression::eNODENAME);
if(lookahead(':', 1) == true)
{
if(tokenIs('*') == true)
{
m_expression->appendOpCode(XPathExpression::eELEMWILDCARD);
}
else
{
m_expression->pushCurrentTokenOnOpCodeMap();
}
nextToken();
consumeExpected(':');
}
else
{
m_expression->appendOpCode(XPathExpression::eEMPTY);
}
if(tokenIs('*') == true)
{
m_expression->appendOpCode(XPathExpression::eELEMWILDCARD);
}
else
{
m_expression->pushCurrentTokenOnOpCodeMap();
}
nextToken();
}
}
void
XPathProcessorImpl::Predicate()
{
if(tokenIs('[') == true)
{
nextToken();
PredicateExpr();
consumeExpected(']');
}
}
void
XPathProcessorImpl::PredicateExpr()
{
assert(m_xpath != 0);
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eOP_PREDICATE);
Expr();
// Terminate for safety.
m_expression->appendOpCode(XPathExpression::eENDOP);
m_expression->updateOpCodeLength(XPathExpression::eOP_PREDICATE,
opPos);
}
void
XPathProcessorImpl::QName()
{
assert(m_xpath != 0);
assert(m_expression != 0);
m_expression->pushCurrentTokenOnOpCodeMap();
nextToken();
consumeExpected(':');
m_expression->pushCurrentTokenOnOpCodeMap();
nextToken();
}
void
XPathProcessorImpl::NCName()
{
assert(m_xpath != 0);
assert(m_expression != 0);
m_expression->pushCurrentTokenOnOpCodeMap();
nextToken();
}
void
XPathProcessorImpl::Literal()
{
assert(m_xpath != 0);
assert(m_expression != 0);
const int last = length(m_token) - 1;
assert(last > 0);
const XMLCh c0 = m_tokenChar;
const XMLCh cX = charAt(m_token, last);
if((c0 == '\"' && cX == '\"') ||
(c0 == '\'' && cX == '\''))
{
XObject* const theArgument =
m_xpath->getXObjectFactory().createString(substring(m_token, 1, last));
m_expression->pushArgumentOnOpCodeMap(theArgument);
nextToken();
}
else
{
error(DOMString("Pattern literal (") +
m_token +
DOMString(") needs to be quoted!"));
}
}
void
XPathProcessorImpl::Number()
{
assert(m_xpath != 0);
assert(m_expression != 0);
if(0 != length(m_token))
{
// Mutate the token to remove the quotes and have the XNumber
object
// already made.
const double num = DOMStringToDouble(m_token);
XObject* const theArgument =
m_xpath->getXObjectFactory().createNumber(num);
m_expression->pushArgumentOnOpCodeMap(theArgument);
nextToken();
}
}
void
XPathProcessorImpl::Pattern()
{
while(true)
{
LocationPathPattern();
if(tokenIs('|') == true)
{
nextToken();
}
else
{
break;
}
}
}
void
XPathProcessorImpl::LocationPathPattern()
{
assert(m_xpath != 0);
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eOP_LOCATIONPATHPATTERN);
// These token FUNC_KEY_STRING should not be here, as it is really
// part of the XSLT standard, and not the XPATH standard.
if(lookahead('(', 1) == true &&
tokenIs(FUNC_ID_STRING) == true ||
tokenIs(FUNC_KEY_STRING) == true)
{
IdKeyPattern();
}
if(tokenIs('/') == true)
{
const int newOpPos = m_expression->opCodeMapLength();
std::vector<XPathExpression::OpCodeMapValueType>
theArgs(1);
// Tell how long the step is without the predicate
theArgs[0] = 4;
if(lookahead('/', 1) == true)
{
m_expression->appendOpCode(XPathExpression::eMATCH_ANY_ANCESTOR_WITH_PREDICATE,
theArgs);
}
else
{
m_expression->appendOpCode(XPathExpression::eFROM_ROOT,
theArgs);
}
m_expression->appendOpCode(XPathExpression::eNODETYPE_ROOT);
m_expression->updateOpCodeLength(newOpPos);
nextToken();
}
if(!tokenIs('|') == true && length(m_token) != 0)
{
RelativePathPattern();
}
// Terminate for safety.
m_expression->appendOpCode(XPathExpression::eENDOP);
m_expression->updateOpCodeLength(XPathExpression::eOP_LOCATIONPATHPATTERN,
opPos);
}
void
XPathProcessorImpl::IdKeyPattern()
{
FunctionCall();
}
void
XPathProcessorImpl::RelativePathPattern()
{
StepPattern();
while(tokenIs('/') == true)
{
nextToken();
StepPattern();
}
}
void
XPathProcessorImpl::StepPattern()
{
AbbreviatedNodeTestStep();
}
void
XPathProcessorImpl::AbbreviatedNodeTestStep()
{
assert(m_xpath != 0);
assert(m_expression != 0);
const int opPos = m_expression->opCodeMapLength();
int matchTypePos = -1;
// The next blocks guarantee that a MATCH_XXX will be added.
if(tokenIs('@') == true)
{
m_expression->appendOpCode(XPathExpression::eMATCH_ATTRIBUTE);
nextToken();
}
else if(tokenIs('/') == true)
{
m_expression->appendOpCode(XPathExpression::eMATCH_ANY_ANCESTOR);
nextToken();
}
else
{
if(tokenIs('/') == true)
{
nextToken();
}
matchTypePos = m_expression->opCodeMapLength();
m_expression->appendOpCode(XPathExpression::eMATCH_IMMEDIATE_ANCESTOR);
}
// Make room for telling how long the step is without the predicate.
// This will be replaced by the right value.
m_expression->appendOpCode(XPathExpression::eENDOP);
NodeTest();
m_expression->updateOpCodeLengthAfterNodeTest(opPos);
while(tokenIs('[') == true)
{
Predicate();
}
if(matchTypePos > -1 && tokenIs('/') == true && lookahead('/', 1) ==
true)
{
assert(m_expression->opCodeMapLength() > matchTypePos);
m_expression->m_opMap[matchTypePos] =
XPathExpression::eMATCH_ANY_ANCESTOR;
}
m_expression->updateOpCodeLength(opPos);
}
bool
XPathProcessorImpl::isValidFunction(const DOMString& key) const
{
bool fResult = true;
if(XPath::isInstalledFunction(key) == false)
{
if (getFunctionToken(key) == 0)
{
fResult = false;
}
}
return fResult;
}
#if 0
// ============= GRAMMAR FUNCTIONS =================
private void ____DIAGNOSTIC_FUNCTIONS____(){}
public static void diagnoseXPathString( String str )
{
XPathSupport callbacks = new XPathSupportDefault();
XPathProcessorImpl processor = new XPathProcessorImpl(callbacks);
XPath xpath = new XPath(callbacks);
processor.initXPath(xpath, str, null);
processor.diagnoseXPath(xpath, 0, 0);
}
static int diagnoseXPathBinaryOperation(String op, XPath xpath, int opPos,
int indent)
{
System.out.println(op+" {");
opPos+=2;
opPos = diagnoseXPath(xpath, opPos, indent+1);
opPos = diagnoseXPath(xpath, opPos, indent+1);
indent(indent);
System.out.println("}");
return opPos;
}
static int diagnoseXPathUnaryOperation(String op, XPath xpath, int opPos,
int indent)
{
System.out.println(op+" {");
opPos+=2;
opPos = diagnoseXPath(xpath, opPos, indent+1);
indent(indent);
System.out.println("}");
return opPos;
}
static int diagnoseXPathMultiOperation(String op, int multiOp, XPath xpath,
int opPos, int indent)
{
System.out.println(op+" {");
opPos+=2;
while(xpath.m_opMap[opPos] == multiOp)
{
indent(indent+1);
System.out.println("{");
opPos = diagnoseXPath(xpath, opPos, indent+2);
indent(indent+1);
System.out.println("}");
}
indent(indent);
System.out.println("}");
return opPos;
}
static int diagnoseToken(XPath xpath, int opPos)
{
System.out.print("{");
System.out.print(xpath.m_tokenQueue[xpath.m_opMap[opPos]]);
System.out.print("}");
return opPos+1;
}
static int diagnoseXPathSimpleOperation(String op, XPath xpath, int opPos,
int indent)
{
opPos+=2;
System.out.print(op);
opPos = diagnoseToken(xpath, opPos);
System.out.println("");
return opPos;
}
static int diagnoseXPathLocationStep(String op, XPath xpath, int opPos, int
indent)
{
// int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
int stepLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1];
opPos+=3;
System.out.print(op);
if(stepLen > 3)
{
opPos = diagnoseXPath(xpath, opPos, 1);
}
System.out.println("");
return opPos;
}
static int diagnoseXPath(XPath xpath, int opPos, int indent)
{
indent(indent);
switch(xpath.m_opMap[opPos])
{
case xpath.OP_XPATH:
opPos = diagnoseXPathUnaryOperation("OP_XPATH", xpath, opPos, indent);
break;
case xpath.EMPTY:
System.out.println("{EMPTY}");
opPos++;
break;
case xpath.OP_OR:
opPos = diagnoseXPathBinaryOperation("OP_OR", xpath, opPos, indent);
break;
case xpath.OP_AND:
opPos = diagnoseXPathBinaryOperation("OP_AND", xpath, opPos, indent);
break;
case xpath.OP_NOTEQUALS:
opPos = diagnoseXPathBinaryOperation("OP_NOTEQUALS", xpath, opPos,
indent);
break;
case xpath.OP_EQUALS:
opPos = diagnoseXPathBinaryOperation("OP_EQUALS", xpath, opPos,
indent);
break;
case xpath.OP_LTE:
opPos = diagnoseXPathBinaryOperation("OP_LTE", xpath, opPos, indent);
break;
case xpath.OP_LT:
opPos = diagnoseXPathBinaryOperation("OP_LT", xpath, opPos, indent);
break;
case xpath.OP_GTE:
opPos = diagnoseXPathBinaryOperation("OP_GTE", xpath, opPos, indent);
break;
case xpath.OP_GT:
opPos = diagnoseXPathBinaryOperation("OP_GT", xpath, opPos, indent);
break;
case xpath.OP_PLUS:
opPos = diagnoseXPathBinaryOperation("OP_PLUS", xpath, opPos, indent);
break;
case xpath.OP_MINUS:
opPos = diagnoseXPathBinaryOperation("OP_MINUS", xpath, opPos,
indent);
break;
case xpath.OP_MULT:
opPos = diagnoseXPathBinaryOperation("OP_MULT", xpath, opPos, indent);
break;
case xpath.OP_DIV:
opPos = diagnoseXPathBinaryOperation("OP_DIV", xpath, opPos, indent);
break;
case xpath.OP_MOD:
opPos = diagnoseXPathBinaryOperation("OP_MOD", xpath, opPos, indent);
break;
case xpath.OP_QUO:
opPos = diagnoseXPathBinaryOperation("OP_QUO", xpath, opPos, indent);
break;
case xpath.OP_NEG:
opPos = diagnoseXPathUnaryOperation("OP_NEG", xpath, opPos, indent);
break;
case xpath.OP_STRING:
opPos = diagnoseXPathUnaryOperation("OP_STRING", xpath, opPos,
indent);
break;
case xpath.OP_BOOL:
opPos = diagnoseXPathUnaryOperation("OP_BOOL", xpath, opPos, indent);
break;
case xpath.OP_NUMBER:
opPos = diagnoseXPathUnaryOperation("OP_NUMBER", xpath, opPos,
indent);
break;
case xpath.OP_UNION:
opPos = diagnoseXPathMultiOperation("OP_UNION",
xpath.OP_LOCATIONPATH, xpath, opPos, indent);
break;
case xpath.OP_LITERAL:
opPos = diagnoseXPathSimpleOperation("OP_LITERAL", xpath, opPos,
indent);
break;
case xpath.OP_VARIABLE:
opPos = diagnoseXPathSimpleOperation("OP_VARIABLE", xpath, opPos,
indent);
break;
case xpath.OP_GROUP:
opPos = diagnoseXPathUnaryOperation("OP_GROUP", xpath, opPos, indent);
break;
case xpath.OP_NUMBERLIT:
opPos = diagnoseXPathSimpleOperation("OP_NUMBERLIT", xpath, opPos,
indent);
break;
case xpath.OP_ARGUMENT:
opPos = diagnoseXPathUnaryOperation("OP_ARGUMENT", xpath, opPos,
indent);
break;
case xpath.OP_EXTFUNCTION:
{
System.out.println("OP_EXTFUNCTION {");
int endExtFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
indent(indent+1);
opPos = diagnoseToken(xpath, opPos);
System.out.print(":");
opPos = diagnoseToken(xpath, opPos);
System.out.println("");
while(opPos < endExtFunc)
{
indent(indent+1);
System.out.println("{");
opPos = diagnoseXPath(xpath, opPos, indent+2);
indent(indent+1);
System.out.println("}");
}
indent(indent);
System.out.println("}");
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
}
break;
case xpath.OP_FUNCTION:
{
System.out.println("OP_FUNCTION {");
int endFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
indent(indent+1);
int funcID = xpath.m_opMap[opPos];
switch(funcID)
{
case xpath.FUNC_LAST: System.out.print("FUNC_LAST"); break;
case xpath.FUNC_POSITION: System.out.print("FUNC_POSITION");
break;
case xpath.FUNC_COUNT: System.out.print("FUNC_COUNT"); break;
case xpath.FUNC_ID: System.out.print("FUNC_ID"); break;
case xpath.FUNC_KEY: System.out.print("FUNC_KEY"); break;
case xpath.FUNC_DOC: System.out.print("FUNC_DOC"); break;
case xpath.FUNC_LOCAL_PART:
System.out.print("FUNC_LOCAL_PART"); break;
case xpath.FUNC_NAMESPACE: System.out.print("FUNC_NAMESPACE");
break;
case xpath.FUNC_QNAME: System.out.print("FUNC_QNAME"); break;
case xpath.FUNC_GENERATE_ID:
System.out.print("FUNC_GENERATE_ID"); break;
case xpath.FUNC_NOT: System.out.print("FUNC_NOT"); break;
case xpath.FUNC_TRUE: System.out.print("FUNC_TRUE"); break;
case xpath.FUNC_FALSE: System.out.print("FUNC_FALSE"); break;
case xpath.FUNC_BOOLEAN: System.out.print("FUNC_BOOLEAN");
break;
case xpath.FUNC_LANG: System.out.print("FUNC_LANG"); break;
case xpath.FUNC_NUMBER: System.out.print("FUNC_NUMBER"); break;
case xpath.FUNC_FLOOR: System.out.print("FUNC_FLOOR"); break;
case xpath.FUNC_CEILING: System.out.print("FUNC_CEILING");
break;
case xpath.FUNC_ROUND: System.out.print("FUNC_ROUND"); break;
case xpath.FUNC_SUM: System.out.print("FUNC_SUM"); break;
case xpath.FUNC_STRING: System.out.print("FUNC_STRING"); break;
case xpath.FUNC_STARTS_WITH:
System.out.print("FUNC_STARTS_WITH"); break;
case xpath.FUNC_CONTAINS: System.out.print("FUNC_CONTAINS");
break;
case xpath.FUNC_SUBSTRING_BEFORE:
System.out.print("FUNC_SUBSTRING_BEFORE"); break;
case xpath.FUNC_SUBSTRING_AFTER:
System.out.print("FUNC_SUBSTRING_AFTER"); break;
case xpath.FUNC_NORMALIZE: System.out.print("FUNC_NORMALIZE");
break;
case xpath.FUNC_TRANSLATE: System.out.print("FUNC_TRANSLATE");
break;
case xpath.FUNC_CONCAT: System.out.print("FUNC_CONCAT"); break;
case xpath.FUNC_FORMAT_NUMBER:
System.out.print("FUNC_FORMAT_NUMBER"); break;
case xpath.FUNC_SYSTEM_PROPERTY:
System.out.print("FUNC_SYSTEM_PROPERTY"); break;
case xpath.FUNC_EXT_FUNCTION_AVAILABLE:
System.out.print("FUNC_EXT_FUNCTION_AVAILABLE"); break;
case xpath.FUNC_EXT_ELEM_AVAILABLE:
System.out.print("FUNC_EXT_ELEM_AVAILABLE"); break;
case xpath.FUNC_SUBSTRING: System.out.print("FUNC_SUBSTRING");
break;
case xpath.FUNC_STRING_LENGTH:
System.out.print("FUNC_STRING_LENGTH"); break;
case xpath.FUNC_DOCLOCATION:
System.out.print("FUNC_DOCLOCATION"); break;
}
opPos++;
System.out.println("");
while(opPos < endFunc)
{
indent(indent+1);
System.out.println("{");
opPos = diagnoseXPath(xpath, opPos, indent+2);
indent(indent+1);
System.out.println("}");
}
indent(indent);
System.out.println("}");
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
}
break;
case xpath.OP_LOCATIONPATH:
System.out.println("OP_LOCATIONPATH"+" {");
int endPath = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
while(opPos < endPath)
{
opPos = diagnoseXPath(xpath, opPos, indent+1);
}
indent(indent);
System.out.println("}");
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
break;
case xpath.OP_PREDICATE:
opPos = diagnoseXPathUnaryOperation("OP_PREDICATE", xpath, opPos,
indent);
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
break;
case xpath.FROM_ANCESTORS:
opPos = diagnoseXPathLocationStep("FROM_ANCESTORS", xpath, opPos, 1);
break;
case xpath.FROM_ANCESTORS_OR_SELF:
opPos = diagnoseXPathLocationStep("FROM_ANCESTORS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_ATTRIBUTES:
opPos = diagnoseXPathLocationStep("FROM_ATTRIBUTES", xpath, opPos, 1);
break;
case xpath.FROM_CHILDREN:
opPos = diagnoseXPathLocationStep("FROM_CHILDREN", xpath, opPos, 1);
break;
case xpath.FROM_DESCENDANTS:
opPos = diagnoseXPathLocationStep("FROM_DESCENDANTS", xpath, opPos,
1);
break;
case xpath.FROM_DESCENDANTS_OR_SELF:
opPos = diagnoseXPathLocationStep("FROM_DESCENDANTS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_FOLLOWING:
opPos = diagnoseXPathLocationStep("FROM_FOLLOWING", xpath, opPos,
indent);
break;
case xpath.FROM_FOLLOWING_SIBLINGS:
opPos = diagnoseXPathLocationStep("FROM_FOLLOWING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_PARENT:
opPos = diagnoseXPathLocationStep("FROM_PARENT", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING:
opPos = diagnoseXPathLocationStep("FROM_PRECEDING", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING_SIBLINGS:
opPos = diagnoseXPathLocationStep("FROM_PRECEDING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_SELF:
opPos = diagnoseXPathLocationStep("FROM_SELF", xpath, opPos, indent);
break;
case xpath.FROM_NAMESPACE:
opPos = diagnoseXPathLocationStep("FROM_NAMESPACE", xpath, opPos,
indent);
break;
// case xpath.FROM_ATTRIBUTE:
// opPos = diagnoseXPathLocationStep("FROM_ATTRIBUTE", xpath,
opPos, indent);
// break;
// case xpath.FROM_DOC:
// opPos = diagnoseXPathLocationStep("FROM_DOC", xpath, opPos,
indent);
// break;
// case xpath.FROM_DOCREF:
// opPos = diagnoseXPathLocationStep("FROM_DOCREF", xpath, opPos,
indent);
// break;
// case xpath.FROM_ID:
// opPos = diagnoseXPathLocationStep("FROM_ID", xpath, opPos,
indent);
// break;
// case xpath.FROM_IDREF:
// opPos = diagnoseXPathLocationStep("FROM_IDREF", xpath, opPos,
indent);
// break;
case xpath.FROM_ROOT:
opPos = diagnoseXPathLocationStep("FROM_ROOT", xpath, opPos, indent);
break;
case xpath.NODETYPE_COMMENT:
System.out.println("{NODETYPE_COMMENT}");
opPos++;
break;
case xpath.NODETYPE_TEXT:
System.out.println("{NODETYPE_TEXT}");
opPos++;
break;
case xpath.NODETYPE_PI:
int piLen = xpath.m_opMap[opPos-1];
System.out.println("{NODETYPE_PI ");
opPos++;
if(piLen > 3)
{
opPos = diagnoseToken(xpath, opPos);
}
break;
case xpath.NODETYPE_NODE:
System.out.println("{NODETYPE_NODE}");
opPos++;
break;
case xpath.NODETYPE_ROOT:
System.out.println("{NODETYPE_ROOT}");
opPos++;
break;
case xpath.NODETYPE_ANYELEMENT:
System.out.println("{NODETYPE_ANYELEMENT}");
opPos++;
break;
case xpath.NODENAME:
System.out.print("{NODENAME ");
opPos++;
if(xpath.m_opMap[opPos] < 0)
{
System.out.print("{EMPTY}");
opPos++;
}
else
{
opPos = diagnoseToken(xpath, opPos);
}
System.out.print(":");
opPos = diagnoseToken(xpath, opPos);
break;
default:
System.out.println("ERROR! Unknown op code: "+xpath.m_opMap[opPos]);
}
return opPos;
}
static void indent(int amount)
{
int n = amount * 3;
for(int i = 0; i < n; i ++)
{
System.out.print(" ");
}
}
private static String m_opLabel = "[";
private static String m_lenLabel = "[";
private static String m_arglenLabel = "[";
private static String m_noLabel = "[";
private static String m_nTestLabel = "[";
private static String m_open = "[";
private static String m_close = "]";
public static void diagnoseXPathString2( String str )
{
XPathSupport callbacks = new XPathSupportDefault();
XPathProcessorImpl processor = new XPathProcessorImpl(callbacks);
XPath xpath = new XPath(callbacks);
processor.initXPath(xpath, str, null);
processor.diagnoseXPath2(xpath, 0, 0);
}
public static void diagnoseXPathString3( String str )
{
XPathSupport callbacks = new XPathSupportDefault();
XPathProcessorImpl processor = new XPathProcessorImpl(callbacks);
XPath xpath = new XPath(callbacks);
processor.initXPath(xpath, str, null);
int len = xpath.m_opMap[xpath.MAPINDEX_LENGTH];
for(int i = 0; i < len; i++)
{
System.out.println("["+xpath.m_opMap[i]+"]");
}
}
private static void diagnoseNodeTest2(int opPos, String op)
{
System.out.print(m_nTestLabel+op+m_close);
}
private static void diagnoseOpNoLable2(int opPos, String op)
{
System.out.println(m_noLabel+op+m_close);
}
private static void diagnoseOpOnly2(int opPos, String op)
{
System.out.println(m_opLabel+op+m_close);
}
private static void diagnoseOp2(String op, XPath xpath, int opPos)
{
System.out.print(m_opLabel+op+m_close);
int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
System.out.println(m_open+opLen+m_close);
}
private static void diagnoseOp2SameLine(String op, XPath xpath, int opPos)
{
System.out.print(m_opLabel+op+m_close);
int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
System.out.print(m_open+opLen+m_close);
}
static int diagnoseXPathBinaryOperation2(String op, XPath xpath, int opPos,
int indent)
{
diagnoseOp2(op, xpath, opPos);
opPos+=2;
opPos = diagnoseXPath2(xpath, opPos, indent+1);
opPos = diagnoseXPath2(xpath, opPos, indent+1);
return opPos;
}
static int diagnoseXPathUnaryOperation2(String op, XPath xpath, int opPos,
int indent)
{
diagnoseOp2(op, xpath, opPos);
opPos+=2;
opPos = diagnoseXPath2(xpath, opPos, indent+1);
return opPos;
}
static int diagnoseXPathMultiOperation2(String op, int multiOp, XPath
xpath, int opPos, int indent)
{
diagnoseOp2(op, xpath, opPos);
opPos+=2;
while(xpath.m_opMap[opPos] == multiOp)
{
opPos = diagnoseXPath2(xpath, opPos, indent+2);
}
return opPos;
}
static int diagnoseToken2(XPath xpath, int opPos)
{
int tokenPos = xpath.m_opMap[opPos];
String token = (tokenPos >= 0) ?
xpath.m_tokenQueue[tokenPos].toString() :
(tokenPos == xpath.ELEMWILDCARD) ?
"*" :
(tokenPos == xpath.EMPTY) ?
"EMPTY" : "UNKNOWN";
System.out.println(m_noLabel+token+m_close);
return opPos+1;
}
static int diagnoseToken2SameLine(XPath xpath, int opPos)
{
System.out.print(m_noLabel+xpath.m_tokenQueue[xpath.m_opMap[opPos]]+m_close);
return opPos+1;
}
static int diagnoseXPathSimpleOperation2(String op, XPath xpath, int opPos,
int indent)
{
diagnoseOp2SameLine(op, xpath, opPos);
opPos+=2;
opPos = diagnoseToken2(xpath, opPos);
return opPos;
}
static int diagnoseXPathLocationStep2(String op, XPath xpath, int opPos,
int indent)
{
int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
int stepLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1];
System.out.print(m_opLabel+op+m_close);
System.out.print(m_open+opLen+m_close);
System.out.print(m_open+stepLen+m_close);
opPos+=3;
if(stepLen > 3)
{
opPos = diagnoseXPath2(xpath, opPos, 0);
}
return opPos;
}
static int diagnoseXPath2(XPath xpath, int opPos, int indent)
{
indent(indent);
switch(xpath.m_opMap[opPos])
{
case xpath.OP_XPATH:
opPos = diagnoseXPathUnaryOperation2("OP_XPATH", xpath, opPos,
indent);
break;
case xpath.EMPTY:
diagnoseOpOnly2(opPos, "EMPTY");
opPos++;
break;
case xpath.OP_OR:
opPos = diagnoseXPathBinaryOperation2("OP_OR", xpath, opPos, indent);
break;
case xpath.OP_AND:
opPos = diagnoseXPathBinaryOperation2("OP_AND", xpath, opPos, indent);
break;
case xpath.OP_NOTEQUALS:
opPos = diagnoseXPathBinaryOperation2("OP_NOTEQUALS", xpath, opPos,
indent);
break;
case xpath.OP_EQUALS:
opPos = diagnoseXPathBinaryOperation2("OP_EQUALS", xpath, opPos,
indent);
break;
case xpath.OP_LTE:
opPos = diagnoseXPathBinaryOperation2("OP_LTE", xpath, opPos, indent);
break;
case xpath.OP_LT:
opPos = diagnoseXPathBinaryOperation2("OP_LT", xpath, opPos, indent);
break;
case xpath.OP_GTE:
opPos = diagnoseXPathBinaryOperation2("OP_GTE", xpath, opPos, indent);
break;
case xpath.OP_GT:
opPos = diagnoseXPathBinaryOperation2("OP_GT", xpath, opPos, indent);
break;
case xpath.OP_PLUS:
opPos = diagnoseXPathBinaryOperation2("OP_PLUS", xpath, opPos,
indent);
break;
case xpath.OP_MINUS:
opPos = diagnoseXPathBinaryOperation2("OP_MINUS", xpath, opPos,
indent);
break;
case xpath.OP_MULT:
opPos = diagnoseXPathBinaryOperation2("OP_MULT", xpath, opPos,
indent);
break;
case xpath.OP_DIV:
opPos = diagnoseXPathBinaryOperation2("OP_DIV", xpath, opPos, indent);
break;
case xpath.OP_MOD:
opPos = diagnoseXPathBinaryOperation2("OP_MOD", xpath, opPos, indent);
break;
case xpath.OP_QUO:
opPos = diagnoseXPathBinaryOperation2("OP_QUO", xpath, opPos, indent);
break;
case xpath.OP_NEG:
opPos = diagnoseXPathUnaryOperation2("OP_NEG", xpath, opPos, indent);
break;
case xpath.OP_STRING:
opPos = diagnoseXPathUnaryOperation2("OP_STRING", xpath, opPos,
indent);
break;
case xpath.OP_BOOL:
opPos = diagnoseXPathUnaryOperation2("OP_BOOL", xpath, opPos, indent);
break;
case xpath.OP_NUMBER:
opPos = diagnoseXPathUnaryOperation2("OP_NUMBER", xpath, opPos,
indent);
break;
case xpath.OP_UNION:
opPos = diagnoseXPathMultiOperation2("OP_UNION",
xpath.OP_LOCATIONPATH, xpath, opPos, indent);
break;
case xpath.OP_LITERAL:
opPos = diagnoseXPathSimpleOperation2("OP_LITERAL", xpath, opPos,
indent);
break;
case xpath.OP_VARIABLE:
opPos = diagnoseXPathSimpleOperation2("OP_VARIABLE", xpath, opPos,
indent);
break;
case xpath.OP_GROUP:
opPos = diagnoseXPathUnaryOperation2("OP_GROUP", xpath, opPos,
indent);
break;
case xpath.OP_NUMBERLIT:
opPos = diagnoseXPathSimpleOperation2("OP_NUMBERLIT", xpath, opPos,
indent);
break;
case xpath.OP_ARGUMENT:
opPos = diagnoseXPathUnaryOperation2("OP_ARGUMENT", xpath, opPos,
indent);
break;
case xpath.OP_EXTFUNCTION:
{
diagnoseOp2SameLine("OP_EXTFUNCTION", xpath, opPos);
int endExtFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
opPos = diagnoseToken2SameLine(xpath, opPos);
opPos = diagnoseToken2(xpath, opPos);
while(opPos < endExtFunc)
{
opPos = diagnoseXPath2(xpath, opPos, indent+2);
}
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+1);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
}
break;
case xpath.OP_FUNCTION:
{
diagnoseOp2SameLine("OP_FUNCTION", xpath, opPos);
int endFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
int funcID = xpath.m_opMap[opPos];
switch(funcID)
{
case xpath.FUNC_LAST: diagnoseOpNoLable2(opPos, "FUNC_LAST");
break;
case xpath.FUNC_POSITION: diagnoseOpNoLable2(opPos,
"FUNC_POSITION"); break;
case xpath.FUNC_COUNT: diagnoseOpNoLable2(opPos, "FUNC_COUNT");
break;
case xpath.FUNC_ID: diagnoseOpNoLable2(opPos, "FUNC_ID"); break;
case xpath.FUNC_KEY: diagnoseOpNoLable2(opPos, "FUNC_KEY");
break;
case xpath.FUNC_DOC: diagnoseOpNoLable2(opPos, "FUNC_DOC");
break;
case xpath.FUNC_LOCAL_PART: diagnoseOpNoLable2(opPos,
"FUNC_LOCAL_PART"); break;
case xpath.FUNC_NAMESPACE: diagnoseOpNoLable2(opPos,
"FUNC_NAMESPACE"); break;
case xpath.FUNC_QNAME: diagnoseOpNoLable2(opPos, "FUNC_QNAME");
break;
case xpath.FUNC_GENERATE_ID: diagnoseOpNoLable2(opPos,
"FUNC_GENERATE_ID"); break;
case xpath.FUNC_NOT: diagnoseOpNoLable2(opPos, "FUNC_NOT");
break;
case xpath.FUNC_TRUE: diagnoseOpNoLable2(opPos, "FUNC_TRUE");
break;
case xpath.FUNC_FALSE: diagnoseOpNoLable2(opPos, "FUNC_FALSE");
break;
case xpath.FUNC_BOOLEAN: diagnoseOpNoLable2(opPos,
"FUNC_BOOLEAN"); break;
case xpath.FUNC_LANG: diagnoseOpNoLable2(opPos, "FUNC_LANG");
break;
case xpath.FUNC_NUMBER: diagnoseOpNoLable2(opPos,
"FUNC_NUMBER"); break;
case xpath.FUNC_FLOOR: diagnoseOpNoLable2(opPos, "FUNC_FLOOR");
break;
case xpath.FUNC_CEILING: diagnoseOpNoLable2(opPos,
"FUNC_CEILING"); break;
case xpath.FUNC_ROUND: diagnoseOpNoLable2(opPos, "FUNC_ROUND");
break;
case xpath.FUNC_SUM: diagnoseOpNoLable2(opPos, "FUNC_SUM");
break;
case xpath.FUNC_STRING: diagnoseOpNoLable2(opPos,
"FUNC_STRING"); break;
case xpath.FUNC_STARTS_WITH: diagnoseOpNoLable2(opPos,
"FUNC_STARTS_WITH"); break;
case xpath.FUNC_CONTAINS: diagnoseOpNoLable2(opPos,
"FUNC_CONTAINS"); break;
case xpath.FUNC_SUBSTRING_BEFORE: diagnoseOpNoLable2(opPos,
"FUNC_SUBSTRING_BEFORE"); break;
case xpath.FUNC_SUBSTRING_AFTER: diagnoseOpNoLable2(opPos,
"FUNC_SUBSTRING_AFTER"); break;
case xpath.FUNC_NORMALIZE: diagnoseOpNoLable2(opPos,
"FUNC_NORMALIZE"); break;
case xpath.FUNC_TRANSLATE: diagnoseOpNoLable2(opPos,
"FUNC_TRANSLATE"); break;
case xpath.FUNC_CONCAT: diagnoseOpNoLable2(opPos,
"FUNC_CONCAT"); break;
case xpath.FUNC_FORMAT_NUMBER: diagnoseOpNoLable2(opPos,
"FUNC_FORMAT_NUMBER"); break;
case xpath.FUNC_SYSTEM_PROPERTY: diagnoseOpNoLable2(opPos,
"FUNC_SYSTEM_PROPERTY"); break;
case xpath.FUNC_EXT_FUNCTION_AVAILABLE:
diagnoseOpNoLable2(opPos, "FUNC_EXT_FUNCTION_AVAILABLE"); break;
case xpath.FUNC_EXT_ELEM_AVAILABLE: diagnoseOpNoLable2(opPos,
"FUNC_EXT_ELEM_AVAILABLE"); break;
case xpath.FUNC_SUBSTRING: diagnoseOpNoLable2(opPos,
"FUNC_SUBSTRING"); break;
case xpath.FUNC_STRING_LENGTH: diagnoseOpNoLable2(opPos,
"FUNC_STRING_LENGTH"); break;
case xpath.FUNC_DOCLOCATION: diagnoseOpNoLable2(opPos,
"FUNC_DOCLOCATION"); break;
}
opPos++;
while(opPos < endFunc)
{
// indent(indent+1);
opPos = diagnoseXPath2(xpath, opPos, indent+2);
}
indent(indent);
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+1);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
}
break;
case xpath.OP_LOCATIONPATH:
diagnoseOp2("OP_LOCATIONPATH", xpath, opPos);
int endPath = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
while(opPos < endPath)
{
opPos = diagnoseXPath2(xpath, opPos, indent+1);
}
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+1);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
break;
case xpath.OP_PREDICATE:
indent(1);
opPos = diagnoseXPathUnaryOperation2("OP_PREDICATE", xpath, opPos,
indent+1);
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+2);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
break;
case xpath.FROM_ANCESTORS:
opPos = diagnoseXPathLocationStep2("FROM_ANCESTORS", xpath, opPos, 1);
break;
case xpath.FROM_ANCESTORS_OR_SELF:
opPos = diagnoseXPathLocationStep2("FROM_ANCESTORS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_ATTRIBUTES:
opPos = diagnoseXPathLocationStep2("FROM_ATTRIBUTES", xpath, opPos,
1);
break;
case xpath.FROM_CHILDREN:
opPos = diagnoseXPathLocationStep2("FROM_CHILDREN", xpath, opPos, 1);
break;
case xpath.FROM_DESCENDANTS:
opPos = diagnoseXPathLocationStep2("FROM_DESCENDANTS", xpath, opPos,
1);
break;
case xpath.FROM_DESCENDANTS_OR_SELF:
opPos = diagnoseXPathLocationStep2("FROM_DESCENDANTS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_FOLLOWING:
opPos = diagnoseXPathLocationStep2("FROM_FOLLOWING", xpath, opPos,
indent);
break;
case xpath.FROM_FOLLOWING_SIBLINGS:
opPos = diagnoseXPathLocationStep2("FROM_FOLLOWING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_PARENT:
opPos = diagnoseXPathLocationStep2("FROM_PARENT", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING:
opPos = diagnoseXPathLocationStep2("FROM_PRECEDING", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING_SIBLINGS:
opPos = diagnoseXPathLocationStep2("FROM_PRECEDING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_SELF:
opPos = diagnoseXPathLocationStep2("FROM_SELF", xpath, opPos, indent);
break;
case xpath.FROM_NAMESPACE:
opPos = diagnoseXPathLocationStep2("FROM_NAMESPACE", xpath, opPos,
indent);
break;
// case xpath.FROM_ATTRIBUTE:
// opPos = diagnoseXPathLocationStep("FROM_ATTRIBUTE", xpath,
opPos, indent);
// break;
// case xpath.FROM_DOC:
// opPos = diagnoseXPathLocationStep("FROM_DOC", xpath, opPos,
indent);
// break;
// case xpath.FROM_DOCREF:
// opPos = diagnoseXPathLocationStep("FROM_DOCREF", xpath, opPos,
indent);
// break;
// case xpath.FROM_ID:
// opPos = diagnoseXPathLocationStep("FROM_ID", xpath, opPos,
indent);
// break;
// case xpath.FROM_IDREF:
// opPos = diagnoseXPathLocationStep("FROM_IDREF", xpath, opPos,
indent);
// break;
case xpath.FROM_ROOT:
opPos = diagnoseXPathLocationStep2("FROM_ROOT", xpath, opPos, indent);
// opPos++;
break;
case xpath.NODETYPE_COMMENT:
diagnoseNodeTest2(opPos, "NODETYPE_COMMENT");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_TEXT:
diagnoseNodeTest2(opPos, "NODETYPE_TEXT");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_PI:
int piLen = xpath.m_opMap[opPos-1];
diagnoseNodeTest2(opPos, "NODETYPE_PI");
opPos++;
if(piLen > 3)
{
opPos = diagnoseToken(xpath, opPos);
}
break;
case xpath.NODETYPE_NODE:
diagnoseNodeTest2(opPos, "NODETYPE_NODE");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_ROOT:
diagnoseNodeTest2(opPos, "NODETYPE_ROOT");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_ANYELEMENT:
diagnoseNodeTest2(opPos, "NODETYPE_ANYELEMENT");
System.out.println();
opPos++;
break;
case xpath.NODENAME:
diagnoseNodeTest2(opPos, "NODENAME");
opPos++;
if(xpath.m_opMap[opPos] < 0)
{
System.out.print(m_noLabel+"EMPTY"+m_close);
opPos++;
}
else
{
opPos = diagnoseToken2(xpath, opPos);
}
opPos = diagnoseToken2(xpath, opPos);
break;
default:
System.out.println("ERROR! Unknown op code: "+xpath.m_opMap[opPos]);
}
return opPos;
}
#endif
void
XPathProcessorImpl::initializeKeywordsTable()
{
// $$$ ToDo: This is very confusing. This table is only used
// by getKeywordToken(). But if you look at the switch
// statement there, none of these values are considered in the
// case statement. So what's the point?
// s_keywords[FROM_SELF_ABBREVIATED_STRING] =
XPathExpression::eFROM_SELF;
// s_keywords[FROM_ATTRIBUTE_STRING] = XPathExpression::eFROM_ATTRIBUTE;
// s_keywords[FROM_DOC_STRING] = XPathExpression::eFROM_DOC;
// s_keywords[FROM_DOCREF_STRING] = XPathExpression::eFROM_DOCREF;
// s_keywords[FROM_ID_STRING] = XPathExpression::eFROM_ID;
// s_keywords[FROM_IDREF_STRING] = XPathExpression::eFROM_IDREF;
// s_keywords[FUNC_ID_STRING] = XPathExpression::eFUNC_ID;
// s_keywords[FUNC_KEY_STRING] = XPathExpression::eFUNC_KEY;
// s_keywords[FUNC_DOCUMENT_STRING] = XPathExpression::eFUNC_DOC;
}
void
XPathProcessorImpl::initializeFunctionTable()
{
s_functions[NODETYPE_PI_STRING] = XPathExpression::eNODETYPE_PI;
s_functions[NODETYPE_COMMENT_STRING] =
XPathExpression::eNODETYPE_COMMENT;
s_functions[NODETYPE_TEXT_STRING] = XPathExpression::eNODETYPE_TEXT;
s_functions[NODETYPE_NODE_STRING] = XPathExpression::eNODETYPE_NODE;
}
void
XPathProcessorImpl::initializeAxisNamesTable()
{
s_axisNames[FROM_ANCESTORS_STRING] = XPathExpression::eFROM_ANCESTORS;
s_axisNames[FROM_ANCESTORS_OR_SELF_STRING] =
XPathExpression::eFROM_ANCESTORS_OR_SELF;
s_axisNames[FROM_ATTRIBUTES_STRING] = XPathExpression::eFROM_ATTRIBUTES;
s_axisNames[FROM_CHILDREN_STRING] = XPathExpression::eFROM_CHILDREN;
s_axisNames[FROM_DESCENDANTS_STRING] =
XPathExpression::eFROM_DESCENDANTS;
s_axisNames[FROM_DESCENDANTS_OR_SELF_STRING] =
XPathExpression::eFROM_DESCENDANTS_OR_SELF;
s_axisNames[FROM_FOLLOWING_STRING] = XPathExpression::eFROM_FOLLOWING;
s_axisNames[FROM_FOLLOWING_SIBLINGS_STRING] =
XPathExpression::eFROM_FOLLOWING_SIBLINGS;
s_axisNames[FROM_PARENT_STRING] = XPathExpression::eFROM_PARENT;
s_axisNames[FROM_PRECEDING_STRING] = XPathExpression::eFROM_PRECEDING;
s_axisNames[FROM_PRECEDING_SIBLINGS_STRING] =
XPathExpression::eFROM_PRECEDING_SIBLINGS;
s_axisNames[FROM_SELF_STRING] = XPathExpression::eFROM_SELF;
s_axisNames[FROM_NAMESPACE_STRING] = XPathExpression::eFROM_NAMESPACE;
}
void
XPathProcessorImpl::initializeNodeTypesTable()
{
s_nodeTypes[NODETYPE_COMMENT_STRING] =
XPathExpression::eNODETYPE_COMMENT;
s_nodeTypes[NODETYPE_TEXT_STRING] = XPathExpression::eNODETYPE_TEXT;
s_nodeTypes[NODETYPE_PI_STRING] = XPathExpression::eNODETYPE_PI;
s_nodeTypes[NODETYPE_NODE_STRING] = XPathExpression::eNODETYPE_NODE;
s_nodeTypes[NODETYPE_ANYELEMENT_STRING] =
XPathExpression::eNODETYPE_ANYELEMENT;
}
XPathProcessorImpl::StaticInitializer::StaticInitializer()
{
XPathProcessorImpl::initializeKeywordsTable();
XPathProcessorImpl::initializeFunctionTable();
XPathProcessorImpl::initializeAxisNamesTable();
XPathProcessorImpl::initializeNodeTypesTable();
}
1.1 xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
Index: XPathProcessorImpl.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHPROCESSORIMPL_HEADER_GUARD_1357924680)
#define XPATHPROCESSORIMPL_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <set>
#include <string>
#include <vector>
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
// Base class header file...
#include <XPath/XPathProcessor.hpp>
#include <XPath/XPath.hpp>
class XPathEnvSupport;
class XPathSupport;
/**
* The XPathProcessorImpl class responsibilities include
* tokenizing and parsing the XPath expression, and acting
* as a general interface to XPaths.
*/
class XALAN_XPATH_EXPORT XPathProcessorImpl : public XPathProcessor
{
public:
typedef std::map<DOMString, int>
KeywordsMapType;
typedef std::map<DOMString, XPathExpression::eOpCodes>
FunctionNameMapType;
typedef std::map<DOMString, XPathExpression::eOpCodes>
AxisNamesMapType;
typedef std::map<DOMString, XPathExpression::eOpCodes>
NodeTypesMapType;
/**
* The parser constructor.
*/
XPathProcessorImpl(
XPathEnvSupport& theXPathEnvSupport,
XPathSupport& theXPathSupport);
virtual
~XPathProcessorImpl();
// These are inherited from XPathProcessor...
/**
* Given a string, make an XPath object, in order that a parse doesn't
* have to be done each time the expression is executed.
*/
virtual void
initXPath(
XPath& pathObj,
const DOMString& expression,
const PrefixResolver& resolver);
/**
* Given a string, make an XSLT Match Pattern object.
*/
virtual void
initMatchPattern(
XPath& pathObj,
const DOMString& expression,
const PrefixResolver& resolver);
// The rest of these interfaces are new...
private:
/**
* Walk through the expression and build a token queue, and a map of
the top-level
* elements.
* @param pat XSLT Expression.
* @param targetStrings Vector to hold Strings, may be null.
*/
void
tokenize(
const DOMString& pat,
std::vector<DOMString>* targetStrings = 0);
/**
* Record the current position on the token queue as long as
* this is a top-level element. Must be called before the
* next token is added to the m_tokenQueue.
*/
bool
mapPatternElemPos(
int nesting,
bool isStart,
bool isAttrName) const;
/**
* Record the correct token string in the passed vector.
*/
void
recordTokenString(std::vector<DOMString>& targetStrings);
void
addToTokenQueue(const DOMString& s) const;
/**
* When a seperator token is found, see if there's a element name or
* the like to map.
*/
int
mapNSTokens(
const DOMString& pat,
int startSubstring,
int posOfNSSep,
int posOfScan)
const;
/**
* Given a map pos, return the corresponding token queue pos.
*/
int
getTokenQueuePosFromMap(int i) const;
/**
* This will return the index above the passed index that
* is the target element, i.e. it holds a value >= TARGETEXTRA.
* If there is no next target, it will return -1.
* Pass -1 in to start testing from zero.
*/
int
getNextTargetIndexInMap(int i) const;
/**
* This will return the normalized index into the pattern
* map above the passed index, or -1 if it is the last pattern.
*/
int
getNextIndexInMap(int i) const;
/**
* This will return the index above the passed index that
* is the start if the next subpattern, or -1 if there is none.
* If there is no next target, it will return -1.
* Pass -1 in to start testing from zero.
*/
int
getNextSubpatternStartIndexInMap(int i) const;
/**
* This will return the next index from the passed index,
* or -1 if it the passed index is the last index of the
* subpattern.
*/
int
getNextPatternPos(int i) const;
/**
* This will return the previous index from the passed index,
* or -1 if it the passed index is the first index of the
* subpattern.
*/
int
getPrevMapIndex(int i) const;
/**
* Check if m_token==s. If m_token is null, this won't throw
* an exception, instead it just returns false (or true
* if s is also null).
*/
bool
tokenIs(const char* s) const;
/**
* Check if m_token==s. If m_token is null, this won't throw
* an exception, instead it just returns false (or true
* if s is also null).
*/
bool
tokenIs(char c) const;
/**
* Lookahead of the current token in order to
* make a branching decision.
* @param s the string to compare it to.
* @param n number of tokens to lookahead. Must be
* greater than 1.
*/
bool
lookahead(
char c,
int n) const;
/**
* Lookahead of the current token in order to
* make a branching decision.
* @param s the string to compare it to.
* @param n number of tokens to lookahead. Must be
* greater than 1.
*/
bool
lookahead(
const char* s,
int n) const;
/**
* Lookbehind the first character of the current token in order to
* make a branching decision.
* @param c the character to compare it to.
* @param n number of tokens to lookbehind. Must be
* greater than 1. Note that the lookbehind terminates
* at either the beginning of the string or on a '|'
* character. Because of this, this method should only
* be used for pattern matching.
*/
bool
lookbehind(
char c,
int n) const;
/**
* look behind the current token in order to
* see if there is a useable token.
* @param n number of tokens to lookahead. Must be
* greater than 1. Note that the lookbehind terminates
* at either the beginning of the string or on a '|'
* character. Because of this, this method should only
* be used for pattern matching.
* @return true if lookbehind has a token, false otherwise.
*/
bool
lookbehindHasToken(int n) const;
/**
* Retrieve the next token from the command and
* store it in m_token string.
*/
void
nextToken();
/**
* Retrieve the next token from the command and
* store it in m_token string.
*/
DOMString
getTokenRelative(int theOffset) const;
/**
* Retrieve the next token from the command and
* store it in m_token string.
*/
void
prevToken();
/**
* Reset token queue mark and m_token to a
* given position.
*/
void
resetTokenMark(int mark);
/**
* Consume an expected token, throwing an exception if it
* isn't there.
*/
void
consumeExpected(const char* expected);
/**
* Consume an expected token, throwing an exception if it
* isn't there.
*/
void
consumeExpected(char expected);
/**
* Warn the user of an problem.
*/
void
warn(
const DOMString& msg,
const DOM_Node& sourceNode = DOM_Node()) const;
/**
* Tell the user of an error, and probably throw an
* exception.
*/
void
error(
const DOMString& msg,
const DOM_Node& sourceNode = DOM_Node()) const;
#if 0
private static final String FROM_ANCESTORS_STRING = "ancestor";
private static final String FROM_ANCESTORS_OR_SELF_STRING =
"ancestor-or-self";
private static final String FROM_ATTRIBUTES_STRING = "attribute";
private static final String FROM_CHILDREN_STRING = "child";
private static final String FROM_DESCENDANTS_STRING = "descendant";
private static final String FROM_DESCENDANTS_OR_SELF_STRING =
"descendant-or-self";
private static final String FROM_FOLLOWING_STRING = "following";
private static final String FROM_FOLLOWING_SIBLINGS_STRING =
"following-sibling";
private static final String FROM_PARENT_STRING = "parent";
private static final String FROM_PRECEDING_STRING = "preceding";
private static final String FROM_PRECEDING_SIBLINGS_STRING =
"preceding-sibling";
private static final String FROM_SELF_STRING = "self";
private static final String FROM_NAMESPACE_STRING = "namespace";
private static final String FROM_SELF_ABBREVIATED_STRING = ".";
private static final String NODETYPE_COMMENT_STRING = "comment";
private static final String NODETYPE_TEXT_STRING = "text";
private static final String NODETYPE_PI_STRING = "processing-instruction";
private static final String NODETYPE_NODE_STRING = "node";
private static final String FROM_ATTRIBUTE_STRING = "@";
private static final String FROM_DOC_STRING = "document";
private static final String FROM_DOCREF_STRING = "document";
private static final String FROM_ID_STRING = "id";
private static final String FROM_IDREF_STRING = "idref";
private static final String NODETYPE_ANYELEMENT_STRING = "*";
private static final String FUNC_CURRENT_STRING = "current";
private static final String FUNC_LAST_STRING = "last";
private static final String FUNC_POSITION_STRING = "position";
private static final String FUNC_COUNT_STRING = "count";
private static final String FUNC_ID_STRING = "id";
private static final String FUNC_IDREF_STRING = "idref";
private static final String FUNC_KEY_STRING = "key";
private static final String FUNC_KEYREF_STRING = "keyref";
private static final String FUNC_DOC_STRING = "doc";
private static final String FUNC_DOCUMENT_STRING = "document";
private static final String FUNC_DOCREF_STRING = "docref";
private static final String FUNC_LOCAL_PART_STRING = "local-name";
private static final String FUNC_NAMESPACE_STRING = "namespace-uri";
private static final String FUNC_NAME_STRING = "name";
private static final String FUNC_GENERATE_ID_STRING = "generate-id";
private static final String FUNC_NOT_STRING = "not";
private static final String FUNC_TRUE_STRING = "true";
private static final String FUNC_FALSE_STRING = "false";
private static final String FUNC_BOOLEAN_STRING = "boolean";
private static final String FUNC_LANG_STRING = "lang";
private static final String FUNC_NUMBER_STRING = "number";
private static final String FUNC_FLOOR_STRING = "floor";
private static final String FUNC_CEILING_STRING = "ceiling";
private static final String FUNC_ROUND_STRING = "round";
private static final String FUNC_SUM_STRING = "sum";
private static final String FUNC_STRING_STRING = "string";
private static final String FUNC_STARTS_WITH_STRING = "starts-with";
private static final String FUNC_CONTAINS_STRING = "contains";
private static final String FUNC_SUBSTRING_BEFORE_STRING =
"substring-before";
private static final String FUNC_SUBSTRING_AFTER_STRING = "substring-after";
private static final String FUNC_NORMALIZE_STRING = "normalize";
private static final String FUNC_TRANSLATE_STRING = "translate";
private static final String FUNC_CONCAT_STRING = "concat";
private static final String FUNC_FORMAT_NUMBER_STRING = "format-number";
private static final String FUNC_SYSTEM_PROPERTY_STRING = "system-property";
private static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING =
"extension-function-available";
private static final String FUNC_EXT_ELEM_AVAILABLE_STRING =
"extension-element-available";
private static final String FUNC_SUBSTRING_STRING = "substring";
private static final String FUNC_STRING_LENGTH_STRING = "string-length";
// Proprietary, built in functions
private static final String FUNC_DOCLOCATION_STRING = "document-location";
static
{
m_axisnames.put((FROM_ANCESTORS_STRING).intern(), new
Integer(XPath.FROM_ANCESTORS));
m_axisnames.put((FROM_ANCESTORS_OR_SELF_STRING).intern(), new
Integer(XPath.FROM_ANCESTORS_OR_SELF));
m_axisnames.put((FROM_ATTRIBUTES_STRING).intern(), new
Integer(XPath.FROM_ATTRIBUTES));
m_axisnames.put((FROM_CHILDREN_STRING).intern(), new
Integer(XPath.FROM_CHILDREN));
m_axisnames.put((FROM_DESCENDANTS_STRING).intern(), new
Integer(XPath.FROM_DESCENDANTS));
m_axisnames.put((FROM_DESCENDANTS_OR_SELF_STRING).intern(), new
Integer(XPath.FROM_DESCENDANTS_OR_SELF));
m_axisnames.put((FROM_FOLLOWING_STRING).intern(), new
Integer(XPath.FROM_FOLLOWING));
m_axisnames.put((FROM_FOLLOWING_SIBLINGS_STRING).intern(), new
Integer(XPath.FROM_FOLLOWING_SIBLINGS));
m_axisnames.put((FROM_PARENT_STRING).intern(), new
Integer(XPath.FROM_PARENT));
m_axisnames.put((FROM_PRECEDING_STRING).intern(), new
Integer(XPath.FROM_PRECEDING));
m_axisnames.put((FROM_PRECEDING_SIBLINGS_STRING).intern(), new
Integer(XPath.FROM_PRECEDING_SIBLINGS));
m_axisnames.put((FROM_SELF_STRING).intern(), new
Integer(XPath.FROM_SELF));
m_axisnames.put((FROM_NAMESPACE_STRING).intern(), new
Integer(XPath.FROM_NAMESPACE));
m_nodetypes.put((NODETYPE_COMMENT_STRING).intern(), new
Integer(XPath.NODETYPE_COMMENT));
m_nodetypes.put((NODETYPE_TEXT_STRING).intern(), new
Integer(XPath.NODETYPE_TEXT));
m_nodetypes.put((NODETYPE_PI_STRING).intern(), new
Integer(XPath.NODETYPE_PI));
m_nodetypes.put((NODETYPE_NODE_STRING).intern(), new
Integer(XPath.NODETYPE_NODE));
m_nodetypes.put((NODETYPE_ANYELEMENT_STRING).intern(), new
Integer(XPath.NODETYPE_ANYELEMENT));
m_keywords.put((FROM_SELF_ABBREVIATED_STRING).intern(), new
Integer(XPath.FROM_SELF));
// m_keywords.put((FROM_ATTRIBUTE_STRING).intern(), new
Integer(XPath.FROM_ATTRIBUTE));
// m_keywords.put((FROM_DOC_STRING).intern(), new
Integer(XPath.FROM_DOC));
// m_keywords.put((FROM_DOCREF_STRING).intern(), new
Integer(XPath.FROM_DOCREF));
// m_keywords.put((FROM_ID_STRING).intern(), new
Integer(XPath.FROM_ID));
// m_keywords.put((FROM_IDREF_STRING).intern(), new
Integer(XPath.FROM_IDREF));
m_keywords.put((FUNC_ID_STRING).intern(), new Integer(XPath.FUNC_ID));
m_keywords.put((FUNC_KEY_STRING).intern(), new Integer(XPath.FUNC_KEY));
m_keywords.put((FUNC_DOCUMENT_STRING).intern(), new
Integer(XPath.FUNC_DOC));
m_functions.put((FUNC_CURRENT_STRING).intern(), new
Integer(XPath.FUNC_CURRENT));
m_functions.put((FUNC_LAST_STRING).intern(), new
Integer(XPath.FUNC_LAST));
m_functions.put((FUNC_POSITION_STRING).intern(), new
Integer(XPath.FUNC_POSITION));
m_functions.put((FUNC_COUNT_STRING).intern(), new
Integer(XPath.FUNC_COUNT));
m_functions.put((FUNC_ID_STRING).intern(), new Integer(XPath.FUNC_ID));
m_functions.put((FUNC_KEY_STRING).intern(), new
Integer(XPath.FUNC_KEY));
m_functions.put((FUNC_DOCUMENT_STRING).intern(), new
Integer(XPath.FUNC_DOC));
m_functions.put((FUNC_LOCAL_PART_STRING).intern(), new
Integer(XPath.FUNC_LOCAL_PART));
m_functions.put((FUNC_NAMESPACE_STRING).intern(), new
Integer(XPath.FUNC_NAMESPACE));
m_functions.put((FUNC_NAME_STRING).intern(), new
Integer(XPath.FUNC_QNAME));
m_functions.put((FUNC_GENERATE_ID_STRING).intern(), new
Integer(XPath.FUNC_GENERATE_ID));
m_functions.put((FUNC_NOT_STRING).intern(), new
Integer(XPath.FUNC_NOT));
m_functions.put((FUNC_TRUE_STRING).intern(), new
Integer(XPath.FUNC_TRUE));
m_functions.put((FUNC_FALSE_STRING).intern(), new
Integer(XPath.FUNC_FALSE));
m_functions.put((FUNC_BOOLEAN_STRING).intern(), new
Integer(XPath.FUNC_BOOLEAN));
m_functions.put((FUNC_LANG_STRING).intern(), new
Integer(XPath.FUNC_LANG));
m_functions.put((FUNC_NUMBER_STRING).intern(), new
Integer(XPath.FUNC_NUMBER));
m_functions.put((FUNC_FLOOR_STRING).intern(), new
Integer(XPath.FUNC_FLOOR));
m_functions.put((FUNC_CEILING_STRING).intern(), new
Integer(XPath.FUNC_CEILING));
m_functions.put((FUNC_ROUND_STRING).intern(), new
Integer(XPath.FUNC_ROUND));
m_functions.put((FUNC_SUM_STRING).intern(), new
Integer(XPath.FUNC_SUM));
m_functions.put((FUNC_STRING_STRING).intern(), new
Integer(XPath.FUNC_STRING));
m_functions.put((FUNC_STARTS_WITH_STRING).intern(), new
Integer(XPath.FUNC_STARTS_WITH));
m_functions.put((FUNC_CONTAINS_STRING).intern(), new
Integer(XPath.FUNC_CONTAINS));
m_functions.put((FUNC_SUBSTRING_BEFORE_STRING).intern(), new
Integer(XPath.FUNC_SUBSTRING_BEFORE));
m_functions.put((FUNC_SUBSTRING_AFTER_STRING).intern(), new
Integer(XPath.FUNC_SUBSTRING_AFTER));
m_functions.put((FUNC_NORMALIZE_STRING).intern(), new
Integer(XPath.FUNC_NORMALIZE));
m_functions.put((FUNC_TRANSLATE_STRING).intern(), new
Integer(XPath.FUNC_TRANSLATE));
m_functions.put((FUNC_CONCAT_STRING).intern(), new
Integer(XPath.FUNC_CONCAT));
m_functions.put((FUNC_FORMAT_NUMBER_STRING).intern(), new
Integer(XPath.FUNC_FORMAT_NUMBER));
m_functions.put((FUNC_SYSTEM_PROPERTY_STRING).intern(), new
Integer(XPath.FUNC_SYSTEM_PROPERTY));
m_functions.put((FUNC_EXT_FUNCTION_AVAILABLE_STRING).intern(), new
Integer(XPath.FUNC_EXT_FUNCTION_AVAILABLE));
m_functions.put((FUNC_EXT_ELEM_AVAILABLE_STRING).intern(), new
Integer(XPath.FUNC_EXT_ELEM_AVAILABLE));
m_functions.put((FUNC_SUBSTRING_STRING).intern(), new
Integer(XPath.FUNC_SUBSTRING));
m_functions.put((FUNC_STRING_LENGTH_STRING).intern(), new
Integer(XPath.FUNC_STRING_LENGTH));
// These aren't really functions.
m_functions.put((NODETYPE_COMMENT_STRING).intern(), new
Integer(XPath.NODETYPE_COMMENT));
m_functions.put((NODETYPE_TEXT_STRING).intern(), new
Integer(XPath.NODETYPE_TEXT));
m_functions.put((NODETYPE_PI_STRING).intern(), new
Integer(XPath.NODETYPE_PI));
m_functions.put((NODETYPE_NODE_STRING).intern(), new
Integer(XPath.NODETYPE_NODE));
m_functions.put((FUNC_DOCLOCATION_STRING).intern(), new
Integer(XPath.FUNC_DOCLOCATION));
}
#endif
/**
* Given a string, return the corresponding token.
*/
int
getKeywordToken(const DOMString& key) const;
/**
* Given a string, return the corresponding token.
*/
int
getFunctionToken(const DOMString& key) const;
/**
*
*
--------------------------------------------------------------------------------
Expr ::= OrExpr
*
--------------------------------------------------------------------------------
*/
void
Expr();
/**
*
*
--------------------------------------------------------------------------------
OrExpr ::= AndExpr
| OrExpr 'or' AndExpr
*
--------------------------------------------------------------------------------
*/
void
OrExpr();
/**
*
*
--------------------------------------------------------------------------------
AndExpr ::= EqualityExpr
| AndExpr 'and' EqualityExpr
*
--------------------------------------------------------------------------------
*/
void
AndExpr() ;
/**
* XXXX.
* @returns an Object which is either a String, a Number, a Boolean, or
a vector
* of nodes.
*
--------------------------------------------------------------------------------
EqualityExpr ::= RelationalExpr
| EqualityExpr '=' RelationalExpr
*
--------------------------------------------------------------------------------
*/
int
EqualityExpr(int opCodePos = -1);
/**
* XXXX.
* @returns an Object which is either a String, a Number, a Boolean, or
a vector
* of nodes.
*
--------------------------------------------------------------------------------
RelationalExpr ::= AdditiveExpr
| RelationalExpr '<' AdditiveExpr
| RelationalExpr '>' AdditiveExpr
| RelationalExpr '<=' AdditiveExpr
| RelationalExpr '>=' AdditiveExpr
*
--------------------------------------------------------------------------------
*/
int
RelationalExpr(int opCodePos = -1);
/**
* XXXX.
* @returns an Object which is either a String, a Number, a Boolean, or
a vector
* of nodes.
*
--------------------------------------------------------------------------------
AdditiveExpr ::= MultiplicativeExpr
| AdditiveExpr '+' MultiplicativeExpr
| AdditiveExpr '-' MultiplicativeExpr
*
--------------------------------------------------------------------------------
*/
int
AdditiveExpr(int opCodePos = -1);
/**
* XXXX.
* @returns an Object which is either a String, a Number, a Boolean, or
a vector
* of nodes.
*
--------------------------------------------------------------------------------
MultiplicativeExpr ::= UnaryExpr
| MultiplicativeExpr MultiplyOperator UnaryExpr
| MultiplicativeExpr 'div' UnaryExpr
| MultiplicativeExpr 'mod' UnaryExpr
| MultiplicativeExpr 'quo' UnaryExpr
*
--------------------------------------------------------------------------------
*/
int
MultiplicativeExpr(int opCodePos = -1);
/**
* XXXX.
* @returns an Object which is either a String, a Number, a Boolean, or
a vector
* of nodes.
*
--------------------------------------------------------------------------------
UnaryExpr ::= UnionExpr
| '-' UnaryExpr
*
--------------------------------------------------------------------------------
*/
void
UnaryExpr();
/**
*
--------------------------------------------------------------------------------
StringExpr ::= Expr
*
--------------------------------------------------------------------------------
*/
void
StringExpr();
/**
*
*
--------------------------------------------------------------------------------
BooleanExpr ::= Expr
*
--------------------------------------------------------------------------------
*/
void
BooleanExpr();
/**
*
*
--------------------------------------------------------------------------------
NumberExpr ::= Expr
*
--------------------------------------------------------------------------------
*/
void
NumberExpr();
/**
* The context of the right hand side expressions is the context of the
* left hand side expression. The results of the right hand side
expressions
* are node sets. The result of the left hand side UnionExpr is the
union
* of the results of the right hand side expressions.
*
*
--------------------------------------------------------------------------------
UnionExpr ::= PathExpr
| UnionExpr '|' PathExpr
*
--------------------------------------------------------------------------------
*/
void
UnionExpr();
/**
*
*
--------------------------------------------------------------------------------
PathExpr ::= LocationPath
| FilterExpr
| FilterExpr '/' RelativeLocationPath
| FilterExpr '//' RelativeLocationPath
*
--------------------------------------------------------------------------------
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
PathExpr();
/**
*
*
--------------------------------------------------------------------------------
FilterExpr ::= PrimaryExpr
| FilterExpr Predicate
*
--------------------------------------------------------------------------------
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
FilterExpr();
/**
*
--------------------------------------------------------------------------------
PrimaryExpr ::= VariableReference
| '(' Expr ')'
| Literal
| Number
| FunctionCall
*
--------------------------------------------------------------------------------
*/
void
PrimaryExpr();
/**
*
--------------------------------------------------------------------------------
Argument ::= Expr
*
--------------------------------------------------------------------------------
*/
void
Argument();
/**
*
--------------------------------------------------------------------------------
FunctionCall ::= FunctionName '(' ( Argument ( ','
Argument)*)? ')'
*
--------------------------------------------------------------------------------
*/
void
FunctionCall();
/**
*
--------------------------------------------------------------------------------
LocationPath ::= RelativeLocationPath
| AbsoluteLocationPath
*
--------------------------------------------------------------------------------
*/
void
LocationPath();
/**
*
--------------------------------------------------------------------------------
RelativeLocationPath ::= Step
| RelativeLocationPath '/' Step
| AbbreviatedRelativeLocationPath
*
--------------------------------------------------------------------------------
*/
void
RelativeLocationPath();
/**
*
--------------------------------------------------------------------------------
Step ::= Basis Predicate*
| AbbreviatedStep
*/
void
Step();
/**
*
--------------------------------------------------------------------------------
Basis ::= AxisName '::' NodeTest
| AbbreviatedBasis
*/
void
Basis();
/**
*
--------------------------------------------------------------------------------
Basis ::= AxisName '::' NodeTest
| AbbreviatedBasis
*/
void
AxisName();
/**
*
--------------------------------------------------------------------------------
NodeTest ::= WildcardName
| NodeType '(' ')'
| 'processing-instruction' '(' Literal ')'
*/
void
NodeTest();
/**
*
--------------------------------------------------------------------------------
Predicate ::= '[' PredicateExpr ']'
*
--------------------------------------------------------------------------------
*/
void
Predicate();
/**
*--------------------------------------------------------------------------------
PredicateExpr ::= Expr
*--------------------------------------------------------------------------------
*/
void
PredicateExpr();
/**
* QName ::= (Prefix ':')? LocalPart
* Prefix ::= NCName
* LocalPart ::= NCName
*/
void
QName();
/**
* NCName ::= (Letter | '_') (NCNameChar)*
* NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar |
Extender
*/
void
NCName();
/**
* The value of the Literal is the sequence of characters inside
* the " or ' characters>.
*
--------------------------------------------------------------------------------
Literal ::= '"' [^"]* '"'
| "'" [^']* "'"
*
--------------------------------------------------------------------------------
*/
void
Literal();
/**
*
--------------------------------------------------------------------------------
* Number ::= [0-9]+('.'[0-9]+)? | '.'[0-9]+
*
--------------------------------------------------------------------------------
*/
void
Number();
/**
*
--------------------------------------------------------------------------------
Pattern ::= LocationPathPattern
| Pattern '|' LocationPathPattern
*
--------------------------------------------------------------------------------
*/
void
Pattern();
/**
*
*
--------------------------------------------------------------------------------
LocationPathPattern ::= '/' RelativePathPattern?
| IdKeyPattern (('/' | '//') RelativePathPattern)?
| '//'? RelativePathPattern
*
--------------------------------------------------------------------------------
*/
void
LocationPathPattern();
/**
*
--------------------------------------------------------------------------------
IdKeyPattern ::= 'id' '(' Literal ')'
| 'key' '(' Literal ',' Literal ')'
* (Also handle doc())
*
--------------------------------------------------------------------------------
*/
void
IdKeyPattern();
/**
*
--------------------------------------------------------------------------------
RelativePathPattern ::= StepPattern
| RelativePathPattern '/' StepPattern
| RelativePathPattern '//' StepPattern
*
--------------------------------------------------------------------------------
*/
void
RelativePathPattern();
/**
*
--------------------------------------------------------------------------------
StepPattern ::= AbbreviatedNodeTestStep
*
--------------------------------------------------------------------------------
*/
void
StepPattern();
/**
*
--------------------------------------------------------------------------------
AbbreviatedNodeTestStep ::= '@'? NodeTest Predicate*
*
--------------------------------------------------------------------------------
*/
void
AbbreviatedNodeTestStep();
bool
isValidFunction(const DOMString& key) const;
#if 0
private void ____DIAGNOSTIC_FUNCTIONS____(){}
public static void diagnoseXPathString( String str )
{
XPathSupport callbacks = new XPathSupportDefault();
XPathProcessorImpl processor = new XPathProcessorImpl(callbacks);
XPath xpath = new XPath(callbacks);
processor.initXPath(xpath, str, null);
processor.diagnoseXPath(xpath, 0, 0);
}
static int diagnoseXPathBinaryOperation(String op, XPath xpath, int opPos,
int indent)
{
System.out.println(op+" {");
opPos+=2;
opPos = diagnoseXPath(xpath, opPos, indent+1);
opPos = diagnoseXPath(xpath, opPos, indent+1);
indent(indent);
System.out.println("}");
return opPos;
}
static int diagnoseXPathUnaryOperation(String op, XPath xpath, int opPos,
int indent)
{
System.out.println(op+" {");
opPos+=2;
opPos = diagnoseXPath(xpath, opPos, indent+1);
indent(indent);
System.out.println("}");
return opPos;
}
static int diagnoseXPathMultiOperation(String op, int multiOp, XPath xpath,
int opPos, int indent)
{
System.out.println(op+" {");
opPos+=2;
while(xpath.m_opMap[opPos] == multiOp)
{
indent(indent+1);
System.out.println("{");
opPos = diagnoseXPath(xpath, opPos, indent+2);
indent(indent+1);
System.out.println("}");
}
indent(indent);
System.out.println("}");
return opPos;
}
static int diagnoseToken(XPath xpath, int opPos)
{
System.out.print("{");
System.out.print(xpath.m_tokenQueue[xpath.m_opMap[opPos]]);
System.out.print("}");
return opPos+1;
}
static int diagnoseXPathSimpleOperation(String op, XPath xpath, int opPos,
int indent)
{
opPos+=2;
System.out.print(op);
opPos = diagnoseToken(xpath, opPos);
System.out.println("");
return opPos;
}
static int diagnoseXPathLocationStep(String op, XPath xpath, int opPos, int
indent)
{
// int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
int stepLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1];
opPos+=3;
System.out.print(op);
if(stepLen > 3)
{
opPos = diagnoseXPath(xpath, opPos, 1);
}
System.out.println("");
return opPos;
}
static int diagnoseXPath(XPath xpath, int opPos, int indent)
{
indent(indent);
switch(xpath.m_opMap[opPos])
{
case xpath.OP_XPATH:
opPos = diagnoseXPathUnaryOperation("OP_XPATH", xpath, opPos, indent);
break;
case xpath.EMPTY:
System.out.println("{EMPTY}");
opPos++;
break;
case xpath.OP_OR:
opPos = diagnoseXPathBinaryOperation("OP_OR", xpath, opPos, indent);
break;
case xpath.OP_AND:
opPos = diagnoseXPathBinaryOperation("OP_AND", xpath, opPos, indent);
break;
case xpath.OP_NOTEQUALS:
opPos = diagnoseXPathBinaryOperation("OP_NOTEQUALS", xpath, opPos,
indent);
break;
case xpath.OP_EQUALS:
opPos = diagnoseXPathBinaryOperation("OP_EQUALS", xpath, opPos,
indent);
break;
case xpath.OP_LTE:
opPos = diagnoseXPathBinaryOperation("OP_LTE", xpath, opPos, indent);
break;
case xpath.OP_LT:
opPos = diagnoseXPathBinaryOperation("OP_LT", xpath, opPos, indent);
break;
case xpath.OP_GTE:
opPos = diagnoseXPathBinaryOperation("OP_GTE", xpath, opPos, indent);
break;
case xpath.OP_GT:
opPos = diagnoseXPathBinaryOperation("OP_GT", xpath, opPos, indent);
break;
case xpath.OP_PLUS:
opPos = diagnoseXPathBinaryOperation("OP_PLUS", xpath, opPos, indent);
break;
case xpath.OP_MINUS:
opPos = diagnoseXPathBinaryOperation("OP_MINUS", xpath, opPos,
indent);
break;
case xpath.OP_MULT:
opPos = diagnoseXPathBinaryOperation("OP_MULT", xpath, opPos, indent);
break;
case xpath.OP_DIV:
opPos = diagnoseXPathBinaryOperation("OP_DIV", xpath, opPos, indent);
break;
case xpath.OP_MOD:
opPos = diagnoseXPathBinaryOperation("OP_MOD", xpath, opPos, indent);
break;
case xpath.OP_QUO:
opPos = diagnoseXPathBinaryOperation("OP_QUO", xpath, opPos, indent);
break;
case xpath.OP_NEG:
opPos = diagnoseXPathUnaryOperation("OP_NEG", xpath, opPos, indent);
break;
case xpath.OP_STRING:
opPos = diagnoseXPathUnaryOperation("OP_STRING", xpath, opPos,
indent);
break;
case xpath.OP_BOOL:
opPos = diagnoseXPathUnaryOperation("OP_BOOL", xpath, opPos, indent);
break;
case xpath.OP_NUMBER:
opPos = diagnoseXPathUnaryOperation("OP_NUMBER", xpath, opPos,
indent);
break;
case xpath.OP_UNION:
opPos = diagnoseXPathMultiOperation("OP_UNION",
xpath.OP_LOCATIONPATH, xpath, opPos, indent);
break;
case xpath.OP_LITERAL:
opPos = diagnoseXPathSimpleOperation("OP_LITERAL", xpath, opPos,
indent);
break;
case xpath.OP_VARIABLE:
opPos = diagnoseXPathSimpleOperation("OP_VARIABLE", xpath, opPos,
indent);
break;
case xpath.OP_GROUP:
opPos = diagnoseXPathUnaryOperation("OP_GROUP", xpath, opPos, indent);
break;
case xpath.OP_NUMBERLIT:
opPos = diagnoseXPathSimpleOperation("OP_NUMBERLIT", xpath, opPos,
indent);
break;
case xpath.OP_ARGUMENT:
opPos = diagnoseXPathUnaryOperation("OP_ARGUMENT", xpath, opPos,
indent);
break;
case xpath.OP_EXTFUNCTION:
{
System.out.println("OP_EXTFUNCTION {");
int endExtFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
indent(indent+1);
opPos = diagnoseToken(xpath, opPos);
System.out.print(":");
opPos = diagnoseToken(xpath, opPos);
System.out.println("");
while(opPos < endExtFunc)
{
indent(indent+1);
System.out.println("{");
opPos = diagnoseXPath(xpath, opPos, indent+2);
indent(indent+1);
System.out.println("}");
}
indent(indent);
System.out.println("}");
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
}
break;
case xpath.OP_FUNCTION:
{
System.out.println("OP_FUNCTION {");
int endFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
indent(indent+1);
int funcID = xpath.m_opMap[opPos];
switch(funcID)
{
case xpath.FUNC_LAST: System.out.print("FUNC_LAST"); break;
case xpath.FUNC_POSITION: System.out.print("FUNC_POSITION");
break;
case xpath.FUNC_COUNT: System.out.print("FUNC_COUNT"); break;
case xpath.FUNC_ID: System.out.print("FUNC_ID"); break;
case xpath.FUNC_KEY: System.out.print("FUNC_KEY"); break;
case xpath.FUNC_DOC: System.out.print("FUNC_DOC"); break;
case xpath.FUNC_LOCAL_PART:
System.out.print("FUNC_LOCAL_PART"); break;
case xpath.FUNC_NAMESPACE: System.out.print("FUNC_NAMESPACE");
break;
case xpath.FUNC_QNAME: System.out.print("FUNC_QNAME"); break;
case xpath.FUNC_GENERATE_ID:
System.out.print("FUNC_GENERATE_ID"); break;
case xpath.FUNC_NOT: System.out.print("FUNC_NOT"); break;
case xpath.FUNC_TRUE: System.out.print("FUNC_TRUE"); break;
case xpath.FUNC_FALSE: System.out.print("FUNC_FALSE"); break;
case xpath.FUNC_BOOLEAN: System.out.print("FUNC_BOOLEAN");
break;
case xpath.FUNC_LANG: System.out.print("FUNC_LANG"); break;
case xpath.FUNC_NUMBER: System.out.print("FUNC_NUMBER"); break;
case xpath.FUNC_FLOOR: System.out.print("FUNC_FLOOR"); break;
case xpath.FUNC_CEILING: System.out.print("FUNC_CEILING");
break;
case xpath.FUNC_ROUND: System.out.print("FUNC_ROUND"); break;
case xpath.FUNC_SUM: System.out.print("FUNC_SUM"); break;
case xpath.FUNC_STRING: System.out.print("FUNC_STRING"); break;
case xpath.FUNC_STARTS_WITH:
System.out.print("FUNC_STARTS_WITH"); break;
case xpath.FUNC_CONTAINS: System.out.print("FUNC_CONTAINS");
break;
case xpath.FUNC_SUBSTRING_BEFORE:
System.out.print("FUNC_SUBSTRING_BEFORE"); break;
case xpath.FUNC_SUBSTRING_AFTER:
System.out.print("FUNC_SUBSTRING_AFTER"); break;
case xpath.FUNC_NORMALIZE: System.out.print("FUNC_NORMALIZE");
break;
case xpath.FUNC_TRANSLATE: System.out.print("FUNC_TRANSLATE");
break;
case xpath.FUNC_CONCAT: System.out.print("FUNC_CONCAT"); break;
case xpath.FUNC_FORMAT_NUMBER:
System.out.print("FUNC_FORMAT_NUMBER"); break;
case xpath.FUNC_SYSTEM_PROPERTY:
System.out.print("FUNC_SYSTEM_PROPERTY"); break;
case xpath.FUNC_EXT_FUNCTION_AVAILABLE:
System.out.print("FUNC_EXT_FUNCTION_AVAILABLE"); break;
case xpath.FUNC_EXT_ELEM_AVAILABLE:
System.out.print("FUNC_EXT_ELEM_AVAILABLE"); break;
case xpath.FUNC_SUBSTRING: System.out.print("FUNC_SUBSTRING");
break;
case xpath.FUNC_STRING_LENGTH:
System.out.print("FUNC_STRING_LENGTH"); break;
case xpath.FUNC_DOCLOCATION:
System.out.print("FUNC_DOCLOCATION"); break;
}
opPos++;
System.out.println("");
while(opPos < endFunc)
{
indent(indent+1);
System.out.println("{");
opPos = diagnoseXPath(xpath, opPos, indent+2);
indent(indent+1);
System.out.println("}");
}
indent(indent);
System.out.println("}");
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
}
break;
case xpath.OP_LOCATIONPATH:
System.out.println("OP_LOCATIONPATH"+" {");
int endPath = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
while(opPos < endPath)
{
opPos = diagnoseXPath(xpath, opPos, indent+1);
}
indent(indent);
System.out.println("}");
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
break;
case xpath.OP_PREDICATE:
opPos = diagnoseXPathUnaryOperation("OP_PREDICATE", xpath, opPos,
indent);
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
opPos++;
break;
case xpath.FROM_ANCESTORS:
opPos = diagnoseXPathLocationStep("FROM_ANCESTORS", xpath, opPos, 1);
break;
case xpath.FROM_ANCESTORS_OR_SELF:
opPos = diagnoseXPathLocationStep("FROM_ANCESTORS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_ATTRIBUTES:
opPos = diagnoseXPathLocationStep("FROM_ATTRIBUTES", xpath, opPos, 1);
break;
case xpath.FROM_CHILDREN:
opPos = diagnoseXPathLocationStep("FROM_CHILDREN", xpath, opPos, 1);
break;
case xpath.FROM_DESCENDANTS:
opPos = diagnoseXPathLocationStep("FROM_DESCENDANTS", xpath, opPos,
1);
break;
case xpath.FROM_DESCENDANTS_OR_SELF:
opPos = diagnoseXPathLocationStep("FROM_DESCENDANTS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_FOLLOWING:
opPos = diagnoseXPathLocationStep("FROM_FOLLOWING", xpath, opPos,
indent);
break;
case xpath.FROM_FOLLOWING_SIBLINGS:
opPos = diagnoseXPathLocationStep("FROM_FOLLOWING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_PARENT:
opPos = diagnoseXPathLocationStep("FROM_PARENT", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING:
opPos = diagnoseXPathLocationStep("FROM_PRECEDING", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING_SIBLINGS:
opPos = diagnoseXPathLocationStep("FROM_PRECEDING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_SELF:
opPos = diagnoseXPathLocationStep("FROM_SELF", xpath, opPos, indent);
break;
case xpath.FROM_NAMESPACE:
opPos = diagnoseXPathLocationStep("FROM_NAMESPACE", xpath, opPos,
indent);
break;
// case xpath.FROM_ATTRIBUTE:
// opPos = diagnoseXPathLocationStep("FROM_ATTRIBUTE", xpath,
opPos, indent);
// break;
// case xpath.FROM_DOC:
// opPos = diagnoseXPathLocationStep("FROM_DOC", xpath, opPos,
indent);
// break;
// case xpath.FROM_DOCREF:
// opPos = diagnoseXPathLocationStep("FROM_DOCREF", xpath, opPos,
indent);
// break;
// case xpath.FROM_ID:
// opPos = diagnoseXPathLocationStep("FROM_ID", xpath, opPos,
indent);
// break;
// case xpath.FROM_IDREF:
// opPos = diagnoseXPathLocationStep("FROM_IDREF", xpath, opPos,
indent);
// break;
case xpath.FROM_ROOT:
opPos = diagnoseXPathLocationStep("FROM_ROOT", xpath, opPos, indent);
break;
case xpath.NODETYPE_COMMENT:
System.out.println("{NODETYPE_COMMENT}");
opPos++;
break;
case xpath.NODETYPE_TEXT:
System.out.println("{NODETYPE_TEXT}");
opPos++;
break;
case xpath.NODETYPE_PI:
int piLen = xpath.m_opMap[opPos-1];
System.out.println("{NODETYPE_PI ");
opPos++;
if(piLen > 3)
{
opPos = diagnoseToken(xpath, opPos);
}
break;
case xpath.NODETYPE_NODE:
System.out.println("{NODETYPE_NODE}");
opPos++;
break;
case xpath.NODETYPE_ROOT:
System.out.println("{NODETYPE_ROOT}");
opPos++;
break;
case xpath.NODETYPE_ANYELEMENT:
System.out.println("{NODETYPE_ANYELEMENT}");
opPos++;
break;
case xpath.NODENAME:
System.out.print("{NODENAME ");
opPos++;
if(xpath.m_opMap[opPos] < 0)
{
System.out.print("{EMPTY}");
opPos++;
}
else
{
opPos = diagnoseToken(xpath, opPos);
}
System.out.print(":");
opPos = diagnoseToken(xpath, opPos);
break;
default:
System.out.println("ERROR! Unknown op code: "+xpath.m_opMap[opPos]);
}
return opPos;
}
static void indent(int amount)
{
int n = amount * 3;
for(int i = 0; i < n; i ++)
{
System.out.print(" ");
}
}
private static String m_opLabel = "[";
private static String m_lenLabel = "[";
private static String m_arglenLabel = "[";
private static String m_noLabel = "[";
private static String m_nTestLabel = "[";
private static String m_open = "[";
private static String m_close = "]";
public static void diagnoseXPathString2( String str )
{
XPathSupport callbacks = new XPathSupportDefault();
XPathProcessorImpl processor = new XPathProcessorImpl(callbacks);
XPath xpath = new XPath(callbacks);
processor.initXPath(xpath, str, null);
processor.diagnoseXPath2(xpath, 0, 0);
}
public static void diagnoseXPathString3( String str )
{
XPathSupport callbacks = new XPathSupportDefault();
XPathProcessorImpl processor = new XPathProcessorImpl(callbacks);
XPath xpath = new XPath(callbacks);
processor.initXPath(xpath, str, null);
int len = xpath.m_opMap[xpath.MAPINDEX_LENGTH];
for(int i = 0; i < len; i++)
{
System.out.println("["+xpath.m_opMap[i]+"]");
}
}
private static void diagnoseNodeTest2(int opPos, String op)
{
System.out.print(m_nTestLabel+op+m_close);
}
private static void diagnoseOpNoLable2(int opPos, String op)
{
System.out.println(m_noLabel+op+m_close);
}
private static void diagnoseOpOnly2(int opPos, String op)
{
System.out.println(m_opLabel+op+m_close);
}
private static void diagnoseOp2(String op, XPath xpath, int opPos)
{
System.out.print(m_opLabel+op+m_close);
int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
System.out.println(m_open+opLen+m_close);
}
private static void diagnoseOp2SameLine(String op, XPath xpath, int opPos)
{
System.out.print(m_opLabel+op+m_close);
int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
System.out.print(m_open+opLen+m_close);
}
static int diagnoseXPathBinaryOperation2(String op, XPath xpath, int opPos,
int indent)
{
diagnoseOp2(op, xpath, opPos);
opPos+=2;
opPos = diagnoseXPath2(xpath, opPos, indent+1);
opPos = diagnoseXPath2(xpath, opPos, indent+1);
return opPos;
}
static int diagnoseXPathUnaryOperation2(String op, XPath xpath, int opPos,
int indent)
{
diagnoseOp2(op, xpath, opPos);
opPos+=2;
opPos = diagnoseXPath2(xpath, opPos, indent+1);
return opPos;
}
static int diagnoseXPathMultiOperation2(String op, int multiOp, XPath
xpath, int opPos, int indent)
{
diagnoseOp2(op, xpath, opPos);
opPos+=2;
while(xpath.m_opMap[opPos] == multiOp)
{
opPos = diagnoseXPath2(xpath, opPos, indent+2);
}
return opPos;
}
static int diagnoseToken2(XPath xpath, int opPos)
{
int tokenPos = xpath.m_opMap[opPos];
String token = (tokenPos >= 0) ?
xpath.m_tokenQueue[tokenPos].toString() :
(tokenPos == xpath.ELEMWILDCARD) ?
"*" :
(tokenPos == xpath.EMPTY) ?
"EMPTY" : "UNKNOWN";
System.out.println(m_noLabel+token+m_close);
return opPos+1;
}
static int diagnoseToken2SameLine(XPath xpath, int opPos)
{
System.out.print(m_noLabel+xpath.m_tokenQueue[xpath.m_opMap[opPos]]+m_close);
return opPos+1;
}
static int diagnoseXPathSimpleOperation2(String op, XPath xpath, int opPos,
int indent)
{
diagnoseOp2SameLine(op, xpath, opPos);
opPos+=2;
opPos = diagnoseToken2(xpath, opPos);
return opPos;
}
static int diagnoseXPathLocationStep2(String op, XPath xpath, int opPos,
int indent)
{
int opLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
int stepLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1];
System.out.print(m_opLabel+op+m_close);
System.out.print(m_open+opLen+m_close);
System.out.print(m_open+stepLen+m_close);
opPos+=3;
if(stepLen > 3)
{
opPos = diagnoseXPath2(xpath, opPos, 0);
}
return opPos;
}
static int diagnoseXPath2(XPath xpath, int opPos, int indent)
{
indent(indent);
switch(xpath.m_opMap[opPos])
{
case xpath.OP_XPATH:
opPos = diagnoseXPathUnaryOperation2("OP_XPATH", xpath, opPos,
indent);
break;
case xpath.EMPTY:
diagnoseOpOnly2(opPos, "EMPTY");
opPos++;
break;
case xpath.OP_OR:
opPos = diagnoseXPathBinaryOperation2("OP_OR", xpath, opPos, indent);
break;
case xpath.OP_AND:
opPos = diagnoseXPathBinaryOperation2("OP_AND", xpath, opPos, indent);
break;
case xpath.OP_NOTEQUALS:
opPos = diagnoseXPathBinaryOperation2("OP_NOTEQUALS", xpath, opPos,
indent);
break;
case xpath.OP_EQUALS:
opPos = diagnoseXPathBinaryOperation2("OP_EQUALS", xpath, opPos,
indent);
break;
case xpath.OP_LTE:
opPos = diagnoseXPathBinaryOperation2("OP_LTE", xpath, opPos, indent);
break;
case xpath.OP_LT:
opPos = diagnoseXPathBinaryOperation2("OP_LT", xpath, opPos, indent);
break;
case xpath.OP_GTE:
opPos = diagnoseXPathBinaryOperation2("OP_GTE", xpath, opPos, indent);
break;
case xpath.OP_GT:
opPos = diagnoseXPathBinaryOperation2("OP_GT", xpath, opPos, indent);
break;
case xpath.OP_PLUS:
opPos = diagnoseXPathBinaryOperation2("OP_PLUS", xpath, opPos,
indent);
break;
case xpath.OP_MINUS:
opPos = diagnoseXPathBinaryOperation2("OP_MINUS", xpath, opPos,
indent);
break;
case xpath.OP_MULT:
opPos = diagnoseXPathBinaryOperation2("OP_MULT", xpath, opPos,
indent);
break;
case xpath.OP_DIV:
opPos = diagnoseXPathBinaryOperation2("OP_DIV", xpath, opPos, indent);
break;
case xpath.OP_MOD:
opPos = diagnoseXPathBinaryOperation2("OP_MOD", xpath, opPos, indent);
break;
case xpath.OP_QUO:
opPos = diagnoseXPathBinaryOperation2("OP_QUO", xpath, opPos, indent);
break;
case xpath.OP_NEG:
opPos = diagnoseXPathUnaryOperation2("OP_NEG", xpath, opPos, indent);
break;
case xpath.OP_STRING:
opPos = diagnoseXPathUnaryOperation2("OP_STRING", xpath, opPos,
indent);
break;
case xpath.OP_BOOL:
opPos = diagnoseXPathUnaryOperation2("OP_BOOL", xpath, opPos, indent);
break;
case xpath.OP_NUMBER:
opPos = diagnoseXPathUnaryOperation2("OP_NUMBER", xpath, opPos,
indent);
break;
case xpath.OP_UNION:
opPos = diagnoseXPathMultiOperation2("OP_UNION",
xpath.OP_LOCATIONPATH, xpath, opPos, indent);
break;
case xpath.OP_LITERAL:
opPos = diagnoseXPathSimpleOperation2("OP_LITERAL", xpath, opPos,
indent);
break;
case xpath.OP_VARIABLE:
opPos = diagnoseXPathSimpleOperation2("OP_VARIABLE", xpath, opPos,
indent);
break;
case xpath.OP_GROUP:
opPos = diagnoseXPathUnaryOperation2("OP_GROUP", xpath, opPos,
indent);
break;
case xpath.OP_NUMBERLIT:
opPos = diagnoseXPathSimpleOperation2("OP_NUMBERLIT", xpath, opPos,
indent);
break;
case xpath.OP_ARGUMENT:
opPos = diagnoseXPathUnaryOperation2("OP_ARGUMENT", xpath, opPos,
indent);
break;
case xpath.OP_EXTFUNCTION:
{
diagnoseOp2SameLine("OP_EXTFUNCTION", xpath, opPos);
int endExtFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
opPos = diagnoseToken2SameLine(xpath, opPos);
opPos = diagnoseToken2(xpath, opPos);
while(opPos < endExtFunc)
{
opPos = diagnoseXPath2(xpath, opPos, indent+2);
}
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+1);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
}
break;
case xpath.OP_FUNCTION:
{
diagnoseOp2SameLine("OP_FUNCTION", xpath, opPos);
int endFunc = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
int funcID = xpath.m_opMap[opPos];
switch(funcID)
{
case xpath.FUNC_LAST: diagnoseOpNoLable2(opPos, "FUNC_LAST");
break;
case xpath.FUNC_POSITION: diagnoseOpNoLable2(opPos,
"FUNC_POSITION"); break;
case xpath.FUNC_COUNT: diagnoseOpNoLable2(opPos, "FUNC_COUNT");
break;
case xpath.FUNC_ID: diagnoseOpNoLable2(opPos, "FUNC_ID"); break;
case xpath.FUNC_KEY: diagnoseOpNoLable2(opPos, "FUNC_KEY");
break;
case xpath.FUNC_DOC: diagnoseOpNoLable2(opPos, "FUNC_DOC");
break;
case xpath.FUNC_LOCAL_PART: diagnoseOpNoLable2(opPos,
"FUNC_LOCAL_PART"); break;
case xpath.FUNC_NAMESPACE: diagnoseOpNoLable2(opPos,
"FUNC_NAMESPACE"); break;
case xpath.FUNC_QNAME: diagnoseOpNoLable2(opPos, "FUNC_QNAME");
break;
case xpath.FUNC_GENERATE_ID: diagnoseOpNoLable2(opPos,
"FUNC_GENERATE_ID"); break;
case xpath.FUNC_NOT: diagnoseOpNoLable2(opPos, "FUNC_NOT");
break;
case xpath.FUNC_TRUE: diagnoseOpNoLable2(opPos, "FUNC_TRUE");
break;
case xpath.FUNC_FALSE: diagnoseOpNoLable2(opPos, "FUNC_FALSE");
break;
case xpath.FUNC_BOOLEAN: diagnoseOpNoLable2(opPos,
"FUNC_BOOLEAN"); break;
case xpath.FUNC_LANG: diagnoseOpNoLable2(opPos, "FUNC_LANG");
break;
case xpath.FUNC_NUMBER: diagnoseOpNoLable2(opPos,
"FUNC_NUMBER"); break;
case xpath.FUNC_FLOOR: diagnoseOpNoLable2(opPos, "FUNC_FLOOR");
break;
case xpath.FUNC_CEILING: diagnoseOpNoLable2(opPos,
"FUNC_CEILING"); break;
case xpath.FUNC_ROUND: diagnoseOpNoLable2(opPos, "FUNC_ROUND");
break;
case xpath.FUNC_SUM: diagnoseOpNoLable2(opPos, "FUNC_SUM");
break;
case xpath.FUNC_STRING: diagnoseOpNoLable2(opPos,
"FUNC_STRING"); break;
case xpath.FUNC_STARTS_WITH: diagnoseOpNoLable2(opPos,
"FUNC_STARTS_WITH"); break;
case xpath.FUNC_CONTAINS: diagnoseOpNoLable2(opPos,
"FUNC_CONTAINS"); break;
case xpath.FUNC_SUBSTRING_BEFORE: diagnoseOpNoLable2(opPos,
"FUNC_SUBSTRING_BEFORE"); break;
case xpath.FUNC_SUBSTRING_AFTER: diagnoseOpNoLable2(opPos,
"FUNC_SUBSTRING_AFTER"); break;
case xpath.FUNC_NORMALIZE: diagnoseOpNoLable2(opPos,
"FUNC_NORMALIZE"); break;
case xpath.FUNC_TRANSLATE: diagnoseOpNoLable2(opPos,
"FUNC_TRANSLATE"); break;
case xpath.FUNC_CONCAT: diagnoseOpNoLable2(opPos,
"FUNC_CONCAT"); break;
case xpath.FUNC_FORMAT_NUMBER: diagnoseOpNoLable2(opPos,
"FUNC_FORMAT_NUMBER"); break;
case xpath.FUNC_SYSTEM_PROPERTY: diagnoseOpNoLable2(opPos,
"FUNC_SYSTEM_PROPERTY"); break;
case xpath.FUNC_EXT_FUNCTION_AVAILABLE:
diagnoseOpNoLable2(opPos, "FUNC_EXT_FUNCTION_AVAILABLE"); break;
case xpath.FUNC_EXT_ELEM_AVAILABLE: diagnoseOpNoLable2(opPos,
"FUNC_EXT_ELEM_AVAILABLE"); break;
case xpath.FUNC_SUBSTRING: diagnoseOpNoLable2(opPos,
"FUNC_SUBSTRING"); break;
case xpath.FUNC_STRING_LENGTH: diagnoseOpNoLable2(opPos,
"FUNC_STRING_LENGTH"); break;
case xpath.FUNC_DOCLOCATION: diagnoseOpNoLable2(opPos,
"FUNC_DOCLOCATION"); break;
}
opPos++;
while(opPos < endFunc)
{
// indent(indent+1);
opPos = diagnoseXPath2(xpath, opPos, indent+2);
}
indent(indent);
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+1);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
}
break;
case xpath.OP_LOCATIONPATH:
diagnoseOp2("OP_LOCATIONPATH", xpath, opPos);
int endPath = opPos+xpath.m_opMap[opPos+1]-1;
opPos+=2;
while(opPos < endPath)
{
opPos = diagnoseXPath2(xpath, opPos, indent+1);
}
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+1);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
break;
case xpath.OP_PREDICATE:
indent(1);
opPos = diagnoseXPathUnaryOperation2("OP_PREDICATE", xpath, opPos,
indent+1);
if(xpath.m_opMap[opPos] != xpath.ENDOP)
{
System.out.println("ERROR! Could not find ENDOP after
OP_LOCATIONPATH");
}
indent(indent+2);
diagnoseOpOnly2(opPos, "ENDOP");
opPos++;
break;
case xpath.FROM_ANCESTORS:
opPos = diagnoseXPathLocationStep2("FROM_ANCESTORS", xpath, opPos, 1);
break;
case xpath.FROM_ANCESTORS_OR_SELF:
opPos = diagnoseXPathLocationStep2("FROM_ANCESTORS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_ATTRIBUTES:
opPos = diagnoseXPathLocationStep2("FROM_ATTRIBUTES", xpath, opPos,
1);
break;
case xpath.FROM_CHILDREN:
opPos = diagnoseXPathLocationStep2("FROM_CHILDREN", xpath, opPos, 1);
break;
case xpath.FROM_DESCENDANTS:
opPos = diagnoseXPathLocationStep2("FROM_DESCENDANTS", xpath, opPos,
1);
break;
case xpath.FROM_DESCENDANTS_OR_SELF:
opPos = diagnoseXPathLocationStep2("FROM_DESCENDANTS_OR_SELF", xpath,
opPos, 1);
break;
case xpath.FROM_FOLLOWING:
opPos = diagnoseXPathLocationStep2("FROM_FOLLOWING", xpath, opPos,
indent);
break;
case xpath.FROM_FOLLOWING_SIBLINGS:
opPos = diagnoseXPathLocationStep2("FROM_FOLLOWING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_PARENT:
opPos = diagnoseXPathLocationStep2("FROM_PARENT", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING:
opPos = diagnoseXPathLocationStep2("FROM_PRECEDING", xpath, opPos,
indent);
break;
case xpath.FROM_PRECEDING_SIBLINGS:
opPos = diagnoseXPathLocationStep2("FROM_PRECEDING_SIBLINGS", xpath,
opPos, indent);
break;
case xpath.FROM_SELF:
opPos = diagnoseXPathLocationStep2("FROM_SELF", xpath, opPos, indent);
break;
case xpath.FROM_NAMESPACE:
opPos = diagnoseXPathLocationStep2("FROM_NAMESPACE", xpath, opPos,
indent);
break;
// case xpath.FROM_ATTRIBUTE:
// opPos = diagnoseXPathLocationStep("FROM_ATTRIBUTE", xpath,
opPos, indent);
// break;
// case xpath.FROM_DOC:
// opPos = diagnoseXPathLocationStep("FROM_DOC", xpath, opPos,
indent);
// break;
// case xpath.FROM_DOCREF:
// opPos = diagnoseXPathLocationStep("FROM_DOCREF", xpath, opPos,
indent);
// break;
// case xpath.FROM_ID:
// opPos = diagnoseXPathLocationStep("FROM_ID", xpath, opPos,
indent);
// break;
// case xpath.FROM_IDREF:
// opPos = diagnoseXPathLocationStep("FROM_IDREF", xpath, opPos,
indent);
// break;
case xpath.FROM_ROOT:
opPos = diagnoseXPathLocationStep2("FROM_ROOT", xpath, opPos, indent);
// opPos++;
break;
case xpath.NODETYPE_COMMENT:
diagnoseNodeTest2(opPos, "NODETYPE_COMMENT");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_TEXT:
diagnoseNodeTest2(opPos, "NODETYPE_TEXT");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_PI:
int piLen = xpath.m_opMap[opPos-1];
diagnoseNodeTest2(opPos, "NODETYPE_PI");
opPos++;
if(piLen > 3)
{
opPos = diagnoseToken(xpath, opPos);
}
break;
case xpath.NODETYPE_NODE:
diagnoseNodeTest2(opPos, "NODETYPE_NODE");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_ROOT:
diagnoseNodeTest2(opPos, "NODETYPE_ROOT");
System.out.println();
opPos++;
break;
case xpath.NODETYPE_ANYELEMENT:
diagnoseNodeTest2(opPos, "NODETYPE_ANYELEMENT");
System.out.println();
opPos++;
break;
case xpath.NODENAME:
diagnoseNodeTest2(opPos, "NODENAME");
opPos++;
if(xpath.m_opMap[opPos] < 0)
{
System.out.print(m_noLabel+"EMPTY"+m_close);
opPos++;
}
else
{
opPos = diagnoseToken2(xpath, opPos);
}
opPos = diagnoseToken2(xpath, opPos);
break;
default:
System.out.println("ERROR! Unknown op code: "+xpath.m_opMap[opPos]);
}
return opPos;
}
#endif
private:
static void
initializeKeywordsTable();
static void
initializeFunctionTable();
static void
initializeAxisNamesTable();
static void
initializeNodeTypesTable();
XPathEnvSupport& m_envSupport;
XPathSupport& m_support;
XPath* m_xpath;
DOMString m_token;
/**
* The first char in m_token, the theory being that this
* is an optimization because we won't have to do charAt(0) as
* often.
*/
XMLCh m_tokenChar;
/**
* A pointer to the current XPath's expression.
*/
XPathExpression* m_expression;
enum eDummy
{
TARGETEXTRA = 10000
};
/**
* Map of keyword names to token values.
*/
static KeywordsMapType s_keywords;
static FunctionNameMapType s_functions;
static AxisNamesMapType s_axisNames;
static NodeTypesMapType s_nodeTypes;
class StaticInitializer
{
public:
StaticInitializer();
~StaticInitializer()
{
}
};
friend class StaticInitializer;
};
#endif // XPATHPROCESSORIMPL_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathSupport.cpp
Index: XPathSupport.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathSupport.hpp"
XPathSupport::XPathSupport() :
Resettable()
{
}
XPathSupport::~XPathSupport()
{
}
1.1 xml-xalan/c/src/XPath/XPathSupport.hpp
Index: XPathSupport.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHSUPPORT_HEADER_GUARD_1357924680)
#define XPATHSUPPORT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <PlatformSupport/Resettable.hpp>
class DocumentHandler;
class URL;
class XALAN_XPATH_EXPORT XPathSupport : public Resettable
{
public:
XPathSupport();
virtual
~XPathSupport();
// These interfaces are inherited from Resettable...
/**
* Reset the instance.
*/
virtual void
reset() = 0;
// These interfaces are inherited from DOMServices::WhitespaceSupport...
/**
* Tell if the node is ignorable whitespace.
* This should be in the DOM. Return false if the
* parser doesn't handle this.
*/
virtual bool
isIgnorableWhitespace(const DOM_Text& node) const = 0;
// These interfaces are new to XPathSupport...
/**
* Given a namespace, get the corresponding prefix.
*/
virtual DOMString
getNamespaceForPrefix(
const DOMString& prefix,
const DOM_Element& namespaceContext) const = 0;
/**
* Returns the namespace of the given node.
*/
virtual DOMString
getNamespaceOfNode(const DOM_Node& n) const = 0;
/**
* Returns the local name of the given node.
*/
virtual DOMString
getLocalNameOfNode(const DOM_Node& n) const = 0;
/**
* Get node data recursively.
* (Note whitespace issues.)
*/
virtual DOMString
getNodeData(const DOM_Node& n) const = 0;
/**
* This function has to be implemented,
* because the DOM WG decided that attributes don't
* have parents.
*/
virtual DOM_Node
getParentOfNode(const DOM_Node& n) const = 0;
/**
* Provides support for XML parsing service.
*/
virtual DOM_Document
parseXML(
const DOMString& urlString,
const DOMString& base) const = 0;
/**
* Take a user string and try and parse XML, and also return
* the url.
* the error condition is severe enough to halt processing.
*/
virtual DOM_Document
parseXML(
const URL& url,
DocumentHandler& docHandler,
const DOM_Document& styleDoc) const = 0;
/**
* Get an element from an ID.
*/
virtual DOM_Element
getElementByID(
const DOMString& id,
const DOM_Document& doc) const = 0;
/**
* Take a user string and try and parse XML, and also return
* the url.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual URL*
getURLFromString(
const DOMString& urlString,
const DOMString& base) const = 0;
/**
* Set whether or not the liaison attempts to expand namespaces.
Used
* for optimization.
*/
virtual void
setProcessNamespaces(bool processNamespaces) = 0;
/**
* Tells if namespaces should be supported. For optimization purposes.
*/
virtual bool
getProcessNamespaces() const = 0;
/**
* The getUnparsedEntityURI function returns the URI of the unparsed
* entity with the specified name in the same document as the context
* node (see [3.3 Unparsed Entities]). It returns the empty string if
* there is no such entity.
*
* Since it states in the DOM draft: "An XML processor may choose to
* completely expand entities before the structure model is passed
* to the DOM; in this case, there will be no EntityReferences in the
DOM tree."
* So I'm not sure how well this is going to work.
*/
virtual DOMString
getUnparsedEntityURI(
const DOMString& theName,
const DOM_Document& theDocument) const = 0;
private:
// These are not implemented...
XPathSupport(const XPathSupport&);
XPathSupport&
operator=(const XPathSupport&);
bool
operator==(const XPathSupport&);
};
#endif // XPATHSUPPORT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPathSupportDefault.cpp
Index: XPathSupportDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPathSupportDefault.hpp"
#include <algorithm>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOM_Entity.hpp>
// $$$ ToDo: Eventually, we shouldn't have to do this, but we need ignorable
// whitespace support
#include <internal/XMLReader.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include <DOMSupport/DOMServices.hpp>
#include <DOMSupport/DOMSupport.hpp>
#include "XPathException.hpp"
XPathSupportDefault::XPathSupportDefault(DOMSupport& theDOMSupport) :
XPathSupport(),
WhitespaceSupport(),
m_DOMSupport(theDOMSupport)
{
}
XPathSupportDefault::~XPathSupportDefault()
{
}
void
XPathSupportDefault::reset()
{
m_DOMSupport.reset();
}
DOMString
XPathSupportDefault::getNamespaceForPrefix(
const DOMString& prefix,
const DOM_Element& namespaceContext) const
{
return DOMServices::getNamespaceForPrefix(prefix,
namespaceContext);
}
DOMString
XPathSupportDefault::getNamespaceOfNode(const DOM_Node& n) const
{
return m_DOMSupport.getNamespaceOfNode(n);
}
DOMString
XPathSupportDefault::getLocalNameOfNode(const DOM_Node& n) const
{
return DOMServices::getLocalNameOfNode(n);
}
DOMString
XPathSupportDefault::getNodeData(const DOM_Node& node) const
{
return DOMServices::getNodeData(node,
*this);
}
/**
* I have to write this silly, and expensive function,
* because the DOM WG decided that attributes don't
* have parents. If XPath is used with a DOM implementation
* that reuses attribute nodes, this will not work correctly.
*/
DOM_Node
XPathSupportDefault::getParentOfNode(const DOM_Node& node) const
{
return DOMServices::getParentOfNode(node);
}
bool
XPathSupportDefault::isIgnorableWhitespace(const DOM_Text& node) const
{
// $$$ ToDo: Eventually, we shouldn't have to do this, but we need ignorable
// whitespace support
const DOMString theData(node.getData());
return XMLReader::isAllSpaces(toCharArray(theData), length(theData));
}
DOM_Document
XPathSupportDefault::parseXML(
const DOMString& /* urlString */,
const DOMString& /* base */) const
{
return DOM_Document();
}
DOM_Document
XPathSupportDefault::parseXML(
const URL& /* url */,
DocumentHandler& /* docHandler */,
const DOM_Document& /* styleDoc */) const
{
return DOM_Document();
}
DOM_Element
XPathSupportDefault::getElementByID(
const DOMString& /* id */,
const DOM_Document& /* doc */) const
{
return DOM_Element();
}
URL*
XPathSupportDefault::getURLFromString(
const DOMString& /* urlString */,
const DOMString& /* base */) const
{
return 0;
}
void
XPathSupportDefault::setProcessNamespaces(bool /* processNamespaces */)
{
}
bool
XPathSupportDefault::getProcessNamespaces() const
{
return false;
}
DOMString
XPathSupportDefault::getUnparsedEntityURI(
const DOMString& theName,
const DOM_Document& theDocument) const
{
DOMString theURI;
const DOM_DocumentType theDoctype = theDocument.getDoctype();
if(theDoctype != 0)
{
DOM_NamedNodeMap theEntities = theDoctype.getEntities();
if (theEntities != 0)
{
const DOM_Node theNode =
theEntities.getNamedItem(theName);
if (theNode != 0 && theNode.getNodeType() ==
DOM_Node::ENTITY_NODE)
{
const DOM_Entity& theEntity =
static_cast<const DOM_Entity&>(theNode);
const DOMString theNotationName =
theEntity.getNotationName();
if(isEmpty(theNotationName) == false) // then
it's unparsed
{
// The draft says: "The XSLT processor
may use the public
// identifier to generate a URI for the
entity instead of the URI
// specified in the system identifier.
If the XSLT processor does
// not use the public identifier to
generate the URI, it must use
// the system identifier; if the system
identifier is a relative
// URI, it must be resolved into an
absolute URI using the URI of
// the resource containing the entity
declaration as the base
// URI [RFC2396]."
// So I'm falling a bit short here.
theURI = theEntity.getSystemId();
if(isEmpty(theURI) == true)
{
theURI =
theEntity.getPublicId();
}
else
{
// This should be resolved to
an absolute URL, but that's hard
// to do from here.
}
}
}
}
}
return theURI;
}
1.1 xml-xalan/c/src/XPath/XPathSupportDefault.hpp
Index: XPathSupportDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHSUPPORTDEFAULT_HEADER_GUARD_1357924680)
#define XPATHSUPPORTDEFAULT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XPathSupport.hpp>
#include <DOMSupport/DOMServices.hpp>
class DOMSupport;
class XALAN_XPATH_EXPORT XPathSupportDefault : public XPathSupport, public
DOMServices::WhitespaceSupport
{
public:
XPathSupportDefault(DOMSupport& theDOMSupport);
virtual
~XPathSupportDefault();
// These interfaces are inherited from Resettable...
/**
* Reset the instance.
*/
virtual void
reset();
// These interfaces are inherited from DOMServices::WhitespaceSupport...
/**
* Tell if the node is ignorable whitespace.
* This should be in the DOM. Return false if the
* parser doesn't handle this.
*/
virtual bool
isIgnorableWhitespace(const DOM_Text& node) const;
// These intefaces are inherited from XPathSupport...
/**
* Given a namespace, get the corresponding prefix.
*/
virtual DOMString
getNamespaceForPrefix(
const DOMString& prefix,
const DOM_Element& namespaceContext) const;
/**
* Returns the namespace of the given node.
*/
virtual DOMString
getNamespaceOfNode(const DOM_Node& n) const;
/**
* Returns the local name of the given node.
*/
virtual DOMString
getLocalNameOfNode(const DOM_Node& n) const;
/**
* Get node data recursively.
* (Note whitespace issues.)
*/
virtual DOMString
getNodeData(const DOM_Node& n) const;
/**
* This function has to be implemented,
* because the DOM WG decided that attributes don't
* have parents.
*/
virtual DOM_Node
getParentOfNode(const DOM_Node& node) const;
/**
* Provides support for XML parsing service.
*/
virtual DOM_Document
parseXML(
const DOMString& urlString,
const DOMString& base) const;
/**
* Take a user string and try and parse XML, and also return
* the url.
* the error condition is severe enough to halt processing.
*/
virtual DOM_Document
parseXML(
const URL& url,
DocumentHandler& docHandler,
const DOM_Document& styleDoc) const;
/**
* Get an element from an ID.
*/
virtual DOM_Element
getElementByID(
const DOMString& id,
const DOM_Document& doc) const;
/**
* Take a user string and try and parse XML, and also return
* the url.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual URL*
getURLFromString(
const DOMString& urlString,
const DOMString& base) const;
/**
* Set whether or not the liaison attempts to expand namespaces.
Used
* for optimization.
*/
virtual void
setProcessNamespaces(bool processNamespaces);
/**
* Tells if namespaces should be supported. For optimization purposes.
*/
virtual bool
getProcessNamespaces() const;
/**
* The getUnparsedEntityURI function returns the URI of the unparsed
* entity with the specified name in the same document as the context
* node (see [3.3 Unparsed Entities]). It returns the empty string if
* there is no such entity.
*
* Since it states in the DOM draft: "An XML processor may choose to
* completely expand entities before the structure model is passed
* to the DOM; in this case, there will be no EntityReferences in the
DOM tree."
* So I'm not sure how well this is going to work.
*/
virtual DOMString
getUnparsedEntityURI(
const DOMString& theName,
const DOM_Document& theDocument) const;
private:
// These are not implemented...
XPathSupportDefault(const XPathSupportDefault&);
XPathSupportDefault&
operator=(const XPathSupportDefault&);
bool
operator==(const XPathSupportDefault&);
// Data members...
DOMSupport& m_DOMSupport;
};
#endif // XPATHSUPPORTDEFAULT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XPointer.cpp
Index: XPointer.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XPointer.hpp"
#include <iostream>
XSpan*
XPointer::getNode(const DOMString& /* xpointer */)
{
using namespace std;
cerr << "Error! XPointer.getNode not yet implemented!"
<< endl;
return 0;
}
/**
* Get a span from an XPath (compiled XPointer) object.
*/
XSpan*
XPointer::getNode(XPath& /* xpath */)
{
using namespace std;
cerr << "Error! XPointer.getNode not yet implemented!"
<< endl;
return 0;
}
1.1 xml-xalan/c/src/XPath/XPointer.hpp
Index: XPointer.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPOINTER_HEADER_GUARD_1357924680)
#define XPOINTER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
class DOMString;
class XPath;
class XSpan;
class XALAN_XPATH_EXPORT XPointer
{
public:
/**
* Gets a span from an XPointer string.
*/
static XSpan*
getNode(const DOMString& xpointer);
/**
* Get a span from an XPath (compiled XPointer) object.
*/
static XSpan*
getNode(XPath& xpath);
};
#endif // XPOINTER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XResultTreeFrag.cpp
Index: XResultTreeFrag.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XResultTreeFrag.hpp"
#include <dom/DOM_Node.hpp>
#include <dom/DOM_NodeList.hpp>
#include <dom/DOM_Text.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include "NodeRefListBase.hpp"
#include "ResultTreeFragBase.hpp"
#include "XObjectTypeCallback.hpp"
#include "XPathSupport.hpp"
XResultTreeFrag::XResultTreeFrag(
XPathEnvSupport& envSupport,
XPathSupport& support,
const ResultTreeFragBase& val,
bool
deepClone) :
XObject(&envSupport),
m_support(support),
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
m_value(dynamic_cast<ResultTreeFragBase*>(val.clone(deepClone)))
#else
m_value(val.clone(deepClone))
#endif
{
}
XResultTreeFrag::XResultTreeFrag(
const XResultTreeFrag& source,
bool deepClone) :
XObject(source),
m_support(source.m_support),
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
m_value(dynamic_cast<ResultTreeFragBase*>(source.m_value->clone(deepClone)))
#else
m_value(source.m_value->clone(deepClone))
#endif
{
}
XResultTreeFrag::~XResultTreeFrag()
{
}
XResultTreeFrag::eObjectType
XResultTreeFrag::getType() const
{
return eTypeResultTreeFrag;
}
DOMString
XResultTreeFrag::getTypeString() const
{
return "#RESULT_TREE_FRAG";
}
double
XResultTreeFrag::num() const
{
const DOMString theValue =
m_support.getNodeData(DOM_ResultTreeFragBase(m_value.get()));
return DOMStringToDouble(theValue);
}
bool
XResultTreeFrag::boolean() const
{
bool fResult = false;
const NodeRefListBase& nl = m_value->getChildNodesAsNodeRefList();
const int nChildren = nl.getLength();
for(int i = 0; i < nChildren; i++)
{
const DOM_Node n = nl.item(i);
if(DOM_Node::TEXT_NODE == n.getNodeType())
{
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(n);
if (m_support.isIgnorableWhitespace(theTextNode) ||
length(trim(theTextNode.getData())) == 0)
{
continue;
}
fResult = true;
break;
}
}
return fResult;
}
DOMString
XResultTreeFrag::str() const
{
return m_support.getNodeData(DOM_ResultTreeFragBase(m_value.get()));
}
const ResultTreeFragBase&
XResultTreeFrag::rtree() const
{
return *m_value.get();
}
ResultTreeFragBase&
XResultTreeFrag::rtree()
{
return *m_value.get();
}
const NodeRefListBase&
XResultTreeFrag::nodeset() const
{
return m_value->getChildNodesAsNodeRefList();
}
const MutableNodeRefList&
XResultTreeFrag::mutableNodeset() const
{
error("Can't cast XResultTreeFrag to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
MutableNodeRefList&
XResultTreeFrag::mutableNodeset()
{
error("Can't cast XResultTreeFrag to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
void
XResultTreeFrag::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject)
{
theCallbackObject.ResultTreeFragment(*this,
rtree());
}
void
XResultTreeFrag::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const
{
theCallbackObject.ResultTreeFragment(*this,
rtree());
}
bool
XResultTreeFrag::equals(const XObject& theRHS) const
{
return ::equals(str(), theRHS.str());
}
1.1 xml-xalan/c/src/XPath/XResultTreeFrag.hpp
Index: XResultTreeFrag.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XRESULTTREEFRAG_HEADER_GUARD_1357924680)
#define XRESULTTREEFRAG_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <memory>
// Base class header file.
#include <XPath/XObject.hpp>
#include <dom/DOMString.hpp>
class XPathSupport;
class XALAN_XPATH_EXPORT XResultTreeFrag : public XObject
{
public:
XResultTreeFrag(
XPathEnvSupport& envSupport,
XPathSupport& support,
const ResultTreeFragBase& val,
bool
deepClone = true);
XResultTreeFrag(const XResultTreeFrag& source,
bool
deepClone = true);
virtual
~XResultTreeFrag();
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const;
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const;
/**
* Cast result object to a number.
*/
virtual double
num() const;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const;
virtual ResultTreeFragBase&
rtree();
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const;
/**
* Cast result object to a nodelist.
*/
virtual const MutableNodeRefList&
mutableNodeset() const;
virtual MutableNodeRefList&
mutableNodeset();
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const;
private:
XPathSupport& m_support;
std::auto_ptr<ResultTreeFragBase> m_value;
};
#endif // XRESULTTREEFRAG_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XSpan.cpp
Index: XSpan.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XSpan.hpp"
XSpan::XSpan(
XPathEnvSupport& envSupport,
XPathSupport& support,
const NodeRefListBase& value) :
XNodeSet(envSupport,
support,
value),
m_start(-1),
m_end(-1)
{
}
XSpan::XSpan(
XPathEnvSupport& envSupport,
XPathSupport& support,
const MutableNodeRefList& value) :
XNodeSet(envSupport,
support,
value),
m_start(-1),
m_end(-1)
{
}
XSpan::XSpan(
XPathEnvSupport& envSupport,
XPathSupport& support,
const DOM_Node& value) :
XNodeSet(envSupport,
support,
value),
m_start(-1),
m_end(-1)
{
}
XSpan::XSpan(const XSpan& source) :
XNodeSet(source),
m_start(source.m_start),
m_end(source.m_end)
{
}
XSpan::~XSpan()
{
}
int
XSpan::getStart() const
{
return m_start;
}
void
XSpan::setStart(int start)
{
m_start = start;
}
int
XSpan::getEnd() const
{
return m_end;
}
void
XSpan::setEnd(int end)
{
m_end = end;
}
void
XSpan::setSpan(
int firstNodeOffset,
int lastNodeOffset)
{
m_start = firstNodeOffset;
m_end = lastNodeOffset;
}
1.1 xml-xalan/c/src/XPath/XSpan.hpp
Index: XSpan.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XSPAN_HEADER_GUARD_1357924680)
#define XSPAN_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file.
#include <XPath/XNodeSet.hpp>
class XALAN_XPATH_EXPORT XSpan : public XNodeSet
{
public:
XSpan(
XPathEnvSupport& envSupport,
XPathSupport& support,
const NodeRefListBase& value = MutableNodeRefList());
XSpan(
XPathEnvSupport& envSupport,
XPathSupport& support,
const MutableNodeRefList& value =
MutableNodeRefList());
XSpan(
XPathEnvSupport& envSupport,
XPathSupport& support,
const DOM_Node& value);
XSpan(const XSpan& source);
virtual
~XSpan();
/**
* Get the start span offset from the first node,
* or -1 if offset isn't set.
*/
virtual int
getStart() const;
/**
* Set the start span offset from the first node,
* or pass -1 if offset isn't set.
*/
virtual void
setStart(int start);
/**
* Get the end span offset from start of the last node,
* or -1 if offset isn't set.
*/
virtual int
getEnd() const;
/**
* Set the end span offset from start of the last node,
* or -1 if offset isn't set.
*/
virtual void
setEnd(int end);
/**
* Set the range of the span, based on offsets from the
* first node and offsets from the last node.
*/
virtual void
setSpan(
int firstNodeOffset,
int lastNodeOffset);
private:
int m_start;
int m_end;
};
#endif // XSPAN_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XString.cpp
Index: XString.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XString.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
#include "ResultTreeFrag.hpp"
#include "XObjectTypeCallback.hpp"
#include "XPathEnvSupport.hpp"
#include "XPathSupport.hpp"
XString::XString(
XPathEnvSupport& envSupport,
XPathSupport& support,
const DOMString& val) :
XObject(&envSupport),
m_support(support),
m_value(val),
m_resultTreeFrag(0)
{
}
XString::XString(const XString& source) :
XObject(source),
m_support(source.m_support),
m_value(source.m_value),
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
0 :
dynamic_cast<ResultTreeFragBase*>(source.m_resultTreeFrag->clone(true)))
#else
m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
0 :
source.m_resultTreeFrag->clone(true))
#endif
{
}
XString::~XString()
{
}
XString::eObjectType
XString::getType() const
{
return eTypeString;
}
DOMString
XString::getTypeString() const
{
return "#STRING";
}
double
XString::num() const
{
return DOMStringToDouble(m_value);
}
bool
XString::boolean() const
{
return length(m_value) > 0 ? true : false;
}
DOMString
XString::str() const
{
return m_value;
}
const ResultTreeFragBase&
XString::rtree() const
{
assert(m_envSupport != 0);
if (m_resultTreeFrag.get() == 0)
{
ResultTreeFrag* const theFrag =
new ResultTreeFrag(m_envSupport->getDOMFactory(),
m_support);
#if defined(XALAN_OLD_AUTO_PTR)
m_resultTreeFrag = std::auto_ptr<ResultTreeFragBase>(theFrag);
#else
m_resultTreeFrag.reset(theFrag);
#endif
const DOM_Node textNode =
m_envSupport->getDOMFactory().createTextNode(str());
theFrag->appendChild(textNode);
}
return *m_resultTreeFrag.get();
}
ResultTreeFragBase&
XString::rtree()
{
if (m_resultTreeFrag.get() == 0)
{
ResultTreeFrag* const theFrag =
new ResultTreeFrag(m_envSupport->getDOMFactory(),
m_support);
#if defined(XALAN_OLD_AUTO_PTR)
m_resultTreeFrag = std::auto_ptr<ResultTreeFragBase>(theFrag);
#else
m_resultTreeFrag.reset(theFrag);
#endif
const DOM_Node textNode =
m_envSupport->getDOMFactory().createTextNode(str());
theFrag->appendChild(textNode);
}
return *m_resultTreeFrag.get();
}
const NodeRefListBase&
XString::nodeset() const
{
error("Can't cast XString to NodeRefListBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<NodeRefListBase*>(0);
}
const MutableNodeRefList&
XString::mutableNodeset() const
{
error("Can't cast XString to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
MutableNodeRefList&
XString::mutableNodeset()
{
error("Can't cast XString to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
void
XString::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject)
{
theCallbackObject.String(*this,
str());
}
void
XString::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const
{
theCallbackObject.String(*this,
str());
}
bool
XString::equals(const XObject& theRHS) const
{
return ::equals(m_value, theRHS.str());
}
1.1 xml-xalan/c/src/XPath/XString.hpp
Index: XString.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XSTRING_HEADER_GUARD_1357924680)
#define XSTRING_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Standard header files.
#include <memory>
#include <dom/DOMString.hpp>
// Base class header file.
#include <XPath/XObject.hpp>
class ResultTreeFragBase;
class XPathSupport;
class XALAN_XPATH_EXPORT XString : public XObject
{
public:
XString(
XPathEnvSupport& envSupport,
XPathSupport& support,
const DOMString& val);
XString(const XString& source);
virtual
~XString();
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const;
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const;
/**
* Cast result object to a number.
*/
virtual double
num() const;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const;
virtual ResultTreeFragBase&
rtree();
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const;
/**
* Cast result object to a nodelist.
*/
virtual const MutableNodeRefList&
mutableNodeset() const;
virtual MutableNodeRefList&
mutableNodeset();
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const;
private:
XPathSupport&
m_support;
const DOMString
m_value;
mutable std::auto_ptr<ResultTreeFragBase> m_resultTreeFrag;
};
#endif // XSTRING_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XUnknown.cpp
Index: XUnknown.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XUnknown.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
#include "XObjectTypeCallback.hpp"
XUnknown::XUnknown(
XPathEnvSupport& envSupport,
const DOMString& name) :
XObject(&envSupport),
m_name(name)
{
}
XUnknown::XUnknown(const XUnknown& source) :
XObject(source),
m_name(source.m_name)
{
}
XUnknown::~XUnknown()
{
}
XUnknown::eObjectType
XUnknown::getType() const
{
return eTypeUnknown;
}
DOMString
XUnknown::getTypeString() const
{
return "#UNKNOWN";
}
double
XUnknown::num() const
{
return 0.0;
}
bool
XUnknown::boolean() const
{
return false;
}
DOMString
XUnknown::str() const
{
return DOMString("Unknown variable: ") + m_name;
}
const ResultTreeFragBase&
XUnknown::rtree() const
{
error("Can't cast XUnknown to ResultTreeFragBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<ResultTreeFragBase*>(0);
}
ResultTreeFragBase&
XUnknown::rtree()
{
error("Can't cast XUnknown to ResultTreeFragBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<ResultTreeFragBase*>(0);
}
const NodeRefListBase&
XUnknown::nodeset() const
{
error("Can't cast XUnknown to NodeRefListBase");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<NodeRefListBase*>(0);
}
const MutableNodeRefList&
XUnknown::mutableNodeset() const
{
error("Can't cast XUnknown to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
MutableNodeRefList&
XUnknown::mutableNodeset()
{
error("Can't cast XUnknown to MutableNodeRefList");
// error will throw, so this is just a dummy
// value to satisfy the compiler.
return *static_cast<MutableNodeRefList*>(0);
}
void
XUnknown::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject)
{
theCallbackObject.Unknown(*this,
m_name);
}
void
XUnknown::ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const
{
theCallbackObject.Unknown(*this,
m_name);
}
bool
XUnknown::equals(const XObject& theRHS) const
{
return theRHS.getType() == eUnknown &&
::equals(m_name, static_cast<const
XUnknown&>(theRHS).m_name);
}
1.1 xml-xalan/c/src/XPath/XUnknown.hpp
Index: XUnknown.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XUKNOWN_HEADER_GUARD_1357924680)
#define XUKNOWN_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <dom/DOMString.hpp>
// Base class header file.
#include <XPath/XObject.hpp>
class XALAN_XPATH_EXPORT XUnknown : public XObject
{
public:
XUnknown(
XPathEnvSupport& envSupport,
const DOMString& name);
XUnknown(const XUnknown& source);
virtual
~XUnknown();
/**
* Tell what kind of class this is.
*/
virtual eObjectType
getType() const;
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*/
virtual DOMString
getTypeString() const;
/**
* Cast result object to a number.
*/
virtual double
num() const;
/**
* Cast result object to a boolean.
*/
virtual bool
boolean() const;
/**
* Cast result object to a string.
*/
virtual DOMString
str() const;
/**
* Cast result object to a result tree fragment.
*/
virtual const ResultTreeFragBase&
rtree() const;
virtual ResultTreeFragBase&
rtree();
/**
* Cast result object to a nodelist.
*/
virtual const NodeRefListBase&
nodeset() const;
/**
* Cast result object to a nodelist.
*/
virtual const MutableNodeRefList&
mutableNodeset() const;
virtual MutableNodeRefList&
mutableNodeset();
/**
* Process a callback request for preferred type information
*
*/
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback&
theCallbackObject) const;
/**
* Tell if two objects are functionally equal.
*/
virtual bool
equals(const XObject& theRHS) const;
private:
const DOMString m_name;
};
#endif // XUKNOWN_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/AVT.cpp
Index: AVT.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "AVT.hpp"
#include "PlatformSupport/StringTokenizer.hpp"
#include "AVTPartSimple.hpp"
#include "AVTPartXPath.hpp"
#include "XSLTEngineImpl.hpp"
/**
* Construct an AVT by parsing the string, and either
* constructing a vector of AVTParts, or simply hold
* on to the string if the AVT is simple.
*/
AVT::AVT(
const DOMString& name,
const XMLCh* type,
const XMLCh* stringedValue,
const PrefixResolver& resolver,
XSLTEngineImpl& processor):
AVTPart(), m_name(name), m_pcType(type)
{
StringTokenizer tokenizer(stringedValue, "{}\"\'", true);
int nTokens = tokenizer.countTokens();
if(nTokens < 2)
{
m_simpleString = stringedValue; // then do the simple thing
}
else
{
m_parts.reserve(nTokens+1);
DOMString buffer;
DOMString exprBuffer;
DOMString t; // base token
DOMString lookahead; // next token
DOMString error; // if non-null, break from loop
while(tokenizer.hasMoreTokens())
{
if(lookahead.length())
{
t = lookahead;
lookahead = "";
}
else t = tokenizer.nextToken();
if(t.length() == 1)
{
switch(t.charAt(0))
{
case('\"'):
case('\''):
{
// just keep on going, since
we're not in an attribute template
append(buffer,t);
break;
}
case('{'):
{
// Attribute Value Template
start
lookahead =
tokenizer.nextToken();
if(lookahead.equals("{"))
{
// Double curlys mean
escape to show curly
append(buffer,lookahead);
lookahead = "";
break; // from switch
}
/*
else if(lookahead.equals("\"")
|| lookahead.equals("\'"))
{
// Error. Expressions
can not begin with quotes.
error = "Expressions
can not begin with quotes.";
break; // from switch
}
*/
else
{
if(buffer.length() > 0)
{
m_parts.push_back(new AVTPartSimple(buffer));
buffer="";
}
exprBuffer = "";
append(exprBuffer,lookahead);
while((lookahead.length()>0) && (!lookahead.equals("}")))
{
lookahead =
tokenizer.nextToken();
if(lookahead.length() == 1)
{
switch(lookahead.charAt(0))
{
case '\'':
case '\"':
{
// String start
append(exprBuffer,lookahead);
DOMString quote = lookahead;
// Consume stuff 'till next quote
lookahead = tokenizer.nextToken();
while(!lookahead.equals(quote))
{
append(exprBuffer,lookahead);
lookahead = tokenizer.nextToken();
}
append(exprBuffer,lookahead);
break;
}
case '{':
{
// What's another curly doing here?
error = "Error: Can not have \"{\" within expression.";
break;
}
case '}':
{
// Proper close of attribute template.
// Evaluate the expression.
// XObject xobj = evalXPathStr(expression, contextNode,
namespaceContext);
// buffer.append(xobj.str());
buffer = "";
XPath *xpath = processor.createXPath(exprBuffer, resolver);
m_parts.push_back(new AVTPartXPath(xpath));
lookahead = ""; // breaks out of inner while loop
break;
}
default:
{
// part of the template stuff, just add it.
append(exprBuffer,lookahead);
}
} //
end inner switch
} // end if
lookahead length == 1
else
{
// part
of the template stuff, just add it.
append(exprBuffer,lookahead);
}
} // end
while(!lookahead.equals("}"))
if(error.length()>0)
{
break; // from
inner while loop
}
}
break;
}
case('}'):
{
lookahead =
tokenizer.nextToken();
if(lookahead.equals("}"))
{
// Double curlys mean
escape to show curly
append(buffer,lookahead);
lookahead = ""; //
swallow
}
else
{
// Illegal, I think...
processor.warn("Found
\"}\" but no attribute template open!");
append(buffer,"}");
// leave the lookahead
to be processed by the next round.
}
break;
}
default:
{
// Anything else just add to
string.
append(buffer,t);
}
} // end switch t
} // end if length == 1
else
{
// Anything else just add to string.
append(buffer,t);
}
if(error.length()>0)
{
processor.warn("Attr Template, "+error);
break;
}
} // end while(tokenizer.hasMoreTokens())
if(buffer.length() > 0)
{
m_parts.push_back(new AVTPartSimple(buffer));
buffer = "";
}
} // end else nTokens > 1
if(m_parts.empty() && (m_simpleString.length()==0))
{
// Error?
m_simpleString = "";
}
}
AVT::~AVT()
{
for (unsigned i=0; i<m_parts.size(); ++i)
delete (m_parts[i]);
m_pcType = 0;
}
void AVT::evaluate(DOMString& buf, const DOM_Node& context,
const PrefixResolver& resolver, const NodeRefListBase&
contextNodeList)
{
if(m_simpleString.length()>0)
{
buf = m_simpleString;
}
else if(!m_parts.empty())
{
buf = "";
int n = m_parts.size();
for(int i = 0; i < n; i++)
{
AVTPart* part = m_parts[i];
part->evaluate(buf, context, resolver, contextNodeList);
}
}
else
{
buf = "";
}
}
1.1 xml-xalan/c/src/XSLT/AVT.hpp
Index: AVT.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_AVT_HEADER_GUARD)
#define XALAN_AVT_HEADER_GUARD
/**
* $Id: AVT.hpp,v 1.1 1999/12/18 19:48:02 robweir Exp $
*
* $State: Exp $
*
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <xpath/XPathSupport.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include "AVTPart.hpp"
#include <vector>
class PrefixResolver;
class XSLTEngineImpl;
/**
* Class to hold an Attribute Value Template.
*/
class AVT: public AVTPart
{
public:
/**
* Construct an AVT by parsing the string, and either
* constructing a vector of AVTParts, or simply hold
* on to the string if the AVT is simple.
*/
AVT(const DOMString& name,
const XMLCh* type,
const XMLCh* stringedValue,
const PrefixResolver& resolver,
XSLTEngineImpl& processor);
virtual ~AVT();
/**
* Write the value into the buffer.
* @param buf Buffer to write into.
* @param context The current source tree context.
* @param resolver The current namespace PrefixResolver.
* @param NodeList The current Context Node List.
*/
virtual void evaluate(DOMString& buf, const DOM_Node& context,
const PrefixResolver& resolver, const NodeRefListBase&
contextNodeList);
const DOMString& getName() const
{
return m_name;
}
const XMLCh* getType() const
{
return m_pcType;
}
private:
// not implemented
AVT(const AVT &);
AVT& operator=(const AVT &);
/**
* If the AVT is not complex, just hold the simple string.
*/
DOMString m_simpleString;
/**
* If the AVT is complex, hold a Vector of AVTParts.
*/
std::vector<AVTPart *> m_parts;
/**
* The name of the attribute.
*/
DOMString m_name;
/**
* The attribute type;
*/
const XMLCh* m_pcType;
};
#endif // XALAN_AVT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/AVTPart.cpp
Index: AVTPart.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "AVTPart.hpp"
AVTPart::AVTPart()
{
}
AVTPart::~AVTPart()
{
}
1.1 xml-xalan/c/src/XSLT/AVTPart.hpp
Index: AVTPart.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_AVTPART_HEADER_GUARD)
#define XALAN_AVTPART_HEADER_GUARD
/**
* $Id: AVTPart.hpp,v 1.1 1999/12/18 19:48:02 robweir Exp $
*
* $State: Exp $
*
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
#include <xpath/XPathSupport.hpp>
#include <xpath/NodeRefListBase.hpp>
class PrefixResolver;
/**
* Class to hold a part, either a string or XPath,
* of an Attribute Value Template.
*/
class AVTPart
{
public:
AVTPart();
virtual
~AVTPart();
/**
* Write the value into the buffer.
* @param buf Buffer to write into.
* @param context The current source tree context.
* @param resolver The current namespace PrefixResolver.
* @param NodeList The current Context Node List.
*/
virtual void evaluate(DOMString& buf, const DOM_Node& context,
const PrefixResolver& resolver, const NodeRefListBase&
contextNodeList) = 0;
};
#endif //XALAN_AVTPART_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/AVTPartSimple.cpp
Index: AVTPartSimple.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "AVTPartSimple.hpp"
/**
* Simple string part of a complex AVT.
*/
AVTPartSimple::AVTPartSimple(const DOMString& val) : AVTPart(), m_val(val)
{
}
void AVTPartSimple::evaluate(DOMString& buf, const DOM_Node& /*context*/,
const PrefixResolver& /*resolver*/, const NodeRefListBase&
/*contextNodeList*/)
{
append(buf, m_val);
}
1.1 xml-xalan/c/src/XSLT/AVTPartSimple.hpp
Index: AVTPartSimple.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_AVTPARTSIMPLE_HEADER_GUARD)
#define XALAN_AVTPARTSIMPLE_HEADER_GUARD
/**
* $Id: AVTPartSimple.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <xpath/XPath.hpp>
#include <xpath/XPathProcessor.hpp>
#include <xpath/XPathFactory.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include "AVTPart.hpp"
/**
* Simple string part of a complex AVT.
*/
class AVTPartSimple: public AVTPart
{
public:
/**
* Construct a simple AVT part.
* @param val A pure string section of an AVT.
*/
AVTPartSimple(const DOMString& val);
/**
* Write the value into the buffer.
* @param buf Buffer to write into.
* @param context The current source tree context.
* @param resolver The current namespace PrefixResolver.
* @param NodeList The current Context Node List.
*/
virtual void evaluate(DOMString& buf, const DOM_Node& context,
const PrefixResolver& resolver, const NodeRefListBase&
contextNodeList);
private:
/**
* Simple string value;
*/
DOMString m_val;
};
#endif //XALAN_AVTPARTSIMPLE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/AVTPartXPath.cpp
Index: AVTPartXPath.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "AVTPartXPath.hpp"
/**
* Construct a simple AVT part.
* @param val A pure string section of an AVT.
*/
AVTPartXPath::AVTPartXPath(XPath* xpath) :AVTPart(), m_pXPath(xpath)
{
}
AVTPartXPath::AVTPartXPath(const DOMString& val, const PrefixResolver&
resolver,
XPathProcessor& xpathProcessor, XPathFactory& factory,
XMLParserLiaison& /*liaison*/):
AVTPart(), m_pXPath(factory.create())
{
xpathProcessor.initMatchPattern(*m_pXPath, val, resolver);
m_pXPath->shrink();
}
void AVTPartXPath::evaluate(DOMString& buf, const DOM_Node& context,
const PrefixResolver& resolver, const NodeRefListBase& contextNodeList)
{
const XObject* xobj = m_pXPath->execute(context, resolver,
contextNodeList);
if(0 != xobj)
{
append(buf,xobj->str());
}
}
1.1 xml-xalan/c/src/XSLT/AVTPartXPath.hpp
Index: AVTPartXPath.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_AVTPARTXPATH_HEADER_GUARD)
#define XALAN_AVTPARTXPATH_HEADER_GUARD
/**
* $Id: AVTPartXPath.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <xpath/XPath.hpp>
#include <xpath/XPathProcessor.hpp>
#include <xpath/XPathFactory.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include "AVTPart.hpp"
/**
* Simple string part of a complex AVT.
*/
class AVTPartXPath: public AVTPart
{
public:
/**
* Construct a simple AVT part.
* @param val A pure string section of an AVT.
*/
AVTPartXPath(XPath* xpath);
/**
* Construct a simple AVT part.
* @param val A pure string section of an AVT.
*/
AVTPartXPath(const DOMString& val, const PrefixResolver& resolver,
XPathProcessor& xpathProcessor,
XPathFactory& factory, XMLParserLiaison& liaison);
/**
* Write the value into the buffer.
* @param buf Buffer to write into.
* @param context The current source tree context.
* @param resolver The current namespace PrefixResolver.
* @param NodeList The current Context Node List.
*/
virtual void evaluate(DOMString& buf, const DOM_Node& context,
const PrefixResolver& resolver, const NodeRefListBase&
contextNodeList);
private:
/**
* Simple string value;
*/
XPath* m_pXPath;
};
#endif //XALAN_AVTPARTXPATH_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/Arg.cpp
Index: Arg.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
// Class header file.
#include "Arg.hpp"
// Other XSL4C header files.
#include <PlatformSupport/DOMStringHelper.hpp>
/*
* Construct an arg that represents an expression
*/
Arg::Arg(
const QName& name,
const DOMString& expr,
bool isParamVar) :
StackEntry(eArgument),
m_qname(name),
m_argType(eExpression),
m_isParamVar(isParamVar),
m_val(0),
m_expression(expr)
{
}
/*
* Construct an arg from an XObject
* NOTE: this should also be able to handle the case of a result tree
* fragment as an XRTreeFrag
*/
Arg::Arg(
const QName& name,
const XObject* val) :
StackEntry(eArgument),
m_qname(name),
m_argType(eXObject),
m_isParamVar(false),
m_val(val),
m_expression()
{
}
Arg::Arg(const Arg& theSource) :
StackEntry(theSource),
m_qname(theSource.m_qname),
m_argType(theSource.m_argType),
m_isParamVar(theSource.m_isParamVar),
m_val(theSource.m_val),
m_expression(theSource.m_expression)
{
}
Arg::~Arg()
{
m_val = 0;
}
bool
Arg::equals(const StackEntry& theRHS) const
{
bool theResult = false;
if(theRHS.getType() == eArgument)
{
const Arg& theArgRHS = static_cast<const Arg&>(theRHS);
if (getArgType() == theArgRHS.getArgType() &&
m_qname.equals(theArgRHS.m_qname) == true)
{
theResult = true;
}
}
return theResult;
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
StackEntry*
#else
Arg*
#endif
Arg::clone() const
{
return new Arg(*this);
}
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/Arg.hpp
Index: Arg.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_ARG_HEADER_GUARD)
#define XALAN_ARG_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <XPath/QName.hpp>
// Base class header file.
#include "StackEntry.hpp"
#include <cassert>
class XObject;
class DOMString;
/**
* This class holds an instance of an argument on the stack.
*/
class Arg : public StackEntry
{
public:
enum eArgumentType { eXObject, eResultTreeFrag, eExpression };
virtual ~Arg();
/**
* Override equals and agree that we're equal if the passed object is a
* string and it matches the name of the arg.
*/
virtual bool
equals(const StackEntry& theRHS) const;
const QName& getName() const { return m_qname; }
bool
getIsParamVar() const
{
return m_isParamVar;
}
eArgumentType
getArgType() const
{
return m_argType;
}
const XObject* getXObjectPtr() const { return m_val; }
void setXObjectPtr(XObject* pxobj) { m_val = pxobj; }
const DOMString& getExpression() const {return m_expression; };
void setExpression(const DOMString& pexpr) {m_expression = pexpr; };
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual StackEntry*
#else
virtual Arg*
#endif
clone() const;
Arg(const Arg& theSource);
// java: Arg(QName qname, String expression, boolean isParamVar)
Arg(
const QName& name,
const DOMString& expr,
bool isParamVar);
Arg(
const QName& name,
const XObject* val);
private:
QName m_qname;
eArgumentType m_argType;
bool m_isParamVar;
const XObject* m_val;
DOMString m_expression;
};
#endif // XALAN_ARG_HEADER_GUARD
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/Constants.hpp
Index: Constants.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_CONSTANTS_HEADER_GUARD)
#define XALAN_CONSTANTS_HEADER_GUARD
/**
* $State: Exp $
*
* @author Scott Boag ([EMAIL PROTECTED])
* @author David N. Bertoni ([EMAIL PROTECTED])
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
/**
* Primary constants used in the XSLTProcessor classes.
*/
namespace Constants
{
static const DOMString S_XMLNAMESPACEURI =
"http://www.w3.org/XML/1998/namespace";
/**
* IDs for XSL element types. These are associated
* with the string literals in the XSLTProcessor class.
* Don't change the numbers.
*/
static const int ELEMNAME_UNDEFINED = -1;
static const int ELEMNAME_WITHPARAM = 2;
static const int ELEMNAME_ADDATTRIBUTE = 4;
static const int ELEMNAME_ANCHOR = 22;
// static const int ELEMNAME_ANCHOR_PATTERN = 23;
static const int ELEMNAME_APPLY_TEMPLATES = 50;
static const int ELEMNAME_USE = 34;
static const int ELEMNAME_CHILDREN = 6;
static const int ELEMNAME_CHOOSE = 37;
static const int ELEMNAME_COMMENT = 59; // my own
static const int ELEMNAME_CONSTRUCT = 7; // my own
static const int ELEMNAME_CONTENTS = 8;
static const int ELEMNAME_COPY = 9;
static const int ELEMNAME_COPY_OF = 74;
static const int ELEMNAME_DEFINEATTRIBUTESET = 40;
// static const int ELEMNAME_DEFINECONSTANT = 29;
// static const int ELEMNAME_DEFINEMACRO = 10;
static const int ELEMNAME_DEFINESCRIPT = 11;
static const int ELEMNAME_DISPLAYIF = 12; // my own
static const int ELEMNAME_EMPTY = 14;
static const int ELEMNAME_EVAL = 15;
static const int ELEMNAME_EXPECTEDCHILDREN = 16;
static const int ELEMNAME_EXTENSION = 54;
static const int ELEMNAME_EXTENSIONHANDLER = 63;
static const int ELEMNAME_FOREACH = 28;
static const int ELEMNAME_KEY = 31;
static const int ELEMNAME_IF = 36;
static const int ELEMNAME_IMPORT = 26;
static const int ELEMNAME_INCLUDE = 27;
static const int ELEMNAME_CALLTEMPLATE = 17;
static const int ELEMNAME_PARAMVARIABLE = 41;
static const int ELEMNAME_NUMBER = 35;
static const int ELEMNAME_OTHERWISE = 39;
static const int ELEMNAME_PI = 58;
static const int ELEMNAME_PRESERVESPACE = 33;
static const int ELEMNAME_REMOVEATTRIBUTE = 5;
static const int ELEMNAME_TEMPLATE = 19;
static const int ELEMNAME_SORT = 64;
static const int ELEMNAME_STRIPSPACE = 32;
static const int ELEMNAME_STYLESHEET = 25;
static const int ELEMNAME_TEXT = 42;
static const int ELEMNAME_VALUEOF = 30;
static const int ELEMNAME_WHEN = 38;
// Pattern by example support
static const int ELEMNAME_ROOT = 44;
static const int ELEMNAME_ANY = 45;
static const int ELEMNAME_ELEMENT = 46;
static const int ELEMNAME_TARGETELEMENT = 47;
static const int ELEMNAME_ATTRIBUTE = 48;
static const int ELEMNAME_TARGETATTRIBUTE = 49;
static const int ELEMNAME_URL = 52; // my own
static const int ELEMNAME_CALL = 55; // my own
static const int ELEMNAME_PARAM = 56;
static const int ELEMNAME_FALLBACK = 57; // my own
static const int ELEMNAME_TARGETPI = 60; // my own
static const int ELEMNAME_TARGETCOMMENT = 61; // my own
static const int ELEMNAME_TARGETTEXT = 62; // my own
static const int ELEMNAME_CSSSTYLECONVERSION = 65; // my own
static const int ELEMNAME_COUNTER = 66;
static const int ELEMNAME_COUNTERS = 67;
static const int ELEMNAME_COUNTERINCREMENT = 68;
static const int ELEMNAME_COUNTERRESET = 69;
static const int ELEMNAME_COUNTERSCOPE = 71;
static const int ELEMNAME_APPLY_IMPORTS = 72;
static const int ELEMNAME_VARIABLE = 73;
static const int ELEMNAME_MESSAGE = 75;
static const int ELEMNAME_LOCALE = 76;
static const int ELEMNAME_LITERALRESULT = 77;
static const int ELEMNAME_TEXTLITERALRESULT = 78;
static const int ELEMNAME_EXTENSIONCALL = 79;
static const int ELEMNAME_OUTPUT = 80;
static const int ELEMNAME_COMPONENT = 81;
static const int ELEMNAME_SCRIPT = 82;
// Next free number: 83
/**
* Literals for XSL element names. Note that there are more
* names than IDs, because some names map to the same ID.
*/
// Result tree counting
static const DOMString ELEMNAME_ANCHOR_STRING = "anchor";
static const DOMString ELEMNAME_ANY_STRING = "any"; //
pattern-by-example support
static const DOMString ELEMNAME_APPLY_IMPORTS_STRING = "apply-imports";
static const DOMString ELEMNAME_APPLY_TEMPLATES_STRING =
"apply-templates";
static const DOMString ELEMNAME_ARG_STRING = "arg";
static const DOMString ELEMNAME_ATTRIBUTESET_STRING = "attribute-set";
static const DOMString ELEMNAME_ATTRIBUTE_STRING = "attribute"; //
pattern-by-example support
static const DOMString ELEMNAME_CALLTEMPLATEARG_STRING = "invoke-arg";
static const DOMString ELEMNAME_CALLTEMPLATE_STRING = "call-template";
static const DOMString ELEMNAME_CALL_STRING = "call";
static const DOMString ELEMNAME_CHILDREN_STRING = "children";
static const DOMString ELEMNAME_CHOOSE_STRING = "choose";
static const DOMString ELEMNAME_COMMENT_STRING = "comment";
static const DOMString ELEMNAME_CONSTRUCT_STRING = "construct"; // my
own
static const DOMString ELEMNAME_CONTENTS_STRING = "contents";
static const DOMString ELEMNAME_COPY_OF_STRING = "copy-of";
static const DOMString ELEMNAME_COPY_STRING = "copy";
static const DOMString ELEMNAME_COUNTERINCREMENT_STRING =
"counter-increment";
static const DOMString ELEMNAME_COUNTERRESET_STRING = "counter-reset";
static const DOMString ELEMNAME_COUNTERSCOPE_STRING = "counter-scope";
static const DOMString ELEMNAME_COUNTERS_STRING = "counters";
static const DOMString ELEMNAME_COUNTER_STRING = "counter";
static const DOMString ELEMNAME_DISPLAYIF_STRING = "display-if"; // my
own
static const DOMString ELEMNAME_ELEMENT_STRING = "element"; //
pattern-by-example support
static const DOMString ELEMNAME_EMPTY_STRING = "empty";
static const DOMString ELEMNAME_EVAL_STRING = "eval";
static const DOMString ELEMNAME_EXPECTEDCHILDREN_STRING =
"expectedchildren";
static const DOMString ELEMNAME_EXTENSIONHANDLER_STRING =
"code-dispatcher";
static const DOMString ELEMNAME_EXTENSION_STRING = "functions";
static const DOMString ELEMNAME_FALLBACK_STRING = "fallback";
static const DOMString ELEMNAME_FOREACH_STRING = "for-each";
static const DOMString ELEMNAME_IF_STRING = "if";
static const DOMString ELEMNAME_IMPORT_STRING = "import";
static const DOMString ELEMNAME_INCLUDE_STRING = "include";
static const DOMString ELEMNAME_KEY_STRING = "key";
static const DOMString ELEMNAME_LOCALE_STRING = "locale";
static const DOMString ELEMNAME_MESSAGE_STRING = "message";
static const DOMString ELEMNAME_NUMBER_STRING = "number";
static const DOMString ELEMNAME_OTHERWISE_STRING = "otherwise";
static const DOMString ELEMNAME_PARAM_STRING = "param";
static const DOMString ELEMNAME_PRESERVESPACE_STRING = "preserve-space";
static const DOMString ELEMNAME_ROOT_STRING = "root"; //
pattern-by-example support
static const DOMString ELEMNAME_SORT_STRING = "sort";
static const DOMString ELEMNAME_STRIPSPACE_STRING = "strip-space";
static const DOMString ELEMNAME_STYLESHEET_STRING = "stylesheet";
static const DOMString ELEMNAME_TARGETATTRIBUTE_STRING =
"target-attribute"; // pattern-by-example support
static const DOMString ELEMNAME_TARGETCOMMENT_STRING = "target-comment";
static const DOMString ELEMNAME_TARGETELEMENT_STRING =
"target-element"; // pattern-by-example support
static const DOMString ELEMNAME_TARGETPI_STRING = "target-pi";
static const DOMString ELEMNAME_TARGETTEXT_STRING = "target-text";
static const DOMString ELEMNAME_TEMPLATE_STRING = "template";
static const DOMString ELEMNAME_TEXT_STRING = "text";
static const DOMString ELEMNAME_TRANSFORM_STRING = "transform";
static const DOMString ELEMNAME_URL_STRING = "uri"; //
pattern-by-example support
static const DOMString ELEMNAME_USE_STRING = "use";
static const DOMString ELEMNAME_VALUEOF_STRING = "value-of";
static const DOMString ELEMNAME_VARIABLE_STRING = "variable";
static const DOMString ELEMNAME_WHEN_STRING = "when";
static const DOMString ELEMNAME_COMPONENT_STRING = "component";
static const DOMString ELEMNAME_CSSSTYLECONVERSION_STRING =
"css-style-conversion";
static const DOMString ELEMNAME_OUTPUT_STRING = "output";
static const DOMString ELEMNAME_PARAMVARIABLE_OLD_STRING =
"param-variable";
static const DOMString ELEMNAME_PARAMVARIABLE_STRING = "param";
static const DOMString ELEMNAME_PI_OLD_STRING = "pi";
static const DOMString ELEMNAME_PI_STRING = "processing-instruction";
static const DOMString ELEMNAME_SCRIPT_STRING = "script";
static const DOMString ELEMNAME_WITHPARAM_STRING = "with-param";
/*---------------------------------------------
* Literals for XSL attribute names.
*/
static const DOMString ATTRNAME_CLASS = "class";
static const DOMString ATTRNAME_ATTRIBUTE = "attribute";
static const DOMString ATTRNAME_ATTRIBUTE_SET = "attribute-set";
static const DOMString ATTRNAME_AMOUNT = "amount";
static const DOMString ATTRNAME_ANCESTOR = "ancestor";
static const DOMString ATTRNAME_CASEORDER = "case-order";
static const DOMString ATTRNAME_CONDITION = "condition";
static const DOMString ATTRNAME_COPYTYPE = "copy-type";
static const DOMString ATTRNAME_COUNT = "count";
static const DOMString ATTRNAME_DATATYPE = "data-type";
static const DOMString ATTRNAME_DEFAULTSPACE = "default-space";
static const DOMString ATTRNAME_DEFAULT = "default";
static const DOMString ATTRNAME_DEPTH = "with-children";
static const DOMString ATTRNAME_DIGITGROUPSEP = "digit-group-sep";
static const DOMString ATTRNAME_ELEMENT = "element";
static const DOMString ATTRNAME_ELEMENTS = "elements";
static const DOMString ATTRNAME_EXPR = "expr";
static const DOMString ATTRNAME_EXTENSIONELEMENTPREFIXES =
"extension-element-prefixes";
static const DOMString ATTRNAME_FORMAT = "format";
static const DOMString ATTRNAME_FROM = "from";
static const DOMString ATTRNAME_GROUPINGSEPARATOR =
"grouping-separator";
static const DOMString ATTRNAME_GROUPINGSIZE = "grouping-size";
static const DOMString ATTRNAME_HREF = "href";
static const DOMString ATTRNAME_ID = "id";
static const DOMString ATTRNAME_IMPORTANCE = "importance";
static const DOMString ATTRNAME_INDENTRESULT = "indent-result";
static const DOMString ATTRNAME_LETTERVALUE = "letter-value";
static const DOMString ATTRNAME_LEVEL = "level";
static const DOMString ATTRNAME_LANG = "lang";
// static const DOMString ATTRNAME_MACRO = "macro";
static const DOMString ATTRNAME_MATCH = "match";
static const DOMString ATTRNAME_MODE = "mode";
static const DOMString ATTRNAME_NAME = "name";
static const DOMString ATTRNAME_NAMESPACE = "namespace";
static const DOMString ATTRNAME_NDIGITSPERGROUP = "n-digits-per-group";
static const DOMString ATTRNAME_ONLY = "only";
static const DOMString ATTRNAME_ORDER = "order";
static const DOMString ATTRNAME_PRIORITY = "priority";
static const DOMString ATTRNAME_REFID = "refID";
static const DOMString ATTRNAME_RESULTNS = "result-ns";
static const DOMString ATTRNAME_SELECT = "select";
static const DOMString ATTRNAME_SEQUENCESRC = "sequence-src";
static const DOMString ATTRNAME_STYLE = "style";
static const DOMString ATTRNAME_TEST = "test";
static const DOMString ATTRNAME_TOSTRING = "to-string";
static const DOMString ATTRNAME_TYPE = "type";
static const DOMString ATTRNAME_USE = "use";
static const DOMString ATTRNAME_USEATTRIBUTESETS = "use-attribute-sets";
static const DOMString ATTRNAME_VALUE = "value";
static const DOMString ATTRNAME_XMLNSDEF = "xmlns";
static const DOMString ATTRNAME_XMLNS = "xmlns:";
static const DOMString ATTRNAME_XMLSPACE = "xml:space";
// Atributes on the functions element
static const DOMString ATTRNAME_NS = "ns";
static const DOMString ATTRNAME_CLASSID = "classid";
static const DOMString ATTRNAME_ARCHIVE = "archive";
static const DOMString ATTRNAME_CODETYPE = "type";
static const DOMString ATTRNAME_CODEBASE = "codebase";
static const DOMString ATTRNAME_METHOD = "calls";
// For space-att
static const DOMString ATTRVAL_PRESERVE = "preserve";
static const DOMString ATTRVAL_STRIP = "strip";
// For indent-result
static const DOMString ATTRVAL_YES = "yes";
static const DOMString ATTRVAL_NO = "no";
// For letter-value attribute (part of conversion attributes).
static const DOMString ATTRVAL_ALPHABETIC = "alphabetic";
static const DOMString ATTRVAL_OTHER = "other";
// For level attribute in xsl:number.
static const DOMString ATTRVAL_SINGLE = "single";
static const DOMString ATTRVAL_MULTI = "multiple";
static const DOMString ATTRVAL_ANY = "any";
// Output stuff -- JMD
static const DOMString ATTRNAME_OUTPUT_METHOD = "method"; // qname,
static const DOMString ATTRNAME_DISABLE_OUTPUT_ESCAPING =
"disable-output-escaping";
static const DOMString ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS =
"cdata-section-elements";
static const DOMString ATTRNAME_OUTPUT_DOCTYPE_PUBLIC =
"doctype-public";
static const DOMString ATTRNAME_OUTPUT_DOCTYPE_SYSTEM =
"doctype-system";
static const DOMString ATTRNAME_OUTPUT_ENCODING = "encoding";
static const DOMString ATTRNAME_OUTPUT_INDENT = "indent";
static const DOMString ATTRNAME_OUTPUT_MEDIATYPE = "media-type";
static const DOMString ATTRNAME_OUTPUT_STANDALONE = "standalone";
static const DOMString ATTRNAME_OUTPUT_VERSION = "version";
static const DOMString ATTRNAME_OUTPUT_XMLDECL = "xml-declaration";
static const DOMString ATTRVAL_OUTPUT_METHOD_HTML = "html";
static const DOMString ATTRVAL_OUTPUT_METHOD_XML = "xml";
static const DOMString ATTRVAL_OUTPUT_METHOD_TEXT = "text";
/*
* Integer equivalents for above
*/
static const int NUMBERLEVEL_SINGLE = 1;
static const int NUMBERLEVEL_MULTI = 2;
static const int NUMBERLEVEL_ANY = 3;
static const int MAX_MULTI_COUNTING_DEPTH = 32;
// some stuff for my patterns-by-example
static const DOMString ATTRVAL_THIS = ".";
static const DOMString ATTRVAL_PARENT = "..";
static const DOMString ATTRVAL_ANCESTOR = "ancestor";
static const DOMString ATTRVAL_ID = "id";
static const int TATTRNAME_OUTPUT_METHOD = 1;
static const int TATTRNAME_AMOUNT = 2;
static const int TATTRNAME_ANCESTOR = 3;
static const int TATTRNAME_ARCHIVE = 4;
static const int TATTRNAME_ATTRIBUTE = 5;
static const int TATTRNAME_ATTRIBUTE_SET = 6;
static const int TATTRNAME_CASEORDER = 7;
static const int TATTRNAME_CLASS = 8;
static const int TATTRNAME_CLASSID = 9;
static const int TATTRNAME_CODEBASE = 10;
static const int TATTRNAME_CODETYPE = 11;
static const int TATTRNAME_CONDITION = 12;
static const int TATTRNAME_COPYTYPE = 13;
static const int TATTRNAME_COUNT = 14;
static const int TATTRNAME_DATATYPE = 15;
static const int TATTRNAME_DEFAULT = 16;
static const int TATTRNAME_DEFAULTSPACE = 17;
static const int TATTRNAME_DEPTH = 18;
static const int TATTRNAME_DIGITGROUPSEP = 19;
static const int TATTRNAME_DISABLE_OUTPUT_ESCAPING = 20;
static const int TATTRNAME_ELEMENT = 21;
static const int TATTRNAME_ELEMENTS = 22;
static const int TATTRNAME_EXPR = 23;
static const int TATTRNAME_EXTENSIONELEMENTPREFIXES = 24;
static const int TATTRNAME_FORMAT = 25;
static const int TATTRNAME_FROM = 26;
static const int TATTRNAME_GROUPINGSEPARATOR = 27;
static const int TATTRNAME_GROUPINGSIZE = 28;
static const int TATTRNAME_HREF = 29;
static const int TATTRNAME_ID = 30;
static const int TATTRNAME_IMPORTANCE = 31;
static const int TATTRNAME_INDENTRESULT = 32;
static const int TATTRNAME_LANG = 33;
static const int TATTRNAME_LETTERVALUE = 34;
static const int TATTRNAME_LEVEL = 35;
static const int TATTRNAME_MATCH = 36;
static const int TATTRNAME_METHOD = 37;
static const int TATTRNAME_MODE = 38;
static const int TATTRNAME_NAME = 39;
static const int TATTRNAME_NAMESPACE = 40;
static const int TATTRNAME_NDIGITSPERGROUP = 41;
static const int TATTRNAME_NS = 42;
static const int TATTRNAME_ONLY = 43;
static const int TATTRNAME_ORDER = 44;
static const int TATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS = 45;
static const int TATTRNAME_OUTPUT_DOCTYPE_PUBLIC = 46;
static const int TATTRNAME_OUTPUT_DOCTYPE_SYSTEM = 47;
static const int TATTRNAME_OUTPUT_ENCODING = 48;
static const int TATTRNAME_OUTPUT_INDENT = 49;
static const int TATTRNAME_OUTPUT_MEDIATYPE = 50;
static const int TATTRNAME_OUTPUT_STANDALONE = 51;
static const int TATTRNAME_OUTPUT_VERSION = 52;
static const int TATTRNAME_OUTPUT_XMLDECL = 53;
static const int TATTRNAME_PRIORITY = 54;
static const int TATTRNAME_REFID = 55;
static const int TATTRNAME_RESULTNS = 56;
static const int TATTRNAME_SELECT = 57;
static const int TATTRNAME_SEQUENCESRC = 58;
static const int TATTRNAME_STYLE = 59;
static const int TATTRNAME_TEST = 60;
static const int TATTRNAME_TOSTRING = 61;
static const int TATTRNAME_TYPE = 62;
static const int TATTRNAME_USE = 63;
static const int TATTRNAME_USEATTRIBUTESETS = 64;
static const int TATTRNAME_VALUE = 65;
static const int TATTRNAME_XMLNSDEF = 66;
static const int TATTRNAME_XMLNS = 67;
static const int TATTRNAME_XMLSPACE = 68;
// These are used mainly for keys in the pattern lookup table,
// for those nodes that don't have unique lookup values
static const DOMString PSEUDONAME_ANY = "*";
static const DOMString PSEUDONAME_ROOT = "/";
static const DOMString PSEUDONAME_TEXT = "#text";
static const DOMString PSEUDONAME_COMMENT = "#comment";
static const DOMString PSEUDONAME_PI = "#pi";
static const DOMString PSEUDONAME_OTHER = "*";
// Stuff for sorting
static const DOMString ATTRVAL_DATATYPE_TEXT = "text";
static const DOMString ATTRVAL_DATATYPE_NUMBER = "number";
static const DOMString ATTRVAL_ORDER_ASCENDING = "ascending";
static const DOMString ATTRVAL_ORDER_DESCENDING = "descending";
static const DOMString ATTRVAL_CASEORDER_UPPER = "upper-first";
static const DOMString ATTRVAL_CASEORDER_LOWER = "lower-first";
}
#endif // XALAN_CONSTANTS_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ContextMarker.cpp
Index: ContextMarker.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ContextMarker.hpp"
ContextMarker::ContextMarker(
const DOM_Node& caller,
const DOM_Node& sourceNode) :
ContextState(caller,
sourceNode,
eContextMarker)
{
}
ContextMarker::ContextMarker(const ContextMarker& theSource) :
ContextState(theSource)
{
}
ContextMarker::~ContextMarker()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
StackEntry*
#else
ContextMarker*
#endif
ContextMarker::clone() const
{
return new ContextMarker(*this);
}
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/ContextMarker.hpp
Index: ContextMarker.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_CONTEXTMARKER_HEADER_GUARD)
#define XALAN_CONTEXTMARKER_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOM_Node.hpp>
// Base class header file.
#include "ContextState.hpp"
/**
* This class marks where a call context ends. Only
* calls above this marker at the top of the stack can
* be reached with getVariable(String name).
*/
class ContextMarker : public ContextState
{
public:
ContextMarker(
const DOM_Node& caller,
const DOM_Node& sourceNode);
ContextMarker(const ContextMarker& theSource);
virtual
~ContextMarker();
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual StackEntry*
#else
virtual ContextMarker*
#endif
clone() const;
};
#endif // XALAN_CONTEXTMARKER_HEADER_GUARD
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/ContextState.cpp
Index: ContextState.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ContextState.hpp"
ContextState::ContextState(
const DOM_Node& caller,
const DOM_Node& sourceNode) :
StackEntry(eContextState),
m_caller(caller),
m_source(sourceNode)
{
}
ContextState::ContextState(
const DOM_Node& caller,
const DOM_Node& sourceNode,
eStackEntryType theType) :
StackEntry(theType),
m_caller(caller),
m_source(sourceNode)
{
}
ContextState::ContextState(const ContextState& theSource) :
StackEntry(theSource),
m_caller(theSource.m_caller),
m_source(theSource.m_source)
{
}
ContextState::~ContextState()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
StackEntry*
#else
ContextState*
#endif
ContextState::clone() const
{
return new ContextState(*this);
}
bool
ContextState::equals(const StackEntry& rhs) const
{
if (getType() == rhs.getType() &&
m_caller == static_cast<const ContextState&>(rhs).m_caller &&
m_source == static_cast<const ContextState&>(rhs).m_source)
{
return true;
}
else
{
return false;
}
}
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/ContextState.hpp
Index: ContextState.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_CONTEXTSTATE_HEADER_GUARD)
#define XALAN_CONTEXTSTATE_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOM_Node.hpp>
// Base class header file.
#include "StackEntry.hpp"
/**
* This class marks where a macro call context ends. Only
* calls above this marker at the top of the stack can
* be reached with getVariable(String name).
*/
class ContextState : public StackEntry
{
public:
ContextState(
const DOM_Node& caller,
const DOM_Node& sourceNode);
ContextState(const ContextState& theSource);
virtual
~ContextState();
const DOM_Node&
getCaller() const
{
return m_caller;
}
const DOM_Node&
getSource() const
{
return m_source;
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual StackEntry*
#else
virtual ContextState*
#endif
clone() const;
virtual bool
equals(const StackEntry& rhs) const;
protected:
ContextState(
const DOM_Node& caller,
const DOM_Node& sourceNode,
eStackEntryType theType);
bool
operator==(const ContextState& theRHS)
{
return equals(theRHS);
}
private:
// Data members...
DOM_Node m_caller;
DOM_Node m_source;
};
#endif // XALAN_CONTEXTSTATE_HEADER_GUARD
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/DecimalToRoman.cpp
Index: DecimalToRoman.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "DecimalToRoman.hpp"
DecimalToRoman::DecimalToRoman(
long postValue,
const DOMString& postLetter,
long preValue,
const DOMString& preLetter) :
m_postValue(postValue),
m_postLetter(postLetter),
m_preValue(preValue),
m_preLetter(preLetter)
{
}
DecimalToRoman::~DecimalToRoman()
{
}
1.1 xml-xalan/c/src/XSLT/DecimalToRoman.hpp
Index: DecimalToRoman.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_DECIMALTOROMAN_HEADER_GUARD)
#define XALAN_DECIMALTOROMAN_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
/**
* Structure to help in converting integers to roman numerals
*/
class XALAN_XSLT_EXPORT DecimalToRoman
{
public:
DecimalToRoman(
long postValue = 0L,
const DOMString& postLetter = DOMString(),
long preValue = 0L,
const DOMString& preLetter = DOMString());
~DecimalToRoman();
long m_postValue;
DOMString m_postLetter;
long m_preValue;
DOMString m_preLetter;
};
#endif // XALAN_DECIMALTOROMAN_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemApplyImport.cpp
Index: ElemApplyImport.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemApplyImport.hpp"
#include "ElemPriv.hpp"
ElemApplyImport::ElemApplyImport(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_mode(),
m_pSelectPattern(0)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(isAttrOK(aname, atts, i) == false)
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemApplyImport::getXSLToken() const
{
return Constants::ELEMNAME_APPLY_IMPORTS;
}
void ElemApplyImport::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
// This will have to change to current template, (which will have
// to be the top of a current template stack).
transformChild(getStylesheet(),
0,
0,
sourceTree,
processor.getXPathSupport().getParentOfNode(sourceNode),
sourceNode,
mode,
getXSLToken());
}
NodeImpl* ElemApplyImport::appendChild(NodeImpl* newChild)
{
assert(newChild != 0);
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
getTagName());
return 0;
}
1.1 xml-xalan/c/src/XSLT/ElemApplyImport.hpp
Index: ElemApplyImport.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMAPPLYIMPORT_HEADER_GUARD)
#define XALAN_ELEMAPPLYIMPORT_HEADER_GUARD
/**
* $Id: ElemApplyImport.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
class AttributeList;
class Stylesheet;
class ElemApplyImport: public ElemTemplateElement
{
public:
ElemApplyImport(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
* <!ELEMENT xsl:apply-imports EMPTY>
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
private:
DOMString m_mode;
XPath* m_pSelectPattern;
};
#endif // XALAN_ELEMAPPLYIMPORT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp
Index: ElemApplyTemplates.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemApplyTemplates.hpp"
#include "ElemPriv.hpp"
ElemApplyTemplates::ElemApplyTemplates(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemForEach(processor, stylesheetTree, name, atts, lineNumber,
columnNumber, false),
m_isDefaultTemplate(false),
m_mode(QName())
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
const int tok = getAttrTok(aname);
switch(tok)
{
case Constants::TATTRNAME_SELECT:
m_pSelectPattern =
processor.createXPath(atts.getValue(i), *this);
break;
case Constants::TATTRNAME_MODE:
m_mode = QName(atts.getValue(i),
getStylesheet().getNamespaces());
break;
default:
if(!isAttrOK(tok, aname, atts, i))
{
processor.error(name + " has an illegal
attribute: " + aname);
}
break;
}
}
if(0 == m_pSelectPattern)
{
if(0 == getStylesheet().getDefaultATXpath())
{
getStylesheet().setDefaultATXpath(
processor.createXPath(DOMString("node()"),
*this));
}
m_pSelectPattern = getStylesheet().getDefaultATXpath();
}
}
int ElemApplyTemplates::getXSLToken() const
{
return Constants::ELEMNAME_APPLY_TEMPLATES;
}
void ElemApplyTemplates::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
if(0 != getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireTraceEvent(TracerEvent(
&processor, sourceTree, sourceNode, mode, *this));
}
if (0 != sourceNode)
{
transformSelectedChildren(getStylesheet(),
this,
0,
sourceTree,
sourceNode,
m_isDefaultTemplate == false ? m_mode : mode,
m_pSelectPattern,
Constants::ELEMNAME_APPLY_TEMPLATES);
}
else // if(null == sourceNode)
{
processor.error("sourceNode is null in
handleApplyTemplatesInstruction!");
}
}
NodeImpl* ElemApplyTemplates::appendChild(NodeImpl* newChild)
{
assert(newChild != 0);
const int type =
dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
// char-instructions
case Constants::ELEMNAME_SORT:
case Constants::ELEMNAME_PARAM:
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
break;
}
return ElemTemplateElement::appendChild(newChild);
}
1.1 xml-xalan/c/src/XSLT/ElemApplyTemplates.hpp
Index: ElemApplyTemplates.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMAPPLYTEMPLATES_HEADER_GUARD)
#define XALAN_ELEMAPPLYTEMPLATES_HEADER_GUARD
/**
* $Id: ElemApplyTemplates.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemForEach.hpp"
class ElemApplyTemplates : public ElemForEach
{
public:
ElemApplyTemplates(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
bool isDefaultTemplate() const
{
return m_isDefaultTemplate;
}
void setDefaultTemplate(bool def)
{
m_isDefaultTemplate = def;
}
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
* <!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*>
* <!ATTLIST xsl:apply-templates
* select %expr; "node()"
* mode %qname; #IMPLIED
* >
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
private:
bool m_isDefaultTemplate;
QName m_mode;
};
#endif // XALAN_ELEMAPPLYTEMPLATES_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemAttribute.cpp
Index: ElemAttribute.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemAttribute.hpp"
#include "ElemPriv.hpp"
ElemAttribute::ElemAttribute(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pNameAVT(0),
m_pNamespaceAVT(0)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname, Constants::ATTRNAME_NAME))
{
m_pNameAVT = new AVT(aname, atts.getType(i),
atts.getValue(i),
*this, processor);
}
else if(equals(aname,Constants::ATTRNAME_NAMESPACE))
{
m_pNamespaceAVT = new AVT(aname, atts.getType(i),
atts.getValue(i),
*this, processor);
}
else if(!(isAttrOK(aname, atts, i) ||
processSpaceAttr(aname, atts, i)))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
if(0 == m_pNameAVT)
{
processor.error(name + " must have a name attribute.");
}
}
ElemAttribute::~ElemAttribute()
{
delete m_pNameAVT;
m_pNameAVT = 0;
delete m_pNamespaceAVT;
m_pNamespaceAVT = 0;
}
int ElemAttribute::getXSLToken() const
{
return Constants::ELEMNAME_ATTRIBUTE;
}
void ElemAttribute::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
assert(m_pNameAVT);
DOMString attrName;
m_pNameAVT->evaluate(attrName, sourceNode, *this,
processor.getContextNodeList());
if(!isEmpty(attrName))
{
if(0 != m_pNamespaceAVT)
{
DOMString attrNameSpace;
m_pNamespaceAVT->evaluate(attrNameSpace, sourceNode,
*this, processor.getContextNodeList());
if(!isEmpty(attrNameSpace))
{
DOMString prefix =
processor.getResultPrefixForNamespace(attrNameSpace);
if(isEmpty(prefix))
{
prefix = DOMString("ns") +
LongToDOMString(processor.getUniqueNSValue());
DOMString nsDecl = DOMString("xmlns:")
+ prefix;
processor.addResultAttribute(processor.getPendingAttributes(),
nsDecl, attrNameSpace);
}
attrName = (prefix + DOMString(":") + attrName);
}
}
if(!isEmpty(processor.getPendingElementName()))
{
DOMString val = childrenToString(processor, sourceTree,
sourceNode, mode);
processor.addResultAttribute(processor.getPendingAttributes(), attrName, val);
}
else
{
//warn(templateChild, sourceNode, "Trying to add
attribute after element child has been added, ignoring...");
}
}
}
NodeImpl* ElemAttribute::appendChild(NodeImpl* newChild)
{
assert(newChild != 0);
const int type =
dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
// char-instructions
case Constants::ELEMNAME_TEXTLITERALRESULT:
case Constants::ELEMNAME_APPLY_TEMPLATES:
case Constants::ELEMNAME_APPLY_IMPORTS:
case Constants::ELEMNAME_CALLTEMPLATE:
case Constants::ELEMNAME_FOREACH:
case Constants::ELEMNAME_VALUEOF:
case Constants::ELEMNAME_COPY_OF:
case Constants::ELEMNAME_NUMBER:
case Constants::ELEMNAME_CHOOSE:
case Constants::ELEMNAME_IF:
case Constants::ELEMNAME_TEXT:
case Constants::ELEMNAME_COPY:
case Constants::ELEMNAME_VARIABLE:
case Constants::ELEMNAME_MESSAGE:
// instructions
// case Constants.ELEMNAME_PI:
// case Constants.ELEMNAME_COMMENT:
// case Constants.ELEMNAME_ELEMENT:
// case Constants.ELEMNAME_ATTRIBUTE:
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
getTagName());
break;
}
return ElemTemplateElement::appendChild(newChild);
}
1.1 xml-xalan/c/src/XSLT/ElemAttribute.hpp
Index: ElemAttribute.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMATTRIBUTE_HEADER_GUARD)
#define XALAN_ELEMATTRIBUTE_HEADER_GUARD
/**
* $Id: ElemAttribute.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include "AVT.hpp"
class ElemAttribute : public ElemTemplateElement
{
public:
ElemAttribute (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemAttribute();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
* <!ELEMENT xsl:attribute %char-template;>
* <!ATTLIST xsl:attribute
* name %avt; #REQUIRED
* namespace %avt; #IMPLIED
* %space-att;
* >
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
private:
AVT* m_pNameAVT;
AVT* m_pNamespaceAVT;
// not implemented
ElemAttribute(const ElemAttribute &);
ElemAttribute& operator=(const ElemAttribute &);
};
#endif // XALAN_ELEMATTRIBUTE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemAttributeSet.cpp
Index: ElemAttributeSet.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemAttributeSet.hpp"
#include "ElemPriv.hpp"
ElemAttributeSet::ElemAttributeSet(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemUse(processor, stylesheetTree, name, atts, lineNumber,
columnNumber),
m_QName()
{
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_NAME))
{
m_QName = QName(atts.getValue(i),
stylesheetTree.getNamespaces());
getStylesheet().addAttributeSet(m_QName, this);
}
else if(!(processUseAttributeSets(aname, atts, i) ||
isAttrOK(aname, atts, i)))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
if(isEmpty(m_QName.getLocalPart()))
{
processor.error(name + " must have a name attribute.");
}
}
ElemAttributeSet::~ElemAttributeSet()
{
}
int ElemAttributeSet::getXSLToken() const
{
return Constants::ELEMNAME_DEFINEATTRIBUTESET;
}
void ElemAttributeSet::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
StylesheetRoot::AttrStackType& stack =
getStylesheet().getStylesheetRoot()->getAttrSetStack();
if(stack.empty() == false)
{
const StylesheetRoot::AttrStackType::const_iterator loc =
std::find(stack.begin(),stack.end(), this);
if(loc != stack.end())
{
DOMString msg("xsl:attribute-set '"
+ m_QName.getLocalPart() +
"' used itself, which will cause an infinite
loop.");
throw SAXException(toCharArray(msg));
}
}
stack.push_back(this);
ElemTemplateElement* attr =
dynamic_cast<ElemTemplateElement*>(getFirstChild());
while(0 != attr)
{
attr->execute(processor, sourceTree, sourceNode, mode);
attr =
dynamic_cast<ElemTemplateElement*>(attr->getNextSibling());
}
ElemUse::execute(processor, sourceTree, sourceNode, mode);
stack.pop_back();
}
/**
* Add a child to the child list.
* <!ELEMENT xsl:attribute-set (xsl:attribute)*>
* <!ATTLIST xsl:attribute-set
* name %qname; #REQUIRED
* use-attribute-sets %qnames; #IMPLIED
* >
*/
NodeImpl* ElemAttributeSet::appendChild(NodeImpl* newChild)
{
int type = dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
case Constants::ELEMNAME_ATTRIBUTE:
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement
*>(newChild)->getTagName() + " to " +
dynamic_cast<ElemTemplateElement*>(this)->getTagName());
}
return ElemTemplateElement::appendChild(newChild);
}
1.1 xml-xalan/c/src/XSLT/ElemAttributeSet.hpp
Index: ElemAttributeSet.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMATTRIBUTESET_HEADER_GUARD)
#define XALAN_ELEMATTRIBUTESET_HEADER_GUARD
/**
* $Id: ElemAttributeSet.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemUse.hpp"
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/QName.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemAttributeSet : public ElemUse
{
public:
ElemAttributeSet (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemAttributeSet();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
* <!ELEMENT xsl:attribute-set (xsl:attribute)*>
* <!ATTLIST xsl:attribute-set
* name %qname; #REQUIRED
* use-attribute-sets %qnames; #IMPLIED
* >
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
const QName& getQName() { return m_QName; }
private:
QName m_QName;
};
#endif // XALAN_ELEMATTRIBUTESET_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemCallTemplate.cpp
Index: ElemCallTemplate.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemCallTemplate.hpp"
#include "ElemPriv.hpp"
ElemCallTemplate::ElemCallTemplate(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pNameAVT(0)
{
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_NAME))
{
m_pNameAVT = new AVT(aname, atts.getType(i),
atts.getValue(i),
*this, processor);
}
else if(!isAttrOK(aname, atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
ElemCallTemplate::~ElemCallTemplate()
{
delete m_pNameAVT;
}
int ElemCallTemplate::getXSLToken() const
{
return Constants::ELEMNAME_CALLTEMPLATE;
}
void ElemCallTemplate::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
assert(m_pNameAVT);
DOMString templateName;
m_pNameAVT->evaluate(templateName, sourceNode, *this,
processor.getContextNodeList());
if(!isEmpty(templateName))
{
ElemTemplateElement* theTemplate = 0;
theTemplate =
processor.getStylesheetRoot()->findNamedTemplate(templateName);
if(0 != theTemplate)
{
processor.getVariableStacks().pushContextMarker(DOM_UnimplementedElement(theTemplate),
sourceNode);
processor.getVariableStacks().pushParams(&getStylesheet(), *this,
sourceTree, sourceNode, mode,
DOM_UnimplementedElement(theTemplate));
theTemplate->execute(processor, sourceTree, sourceNode,
mode);
processor.getVariableStacks().popCurrentContext();
}
else
{
processor.error("Could not find template named: '" +
templateName + "'");
}
}
else
{
processor.error("Could not resolve name AVT in
xsl:call-template.");
}
}
/**
* Add a child to the child list.
*/
NodeImpl* ElemCallTemplate::appendChild(NodeImpl* newChild)
{
const int type =
dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
case Constants::ELEMNAME_PARAM:
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
}
return ElemTemplateElement::appendChild(newChild);
}
1.1 xml-xalan/c/src/XSLT/ElemCallTemplate.hpp
Index: ElemCallTemplate.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMCALLTEMPLATE_HEADER_GUARD)
#define XALAN_ELEMCALLTEMPLATE_HEADER_GUARD
/**
* $Id: ElemCallTemplate.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include "AVT.hpp"
class ElemCallTemplate: public ElemTemplateElement
{
public:
ElemCallTemplate (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemCallTemplate();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
private:
// not implemented
ElemCallTemplate(const ElemCallTemplate &);
ElemCallTemplate& operator=(const ElemCallTemplate &);
AVT* m_pNameAVT; // = null;
};
#endif // XALAN_ELEMCALLTEMPLATE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemChoose.cpp
Index: ElemChoose.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemChoose.hpp"
#include "ElemWhen.hpp"
#include "ElemPriv.hpp"
ElemChoose::ElemChoose(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber)
{
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(isAttrOK(aname, atts, i)== false || processSpaceAttr(aname,
atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemChoose::getXSLToken() const
{
return Constants::ELEMNAME_CHOOSE;
}
void ElemChoose::execute(XSLTEngineImpl& processor, const DOM_Node&
sourceTree,
const DOM_Node& sourceNode, const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
for (ElemTemplateElement* node =
dynamic_cast<ElemTemplateElement*>(getFirstChild());
node != 0; node =
dynamic_cast<ElemTemplateElement*>(node->getNextSibling()))
{
int type = node->getXSLToken();
if(Constants::ELEMNAME_WHEN == type)
{
ElemWhen* when = static_cast<ElemWhen*>(node);
XObject* test = when->getXPath()->execute(sourceNode,
*this,
processor.getContextNodeList());
if(0 !=
getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireSelectedEvent(
SelectionEvent(getStylesheet().getProcessor(),
sourceNode,
when,
DOMString("test"),
when->getXPath(),
test));
}
if(test->boolean())
{
when->executeChildren(processor, sourceTree,
sourceNode, mode);
break;
}
}
else
{
// xsl:otherwise
node->executeChildren(processor, sourceTree,
sourceNode, mode);
}
}
}
/**
* Add a child to the child list.
*/
NodeImpl* ElemChoose::appendChild(NodeImpl* newChild)
{
int type = dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
case Constants::ELEMNAME_WHEN:
case Constants::ELEMNAME_OTHERWISE:
// TODO: Positional checking
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
}
return ElemTemplateElement::appendChild(newChild);
}
1.1 xml-xalan/c/src/XSLT/ElemChoose.hpp
Index: ElemChoose.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMCHOOSE_HEADER_GUARD)
#define XALAN_ELEMCHOOSE_HEADER_GUARD
/**
* $Id: ElemChoose.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
class ElemChoose: public ElemTemplateElement
{
public:
ElemChoose(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
};
#endif // XALAN_ELEMCHOOSE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemComment.cpp
Index: ElemComment.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemComment.hpp"
#include "ElemPriv.hpp"
ElemComment::ElemComment(XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor,stylesheetTree,name, lineNumber,
columnNumber)
{
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(isAttrOK(aname, atts, i)== false || processSpaceAttr(aname,
atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemComment::getXSLToken() const
{
return Constants::ELEMNAME_COMMENT;
}
void ElemComment::execute(XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
// Note the content model is:
// <!ENTITY % instructions "
// %char-instructions;
// | xsl:processing-instruction
// | xsl:comment
// | xsl:element
// | xsl:attribute
// ">
DOMString data = childrenToString(processor, sourceTree, sourceNode,
mode);
processor.comment(toCharArray(data));
}
/**
* Add a child to the child list.
*/
NodeImpl* ElemComment::appendChild(NodeImpl* newChild)
{
int type = dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
// char-instructions
case Constants::ELEMNAME_TEXTLITERALRESULT:
case Constants::ELEMNAME_APPLY_TEMPLATES:
case Constants::ELEMNAME_APPLY_IMPORTS:
case Constants::ELEMNAME_CALLTEMPLATE:
case Constants::ELEMNAME_FOREACH:
case Constants::ELEMNAME_VALUEOF:
case Constants::ELEMNAME_COPY_OF:
case Constants::ELEMNAME_NUMBER:
case Constants::ELEMNAME_CHOOSE:
case Constants::ELEMNAME_IF:
case Constants::ELEMNAME_TEXT:
case Constants::ELEMNAME_COPY:
case Constants::ELEMNAME_VARIABLE:
case Constants::ELEMNAME_MESSAGE:
// instructions
// case Constants.ELEMNAME_PI:
// case Constants.ELEMNAME_COMMENT:
// case Constants.ELEMNAME_ELEMENT:
// case Constants.ELEMNAME_ATTRIBUTE:
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
}
return
dynamic_cast<ElemTemplateElement*>(ElemTemplateElement::appendChild(newChild));
}
1.1 xml-xalan/c/src/XSLT/ElemComment.hpp
Index: ElemComment.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMCOMMENT_HEADER_GUARD)
#define XALAN_ELEMCOMMENT_HEADER_GUARD
/**
* $Id: ElemComment.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemComment: public ElemTemplateElement
{
public:
ElemComment (XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
* <!ELEMENT xsl:apply-imports EMPTY>
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
};
#endif // XALAN_ELEMCOMMENT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemCopy.cpp
Index: ElemCopy.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemCopy.hpp"
#include "ElemPriv.hpp"
ElemCopy::ElemCopy(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemUse(processor, stylesheetTree, name, atts, lineNumber,
columnNumber)
{
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(! (processUseAttributeSets(aname, atts, i) ||
processSpaceAttr(aname, atts, i) ||
isAttrOK(aname, atts, i)))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemCopy::getXSLToken() const
{
return Constants::ELEMNAME_COPY;
}
void ElemCopy::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
int nodeType = sourceNode.getNodeType();
if((DOM_Node::DOCUMENT_NODE != nodeType))
{
processor.cloneToResultTree(getStylesheet(),
sourceNode,
false,
false,
false,
false );
if(DOM_Node::ELEMENT_NODE == nodeType)
{
ElemUse::execute(processor,
sourceTree,
sourceNode,
mode);
processor.copyNamespaceAttributes(sourceNode,
false,
processor.getPendingAttributes());
executeChildren(processor,
sourceTree,
sourceNode,
mode);
const DOMString s = sourceNode.getNodeName();
processor.endElement(toCharArray(s));
}
else
{
if(0 !=
getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireTraceEvent(TracerEvent(&processor,
sourceTree,
sourceNode,
mode,
*this));
}
}
}
else
{
if(0 !=
getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireTraceEvent(TracerEvent(&processor,
sourceTree,
sourceNode,
mode,
*this));
}
executeChildren(processor, sourceTree, sourceNode, mode);
}
}
1.1 xml-xalan/c/src/XSLT/ElemCopy.hpp
Index: ElemCopy.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMCOPY_HEADER_GUARD)
#define XALAN_ELEMCOPY_HEADER_GUARD
/**
* $Id: ElemCopy.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemUse.hpp"
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include <XPath/QName.hpp>
class ElemCopy: public ElemUse
{
public:
ElemCopy (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
};
#endif // XALAN_ELEMAPPLYIMPORT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemCopyOf.cpp
Index: ElemCopyOf.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemCopyOf.hpp"
#include "ElemPriv.hpp"
ElemCopyOf::ElemCopyOf(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pSelectPattern(0)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname, Constants::ATTRNAME_SELECT))
{
m_pSelectPattern =
processor.createXPath(atts.getValue(i), *this);
}
else if(!isAttrOK(aname, atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemCopyOf::getXSLToken() const
{
return Constants::ELEMNAME_COPY_OF;
}
void ElemCopyOf::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
assert(m_pSelectPattern);
XObject* pValue = m_pSelectPattern->execute(sourceNode, *this,
processor.getContextNodeList());
if(0 != getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireSelectedEvent(
SelectionEvent(getStylesheet().getProcessor(),
sourceNode,
this, DOMString("select"), m_pSelectPattern,
pValue));
}
if(0 != pValue)
{
const int type = pValue->getType();
DOMString s;
switch(type)
{
case XObject::eTypeBoolean:
case XObject::eTypeNumber:
case XObject::eTypeString:
s = pValue->str();
processor.characters(toCharArray(s), 0, length(s));
break;
case XObject::eTypeNodeSet:
{
NodeRefList nl(pValue->nodeset());
int nChildren = nl.getLength();
for(int i = 0; i < nChildren; i++)
{
DOM_Node pos(nl.item(i));
DOM_Node top(pos);
while(0 != pos)
{
processor.flushPending();
processor.cloneToResultTree(
getStylesheet(),
pos,
false,
false,
false,
true);
DOM_Node nextNode(pos.getFirstChild());
while(0 == nextNode)
{
if(DOM_Node::ELEMENT_NODE ==
pos.getNodeType())
{
s = pos.getNodeName();
processor.endElement(toCharArray(s));
}
if(top == pos)
break;
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
pos =
pos.getParentNode();
if(top == pos)
{
if(DOM_Node::ELEMENT_NODE == pos.getNodeType())
{
s =
pos.getNodeName();
processor.endElement(toCharArray(s));
}
nextNode = 0;
break;
}
}
}
pos = nextNode;
}
}
break;
}
case XObject::eTypeResultTreeFrag:
processor.outputResultTreeFragment(pValue);
break;
default:
s = pValue->str();
if (!isEmpty(s))
processor.characters(toCharArray(s), 0,
s.length());
break;
}
}
}
/**
* Add a child to the child list.
*/
NodeImpl* ElemCopyOf::appendChild(NodeImpl* newChild)
{
error("Can not add "
+dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
return 0;
}
1.1 xml-xalan/c/src/XSLT/ElemCopyOf.hpp
Index: ElemCopyOf.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMCOPYOF_HEADER_GUARD)
#define XALAN_ELEMCOPYOF_HEADER_GUARD
/**
* $Id: ElemCopyOf.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemCopyOf: public ElemTemplateElement
{
public:
ElemCopyOf (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
private:
XPath* m_pSelectPattern;
};
#endif // XALAN_ELEMCOPYOF_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemElement.cpp
Index: ElemElement.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemElement.hpp"
#include "ElemPriv.hpp"
ElemElement::ElemElement(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemUse(processor, stylesheetTree, name, atts, lineNumber,
columnNumber),
m_nameAVT(0),
m_namespaceAVT(0)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname, Constants::ATTRNAME_NAME))
{
m_nameAVT = new AVT(aname, atts.getType(i),
atts.getValue(i),
*this, processor);
}
else if(equals(aname, Constants::ATTRNAME_NAMESPACE))
{
m_namespaceAVT = new AVT(aname, atts.getType(i),
atts.getValue(i),
*this, processor);
}
else if(!(processUseAttributeSets(aname, atts, i) ||
processSpaceAttr(aname, atts, i) ||
isAttrOK(aname, atts, i)
))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
if(0 == m_nameAVT)
{
processor.error(name + " must have a name attribute.");
}
}
ElemElement::~ElemElement()
{
delete m_nameAVT;
m_nameAVT = 0;
delete m_namespaceAVT;
m_namespaceAVT = 0;
}
int ElemElement::getXSLToken() const
{
return Constants::ELEMNAME_ELEMENT;
}
void ElemElement::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
DOMString elemName;
assert(m_nameAVT);
m_nameAVT->evaluate(elemName,sourceNode, *this,
processor.getContextNodeList());
if(!isEmpty(elemName))
{
if(0 != m_namespaceAVT)
{
DOMString elemNameSpace;
m_namespaceAVT->evaluate(elemNameSpace, sourceNode,
*this, processor.getContextNodeList());
if(!isEmpty(elemNameSpace))
{
DOMString prefix =
processor.getResultPrefixForNamespace(elemNameSpace);
if(isEmpty(prefix))
{
prefix = DOMString("ns") +
LongToDOMString(processor.getUniqueNSValue());
DOMString nsDecl = DOMString("xmlns:")
+ prefix;
processor.addResultAttribute(processor.getPendingAttributes(),
nsDecl, elemNameSpace);
}
elemName = (prefix + ":" + elemName);
}
}
processor.startElement(toCharArray(elemName));
ElemUse::execute(processor, sourceTree, sourceNode, mode);
executeChildren(processor, sourceTree, sourceNode, mode);
processor.endElement(toCharArray(elemName));
}
}
1.1 xml-xalan/c/src/XSLT/ElemElement.hpp
Index: ElemElement.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMELEMENT_HEADER_GUARD)
#define XALAN_ELEMELEMENT_HEADER_GUARD
/**
* $Id: ElemElement.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include "ElemUse.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include "AVT.hpp"
class ElemElement: public ElemUse
{
public:
ElemElement (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemElement();
virtual int getXSLToken() const;
virtual void
execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
private:
// not implemented
ElemElement(const ElemElement &);
ElemElement& operator=(const ElemElement &);
AVT* m_nameAVT;
AVT* m_namespaceAVT;
};
#endif // XALAN_ELEMELEMENT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemEmpty.cpp
Index: ElemEmpty.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemEmpty.hpp"
#include "ElemPriv.hpp"
ElemEmpty::ElemEmpty(XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& /*atts*/,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor,stylesheetTree, name,
lineNumber, columnNumber)
{
}
int ElemEmpty::getXSLToken() const
{
return Constants::ELEMNAME_UNDEFINED;
}
void ElemEmpty::execute(XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
assert(false); // really shouldn't be executing empty nodes
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
}
1.1 xml-xalan/c/src/XSLT/ElemEmpty.hpp
Index: ElemEmpty.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMEMPTY_HEADER_GUARD)
#define XALAN_ELEMEMPTY_HEADER_GUARD
/**
* Simple empty elem to push on the stack when nothing
* else got pushed, so that pop() works correctly.
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
class ElemEmpty : public ElemTemplateElement
{
public:
ElemEmpty (XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
};
#endif // XALAN_ELEMEMPTY_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemExtensionCall.cpp
Index: ElemExtensionCall.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemExtensionCall.hpp"
#include "ElemPriv.hpp"
ElemExtensionCall::ElemExtensionCall(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
ExtensionNSHandler ns,
const DOMString& name,
const DOMString& localpart,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemLiteralResult(processor, stylesheetTree, name, atts,
lineNumber, columnNumber),
nsh(ns),
localPart(localpart)
{
}
int ElemExtensionCall::getXSLToken() const
{
return Constants::ELEMNAME_EXTENSIONCALL;
}
void ElemExtensionCall::execute(
XSLTEngineImpl& processor,
const DOM_Node& /*sourceTree*/,
const DOM_Node& /*sourceNode*/,
const QName& /*mode*/)
{
/*
nsh.processElement(localPart, this, processor, getStylesheet(),
sourceTree, sourceNode, mode);
*/
processor.warn("XSL4C does not yet handle Extensions!");
}
1.1 xml-xalan/c/src/XSLT/ElemExtensionCall.hpp
Index: ElemExtensionCall.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMEXTENSIONCALL_HEADER_GUARD)
#define XALAN_ELEMEXTENSIONCALL_HEADER_GUARD
/**
* $Id: ElemExtensionCall.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include "ElemLiteralResult.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include "ExtensionNSHandler.hpp"
class ElemExtensionCall: public ElemLiteralResult
{
public:
ElemExtensionCall (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
ExtensionNSHandler ns,
const DOMString& name,
const DOMString& localpart,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
private:
ExtensionNSHandler nsh;
DOMString localPart;
};
#endif // XALAN_ELEMEXTENSIONCALL_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemForEach.cpp
Index: ElemForEach.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemForEach.hpp"
#include "ElemPriv.hpp"
ElemForEach::ElemForEach(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber,
bool isOnlyForEach) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pSelectPattern(0)
{
// since we're calling the virtual function getXSLToken() from a ctor,
subclasses
// like ElemApplyTemplates when in a partially constructed state will
get
// ELEMNAME_FOREACH. So, as an extra check, we pass in a boolean flag,
isOnlyFor each
// which is true iff an ElemForEach object is being created not part of
a subclass
//
if(isOnlyForEach)
{
assert(Constants::ELEMNAME_FOREACH == getXSLToken());
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_SELECT))
{
m_pSelectPattern =
processor.createXPath(atts.getValue(i), *this);
}
else if(!(isAttrOK(aname, atts, i) ||
processSpaceAttr(aname, atts, i)))
{
processor.error(name + " has an illegal
attribute: " + aname);
}
}
if(0 == m_pSelectPattern)
{
processor.error(name + " requires attribute: " +
Constants::ATTRNAME_SELECT);
}
}
}
ElemForEach::~ElemForEach()
{
size_t len = m_sortElems.size();
for (size_t i=0; i< len; i++)
delete m_sortElems[i];
m_pSelectPattern = 0;
}
int ElemForEach::getXSLToken() const
{
return Constants::ELEMNAME_FOREACH;
}
void ElemForEach::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
if (sourceNode != 0)
{
assert(m_pSelectPattern);
transformSelectedChildren(getStylesheet(),
this,this,sourceTree,sourceNode,mode,
m_pSelectPattern, Constants::ELEMNAME_FOREACH);
}
else
{
// error wants DOM_node for first param
processor.error(DOM_UnimplementedElement(this), sourceNode,
"sourceNode is null in
handleApplyTemplatesInstruction!");
}
}
1.1 xml-xalan/c/src/XSLT/ElemForEach.hpp
Index: ElemForEach.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMFOREACH_HEADER_GUARD)
#define XALAN_ELEMFOREACH_HEADER_GUARD
/**
* $Id: ElemForEach.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include "ElemSort.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include <memory>
#include <vector>
class ElemForEach: public ElemTemplateElement
{
public:
ElemForEach (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber,
bool isOnlyForEach); // true iff this is not called on a
subclass for ElemForEach
virtual ~ElemForEach();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
typedef std::vector<ElemSort*> SortElemsVector;
const SortElemsVector& getSortElems() const
{
return m_sortElems;
}
SortElemsVector& getSortElems()
{
return m_sortElems;
}
private:
SortElemsVector m_sortElems;
protected:
XPath* m_pSelectPattern; // = null;
};
#endif // XALAN_ELEMFOREACH_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemIf.cpp
Index: ElemIf.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemIf.hpp"
#include "ElemPriv.hpp"
ElemIf::ElemIf(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber,columnNumber), m_pTest(0)
{
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
int tok = getAttrTok(aname);
switch(tok)
{
case Constants::TATTRNAME_TEST:
m_pTest =
getStylesheet().getProcessor()->createXPath(atts.getValue(i), *this);
break;
case Constants::TATTRNAME_XMLSPACE:
processSpaceAttr(atts, i);
break;
default:
if(!isAttrOK(tok, aname, atts, i))
{
processor.error(name + " has an illegal
attribute: " + aname);
}
}
}
if(0 == m_pTest)
{
processor.error(name + " must have a 'test' attribute.");
}
}
int ElemIf::getXSLToken() const
{
return Constants::ELEMNAME_IF;
}
void ElemIf::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
assert(m_pTest);
XObject* test = m_pTest->execute(sourceNode, *this,
processor.getContextNodeList());
if(0 != getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireSelectedEvent(
SelectionEvent(getStylesheet().getProcessor(),
sourceNode,
this,
"test",
m_pTest,
test));
}
if(test->boolean())
{
executeChildren(processor, sourceTree, sourceNode, mode);
}
}
1.1 xml-xalan/c/src/XSLT/ElemIf.hpp
Index: ElemIf.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMIF_HEADER_GUARD)
#define XALAN_ELEMIF_HEADER_GUARD
/**
* $Id: ElemIf.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemIf: public ElemTemplateElement
{
public:
ElemIf (XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
private:
XPath* m_pTest;
};
#endif // XALAN_ELEMIF_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemLiteralResult.cpp
Index: ElemLiteralResult.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemLiteralResult.hpp"
#include "ElemPriv.hpp"
typedef std::vector<NameSpace> NamespaceVectorType;
ElemLiteralResult::ElemLiteralResult(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemUse(processor, stylesheetTree, name, atts, lineNumber,
columnNumber),
m_pExtensionElementPrefixes(0),
m_QName(name)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
bool needToProcess = true;
int indexOfNSSep = indexOf(aname,':');
DOMString prefix;
if(indexOfNSSep > 0)
{
prefix = substring(aname,0,indexOfNSSep);
if(!prefix.equals("xmlns"))
{
DOMString ns = getNamespaceForPrefix(prefix);
if(startsWith(ns,getStylesheet().getProcessor()->getXSLNameSpaceURLPre()))
{
const DOMString localName =
substring(aname,indexOfNSSep+1);
if(equals(localName,
Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES))
{
needToProcess = false;
const DOMString qnames =
atts.getValue(i);
StringTokenizer
tokenizer(qnames, " \t\n\r", false);
m_extensionElementPrefixes.reserve(tokenizer.countTokens());
while(tokenizer.hasMoreTokens())
{
m_extensionElementPrefixes.push_back(tokenizer.nextToken());
}
}
}
}
}
if(needToProcess)
{
bool _processUseAttributeSets =
processUseAttributeSets(aname, atts, i);
bool _processSpaceAttr = processSpaceAttr(aname, atts,
i);
if(!(isAttrOK(aname, atts, i) ||
_processUseAttributeSets || _processSpaceAttr))
{
m_avts.push_back(new AVT(aname,
atts.getType(i), atts.getValue(i),
*this, processor));
}
}
}
}
ElemLiteralResult::~ElemLiteralResult()
{
m_pExtensionElementPrefixes = 0;
}
int ElemLiteralResult::getXSLToken() const
{
return Constants::ELEMNAME_LITERALRESULT;
}
void ElemLiteralResult::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
processor.startElement (toCharArray(m_QName));
ElemUse::execute(processor, sourceTree, sourceNode, mode);
if(0 != m_avts.size())
{
int nAttrs = m_avts.size();
for(int i = (nAttrs-1); i >= 0; i--)
{
AVT *avt = m_avts[i];
DOMString stringedValue;
avt->evaluate(stringedValue, sourceNode, *this,
processor.getContextNodeList());
if(!isEmpty(stringedValue))
{
processor.getPendingAttributes().removeAttribute(toCharArray(avt->getName()));
processor.getPendingAttributes().addAttribute(toCharArray(avt->getName()),
avt->getType(),
toCharArray(stringedValue));
}
}
}
ElemTemplateElement* elem = dynamic_cast<ElemTemplateElement *>(this);
NamespaceVectorType nsVector = elem->getNameSpace();
bool more = true;
while (more)
{
int i;
NameSpace ns;
// Traverse the vector of namespaces, which in java is a linked
list
// starting with last namespace; our vector pushes elements on
the back,
// so we have to iterate from there down
for (i=nsVector.size()-1; i>=0; i--)
{
ns = nsVector.at(i);
if(!isEmpty(ns.getURI()) && ns.getResultCandidate())
{
bool hasPrefix = !isEmpty(ns.getPrefix());
DOMString prefix = hasPrefix ? ns.getPrefix() :
DOMString();
DOMString desturi =
processor.getResultNamespaceForPrefix(prefix);
DOMString attrName = hasPrefix ?
(DOMString("xmlns:") + prefix) :
DOMString("xmlns");
DOMString srcURI = ns.getURI();
bool isXSLNS =
srcURI.equals(processor.getXSLNameSpaceURL())
|| (0 !=
getStylesheet().lookupExtensionNSHandler(srcURI))
||
equalsIgnoreCase(srcURI,processor.getXSLT4JNameSpaceURL());
if(!isXSLNS)
{
if(startsWith(srcURI,DOMString("quote:")))
{
srcURI = substring(srcURI,6);
}
if(!equalsIgnoreCase(srcURI,desturi))
// TODO: Check for extension namespaces
{
processor.addResultAttribute(processor.getPendingAttributes(),
attrName,
srcURI);
}
}
else
{
ns.setResultCandidate(false);
}
}
}
// We didn't find a namespace, start looking at the parents
if (0 != elem)
{
elem = dynamic_cast<ElemTemplateElement
*>(elem->getParentNode());
while(0 != elem)
{
nsVector = elem->getNameSpace();
if(0 == nsVector.size())
elem = dynamic_cast<ElemTemplateElement
*>(elem->getParentNode());
else
break;
}
// Last chance, try the stylesheet namespace
if (0 == nsVector.size())
nsVector = getStylesheet().getNamespaceDecls();
if (0 == nsVector.size())
more = false;
}
else
more = false;
}
executeChildren(processor, sourceTree, sourceNode, mode);
processor.endElement (toCharArray(m_QName));
}
1.1 xml-xalan/c/src/XSLT/ElemLiteralResult.hpp
Index: ElemLiteralResult.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMLITERALRESULT_HEADER_GUARD)
#define XALAN_ELEMLITERALRESULT_HEADER_GUARD
/**
* $Id: ElemLiteralResult.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include "ElemUse.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include "AVT.hpp"
class ElemLiteralResult: public ElemUse
{
public:
ElemLiteralResult (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemLiteralResult();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
private:
// not implemented
ElemLiteralResult(const ElemLiteralResult &);
ElemLiteralResult& operator=(const ElemLiteralResult &);
/**
* A stack to keep track of the attribute elements.
*/
typedef std::vector<AVT*> AvtsVectorType;
AvtsVectorType m_avts;
DOMString* m_pExtensionElementPrefixes;
DOMString m_QName;
std::vector<DOMString> m_extensionElementPrefixes;
};
#endif // XALAN_ELEMLITERALRESULT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemMessage.cpp
Index: ElemMessage.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemMessage.hpp"
#include "ElemPriv.hpp"
ElemMessage::ElemMessage(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(isAttrOK(aname, atts, i)== false || processSpaceAttr(aname,
atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemMessage::getXSLToken() const
{
return Constants::ELEMNAME_MESSAGE;
}
void ElemMessage::execute(XSLTEngineImpl& processor, const DOM_Node&
sourceTree,
const DOM_Node& sourceNode, const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
DOMString data = childrenToString(processor, sourceTree, sourceNode,
mode);
processor.message(DOM_UnimplementedElement(this), sourceNode, data);
}
1.1 xml-xalan/c/src/XSLT/ElemMessage.hpp
Index: ElemMessage.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMMESSAGE_HEADER_GUARD)
#define XALAN_ELEMMESSAGE_HEADER_GUARD
/**
* $Id: ElemMessage.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemMessage: public ElemTemplateElement
{
public:
ElemMessage (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(XSLTEngineImpl& processor, const DOM_Node&
sourceTree,
const DOM_Node& sourceNode, const QName& mode);
};
#endif // XALAN_ELEMMESSAGE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemNumber.cpp
Index: ElemNumber.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemNumber.hpp"
#include "ElemPriv.hpp"
#include "NumeratorFormatter.hpp"
const DOMString ElemNumber::m_alphaCountTable = "ZABCDEFGHIJKLMNOPQRSTUVWXY";
const DecimalToRoman ElemNumber::m_romanConvertTable[] =
{
DecimalToRoman(1000, "M", 900, "CM"),
DecimalToRoman(500, "D", 400, "CD"),
DecimalToRoman(100L, "C", 90L, "XC"),
DecimalToRoman(50L, "L", 40L, "XL"),
DecimalToRoman(10L, "X", 9L, "IX"),
DecimalToRoman(5L, "V", 4L, "IV"),
DecimalToRoman(1L, "I", 1L, "I")
};
ElemNumber::ElemNumber(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pCountMatchPattern(0),
m_pFromMatchPattern(0),
m_pValueExpr(0),
m_level(Constants::NUMBERLEVEL_SINGLE),
m_format_avt(DOMString()),
m_lang_avt(DOMString()),
m_lettervalue_avt(DOMString()),
m_groupingSeparator_avt(DOMString()),
m_groupingSize_avt(DOMString())
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_LEVEL))
{
const DOMString levelValue = atts.getValue(i);
if(! isEmpty(levelValue))
{
if(equals(Constants::ATTRVAL_MULTI, levelValue))
m_level = Constants::NUMBERLEVEL_MULTI;
else
if(equals(levelValue,Constants::ATTRVAL_ANY))
m_level = Constants::NUMBERLEVEL_ANY;
else
if(equals(levelValue,Constants::ATTRVAL_SINGLE))
m_level = Constants::NUMBERLEVEL_SINGLE;
else
error("Bad value on level attribute: "
+ levelValue);
}
}
else if(equals(aname,Constants::ATTRNAME_COUNT))
{
m_pCountMatchPattern =
processor.createMatchPattern(atts.getValue(i), *this);
}
else if(equals(aname,Constants::ATTRNAME_FROM))
{
m_pFromMatchPattern =
processor.createMatchPattern(atts.getValue(i), *this);
}
else if(equals(aname,Constants::ATTRNAME_VALUE))
{
m_pValueExpr =
getStylesheet().getProcessor()->createXPath(atts.getValue(i), *this);
}
else if(equals(aname,Constants::ATTRNAME_FORMAT))
{
m_format_avt = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_LANG))
{
m_lang_avt = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_LETTERVALUE))
{
processor.warn(Constants::ATTRNAME_LETTERVALUE + " not
supported yet!");
m_lettervalue_avt = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_GROUPINGSEPARATOR))
{
m_groupingSeparator_avt = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_GROUPINGSIZE))
{
m_groupingSize_avt = atts.getValue(i);
}
else if(!isAttrOK(aname, atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemNumber::getXSLToken() const
{
return Constants::ELEMNAME_NUMBER;
}
void ElemNumber::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
DOMString countString = getCountString(processor, sourceTree,
sourceNode);
if (! isEmpty(countString))
processor.characters(toCharArray(countString), 0, length(countString));
}
/**
* Add a child to the child list.
*/
NodeImpl* ElemNumber::appendChild(NodeImpl* newChild)
{
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
return 0;
}
/**
* Given a 'from' pattern (ala xsl:number), a match pattern
* and a context, find the first ancestor that matches the
* pattern (including the context handed in).
* @param matchPatternString The match pattern.
* @param node The node that "." expresses.
* @param namespaceContext The context in which namespaces in the
* queries are supposed to be expanded.
*/
DOM_Node ElemNumber::findAncestor(
XSLTEngineImpl& processor,
XPath* fromMatchPattern,
XPath* countMatchPattern,
const DOM_Node& context,
const DOM_Element& /*namespaceContext*/)
{
DOM_Node contextCopy(context);
while(0 != contextCopy)
{
if(0 != fromMatchPattern)
{
if(fromMatchPattern->getMatchScore(contextCopy) !=
XPath::s_MatchScoreNone)
{
contextCopy = DOM_Node();
break;
}
}
if(0 != countMatchPattern)
{
if(countMatchPattern->getMatchScore(context) !=
XPath::s_MatchScoreNone)
{
break;
}
}
contextCopy =
processor.getXPathSupport().getParentOfNode(contextCopy);
}
return contextCopy;
}
/**
* Given a 'from' pattern (ala xsl:number), a match pattern
* and a context, find the first ancestor that matches the
* pattern (including the context handed in).
* @param matchPatternString The match pattern.
* @param node The node that "." expresses.
* @param namespaceContext The context in which namespaces in the
* queries are supposed to be expanded.
*/
DOM_Node ElemNumber::findPrecedingOrAncestorOrSelf(
XSLTEngineImpl& processor,
XPath* fromMatchPattern,
XPath* countMatchPattern,
const DOM_Node& context,
const DOM_Element& /*namespaceContext*/)
{
DOM_Node contextCopy(context);
while(0 != contextCopy)
{
if(0 != fromMatchPattern)
{
if(fromMatchPattern->getMatchScore(contextCopy) !=
XPath::s_MatchScoreNone)
{
contextCopy = DOM_Node();
break;
}
}
if(0 != countMatchPattern)
{
if(countMatchPattern->getMatchScore(contextCopy) !=
XPath::s_MatchScoreNone)
{
break;
}
}
DOM_Node prevSibling = contextCopy.getPreviousSibling();
if(0 == prevSibling)
{
contextCopy =
processor.getXPathSupport().getParentOfNode(contextCopy);
}
else
{
contextCopy = prevSibling;
}
}
return contextCopy;
}
/**
* Get the count match pattern, or a default value.
*/
XPath* ElemNumber::getCountMatchPattern(
XSLTEngineImpl& processor,
const DOM_Node& contextNode)
{
XPath* countMatchPattern = m_pCountMatchPattern;
if(0 == countMatchPattern)
{
switch( contextNode.getNodeType())
{
case DOM_Node::ELEMENT_NODE:
countMatchPattern =
processor.createMatchPattern(contextNode.getNodeName(),
*this);
break;
case DOM_Node::ATTRIBUTE_NODE:
countMatchPattern =
processor.createMatchPattern(DOMString("@") + contextNode.getNodeName(),
*this);
break;
case DOM_Node::CDATA_SECTION_NODE:
case DOM_Node::TEXT_NODE:
countMatchPattern =
processor.createMatchPattern(DOMString("text()"),
*this);
break;
case DOM_Node::COMMENT_NODE:
countMatchPattern =
processor.createMatchPattern(DOMString("comment()"),
*this);
break;
case DOM_Node::DOCUMENT_NODE:
countMatchPattern =
processor.createMatchPattern(DOMString("/"),
*this);
break;
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
countMatchPattern =
processor.createMatchPattern(DOMString("pi(") +
contextNode.getNodeName() + DOMString(")"),
*this);
break;
default:
assert(false);
break;
}
}
return countMatchPattern;
}
/**
* Given an XML source node, get the count according to the
* parameters set up by the xsl:number attributes.
*/
DOMString ElemNumber::getCountString(
XSLTEngineImpl& processor,
const DOM_Node& /*sourceTree*/,
const DOM_Node& sourceNode)
{
IntArrayType list;
if(0 != m_pValueExpr)
{
XObject* countObj = m_pValueExpr->execute(sourceNode, *this,
processor.getContextNodeList());
int count = static_cast<int>(countObj->num());
list = IntArrayType(1);
list[0] = count;
}
else
{
XPath* countMatchPattern = getCountMatchPattern(processor,
sourceNode);
if((Constants::NUMBERLEVEL_ANY == m_level) ||
(Constants::NUMBERLEVEL_SINGLE == m_level))
{
list = IntArrayType(1);
if(Constants::NUMBERLEVEL_SINGLE == m_level)
{
DOM_Node target = findAncestor(processor,
m_pFromMatchPattern,
countMatchPattern, sourceNode,
DOM_UnimplementedElement(this));
if(0 == target)
target =
processor.getXPathSupport().getParentOfNode(sourceNode);
if(0 != target)
{
list[0] = getSiblingNumber(processor,
countMatchPattern, target);
}
else
{
processor.warn(DOM_Node(), sourceNode,
DOMString("Warning: count
attribute does not match an ancestor in xsl:number! Target = ")
+
sourceNode.getNodeName());
}
}
else // if NUMBERLEVEL_ANY
{
DOM_Node from;
if(0 != m_pFromMatchPattern)
{
from=
findPrecedingOrAncestorOrSelf(processor, 0, m_pFromMatchPattern,
sourceNode,
DOM_UnimplementedElement(this));
if(0 == from)
{
from = sourceNode;
}
}
else
{
from = sourceNode.getOwnerDocument();
}
DOM_Node fromPos = (from != sourceNode) ?
getNextInTree(from, from) : from;
list[0] = getNumberInTree(countMatchPattern,
fromPos, from, sourceNode, 0);
}
}
else // if NUMBERLEVEL_MULTI
{
list = getAncestorNumbers(processor,
m_pFromMatchPattern,
countMatchPattern, sourceNode);
}
}
return (list.size()>0) ? formatNumberList(processor, list, sourceNode)
: DOMString();
}
/**
* from any position in the tree, return the
* next node in the tree, assuming preorder
* traversal preceded, or null if at the end.
*/
DOM_Node ElemNumber::getNextInTree(const DOM_Node& pos, const DOM_Node& from)
{
DOM_Node posCopy(pos);
DOM_Node nextNode(posCopy.getFirstChild());
while(0 == nextNode)
{
nextNode = posCopy.getNextSibling();
if(0 == nextNode)
{
posCopy = posCopy.getParentNode();
if(posCopy == from)
{
break;
}
}
}
return nextNode;
}
/**
* Get a number that represents a node based on the
* position of that node among within the document tree,
* and taking into account the count and from patterns as
* specified in the XSL specification.
* @param fromMatchPattern if non-null, where to
* start counting from.
* @param countMatchPattern if non-null, count only nodes
* that match this pattern.
* @param target count this node and preceding nodes.
* @return A number that counts target and preceding
* nodes that qualify.
*/
int ElemNumber::getNumberInTree(
XPath* countMatchPattern,
const DOM_Node& pos,
const DOM_Node& from,
const DOM_Node& target,
int countFrom)
{
DOM_Node posCopy(pos);
int count = countFrom;
if(0 != posCopy)
{
do
{
if( (0 == countMatchPattern) ||
(countMatchPattern->getMatchScore(posCopy) !=
XPath::s_MatchScoreNone))
{
count++;
}
}
while((posCopy != target) &&
(0 != (posCopy = getNextInTree(posCopy, from))));
}
return count;
}
/**
* Get a number that represents a node based on the
* position of that node among it's siblings, and
* taking into account the count and from patterns.
* @param fromMatchPattern if non-null, where to
* start counting from.
* @param countMatchPattern if non-null, count only nodes
* that match this pattern.
* @param target count this node and preceding siblings.
* @return A number that counts target and preceding
* siblings that qualify.
*/
int ElemNumber::getSiblingNumber(
XSLTEngineImpl& processor,
XPath* countMatchPattern,
const DOM_Node& target)
{
// TODO: If target is an Attr, implement special handling.
DOM_NodeList siblings = processor.getXPathSupport().
getParentOfNode(target).getChildNodes();
int nNodes = siblings.getLength();
int number = 0; // return val
for(int i = 0; i < nNodes; i++)
{
DOM_Node child = siblings.item(i);
if(child == target)
{
number++; // always count the target
break;
}
else if((0 == countMatchPattern) ||
countMatchPattern->getMatchScore(child) !=
XPath::s_MatchScoreNone)
{
number++;
}
}
return number;
}
/**
* Count the ancestors, up to the root, that match the
* pattern.
* @param patterns if non-null, count only nodes
* that match this pattern, if null count all ancestors.
* @param node Count this node and it's ancestors.
* @return The number of ancestors that match the pattern.
*/
int ElemNumber::countMatchingAncestors(
XSLTEngineImpl& processor,
XPath* patterns,
const DOM_Node& node)
{
int count = 0; // return val
DOM_Node nodeCopy(node);
while( 0 != nodeCopy )
{
if(0 != patterns)
{
if(patterns->getMatchScore(nodeCopy) !=
XPath::s_MatchScoreNone)
{
count++;
}
}
else
{
count++;
}
nodeCopy =
processor.getXPathSupport().getParentOfNode(nodeCopy);
}
return count;
}
/**
* Climb up the ancestor tree, collecting sibling position
* numbers (as modified by the fromMatchPattern and
* countMatchPattern patterns).
* @param fromMatchPattern if non-null, where to
* start counting from in each sibling list.
* @param countMatchPattern if non-null, count only ancestors
* and siblings that match this pattern.
* @param node count this node and ancestors that match the countMatchPattern.
* @return An array of ints of length that matches exactly the number
* of ancestors that match countMatchPattern.
* @exception XSLProcessorException thrown if the active ProblemListener and
XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
ElemNumber::IntArrayType ElemNumber::getAncestorNumbers(
XSLTEngineImpl& processor,
XPath* fromMatchPattern,
XPath* countMatchPattern,
const DOM_Node& node)
{
DOM_Node nodeCopy(node);
int nMatchingAncestors =
countMatchingAncestors( processor,
countMatchPattern,
nodeCopy);
IntArrayType counts;
if(nMatchingAncestors > 0)
{
counts = IntArrayType(nMatchingAncestors);
int countIndex = counts.size() - 1; // position to put count
into
while( 0 != nodeCopy )
{
bool countIt = false;
if(0 != countMatchPattern)
{
if(countMatchPattern->getMatchScore(nodeCopy)
!= XPath::s_MatchScoreNone)
{
countIt = true;
}
}
else
{
countIt = true;
}
if(countIt)
{
DOM_Node target = findAncestor(processor,
fromMatchPattern,
countMatchPattern,
nodeCopy,
DOM_UnimplementedElement(this));
if(0 == target)
target = nodeCopy;
counts[countIndex] =
getSiblingNumber(processor, countMatchPattern, target);
countIndex--;
}
nodeCopy =
processor.getXPathSupport().getParentOfNode(nodeCopy);
} // end while
} // end if nMatchingAncestors > 0
return counts;
}
/**
* Get the locale we should be using.
*/
std::locale ElemNumber::getLocale(XSLTEngineImpl& /*processor*/, const
DOM_Node& /*contextNode*/)
{
//TODO
return std::locale();
}
NumberFormat* ElemNumber::getNumberFormatter(
XSLTEngineImpl& processor,
const DOM_Node& contextNode)
{
std::locale loc = getLocale(processor, contextNode);
// Helper to format local specific numbers to strings.
NumberFormat* formatter = new NumberFormat();
DOMString digitGroupSepValue = (!isEmpty(m_groupingSeparator_avt))
? processor.evaluateAttrVal(contextNode,
DOM_UnimplementedElement(this),
m_groupingSeparator_avt) : DOMString();
DOMString nDigitsPerGroupValue = (!isEmpty(m_groupingSize_avt))
? processor.evaluateAttrVal(contextNode,
DOM_UnimplementedElement(this),
m_groupingSize_avt) : DOMString();
// TODO: Handle digit-group attributes
if( !isEmpty(digitGroupSepValue) || !isEmpty(nDigitsPerGroupValue) )
{
formatter->setGroupingUsed(true);
formatter->setGroupingSeparator(m_groupingSeparator_avt);
formatter->setGroupingSize(m_groupingSize_avt);
}
return formatter;
}
/**
* Format a vector of numbers into a formatted string.
* @param xslNumberElement Element that takes %conversion-atts; attributes.
* @param list Array of one or more integer numbers.
* @return String that represents list according to
* %conversion-atts; attributes.
* TODO: Optimize formatNumberList so that it caches the last count and
* reuses that info for the next count.
*/
DOMString ElemNumber::formatNumberList(
XSLTEngineImpl& processor,
IntArrayType theList,
const DOM_Node& contextNode)
{
DOMString formattedNumber;
int nNumbers = theList.size();
XMLCh numberType = '1';
int numberWidth = 1;
DOMString formatToken;
DOMString sepString;
DOMString lastSepString;
DOMString formatValue = (!isEmpty(m_format_avt))
? processor.evaluateAttrVal(contextNode,
DOM_UnimplementedElement(this), m_format_avt)
: DOMString();
if(isEmpty(formatValue))
formatValue = DOMString("1");
NumeratorFormatter::NumberFormatStringTokenizer
formatTokenizer(formatValue);
std::locale loc = getLocale(processor, contextNode);
for(int i = 0; i < nNumbers; i++)
{
while(formatTokenizer.hasMoreTokens())
{
formatToken = formatTokenizer.nextToken();
if(isLetterOrDigit(charAt(formatToken,
formatToken.length()-1)))
{
numberWidth = formatToken.length();
numberType = charAt(formatToken, numberWidth-1);
break; // from while(tokenizer.hasMoreTokens())
}
else
{
sepString = formatToken;
formattedNumber += sepString;
if(formatTokenizer.hasMoreTokens())
{
while(formatTokenizer.hasMoreTokens())
{
formatToken =
formatTokenizer.nextToken();
if(!isLetterOrDigit(charAt(formatToken, 0)))
{
lastSepString =
sepString + formatToken; // possibly the last separator
}
else
{
numberWidth =
formatToken.length();
numberType =
charAt(formatToken, numberWidth-1);
break; // from inner
while loop
}
}
break; // from
while(tokenizer.hasMoreTokens())
}
}
} // end while
formattedNumber += getFormattedNumber(processor, contextNode,
numberType, numberWidth, theList[i]);
}
// Check to see if we finished up the format string...
if(isEmpty(lastSepString))
lastSepString = DOMString();
while(formatTokenizer.hasMoreTokens())
{
formatToken = formatTokenizer.nextToken();
if(!isLetterOrDigit(charAt(formatToken, 0)))
{
lastSepString += formatToken;
}
else
{
lastSepString = DOMString();
}
}
if(! isEmpty(lastSepString))
{
formattedNumber += lastSepString;
}
return formattedNumber;
}
DOMString ElemNumber::getFormattedNumber(
XSLTEngineImpl& processor, const DOM_Node& contextNode,
XMLCh numberType, int numberWidth, int listElement)
{
std::auto_ptr<NumberFormat> formatter(getNumberFormatter(processor,
contextNode));
DOMString padString = formatter->format(0);
DOMString lookahead; // next token
DOMString formattedNumber;
switch(numberType)
{
case 'A':
formattedNumber += int2alphaCount(listElement,
m_alphaCountTable);
break;
case 'a':
formattedNumber +=
toLowerCase(int2alphaCount(listElement, m_alphaCountTable));
break;
case 'I':
formattedNumber += long2roman(listElement, true);
break;
case 'i':
formattedNumber += toLowerCase(long2roman(listElement,
true));
break;
default: // "1"
DOMString numString = formatter->format(listElement);
int nPadding = numberWidth - numString.length();
for(int k = 0; k < nPadding; k++)
{
formattedNumber += padString;
}
formattedNumber += numString;
}
return formattedNumber;
}
/**
* Convert a long integer into alphabetic counting, in other words
* count using the sequence A B C ... Z AA AB AC.... etc.
* @param val Value to convert -- must be greater than zero.
* @param table a table containing one character for each digit in the radix
* @return String representing alpha count of number.
* @see XSLTEngineImpl#DecimalToRoman
*
* Note that the radix of the conversion is inferred from the size
* of the table.
*/
DOMString ElemNumber::int2alphaCount(int val, const DOMString& table)
{
int radix = table.length();
// Create a buffer to hold the result
// TODO: size of the table can be determined by computing
// logs of the radix. For now, we fake it.
const int buflen = 100;
XMLCh buf[buflen+1];
memset(buf,'\0',sizeof(XMLCh)*(buflen+1));
// next character to set in the buffer
int charPos = buflen-1 ; // work backward through buf[]
// index in table of the last character that we stored
int lookupIndex = 1; // start off with anything other than zero to
make correction work
// Correction number
//
// Correction can take on exactly two values:
//
// 0 if the next character is to be emitted is usual
//
// radix - 1
// if the next char to be emitted should be one
less than
// you would expect
//
// For example, consider radix 10, where 1="A" and 10="J"
//
// In this scheme, we count: A, B, C ... H, I, J (not A0 and certainly
// not AJ), A1
//
// So, how do we keep from emitting AJ for 10? After correctly
emitting the
// J, lookupIndex is zero. We now compute a correction number of 9
(radix-1).
// In the following line, we'll compute (val+correction) % radix, which
is,
// (val+9)/10. By this time, val is 1, so we compute (1+9) % 10, which
// is 10 % 10 or zero. So, we'll prepare to emit "JJ", but then we'll
// later suppress the leading J as representing zero (in the mod
system,
// it can represent either 10 or zero). In summary, the correction
value of
// "radix-1" acts like "-1" when run through the mod operator, but with
the
// desireable characteristic that it never produces a negative number.
int correction = 0;
// TODO: throw error on out of range input
do
{
// most of the correction calculation is explained above, the
reason for the
// term after the "|| " is that it correctly propagates carries
across
// multiple columns.
correction = ((lookupIndex == 0) ||
(correction != 0 && lookupIndex == radix-1 )) ?
(radix-1) : 0;
// index in "table" of the next char to emit
lookupIndex = (val+correction) % radix;
// shift input by one "column"
val = (val / radix);
// if the next value we'd put out would be a leading zero,
we're done.
if (lookupIndex == 0 && val == 0)
break;
// put out the next character of output
buf[charPos--] = static_cast<char>(table.charAt(lookupIndex));
}
while (val > 0);
DOMString retStr(buf+ charPos+1, (buflen - charPos -1));
return retStr;
}
/**
* Convert a long integer into roman numerals.
* @param val Value to convert.
* @param prefixesAreOK true_ to enable prefix notation (e.g. 4 = "IV"),
* false_ to disable prefix notation (e.g. 4 = "IIII").
* @return Roman numeral string.
* @see DecimalToRoman
* @see m_romanConvertTable
*/
DOMString ElemNumber::long2roman(long val, bool prefixesAreOK)
{
if(val <= 0)
{
return DOMString( "#E(" + LongToDOMString(val) +")" );
}
DOMString roman;
int place = 0;
if (val <= 3999L)
{
do
{
while (val >= m_romanConvertTable[place].m_postValue)
{
roman +=
m_romanConvertTable[place].m_postLetter;
val -= m_romanConvertTable[place].m_postValue;
}
if (prefixesAreOK)
{
if (val >=
m_romanConvertTable[place].m_preValue)
{
roman +=
m_romanConvertTable[place].m_preLetter;
val -=
m_romanConvertTable[place].m_preValue;
}
}
place++;
}
while (val > 0);
}
else
{
roman = "#error";
}
return roman;
}
1.1 xml-xalan/c/src/XSLT/ElemNumber.hpp
Index: ElemNumber.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMNUMBER_HEADER_GUARD)
#define XALAN_ELEMNUMBER_HEADER_GUARD
/**
* $Id: ElemNumber.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <PlatformSupport/NumberFormat.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include <locale>
#include "DecimalToRoman.hpp"
class ElemNumber: public ElemTemplateElement
{
public:
typedef std::vector<int> IntArrayType;
ElemNumber(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
* <!ELEMENT xsl:apply-imports EMPTY>
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
/**
* Given a 'from' pattern (ala xsl:number), a match pattern
* and a context, find the first ancestor that matches the
* pattern (including the context handed in).
* @param matchPatternString The match pattern.
* @param node The node that "." expresses.
* @param namespaceContext The context in which namespaces in the
* queries are supposed to be expanded.
*/
DOM_Node findAncestor(
XSLTEngineImpl& processor,
XPath* fromMatchPattern,
XPath* countMatchPattern,
const DOM_Node& context,
const DOM_Element& namespaceContext);
/**
* Given a 'from' pattern (ala xsl:number), a match pattern
* and a context, find the first ancestor that matches the
* pattern (including the context handed in).
* @param matchPatternString The match pattern.
* @param node The node that "." expresses.
* @param namespaceContext The context in which namespaces in the
* queries are supposed to be expanded.
*/
DOM_Node findPrecedingOrAncestorOrSelf(
XSLTEngineImpl& processor,
XPath* fromMatchPattern,
XPath* countMatchPattern,
const DOM_Node& context,
const DOM_Element& namespaceContext);
/**
* Get the count match pattern, or a default value.
*/
XPath* getCountMatchPattern(XSLTEngineImpl& processor, const
DOM_Node& contextNode);
/**
* Given an XML source node, get the count according to the
* parameters set up by the xsl:number attributes.
*/
DOMString getCountString(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode);
/**
* from any position in the tree, return the
* next node in the tree, assuming preorder
* traversal preceded, or null if at the end.
*/
DOM_Node getNextInTree(const DOM_Node& pos, const DOM_Node& from);
/**
* Get a number that represents a node based on the
* position of that node among within the document tree,
* and taking into account the count and from patterns as
* specified in the XSL specification.
* @param fromMatchPattern if non-null, where to
* start counting from.
* @param countMatchPattern if non-null, count only nodes
* that match this pattern.
* @param target count this node and preceding nodes.
* @return A number that counts target and preceding
* nodes that qualify.
*/
int getNumberInTree(
XPath* countMatchPattern,
const DOM_Node& pos,
const DOM_Node& from,
const DOM_Node& target,
int countFrom);
/**
* Get a number that represents a node based on the
* position of that node among it's siblings, and
* taking into account the count and from patterns.
* @param fromMatchPattern if non-null, where to
* start counting from.
* @param countMatchPattern if non-null, count only nodes
* that match this pattern.
* @param target count this node and preceding siblings.
* @return A number that counts target and preceding
* siblings that qualify.
*/
int getSiblingNumber(
XSLTEngineImpl& processor,
XPath* countMatchPattern,
const DOM_Node& target);
/**
* Count the ancestors, up to the root, that match the
* pattern.
* @param patterns if non-null, count only nodes
* that match this pattern, if null count all ancestors.
* @param node Count this node and it's ancestors.
* @return The number of ancestors that match the pattern.
*/
int countMatchingAncestors(
XSLTEngineImpl& processor,
XPath* patterns,
const DOM_Node& node);
/**
* Climb up the ancestor tree, collecting sibling position
* numbers (as modified by the fromMatchPattern and
* countMatchPattern patterns).
* @param fromMatchPattern if non-null, where to
* start counting from in each sibling list.
* @param countMatchPattern if non-null, count only ancestors
* and siblings that match this pattern.
* @param node count this node and ancestors that match the
countMatchPattern.
* @return An array of ints of length that matches exactly the number
* of ancestors that match countMatchPattern.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
IntArrayType getAncestorNumbers(
XSLTEngineImpl& processor,
XPath* fromMatchPattern,
XPath* countMatchPattern,
const DOM_Node& node);
/**
* Get the locale we should be using.
*/
std::locale getLocale(XSLTEngineImpl& processor, const DOM_Node&
contextNode);
NumberFormat* getNumberFormatter(XSLTEngineImpl& processor, const
DOM_Node& contextNode);
/**
* Format a vector of numbers into a formatted string.
* @param xslNumberElement Element that takes %conversion-atts;
attributes.
* @param list Array of one or more integer numbers.
* @return String that represents list according to
* %conversion-atts; attributes.
* TODO: Optimize formatNumberList so that it caches the last count and
* reuses that info for the next count.
*/
DOMString formatNumberList(
XSLTEngineImpl& processor,
IntArrayType theList,
const DOM_Node& contextNode);
protected:
/**
* Convert a long integer into alphabetic counting, in other words
* count using the sequence A B C ... Z AA AB AC.... etc.
* @param val Value to convert -- must be greater than zero.
* @param table a table containing one character for each digit in the
radix
* @return String representing alpha count of number.
* @see XSLTEngineImpl#DecimalToRoman
*
* Note that the radix of the conversion is inferred from the size
* of the table.
*/
DOMString int2alphaCount(int val, const DOMString& table);
/**
* Convert a long integer into roman numerals.
* @param val Value to convert.
* @param prefixesAreOK true_ to enable prefix notation (e.g. 4 = "IV"),
* false_ to disable prefix notation (e.g. 4 = "IIII").
* @return Roman numeral string.
* @see DecimalToRoman
* @see m_romanConvertTable
*/
DOMString long2roman(long val, bool prefixesAreOK);
private:
/*
* Get Formatted number
*/
DOMString getFormattedNumber(
XSLTEngineImpl& processor, const DOM_Node& contextNode,
XMLCh numberType, int numberWidth, int listElement);
XPath* m_pCountMatchPattern; // = null;
XPath* m_pFromMatchPattern; // = null;
XPath* m_pValueExpr; // = null;
int m_level; // = Constants.NUMBERLEVEL_SINGLE;
DOMString m_format_avt; // = null;
DOMString m_lang_avt; // = null;
DOMString m_lettervalue_avt; // = null;
DOMString m_groupingSeparator_avt; // = null;
DOMString m_groupingSize_avt; // = null;
/**
* Chars for converting integers into alpha counts.
* @see XSLTEngineImpl#int2alphaCount
*/
static const DOMString m_alphaCountTable;
/**
* Table to help in converting decimals to roman numerals.
* @see XSLTEngineImpl#DecimalToRoman
* @see XSLTEngineImpl#long2roman
*/
static const DecimalToRoman m_romanConvertTable[];
};
#endif // XALAN_ELEMNUMBER_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemOtherwise.cpp
Index: ElemOtherwise.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemOtherwise.hpp"
#include "ElemPriv.hpp"
ElemOtherwise::ElemOtherwise(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(isAttrOK(aname, atts, i)== false || processSpaceAttr(aname,
atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
int ElemOtherwise::getXSLToken() const
{
return Constants::ELEMNAME_OTHERWISE;
}
1.1 xml-xalan/c/src/XSLT/ElemOtherwise.hpp
Index: ElemOtherwise.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMOTHERWISE_HEADER_GUARD)
#define XALAN_ELEMOTHERWISE_HEADER_GUARD
/**
* $Id: ElemOtherwise.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemOtherwise: public ElemTemplateElement
{
public:
ElemOtherwise (XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
};
#endif // XALAN_ELEMOTHERWISE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemPI.cpp
Index: ElemPI.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemPI.hpp"
#include "ElemPriv.hpp"
ElemPI::ElemPI(XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_name_atv(DOMString())
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_NAME))
{
m_name_atv = atts.getValue(i);
}
else if(isAttrOK(aname, atts, i)== false ||
processSpaceAttr(aname, atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
if(isEmpty(m_name_atv))
{
processor.error(name + " must have a name attribute.");
}
}
int ElemPI::getXSLToken() const
{
return Constants::ELEMNAME_PI;
}
void ElemPI::execute(XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
DOMString piName = processor.evaluateAttrVal(sourceNode,
DOM_UnimplementedElement(this), m_name_atv);
if(equalsIgnoreCase(piName,DOMString("xml")))
{
error("processing-instruction name can not be 'xml'");
}
else if(!isValidNCName(piName))
{
error("processing-instruction name must be a valid NCName: " +
piName);
}
// Note the content model is:
// <!ENTITY % instructions "
// %char-instructions;
// | xsl:processing-instruction
// | xsl:comment
// | xsl:element
// | xsl:attribute
// ">
DOMString data = childrenToString(processor, sourceTree, sourceNode,
mode);
processor.processingInstruction(toCharArray(piName), toCharArray(data));
}
/**
* Add a child to the child list.
* <!ELEMENT xsl:apply-imports EMPTY>
*/
NodeImpl* ElemPI::appendChild(NodeImpl* newChild)
{
int type = dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
// char-instructions
case Constants::ELEMNAME_TEXTLITERALRESULT:
case Constants::ELEMNAME_APPLY_TEMPLATES:
case Constants::ELEMNAME_APPLY_IMPORTS:
case Constants::ELEMNAME_CALLTEMPLATE:
case Constants::ELEMNAME_FOREACH:
case Constants::ELEMNAME_VALUEOF:
case Constants::ELEMNAME_COPY_OF:
case Constants::ELEMNAME_NUMBER:
case Constants::ELEMNAME_CHOOSE:
case Constants::ELEMNAME_IF:
case Constants::ELEMNAME_TEXT:
case Constants::ELEMNAME_COPY:
case Constants::ELEMNAME_VARIABLE:
case Constants::ELEMNAME_MESSAGE:
// instructions
// case Constants.ELEMNAME_PI:
// case Constants.ELEMNAME_COMMENT:
// case Constants.ELEMNAME_ELEMENT:
// case Constants.ELEMNAME_ATTRIBUTE:
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
getTagName());
}
return ElemTemplateElement::appendChild(newChild);
}
1.1 xml-xalan/c/src/XSLT/ElemPI.hpp
Index: ElemPI.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMPI_HEADER_GUARD)
#define XALAN_ELEMPI_HEADER_GUARD
/**
* $Id: ElemPI.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemPI: public ElemTemplateElement
{
public:
ElemPI (XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Add a child to the child list.
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
private:
DOMString m_name_atv;
};
#endif // XALAN_ELEMPI_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemParam.cpp
Index: ElemParam.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemParam.hpp"
#include "ElemPriv.hpp"
ElemParam::ElemParam(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemVariable(processor, stylesheetTree, name, atts, lineNumber,
columnNumber)
{
}
int ElemParam::getXSLToken() const
{
return Constants::ELEMNAME_PARAMVARIABLE;
}
void ElemParam::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
const XObject* obj =
processor.getVariableStacks().getXObjectParamVariable(*m_qname);
if(0 == obj)
{
ElemVariable::execute(processor, sourceTree, sourceNode, mode);
}
else
{
if(0 !=
getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireTraceEvent(
TracerEvent(
&processor,
sourceTree,
sourceNode,
mode,
*this));
}
}
}
1.1 xml-xalan/c/src/XSLT/ElemParam.hpp
Index: ElemParam.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMPARAM_HEADER_GUARD)
#define XALAN_ELEMPARAM_HEADER_GUARD
/**
* $Id: ElemParam.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include "ElemVariable.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemParam: public ElemVariable
{
public:
ElemParam (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
};
#endif // XALAN_ELEMPARAM_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemPriv.hpp
Index: ElemPriv.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMPRIV_HEADER_GUARD)
#define XALAN_ELEMPRIV_HEADER_GUARD
/*
A set of headers used in the implementations of
most of the Elem* classes.
*/
#include <sax/SaxException.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include "Constants.hpp"
#include "XSLTEngineImpl.hpp"
#include "Stylesheet.hpp"
#include "StylesheetRoot.hpp"
#include "TracerEvent.hpp"
#include "SelectionEvent.hpp"
#endif // XALAN_ELEMPRIV_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemSort.cpp
Index: ElemSort.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemSort.hpp"
#include "ElemPriv.hpp"
ElemSort::ElemSort(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pSelectPattern(0),
m_langAVT(DOMString()),
m_dataTypeAVT("text"),
m_orderAVT("ascending"),
m_caseOrderAVT(DOMString())
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_SELECT))
{
m_pSelectPattern
= processor.createXPath(atts.getValue(i),
*this);
}
else if(equals(aname,Constants::ATTRNAME_LANG))
{
m_langAVT = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_DATATYPE))
{
m_dataTypeAVT = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_ORDER))
{
m_orderAVT = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_CASEORDER))
{
processor.warn("XSL4C does not yet handle the " +
Constants::ATTRNAME_CASEORDER + " attribute!");
m_caseOrderAVT = atts.getValue(i);
}
else if(!isAttrOK(aname, atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
if(0 == m_pSelectPattern)
{
m_pSelectPattern = processor.createXPath(DOMString("."), *this);
}
}
int ElemSort::getXSLToken() const
{
return Constants::ELEMNAME_SORT;
}
NodeImpl* ElemSort::appendChild(NodeImpl* newChild)
{
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
return 0;
}
1.1 xml-xalan/c/src/XSLT/ElemSort.hpp
Index: ElemSort.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMSORT_HEADER_GUARD)
#define XALAN_ELEMSORT_HEADER_GUARD
/**
* $Id: ElemSort.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemSort: public ElemTemplateElement
{
public:
ElemSort (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
/**
* Add a child to the child list.
* <!ELEMENT xsl:attribute-set (xsl:attribute)*>
* <!ATTLIST xsl:attribute-set
* name %qname; #REQUIRED
* use-attribute-sets %qnames; #IMPLIED
* >
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
const DOMString& getLangAVT() const
{
return m_langAVT;
}
const DOMString& getOrderAVT() const
{
return m_orderAVT;
}
const DOMString& getDataTypeAVT() const
{
return m_dataTypeAVT;
}
const XPath* getSelectPattern() const
{
return m_pSelectPattern;
}
private:
XPath* m_pSelectPattern; // =
null;
DOMString m_langAVT; //= null;
DOMString m_dataTypeAVT; //= "text";
DOMString m_orderAVT; // =
"ascending";
DOMString m_caseOrderAVT; // = null;
};
#endif // XALAN_ELEMSORT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemTemplate.cpp
Index: ElemTemplate.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemTemplate.hpp"
#include "ElemPriv.hpp"
#include <XPath/XPathFactory.hpp>
#include <XPath/XPathProcessor.hpp>
ElemTemplate::ElemTemplate(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name, lineNumber,
columnNumber),
m_pMatchPattern(0),
m_pName(0),
m_pMode(0),
m_priority(XPath::s_MatchScoreNone)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
int tok = getAttrTok(aname);
switch(tok)
{
case Constants::TATTRNAME_MATCH:
m_pMatchPattern = processor.getXPathFactory()->create();
processor.getXPathProcessor()->initMatchPattern(*m_pMatchPattern,
atts.getValue(i), *this);
break;
case Constants::TATTRNAME_NAME:
m_pName = new QName(atts.getValue(i),
getStylesheet().getNamespaces());
break;
case Constants::TATTRNAME_PRIORITY:
{
const DOMString priorityVal = atts.getValue(i);
m_priority = DOMStringToDouble(priorityVal);
}
break;
case Constants::TATTRNAME_MODE:
m_pMode = new QName(atts.getValue(i),
getStylesheet().getNamespaces());
break;
case Constants::TATTRNAME_XMLSPACE:
processSpaceAttr(atts, i);
break;
default:
if(isAttrOK(tok, aname, atts, i)== false)
{
processor.error(name + " has an illegal
attribute: " + aname);
}
}
}
if((0 == m_pMatchPattern) && (m_pName == 0))
{
processor.error(name + " requires either a name or a match
attribute.");
}
}
ElemTemplate::~ElemTemplate()
{
delete m_pName;
m_pName = 0;
delete m_pMode;
m_pMode = 0;
// the factory will free the memory
m_pMatchPattern = 0;
}
int ElemTemplate::getXSLToken() const
{
return Constants::ELEMNAME_TEMPLATE;
}
void ElemTemplate::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
executeChildren(processor, sourceTree, sourceNode, mode);
}
1.1 xml-xalan/c/src/XSLT/ElemTemplate.hpp
Index: ElemTemplate.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMTEMPLATE_HEADER_GUARD)
#define XALAN_ELEMTEMPLATE_HEADER_GUARD
/**
* $Id: ElemTemplate.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemTemplate : public ElemTemplateElement
{
public:
ElemTemplate (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemTemplate();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
const QName* getName() const
{
return m_pName;
}
const QName* getMode() const
{
return m_pMode;
}
XPath* getMatchPattern() const
{
return m_pMatchPattern;
}
double getPriority() const
{
return m_priority;
}
private:
// not implemented
ElemTemplate(const ElemTemplate &);
ElemTemplate& operator=(const ElemTemplate &);
XPath* m_pMatchPattern;
QName* m_pName;
QName* m_pMode;
double m_priority;
};
#endif // XALAN_ELEMTEMPLATE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemTemplateElement.cpp
Index: ElemTemplateElement.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemTemplateElement.hpp"
#include "ElemPriv.hpp"
#include <PlatformSupport/DOMStringPrintWriter.hpp>
#include <XMLSupport/FormatterToText.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include "ElemForEach.hpp"
#include "NodeSortKey.hpp"
#include "NodeSorter.hpp"
/**
* @param processor The XSLT Processor.
* @param stylesheetTree The owning stylesheet.
* @param name The name of the element.
* @param atts The element attributes.
* @param lineNumber The line in the XSLT file that the element occurs on.
* @param columnNumber The column index in the XSLT file that the element
occurs on.
* @exception SAXException Never.
*/
ElemTemplateElement::ElemTemplateElement(
const XSLTEngineImpl& /*processor*/,
Stylesheet& stylesheetTree,
const DOMString& name,
int lineNumber,
int columnNumber) :
UnimplementedElement(&stylesheetTree),
PrefixResolver(),
m_stylesheet(stylesheetTree),
m_lineNumber(lineNumber),
m_columnNumber(columnNumber),
m_defaultSpace(true),
m_finishedConstruction(false),
m_namespaces(m_stylesheet.getCurrentNamespace()),
m_elemName(name),
m_parentNode(0),
m_nextSibling(0),
m_firstChild(0)
{
}
ElemTemplateElement::~ElemTemplateElement()
{
m_parentNode = 0;
m_nextSibling = 0;
m_firstChild = 0;
}
int ElemTemplateElement::getLineNumber() const
{
return m_lineNumber;
}
int ElemTemplateElement::getColumnNumber() const
{
return m_columnNumber;
}
NodeImpl* ElemTemplateElement::getParentNode()
{
return m_parentNode;
}
void ElemTemplateElement::setParentNode(NodeImpl* elem)
{
m_parentNode = dynamic_cast<ElemTemplateElement *>(elem);
}
NodeImpl* ElemTemplateElement::getNextSibling()
{
return m_nextSibling;
}
void ElemTemplateElement::setNextSibling(NodeImpl* elem)
{
m_nextSibling = dynamic_cast<ElemTemplateElement *>(elem);
}
DOMString ElemTemplateElement::getNamespaceForPrefix(const DOMString& prefix)
const
{
DOMString nameSpace;
if(m_finishedConstruction == true)
{
if(!isEmpty(prefix))
{
ElemTemplateElement* elem =
const_cast<ElemTemplateElement *>(this);
while(isEmpty(nameSpace) && elem != 0)
{
NamespaceVectorType nsVector =
elem->getNameSpace();
nameSpace =
QName::getNamespaceForPrefix(nsVector, prefix);
if (! isEmpty(nameSpace)) break;
elem = dynamic_cast<ElemTemplateElement
*>(elem->getParentNode());
}
}
else
{
nameSpace =
getStylesheet().getNamespaceForPrefixFromStack(prefix);
}
}
else
{
nameSpace =
getStylesheet().getNamespaceForPrefixFromStack(prefix);
}
if(isEmpty(nameSpace))
error("Can not resolve namespace prefix: "+prefix);
return nameSpace;
}
/**
* Given an XSL tag name, return an integer token
* that corresponds to ELEMNAME_XXX constants defined
* in Constants.java.
* Note: I tried to optimize this by caching the node to
* id lookups in a hash table, but it helped not a bit.
* I'm not sure that it's spending too much time here anyway.
* @param node a probable xsl:xxx element.
* @return Constants.ELEMNAME_XXX token, or -1 if in xsl
* or Xalan namespace, -2 if not in known namespace.
*/
// rcw: we should declare some constants rather than magic numbers like -1
and -2
int ElemTemplateElement::getAttrTok(const DOMString& name) const
{
XSLTEngineImpl::AttributeKeysMapType::const_iterator iter=
XSLTEngineImpl::getAttributeKeys().find(name);
return (iter == XSLTEngineImpl::getAttributeKeys().end() ? -2 :
(*iter).second);
}
/**
* See if this is a xmlns attribute, and, if so, process it.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not used at
* this time).
* @param which The index into the attribute list (not used at this time).
* @return True if this is a namespace name.
*/
bool ElemTemplateElement::isAttrOK(int tok, const DOMString& attrName,
const AttributeList& /*atts*/, int /*which*/) const
{
bool isXMLNS = (Constants::TATTRNAME_XMLNSDEF == tok)
|| startsWith(attrName,Constants::ATTRNAME_XMLNS);
// TODO: Well, process it...
return isXMLNS;
}
/**
* See if this is a xmlns attribute, and, if so, process it.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not used at
* this time).
* @param which The index into the attribute list (not used at this time).
* @return True if this is a namespace name.
*/
bool ElemTemplateElement::isAttrOK(const DOMString& attrName,
const AttributeList& atts, int which) const
{
return m_stylesheet.isAttrOK(attrName, atts, which);
}
/**
* Tell whether or not this is a xml:space attribute and, if so, process it.
*
* @param aname The name of the attribute in question.
* @param atts The attribute list that owns the attribute.
* @param which The index of the attribute into the attribute list.
* @return True if this is a xml:space attribute.
*/
void ElemTemplateElement::processSpaceAttr(const AttributeList& atts,
int which)
{
const DOMString spaceVal = atts.getValue(which);
if(equals(spaceVal, "default") == true)
{
m_defaultSpace = true;
}
else if(equals(spaceVal, "preserve") == true)
{
m_defaultSpace = false;
}
else
{
error("xml:space has an illegal value: " + spaceVal);
}
}
/**
* Tell whether or not this is a xml:space attribute and, if so, process it.
*
* @param aname The name of the attribute in question.
* @param atts The attribute list that owns the attribute.
* @param which The index of the attribute into the attribute list.
* @return True if this is a xml:space attribute.
*/
bool ElemTemplateElement::processSpaceAttr(const DOMString& aname,
const AttributeList& atts, int which)
{
const bool isSpaceAttr = equals(aname, "xml:space");
if(isSpaceAttr == true)
{
const DOMString spaceVal = atts.getValue(which);
if(equals(spaceVal, "default"))
{
m_defaultSpace = true;
}
else if(equals(spaceVal, "preserve") == true)
{
m_defaultSpace = false;
}
else
{
error("xml:space has an illegal value: " + spaceVal);
}
}
return isSpaceAttr;
}
/**
* Validate that the string is an NCName.
*
* @param s The name in question.
* @return True if the string is a valid NCName according to XML rules.
* @see http://www.w3.org/TR/REC-xml-names#NT-NCName
*/
bool ElemTemplateElement::isValidNCName(const DOMString& s)
{
int len = length(s);
XMLCh c = charAt(s,0);
if(!(isLetterOrDigit(c) || (c == '_')))
return false;
if(len > 0)
{
for(int i = 1; i < len; i++)
{
c = charAt(s,i);
if(!(isLetterOrDigit(c) || (c == '_') || (c == '-') || (c == '.')))
return false;
}
}
return true;
}
/** Execute the element's primary function. Subclasses of this
* function may recursivly execute down the element tree.
*
* @exception XSLProcessorException
* @exception java.net.MalformedURLException
* @exception java.io.FileNotFoundException
* @exception java.io.IOException
* @exception SAXException
* @param processor The XSLT Processor.
* @param sourceTree The input source tree.
* @param sourceNode The current context node.
* @param mode The current mode.
*/
void ElemTemplateElement::execute(XSLTEngineImpl& processor, const DOM_Node&
sourceTree,
const DOM_Node& sourceNode, const QName& mode)
{
if(0 != getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireTraceEvent(
TracerEvent(&processor, sourceTree, sourceNode, mode,
*this));
}
}
/**
* Process the children of a template.
*
* @param processor The XSLT processor instance.
* @param sourceTree The input source tree.
* @param sourceNode The current context node.
* @param mode The current mode.
* @exception XSLProcessorException Thrown from one of the child execute
* methods.
* @exception java.net.MalformedURLException Might be thrown from the
* document() function, or from xsl:include or xsl:import.
* @exception java.io.FileNotFoundException Might be thrown from the
* document() function, or from xsl:include or xsl:import.
* @exception java.io.IOException Might be thrown from the document()
* function, or from xsl:include or xsl:import.
* @exception SAXException Might be thrown from the document() function, or
* from xsl:include or xsl:import.
*/
void ElemTemplateElement::executeChildren(XSLTEngineImpl& processor,
const DOM_Node& sourceTree, const DOM_Node& sourceNode, const QName&
mode)
{
for (ElemTemplateElement* node = m_firstChild; node != 0; node =
node->m_nextSibling)
{
node->execute(processor, sourceTree, sourceNode, mode);
}
}
/**
* Take the contents of a template element, process it, and
* convert it to a string.
*
* @exception XSLProcessorException Thrown from one of the child execute
* methods.
* @exception java.net.MalformedURLException Might be thrown from the
* document() function, or from xsl:include or xsl:import.
* @exception java.io.FileNotFoundException Might be thrown from the
* document() function, or from xsl:include or xsl:import.
* @exception java.io.IOException Might be thrown from the document()
* function, or from xsl:include or xsl:import.
* @exception SAXException Might be thrown from the document() function, or
* from xsl:include or xsl:import.
* @param processor The XSLT processor instance.
* @param sourceTree The primary source tree.
* @param sourceNode The current source node context.
* @param mode The current mode.
* @return The stringized result of executing the elements children.
*/
DOMString ElemTemplateElement::childrenToString(XSLTEngineImpl& processor,
const DOM_Node& sourceTree, const DOM_Node& sourceNode, const QName&
mode)
{
FormatterListener* savedFListener = processor.getFormatterListener();
DOMStringPrintWriter thePrintWriter;
FormatterToText theFormatter(thePrintWriter);
try
{
processor.setFormatterListener(&theFormatter);
const DOMString savedPendingName =
processor.getPendingElementName();
try
{
processor.setPendingElementName(DOMString());
const AttributeListImpl
savedPendingAttributes(processor.getPendingAttributes());
try
{
processor.setPendingAttributes(AttributeListImpl());
executeChildren(processor, sourceTree,
sourceNode, mode);
}
catch(...)
{
processor.setPendingAttributes(savedPendingAttributes);
throw;
}
processor.setPendingAttributes(savedPendingAttributes);
}
catch(...)
{
processor.setPendingElementName(savedPendingName);
throw;
}
processor.setPendingElementName(savedPendingName);
}
catch(...)
{
processor.setFormatterListener(savedFListener);
throw;
}
processor.setFormatterListener(savedFListener);
return thePrintWriter.getString();
}
/**
* Perform a query if needed, and call transformChild for each child.
*
* @param stylesheetTree The owning stylesheet tree.
* @param xslInstruction The stylesheet element context (depricated -- I do
* not think we need this).
* @param template The owning template context.
* @param sourceTree The input source tree.
* @param sourceNodeContext The current source node context.
* @param mode The current mode.
* @param selectPattern The XPath with which to perform the selection.
* @param xslToken The current XSLT instruction (depricated -- I do not
* think we want this).
*/
void ElemTemplateElement::transformSelectedChildren(
const Stylesheet& stylesheetTree,
const ElemTemplateElement* xslInstruction, // xsl:apply-templates or
xsl:for-each
ElemTemplateElement* theTemplate, // The template to copy to the
result tree
const DOM_Node& /*sourceTree*/,
const DOM_Node& sourceNodeContext,
const QName& mode,
XPath* selectPattern,
int xslToken)
{
// Sort the nodes according to the xsl:sort method
int tok = xslInstruction->getXSLToken();
std::vector<NodeSortKey> keys;
if((Constants::ELEMNAME_APPLY_TEMPLATES == tok) ||
(Constants::ELEMNAME_FOREACH == tok))
{
const ElemForEach* foreach = static_cast<const ElemForEach
*>(xslInstruction);
int nChildren = foreach->getSortElems().size();
// March backwards, performing a sort on each xsl:sort child.
// Probably not the most efficient method.
for(int i = 0; i < nChildren; i++)
{
ElemSort* sort = (foreach->getSortElems())[i];
DOMString langString = (!isEmpty(sort->getLangAVT())) ?
getProcessor()->evaluateAttrVal(sourceNodeContext,
DOM_UnimplementedElement(sort), sort->getLangAVT()): DOMString();
DOMString dataTypeString =
getProcessor()->evaluateAttrVal(sourceNodeContext,
DOM_UnimplementedElement(sort), sort->getDataTypeAVT());
bool treatAsNumbers = ((!isEmpty(dataTypeString)) &&
equals(dataTypeString,Constants::ATTRVAL_DATATYPE_NUMBER)) ?
true : false;
DOMString orderString =
getProcessor()->evaluateAttrVal(sourceNodeContext,
DOM_UnimplementedElement(sort), sort->getOrderAVT());
bool descending = ((!isEmpty(orderString)) &&
equals(orderString,Constants::ATTRVAL_ORDER_DESCENDING))?
true : false;
NodeSortKey key(getProcessor(),
sort->getSelectPattern(),
treatAsNumbers,
descending,
langString,
*xslInstruction);
keys.push_back(key);
}
}
MutableNodeRefList sourceNodes;
if (0 != selectPattern)
{
XObject* const result = selectPattern->execute(
sourceNodeContext,
*const_cast<ElemTemplateElement*>(xslInstruction),
getProcessor()->getContextNodeList());
sourceNodes = result->mutableNodeset();
if(0 !=
getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireSelectedEvent(
SelectionEvent(getProcessor(),
sourceNodeContext,
this,
"select",
selectPattern,
result));
}
}
else if (keys.size()>0)
{
MutableNodeRefList
msourceNodes(&(getStylesheet().getProcessor()->getXPathSupport()));
DOM_NodeList children = sourceNodeContext.getChildNodes();
int nNodes = children.getLength();
for(int i = 0; i < nNodes; i++)
{
msourceNodes.addNode(children.item(i));
}
sourceNodes = msourceNodes;
}
int nNodes = sourceNodes.getLength();
if(nNodes > 0)
{
if (keys.size()>0)
{
NodeSorter sorter(*getStylesheet().getProcessor());
sorter.sort(sourceNodes, keys);
}
const MutableNodeRefList& savedContextNodeList =
getStylesheet().getProcessor()->getContextNodeList();
getStylesheet().getProcessor()->setContextNodeList(sourceNodes);
if(getProcessor()->isTraceSelect())
getProcessor()->traceSelect(
DOM_UnimplementedElement(const_cast<ElemTemplateElement *>(xslInstruction)),
sourceNodes);
for(int i = 0; i < nNodes; i++)
{
const DOM_Node childNode = sourceNodes.item(i);
DOM_Document ownerDoc = childNode.getOwnerDocument();
if((DOM_Node::DOCUMENT_NODE != childNode.getNodeType())
&& (0 == ownerDoc))
{
error(DOMString("Child node does not have an
owner document!"));
}
transformChild(
stylesheetTree,
xslInstruction,
theTemplate,
ownerDoc,
sourceNodeContext,
childNode,
mode,
xslToken);
}
getStylesheet().getProcessor()->setContextNodeList(savedContextNodeList);
}
}
/**
* Given an element and mode, find the corresponding
* template and process the contents.
*
* @param stylesheetTree The current Stylesheet object.
* @param xslInstruction The calling element (deprecated -- I dont think we
* need this).
* @param template The template to use if xsl:for-each, or null.
* @param sourceTree The source DOM tree.
* @param selectContext The selection context.
* @param child The source context node.
* @param mode The current mode, may be null.
* @param xslToken ELEMNAME_APPLY_TEMPLATES, ELEMNAME_APPLY_IMPORTS, or
* ELEMNAME_FOREACH.
* @return true if applied a template, false if not.
*/
bool ElemTemplateElement::transformChild(
const Stylesheet& stylesheet_tree,
const ElemTemplateElement* xslInstruction, // xsl:apply-templates
or xsl:for-each
ElemTemplateElement* theTemplate, // may be null
const DOM_Node& sourceTree,
const DOM_Node& selectContext,
const DOM_Node& child,
const QName& mode,
int xslToken)
{
bool doApplyTemplate = true; // return value
bool shouldStrip = false;
int nodeType = child.getNodeType();
const Stylesheet* stylesheetTree = &stylesheet_tree;
bool isApplyImports = (xslToken == Constants::ELEMNAME_APPLY_IMPORTS);
if(!shouldStrip) // rcw: odd, seems that shouldStripis always false
{
if(0 == theTemplate)
{
// Find the XSL template that is the best match for the
// element, and call buildResultFromTemplate.
Stylesheet* foundStylesheet = 0;
if(!isApplyImports)
{
stylesheetTree =
getStylesheet().getStylesheetRoot();
}
theTemplate = stylesheetTree->findTemplate(sourceTree,
child, &mode,
isApplyImports, foundStylesheet);
if(isApplyImports && (0 != theTemplate))
{
stylesheetTree = foundStylesheet;
}
// mode = null; // non-sticky modes
}
if(doApplyTemplate) //rcw: seems to always be true
{
if(0 == theTemplate)
{
switch(nodeType)
{
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
case DOM_Node::ELEMENT_NODE:
theTemplate =
getStylesheet().getStylesheetRoot()->getDefaultRule();
break;
case DOM_Node::CDATA_SECTION_NODE:
case DOM_Node::TEXT_NODE:
case DOM_Node::ATTRIBUTE_NODE:
theTemplate =
getStylesheet().getStylesheetRoot()->getDefaultTextRule();
break;
case DOM_Node::DOCUMENT_NODE:
theTemplate =
getStylesheet().getStylesheetRoot()->getDefaultRootRule();
break;
case DOM_Node::COMMENT_NODE:
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
break;
default:
assert(false);
break;
}
if(0 != theTemplate)
{
// Not sure if this is needed. -sb
stylesheetTree =
getStylesheet().getStylesheetRoot();
}
}
if(0 != theTemplate)
{
getStylesheet().getProcessor()->resetCurrentState(sourceTree, child);
if(theTemplate ==
getStylesheet().getStylesheetRoot()->getDefaultTextRule())
{
switch(nodeType)
{
case DOM_Node::CDATA_SECTION_NODE:
case DOM_Node::TEXT_NODE:
getStylesheet().getProcessor()->cloneToResultTree(*stylesheetTree,
child, false, false,
false, false);
break;
case DOM_Node::ATTRIBUTE_NODE:
{
//rcw: DOM_node has no
virtual funcs so we can't do a dynamic_cast<>.
const DOM_Attr& attr =
static_cast<const DOM_Attr&>(child);
DOMString val =
attr.getValue();
getStylesheet().getProcessor()->characters(toCharArray(val),
0, length(val));
}
break;
default:
assert(false);
break;
}
}
else
{
bool doPush = (xslToken !=
Constants::ELEMNAME_FOREACH);
if(doPush)
{
getStylesheet().getProcessor()->getVariableStacks().
pushContextMarker(DOM_UnimplementedElement(theTemplate), child);
if(0 != xslInstruction)
{
getStylesheet().getProcessor()->getVariableStacks().
pushParams(
stylesheetTree, *xslInstruction,
sourceTree,
selectContext, mode,
DOM_UnimplementedElement(theTemplate));
}
}
if(0 !=
getStylesheet().getStylesheetRoot()->getTraceListeners())
{
TracerEvent
te(getStylesheet().getProcessor(), sourceTree, child,
mode, *theTemplate);
getStylesheet().getStylesheetRoot()->fireTraceEvent(te);
}
theTemplate->executeChildren(*getStylesheet().getProcessor(),
sourceTree, child, mode);
if(doPush)
{
getStylesheet().getProcessor()->getVariableStacks().popCurrentContext();
}
}
getStylesheet().getProcessor()->resetCurrentState(sourceTree, selectContext);
}
}
}
return doApplyTemplate;
}
/**
* Throw a template element runtime error. (Note: should we throw a
SAXException instead?)
*
* @param msg Description of the error that occured.
*/
void ElemTemplateElement::error(const DOMString& msg) const
{
throw ("ElemTemplateElement error: " + msg);
}
// Implemented DOM Element methods.
/**
* Add a child to the child list.
*
* @exception DOMException
* @param newChild
*/
NodeImpl* ElemTemplateElement::appendChild(NodeImpl* newChild)
{
if(0 == newChild)
{
error("Trying to add a null child!");
}
NodeImpl* elem = newChild;
if(0 == m_firstChild)
{
m_firstChild = dynamic_cast<ElemTemplateElement*>(elem);
}
else
{
ElemTemplateElement* last =
dynamic_cast<ElemTemplateElement*>(getLastChild());
assert(last != 0);
last->setNextSibling(elem);
}
dynamic_cast<ElemTemplateElement*>(elem)->setParentNode(this);
return newChild;
}
/*
* Remove a node from the child list
*/
NodeImpl* ElemTemplateElement::removeChild(NodeImpl *oldChild)
{
if(0 == oldChild)
{
error("Trying to remove a null child!");
}
NodeImpl *pTest = m_firstChild;
// first try the common, easy cases
if (pTest == 0)
return 0;
if (pTest == oldChild)
{
m_firstChild = 0;
return pTest;
}
// now we walk this singly-linked list, peeling one ahead, since we
need be
// able to patch up the list
while (pTest->getNextSibling() != 0 && pTest->getNextSibling() !=
oldChild)
pTest = pTest->getNextSibling();
NodeImpl* ret = pTest->getNextSibling();
if (pTest->getNextSibling() != 0)
dynamic_cast<ElemTemplateElement*>(pTest)->setNextSibling(pTest->getNextSibling()->getNextSibling());
return ret;
}
/**
* Tell if there are child nodes.
*/
bool ElemTemplateElement::hasChildNodes()
{
return (0 != m_firstChild);
}
/**
* Get the type of the node.
*/
short ElemTemplateElement::getNodeType()
{
return DOM_Node::ELEMENT_NODE;
}
/** Return the nodelist (same reference).
*/
NodeListImpl* ElemTemplateElement::getChildNodes()
{
return this;
}
/** Get the first child
*/
NodeImpl* ElemTemplateElement::getFirstChild()
{
return m_firstChild;
}
/** Get the last child.
*/
NodeImpl* ElemTemplateElement::getLastChild()
{
ElemTemplateElement* lastChild = 0;
for (ElemTemplateElement* node = m_firstChild;
node != 0; node = node->m_nextSibling)
{
lastChild = node;
}
return lastChild;
}
/**
* NodeList method: Count the immediate children of this node
*
* @return int
*/
int ElemTemplateElement::getLength()
{
// It is assumed that the getChildNodes call synchronized
// the children. Therefore, we can access the first child
// reference directly.
int count = 0;
for (ElemTemplateElement* node = m_firstChild; node != 0; node =
node->m_nextSibling)
{
count++;
}
return count;
}
/**
* NodeList method: Return the Nth immediate child of this node, or
* null if the index is out of bounds.
*
* @param index
* @return org.w3c.dom.Node
*/
NodeImpl* ElemTemplateElement::item(int index)
{
// It is assumed that the getChildNodes call synchronized
// the children. Therefore, we can access the first child
// reference directly.
ElemTemplateElement* node = m_firstChild;
for (int i = 0; i < index && node != 0; i++)
{
node = node->m_nextSibling;
}
return node;
}
/** Get the stylesheet owner.
*/
Stylesheet& ElemTemplateElement::getStylesheet() const
{
return m_stylesheet;
}
XSLTEngineImpl* ElemTemplateElement::getProcessor() const
{
return getStylesheet().getProcessor();
}
void ElemTemplateElement::setXSLProcessor(XSLTEngineImpl* processor) const
{
getStylesheet().setXSLProcessor(processor);
}
1.1 xml-xalan/c/src/XSLT/ElemTemplateElement.hpp
Index: ElemTemplateElement.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD)
#define XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD
/**
* $Id: ElemTemplateElement.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com)
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
#include <XPath/PrefixResolver.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
#include <XPath/QName.hpp>
#include <DOMSupport/UnimplementedElement.hpp>
class AttributeList;
class XSLTEngineImpl;
class Stylesheet;
/**
* An instance of this class represents an element inside
* an xsl:template class. It has a single "execute" method
* which is expected to perform the given action on the
* result tree.
*
* @see Stylesheet
*/
class ElemTemplateElement : public UnimplementedElement, public PrefixResolver
{
public:
/** Construct a template element instance.
*
* @param processor The XSLT Processor.
* @param stylesheetTree The owning stylesheet.
* @param name The name of the element.
* @param atts The element attributes.
* @param lineNumber The line in the XSLT file that the element occurs
on.
* @param columnNumber The column index in the XSLT file that the
element occurs on.
*/
ElemTemplateElement (
const XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
int lineNumber,
int columnNumber);
virtual ~ElemTemplateElement();
/**
* Given a namespace, get the corresponding prefix.
*/
DOMString getNamespaceForPrefix(const DOMString& prefix) const;
/**
* Given an XSL tag name, return an integer token
* that corresponds to ELEMNAME_XXX constants defined
* in Constants.java.
* Note: I tried to optimize this by caching the node to
* id lookups in a hash table, but it helped not a bit.
* I'm not sure that it's spending too much time here anyway.
* @param node a probable xsl:xxx element.
* @return Constants.ELEMNAME_XXX token, or -1 if in xsl
* or Xalan namespace, -2 if not in known namespace.
*/
int getAttrTok(const DOMString& name) const;
/**
* See if this is a xmlns attribute, and, if so, process it.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not used
at
* this time).
* @param which The index into the attribute list (not used at this
time).
* @return True if this is a namespace name.
*/
bool isAttrOK(int tok, const DOMString& attrName,
const AttributeList& atts, int which) const;
/**
* See if this is a xmlns attribute or in a non-XSLT.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not used
at
* this time).
* @param which The index into the attribute list (not used at this
time).
* @return True if this attribute should not be flagged as an error.
*/
bool isAttrOK(const DOMString& attrName,
const AttributeList& atts, int which) const;
/**
* Tell whether or not this is a xml:space attribute and, if so,
process it.
*
* @param aname The name of the attribute in question.
* @param atts The attribute list that owns the attribute.
* @param which The index of the attribute into the attribute list.
* @return True if this is a xml:space attribute.
*/
void processSpaceAttr(const AttributeList& atts, int which);
/**
* Tell whether or not this is a xml:space attribute and, if so,
process it.
*
* @param aname The name of the attribute in question.
* @param atts The attribute list that owns the attribute.
* @param which The index of the attribute into the attribute list.
* @return True if this is a xml:space attribute.
*/
bool processSpaceAttr(const DOMString& aname,
const AttributeList& atts, int which);
/**
* Validate that the string is an NCName.
*
* @param s The name in question.
* @return True if the string is a valid NCName according to XML rules.
* @see http://www.w3.org/TR/REC-xml-names#NT-NCName
*/
static bool isValidNCName(const DOMString& s);
/** Execute the element's primary function. Subclasses of this
* function may recursivly execute down the element tree.
*
* @param processor The XSLT Processor.
* @param sourceTree The input source tree.
* @param sourceNode The current context node.
* @param mode The current mode.
*/
virtual void execute(XSLTEngineImpl& processor, const DOM_Node&
sourceTree,
const DOM_Node& sourceNode, const QName& mode);
/**
* Process the children of a template.
*
* @param processor The XSLT processor instance.
* @param sourceTree The input source tree.
* @param sourceNode The current context node.
* @param mode The current mode.
*/
void executeChildren(XSLTEngineImpl& processor, const DOM_Node&
sourceTree,
const DOM_Node& sourceNode, const QName& mode);
/**
* Take the contents of a template element, process it, and
* convert it to a string.
*
* @exception XSLProcessorException Thrown from one of the child
execute
* methods.
* @exception java.net.MalformedURLException Might be thrown from the
* document() function, or from xsl:include or xsl:import.
* @exception java.io.FileNotFoundException Might be thrown from the
* document() function, or from xsl:include or xsl:import.
* @exception java.io.IOException Might be thrown from the document()
* function, or from xsl:include or xsl:import.
* @exception SAXException Might be thrown from the document()
function, or
* from xsl:include or xsl:import.
* @param processor The XSLT processor instance.
* @param sourceTree The primary source tree.
* @param sourceNode The current source node context.
* @param mode The current mode.
* @return The stringized result of executing the elements children.
*/
DOMString childrenToString(XSLTEngineImpl& processor,
const DOM_Node& sourceTree, const DOM_Node& sourceNode,
const QName& mode);
/**
* Get an integer representation of the element type.
*
* @return An integer representation of the element, defined in the
* Constants class.
* @see class Constants
*/
virtual int getXSLToken() const = 0;
/**
* Tell if the string is whitespace.
*
* @param string The string in question.
* @return True if the string is pure whitespace.
*/
static bool isWhiteSpace(const DOMString& theString);
/**
* Throw a template element runtime error.
* (Note: should we throw a SAXException instead?)
*
* @param msg Description of the error that occured.
**/
virtual void error(const DOMString& msg) const;
protected:
/**
* Perform a query if needed, and call transformChild for each child.
*
* @param stylesheetTree The owning stylesheet tree.
* @param xslInstruction The stylesheet element context (depricated --
I do
* not think we need this).
* @param template The owning template context.
* @param sourceTree The input source tree.
* @param sourceNodeContext The current source node context.
* @param mode The current mode.
* @param selectPattern The XPath with which to perform the selection.
* @param xslToken The current XSLT instruction (depricated -- I do not
* think we want this).
*/
void transformSelectedChildren(
const Stylesheet& stylesheetTree,
const ElemTemplateElement* xslInstruction, //
xsl:apply-templates or xsl:for-each
ElemTemplateElement* theTemplate, // The template to copy to
the result tree
const DOM_Node& sourceTree,
const DOM_Node& sourceNodeContext,
const QName& mode,
XPath* selectPattern,
int xslToken);
/**
* Given an element and mode, find the corresponding
* template and process the contents.
*
* @param stylesheetTree The current Stylesheet object.
* @param xslInstruction The calling element (deprecated -- I dont
think we
* need this).
* @param template The template to use if xsl:for-each, or null.
* @param sourceTree The source DOM tree.
* @param selectContext The selection context.
* @param child The source context node.
* @param mode The current mode, may be null.
* @param xslToken ELEMNAME_APPLY_TEMPLATES, ELEMNAME_APPLY_IMPORTS, or
* ELEMNAME_FOREACH.
* @return true if applied a template, false if not.
*/
bool transformChild(const Stylesheet& stylesheetTree,
const ElemTemplateElement* xslInstruction, //
xsl:apply-templates or xsl:for-each
ElemTemplateElement* theTemplate, // may be null
const DOM_Node& sourceTree, const DOM_Node& selectContext,
const DOM_Node& child, const QName& mode,
int xslToken);
// Implemented DOM Element methods.
public:
virtual NodeImpl* cloneNode(bool /*deep*/)
{
//should not be called
assert(false);
return 0;
}
/**
* Add a child to the child list.
*
* @exception DOMException
* @param newChild
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
/*
* Remove a node from the child list
*/
virtual NodeImpl* removeChild(NodeImpl *oldChild);
/**
* Tell if there are child nodes.
*/
virtual bool hasChildNodes();
/**
* Get the type of the node.
*/
virtual short getNodeType();
/** Get the parent.
*/
virtual NodeImpl* getParentNode();
virtual void setParentNode(NodeImpl* elem);
/** Return the nodelist (same reference).
*/
virtual NodeListImpl* getChildNodes();
/** Get the first child
*/
virtual NodeImpl* getFirstChild();
/** Get the last child.
*/
virtual NodeImpl*getLastChild();
/** Get the next sibling or return null.
*/
virtual NodeImpl* getNextSibling();
/** Set the next sibling.
*/
virtual void setNextSibling(NodeImpl* elem);
/**
* NodeList method: Count the immediate children of this node
*
* @return int
*/
virtual int getLength();
/**
* NodeList method: Return the Nth immediate child of this node, or
* null if the index is out of bounds.
*
* @param index
* @return org.w3c.dom.Node
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual NodeImpl*
#else
virtual ElemTemplateElement*
#endif
item(int i);
Stylesheet& getStylesheet() const;
XSLTEngineImpl* getProcessor() const;
virtual void setXSLProcessor(XSLTEngineImpl* processor) const;
/** Return the element name.
*/
virtual DOMString getTagName()
{
return m_elemName;
}
/** Return the node name.
*/
virtual DOMString getNodeName()
{
return m_elemName;
}
int getLineNumber() const;
int getColumnNumber() const;
typedef std::vector<NameSpace> NamespaceVectorType;
const NamespaceVectorType& getNameSpace() const
{
return m_namespaces;
}
void setFinishedConstruction(bool bFinished)
{
m_finishedConstruction = bFinished;
}
private:
Stylesheet&
m_stylesheet;
const int
m_lineNumber;
const int
m_columnNumber;
NamespaceVectorType m_namespaces;
bool
m_defaultSpace; // = true
bool
m_finishedConstruction; // = false
const DOMString m_elemName;
ElemTemplateElement* m_parentNode;
ElemTemplateElement* m_nextSibling;
ElemTemplateElement* m_firstChild;
};
#endif // XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemText.cpp
Index: ElemText.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemText.hpp"
#include "ElemPriv.hpp"
/**
* This primarily acts as a marker on the element
* stack to signal that whitespace should be preserved.
*/
ElemText::ElemText(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_disableOutputEscaping(false)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_DISABLE_OUTPUT_ESCAPING))
{
m_disableOutputEscaping =
getStylesheet().getYesOrNo(aname, atts.getValue(i));
}
else if(!isAttrOK(aname, atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
}
/**
* Add a child to the child list.
*/
NodeImpl* ElemText::appendChild(NodeImpl* newChild)
{
int type = dynamic_cast<ElemTemplateElement*>(newChild)->getXSLToken();
switch(type)
{
case Constants::ELEMNAME_TEXTLITERALRESULT:
break;
default:
error("Can not add " +
dynamic_cast<ElemTemplateElement*>(newChild)->getTagName() + " to " +
this->getTagName());
}
return ElemTemplateElement::appendChild(newChild);
}
int ElemText::getXSLToken() const
{
return Constants::ELEMNAME_TEXT;
}
1.1 xml-xalan/c/src/XSLT/ElemText.hpp
Index: ElemText.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMTEXT_HEADER_GUARD)
#define XALAN_ELEMTEXT_HEADER_GUARD
/**
* $Id: ElemText.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
/**
* This primarily acts as a marker on the element
* stack to signal that whitespace should be preserved.
*/
class ElemText : public ElemTemplateElement
{
public:
ElemText(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
/**
* Add a child to the child list.
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
virtual int getXSLToken() const;
bool getDisableOutputEscaping() const
{
return m_disableOutputEscaping;
}
private:
bool m_disableOutputEscaping; // = false;
};
#endif // XALAN_ELEMTEXT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemTextLiteral.cpp
Index: ElemTextLiteral.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemTextLiteral.hpp"
#include "ElemPriv.hpp"
ElemTextLiteral::ElemTextLiteral(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const XMLCh* const ch,
int start,
int theLength,
bool isCData,
bool preserveSpace,
bool disableOutputEscaping,
int lineNumber,
int columnNumber):
ElemTemplateElement(processor,
stylesheetTree,
DOMString("#text"),
lineNumber,
columnNumber),
m_isCData(isCData),
m_preserveSpace(preserveSpace),
// $$$ ToDo: Why isn't this just a const std::vector<XMLCh>?
m_ch(new XMLCh[theLength]),
m_start(start),
m_length(theLength),
m_disableOutputEscaping(disableOutputEscaping)
{
assert(theLength > 0);
assert(m_ch != 0);
memcpy(m_ch, ch, theLength * sizeof(XMLCh));
}
ElemTextLiteral::~ElemTextLiteral()
{
delete [] m_ch;
}
int ElemTextLiteral::getXSLToken() const
{
return Constants::ELEMNAME_TEXTLITERALRESULT;
}
void ElemTextLiteral::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
if(!m_disableOutputEscaping)
{
processor.characters(m_ch, m_start, m_length);
}
else
{
processor.charactersRaw(m_ch, m_start, m_length);
}
}
1.1 xml-xalan/c/src/XSLT/ElemTextLiteral.hpp
Index: ElemTextLiteral.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMTEXTLITERAL_HEADER_GUARD)
#define XALAN_ELEMTEXTLITERAL_HEADER_GUARD
/**
* $Id: ElemTextLiteral.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemTextLiteral : public ElemTemplateElement
{
public:
ElemTextLiteral (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const XMLCh* const ch,
int start,
int length,
bool isCData,
bool preserveSpace,
bool disableOutputEscaping,
int lineNumber,
int columnNumber);
virtual ~ElemTextLiteral();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
bool isPreserveSpace() const
{
return m_preserveSpace;
}
private:
// not implemented
ElemTextLiteral(const ElemTextLiteral &);
ElemTextLiteral& operator=(const ElemTextLiteral &);
bool m_isCData;
bool m_preserveSpace;
bool m_disableOutputEscaping;
XMLCh* m_ch;
int m_start;
int m_length;
};
#endif // XALAN_ELEMTEXTLITERAL_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemUse.cpp
Index: ElemUse.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemUse.hpp"
#include "ElemPriv.hpp"
/**
* This acts as a superclass for ElemCopy, ElemAttributeSet,
* ElemElement, and ElemLiteralResult, on order to implement
* shared behavior the use-attribute-sets attribute.
*/
ElemUse::ElemUse(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& /*atts*/,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_attributeSetsNames(0)
{
}
void ElemUse::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
if(0 != m_attributeSetsNames.size())
getStylesheet().applyAttrSets(m_attributeSetsNames,
&processor, sourceTree, sourceNode, mode);
}
int ElemUse::getXSLToken() const
{
return Constants::ELEMNAME_USE;
}
/**
* See if this is a use-attribute-sets attribute, and, if so, process it.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not used at
* this time).
* @param which The index into the attribute list (not used at this time).
* @return True if this is a use-attribute-sets attribute.
*/
bool ElemUse::processUseAttributeSets(
const DOMString& attrName,
const AttributeList& atts,
int which)
{
bool isUAS = false;
if(Constants::ELEMNAME_LITERALRESULT == getXSLToken())
{
QName qname(attrName, getStylesheet().getNamespaces());
isUAS = ((equals(qname.getNamespace(),
getStylesheet().getProcessor()->getXSLNameSpaceURL()))
&&
(equals(qname.getLocalPart(),Constants::ATTRNAME_USEATTRIBUTESETS)));
}
else
{
isUAS = equals(attrName,Constants::ATTRNAME_USEATTRIBUTESETS);
}
if(isUAS)
{
isUAS = true;
DOMString qnames = atts.getValue(which);
StringTokenizer tokenizer(qnames, " \t\n\r", false);
int numTokens = tokenizer.countTokens();
m_attributeSetsNames.reserve(numTokens);
while(tokenizer.hasMoreTokens())
{
DOMString qname = tokenizer.nextToken();
m_attributeSetsNames.push_back(QName(qname,
getStylesheet().getNamespaces()));
}
}
return isUAS;
}
1.1 xml-xalan/c/src/XSLT/ElemUse.hpp
Index: ElemUse.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMUSE_HEADER_GUARD)
#define XALAN_ELEMUSE_HEADER_GUARD
/**
* $Id: ElemUse.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com)
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/QName.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemUse : public ElemTemplateElement
{
public:
ElemUse (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
virtual int getXSLToken() const;
/**
* See if this is a use-attribute-sets attribute, and, if so, process
it.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not
used at
* this time).
* @param which The index into the attribute list (not used at this
time).
* @return True if this is a use-attribute-sets attribute.
*/
bool processUseAttributeSets(
const DOMString& attrName,
const AttributeList& atts,
int which);
private:
std::vector<QName> m_attributeSetsNames;
};
#endif // XALAN_ELEMUSE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemValueOf.cpp
Index: ElemValueOf.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemValueOf.hpp"
#include "ElemPriv.hpp"
ElemValueOf::ElemValueOf(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_selectPattern(0),
m_disableOutputEscaping(false)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
const int tok = getAttrTok(aname);
switch(tok)
{
case Constants::TATTRNAME_SELECT:
m_selectPattern =
processor.createXPath(atts.getValue(i),
*this);
break;
case Constants::TATTRNAME_DISABLE_OUTPUT_ESCAPING:
m_disableOutputEscaping =
getStylesheet().getYesOrNo(aname, atts.getValue(i));
break;
case Constants::TATTRNAME_XMLSPACE:
processSpaceAttr(atts, i);
break;
default:
if(!isAttrOK(tok, aname, atts, i))
{
processor.error(name + " has an illegal
attribute: " + aname);
}
}
}
if(0 == m_selectPattern)
{
processor.error(name + " requires a select attribute.");
}
}
int ElemValueOf::getXSLToken() const
{
return Constants::ELEMNAME_VALUEOF;
}
/**
* Add a child to the child list.
*/
NodeImpl* ElemValueOf::appendChild(NodeImpl* newChild)
{
error("Can not add " +
dynamic_cast<ElemTemplateElement *>(newChild)->getTagName()
+ " to " + this->getTagName());
return 0;
}
void ElemValueOf::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
XObject* value = m_selectPattern->execute(sourceNode, *this,
processor.getContextNodeList());
if(0 != getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireSelectedEvent(
SelectionEvent(getStylesheet().getProcessor(),sourceNode,
this, DOMString("select"), m_selectPattern, value));
}
if(0 != value)
{
const int type = value->getType();
if (XObject::eTypeNull != type)
{
DOMString s = value->str();
if(!isEmpty(s))
{
int len = length(s);
if(len > 0)
{
if(!m_disableOutputEscaping)
{
processor.characters(toCharArray(s), 0, length(s));
}
else
{
processor.charactersRaw(toCharArray(s), 0, length(s));
}
}
}
}
}
}
1.1 xml-xalan/c/src/XSLT/ElemValueOf.hpp
Index: ElemValueOf.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMVALUEOF_HEADER_GUARD)
#define XALAN_ELEMVALUEOF_HEADER_GUARD
/**
* $Id: ElemValueOf.hpp,v 1.1 1999/12/18 19:48:03 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/QName.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemValueOf : public ElemTemplateElement
{
public:
ElemValueOf (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
/**
* Add a child to the child list.
*/
virtual NodeImpl* appendChild(NodeImpl* newChild);
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
private:
/**
* The select pattern used to locate the value.
*/
XPath* m_selectPattern; // = null;
/**
* Tells if this element should disable escaping.
*/
bool m_disableOutputEscaping; // = false;
};
#endif // XALAN_ELEMVALUEOF_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemVariable.cpp
Index: ElemVariable.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemVariable.hpp"
#include "ElemPriv.hpp"
#include <XPath/XResultTreeFrag.hpp>
#include <XPath/ResultTreeFrag.hpp>
ElemVariable::ElemVariable(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_selectPattern(0),
m_qname(0),
m_isTopLevel(false),
m_value(0),
m_varContext(DOM_Node())
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
const int tok = getAttrTok(aname);
switch(tok)
{
case Constants::TATTRNAME_SELECT:
m_selectPattern =
processor.createXPath(atts.getValue(i),
*this);
break;
case Constants::TATTRNAME_NAME:
m_qname = new QName(atts.getValue(i),
stylesheetTree.getNamespaces());
break;
case Constants::TATTRNAME_XMLSPACE:
processSpaceAttr(atts, i);
break;
default:
if(!isAttrOK(tok, aname, atts, i))
{
processor.error(name + " has an illegal
attribute: " + aname);
}
}
}
if(0 == m_qname)
{
processor.error(name + " must have a 'name' attribute.");
}
}
ElemVariable::~ElemVariable()
{
delete m_qname;
m_qname=0;
m_selectPattern = 0;
m_value = 0;
}
int ElemVariable::getXSLToken() const
{
return Constants::ELEMNAME_VARIABLE;
}
void ElemVariable::execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
ElemTemplateElement::execute(processor, sourceTree, sourceNode, mode);
XObject* var = getValue(processor, sourceTree, sourceNode);
processor.getVariableStacks().pushVariable(*m_qname, var,
XALAN_DOM_NodeHack(getParentNode()));
}
/**
* Get the XObject representation of the variable.
*/
XObject* ElemVariable::getValue(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode)
{
XObject* var;
if(0 != m_selectPattern)
{
var = m_selectPattern->execute(sourceNode, *this,
processor.getContextNodeList());
if(0 !=
getStylesheet().getStylesheetRoot()->getTraceListeners())
{
getStylesheet().getStylesheetRoot()->fireSelectedEvent(
SelectionEvent(getStylesheet().getProcessor(),
sourceNode,
this, DOMString("select"),
m_selectPattern, var));
}
}
else
{
// Use result tree fragment
std::auto_ptr<ResultTreeFragBase>
df(processor.createResultTreeFrag(&getStylesheet(),
*this,
sourceTree, sourceNode, QName()));
// to do : is this XResultTreeFrag??
var = processor.createXResultTreeFrag(*df);
}
return var;
}
1.1 xml-xalan/c/src/XSLT/ElemVariable.hpp
Index: ElemVariable.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMVARIABLE_HEADER_GUARD)
#define XALAN_ELEMVARIABLE_HEADER_GUARD
/**
* $Id: ElemVariable.hpp,v 1.1 1999/12/18 19:48:04 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/QName.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemVariable : public ElemTemplateElement
{
public:
ElemVariable (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemVariable();
virtual int getXSLToken() const;
virtual void execute(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Get the XObject representation of the variable.
*/
XObject* getValue(
XSLTEngineImpl& processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode);
bool isTopLevel() const
{
return m_isTopLevel;
}
void setTopLevel(bool bTopLevel)
{
m_isTopLevel = bTopLevel;
}
QName* getName() { return m_qname; }
protected:
QName* m_qname; // = null;
private:
// not implemented
ElemVariable(const ElemVariable &);
ElemVariable& operator=(const ElemVariable &);
XPath* m_selectPattern; // = null;
bool m_isTopLevel; // = false;
XObject* m_value; // = null;
DOM_Node m_varContext; // = null;
};
#endif // XALAN_ELEMVARIABLE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemWhen.cpp
Index: ElemWhen.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemWhen.hpp"
#include "ElemPriv.hpp"
ElemWhen::ElemWhen(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pTest(0)
{
const int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
const int tok = getAttrTok(aname);
switch(tok)
{
case Constants::TATTRNAME_TEST:
m_pTest =
getStylesheet().getProcessor()->createXPath(atts.getValue(i), *this);
break;
case Constants::TATTRNAME_XMLSPACE:
processSpaceAttr(atts, i);
break;
default:
if(!isAttrOK(tok, aname, atts, i))
{
processor.error(name + " has an illegal
attribute: " + aname);
}
}
}
if(0== m_pTest)
{
processor.error("xsl:when must have a 'test' attribute.");
}
}
int ElemWhen::getXSLToken() const
{
return Constants::ELEMNAME_WHEN;
}
1.1 xml-xalan/c/src/XSLT/ElemWhen.hpp
Index: ElemWhen.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMWHEN_HEADER_GUARD)
#define XALAN_ELEMWHEN_HEADER_GUARD
/**
* $Id: ElemWhen.hpp,v 1.1 1999/12/18 19:48:04 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/QName.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemWhen : public ElemTemplateElement
{
public:
ElemWhen (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual int getXSLToken() const;
XPath* getXPath() const
{
return m_pTest;
}
private:
XPath* m_pTest;
};
#endif // XALAN_ELEMWHEN_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElemWithParam.cpp
Index: ElemWithParam.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElemWithParam.hpp"
#include "ElemPriv.hpp"
ElemWithParam::ElemWithParam(
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber) :
ElemTemplateElement(processor, stylesheetTree, name,
lineNumber, columnNumber),
m_pSelectPattern(0),
m_pQName(0)
{
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname(atts.getName(i));
if(equals(aname,Constants::ATTRNAME_SELECT))
{
m_pSelectPattern =
processor.createXPath(atts.getValue(i), *this);
}
else if(equals(aname,Constants::ATTRNAME_NAME))
{
m_pQName = new QName(atts.getValue(i),
stylesheetTree.getNamespaces());
}
else if(!isAttrOK(aname, atts, i))
{
processor.error(name + " has an illegal attribute: " +
aname);
}
}
if(0 == m_pQName)
processor.error("xsl:with-param must have a 'name'
attribute.");
}
ElemWithParam::~ElemWithParam()
{
delete m_pQName;
m_pQName = 0;
m_pSelectPattern = 0; // free'd by XPath
}
int ElemWithParam::getXSLToken() const
{
return Constants::ELEMNAME_PARAM;
}
1.1 xml-xalan/c/src/XSLT/ElemWithParam.hpp
Index: ElemWithParam.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_ELEMWITHPARAM_HEADER_GUARD)
#define XALAN_ELEMWITHPARAM_HEADER_GUARD
/**
* $Id: ElemWithParam.hpp,v 1.1 1999/12/18 19:48:04 robweir Exp $
*
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class header file.
#include "ElemTemplateElement.hpp"
#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
#include <XPath/QName.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPath.hpp>
class ElemWithParam : public ElemTemplateElement
{
public:
ElemWithParam (
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOMString& name,
const AttributeList& atts,
int lineNumber,
int columnNumber);
virtual ~ElemWithParam();
virtual int getXSLToken() const;
QName* getQName() const { return m_pQName; }
XPath* getSelectPattern() const { return m_pSelectPattern; }
private:
// not implemented
ElemWithParam(const ElemWithParam &);
ElemWithParam& operator=(const ElemWithParam &);
XPath* m_pSelectPattern;
QName* m_pQName;
};
#endif // XALAN_ELEMWITHPARAM_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ElementMarker.cpp
Index: ElementMarker.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ElementMarker.hpp"
ElementMarker::ElementMarker(const DOM_Node& elem) :
StackEntry(eElementMarker),
m_elem(elem)
{
}
ElementMarker::ElementMarker(const ElementMarker& theSource) :
StackEntry(theSource),
m_elem(theSource.m_elem)
{
}
ElementMarker::~ElementMarker()
{
}
bool
ElementMarker::equals(const StackEntry& rhs) const
{
if (getType() == rhs.getType() &&
m_elem == static_cast<const ElementMarker&>(rhs).m_elem)
{
return true;
}
else
{
return false;
}
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
StackEntry*
#else
ElementMarker*
#endif
ElementMarker::clone() const
{
return new ElementMarker(*this);
}
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/ElementMarker.hpp
Index: ElementMarker.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_ELEMENTMARKER_HEADER_GUARD)
#define XALAN_ELEMENTMARKER_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOM_Node.hpp>
// Base class header file.
#include "StackEntry.hpp"
#include "ElemTemplateElement.hpp"
// This class marks the point in the stack where an Element's context
// begins.
class ElementMarker : public StackEntry
{
public:
ElementMarker(const DOM_Node& elem);
ElementMarker(const ElementMarker& theSource);
virtual
~ElementMarker();
virtual bool
equals(const StackEntry& rhs) const;
const DOM_Node&
getElement() const
{
return m_elem;
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual StackEntry*
#else
virtual ElementMarker*
#endif
clone() const;
bool
operator==(const ElementMarker& theRHS)
{
return equals(theRHS);
}
private:
const DOM_Node& m_elem;
};
#endif // XALAN_ELEMENTMARKER_HEADER_GUARD
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/ExtensionFunctionHandler.cpp
Index: ExtensionFunctionHandler.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "ExtensionFunctionHandler.hpp"
/**
* Class handling an extension namespace for XPath. Provides functions
* to test a function's existence and call a function
*
* @author Sanjiva Weerawarana ([EMAIL PROTECTED])
*/
ExtensionFunctionHandler::ExtensionFunctionHandler (const DOMString&
namespaceUri) :
m_namespaceUri(namespaceUri),
m_scriptLang(),
m_scriptSrc(),
m_scriptSrcURL(),
m_javaObject(0),
m_functions(),
m_componentStarted(false)
{
}
ExtensionFunctionHandler::~ExtensionFunctionHandler()
{
m_javaObject = 0;
}
/////////////////////////////////////////////////////////////////////////
/**
* Construct a new extension namespace handler given all the information
* needed.
*
* @param namespaceUri the extension namespace URI that I'm implementing
* @param funcNames string containing list of functions of extension NS
* @param lang language of code implementing the extension
* @param srcURL value of src attribute (if any) - treated as a URL
* or a classname depending on the value of lang. If
* srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
ExtensionFunctionHandler::ExtensionFunctionHandler (
const
DOMString& namespaceUri,
const
DOMString& funcNames,
const
DOMString& lang,
const
DOMString& srcURL,
const
DOMString& src) :
m_namespaceUri(namespaceUri),
m_scriptLang(lang),
m_scriptSrc(src),
m_scriptSrcURL(srcURL),
m_javaObject(0),
m_functions(),
m_componentStarted(false)
{
setFunctions (funcNames);
}
/////////////////////////////////////////////////////////////////////////
// Main API
/////////////////////////////////////////////////////////////////////////
/**
* Set function local parts of extension NS.
*
* @param functions whitespace separated list of function names defined
* by this extension namespace.
*/
void ExtensionFunctionHandler::setFunctions (const DOMString& funcNames)
{
if (isEmpty(funcNames))
{
return;
}
StringTokenizer st(funcNames, " \t\n\r", false);
while (st.hasMoreTokens ())
{
DOMString tok = st.nextToken ();
m_functions.insert(tok);
}
}
/////////////////////////////////////////////////////////////////////////
/**
* Set the script data for this extension NS. If srcURL is !null then
* the script body is read from that URL. If not the scriptSrc is used
* as the src. This method does not actually execute anything - that's
* done when the component is first hit by the user by an element or
* a function call.
*
* @param lang language of the script.
* @param srcURL value of src attribute (if any) - treated as a URL
* or a classname depending on the value of lang. If
* srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
void ExtensionFunctionHandler::setScript (const DOMString& lang,
const DOMString& srcURL,
const DOMString&
scriptSrc)
{
m_scriptLang = lang;
m_scriptSrcURL = srcURL;
m_scriptSrc = scriptSrc;
}
/////////////////////////////////////////////////////////////////////////
/**
* Tests whether a certain function name is known within this namespace.
*
* @param function name of the function being tested
*
* @return true if its known, false if not.
*/
bool ExtensionFunctionHandler::isFunctionAvailable (const DOMString&
function)
{
return m_functions.find(function) != m_functions.end();
}
/////////////////////////////////////////////////////////////////////////
/**
* Process a call to a function.
*
* @param funcName Function name.
* @param args The arguments of the function call.
*
* @return the return value of the function evaluation.
*
* @exception XSLProcessorException thrown if something goes wrong
* while running the extension handler.
* @exception MalformedURLException if loading trouble
* @exception FileNotFoundException if loading trouble
* @exception IOException if loading trouble
* @exception SAXException if parsing trouble
*/
XObject* ExtensionFunctionHandler::callFunction (const DOMString& funcName,
const ArgVector& args)
{
assert(0); // @@ TODO: Not implemented
if (!m_componentStarted)
{
startupComponent ();
}
// System.out.println("Extensions not implemented!");
return 0;
}
/////////////////////////////////////////////////////////////////////////
// Private/Protected Functions
/////////////////////////////////////////////////////////////////////////
/**
* Start the component up by executing any script that needs to run
* at startup time. This needs to happen before any functions can be
* called on the component.
*
* @exception XPathProcessorException if something bad happens.
*/
void ExtensionFunctionHandler::startupComponent()
{
// special case the javaclass engine - the scriptSrcURL is
// the class name to run. If it starts with class: then use the
// class object with that name instead of init'ing it as the
// target of the calls later
if (m_scriptLang.equals ("javaclass"))
{
try
{
DOMString cname = m_scriptSrcURL;
bool isClass = false;
if (startsWith (m_scriptSrcURL, "class:"))
{
cname = substring (m_scriptSrcURL, 6);
isClass = true;
}
// @@ JMD: Can't do this in C++
/*
Class cl = Class.forName (cname);
if (isClass)
{
m_javaObject = cl;
}
else
{
m_javaObject = cl.newInstance ();
}
*/
m_componentStarted = true;
return;
}
//catch (Exception e)
catch (...)
{
assert(0);
// System.out.println("Extension error: "+e.getMessage
());
// throw new XPathProcessorException (e.getMessage (),
e);
}
}
// if scriptSrcURL is specified read it off
if (!isEmpty(m_scriptSrcURL))
{
assert(0);
// throw new XPathProcessorException ("src attr not supported
(yet)");
}
if (isEmpty(m_scriptSrc))
{
return;
}
// evaluate the src to load whatever content is in that string to
// the engines
assert(0);
// System.out.println("Error! Extensions not implemented!");
/*
try
{
mgr.exec (m_scriptLang, "XSLTScript", -1, -1, scriptSrc);
}
catch (BSFException bsfe)
{
throw new XPathProcessorException (bsfe.getMessage (), bsfe);
}
*/
m_componentStarted = true;
}
1.1 xml-xalan/c/src/XSLT/ExtensionFunctionHandler.hpp
Index: ExtensionFunctionHandler.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD)
#define XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <set>
#include <vector>
#include <cassert>
class XObject;
/**
* Class handling an extension namespace for XPath. Provides functions
* to test a function's existence and call a function
*
* @author Sanjiva Weerawarana ([EMAIL PROTECTED])
*/
class XALAN_XSLT_EXPORT ExtensionFunctionHandler
{
protected:
DOMString m_namespaceUri; // uri of the extension namespace
DOMString m_scriptLang; // scripting language of implementation
DOMString m_scriptSrc; // script source to run (if any)
DOMString m_scriptSrcURL; // URL of source of script (if any)
// @@
void* m_javaObject; // object for javaclass engine
typedef std::set<DOMString> StringSetType;
StringSetType m_functions; // functions of namespace
// BSFManager mgr = new BSFManager (); // mgr used to run scripts
bool m_componentStarted; // true when the scripts in a
// component description (if any) have been run
/////////////////////////////////////////////////////////////////////////
// Constructors
/////////////////////////////////////////////////////////////////////////
/**
* Construct a new extension namespace handler for a given extension NS.
* This doesn't do anything - just hang on to the namespace URI.
*
* @param namespaceUri the extension namespace URI that I'm implementing
*/
public:
ExtensionFunctionHandler (const DOMString& namespaceUri);
/////////////////////////////////////////////////////////////////////////
/**
* Construct a new extension namespace handler given all the information
* needed.
*
* @param namespaceUri the extension namespace URI that I'm implementing
* @param funcNames string containing list of functions of extension
NS
* @param lang language of code implementing the extension
* @param srcURL value of src attribute (if any) - treated as a
URL
* or a classname depending on the value of lang. If
* srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
ExtensionFunctionHandler (const DOMString& namespaceUri,
const DOMString& funcNames,
const DOMString& lang,
const DOMString& srcURL,
const DOMString& src);
virtual ~ExtensionFunctionHandler();
/////////////////////////////////////////////////////////////////////////
// Main API
/////////////////////////////////////////////////////////////////////////
/**
* Set function local parts of extension NS.
*
* @param functions whitespace separated list of function names defined
* by this extension namespace.
*/
virtual void setFunctions (const DOMString& funcNames);
/////////////////////////////////////////////////////////////////////////
/**
* Set the script data for this extension NS. If srcURL is !null then
* the script body is read from that URL. If not the scriptSrc is used
* as the src. This method does not actually execute anything - that's
* done when the component is first hit by the user by an element or
* a function call.
*
* @param lang language of the script.
* @param srcURL value of src attribute (if any) - treated as a URL
* or a classname depending on the value of lang. If
* srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
virtual void setScript (const DOMString& lang,
const
DOMString& srcURL,
const
DOMString& scriptSrc);
/////////////////////////////////////////////////////////////////////////
/**
* Tests whether a certain function name is known within this namespace.
*
* @param function name of the function being tested
*
* @return true if its known, false if not.
*/
virtual bool isFunctionAvailable (const DOMString& function);
/////////////////////////////////////////////////////////////////////////
/**
* Process a call to a function.
*
* @param funcName Function name.
* @param args The arguments of the function call.
*
* @return the return value of the function evaluation.
*
* @exception XSLProcessorException thrown if something goes wrong
* while running the extension handler.
* @exception MalformedURLException if loading trouble
* @exception FileNotFoundException if loading trouble
* @exception IOException if loading trouble
* @exception SAXException if parsing trouble
*/
typedef std::vector<void*> ArgVector;
virtual XObject* callFunction (const DOMString& funcName, const
ArgVector& args);
/////////////////////////////////////////////////////////////////////////
// Private/Protected Functions
/////////////////////////////////////////////////////////////////////////
/**
* Start the component up by executing any script that needs to run
* at startup time. This needs to happen before any functions can be
* called on the component.
*
* @exception XPathProcessorException if something bad happens.
*/
protected:
virtual void startupComponent();
};
#endif // XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ExtensionNSHandler.cpp
Index: ExtensionNSHandler.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
// Class header file.
#include "ExtensionNSHandler.hpp"
#include "ExtensionFunctionHandler.hpp"
class XSLTEngineImpl;
class Stylesheet;
class DOM_Node;
class DOM_Node;
class QName;
struct XSLProcessorContext
{
const XSLTEngineImpl& m_processor;
const Stylesheet& m_stylesheetTree;
const DOM_Node& m_sourceTree;
const DOM_Node& m_sourceNode;
const QName& m_mode;
XSLProcessorContext(
const XSLTEngineImpl& processor,
const Stylesheet& stylesheetTree,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode) :
m_processor(processor),
m_stylesheetTree(stylesheetTree),
m_mode(mode),
m_sourceTree(sourceTree),
m_sourceNode(sourceNode)
{}
};
/**
* Construct a new extension namespace handler for a given extension NS.
* This doesn't do anything - just hang on to the namespace URI.
*
* @param xslp handle to the XSL processor
that I'm working for
* @param namespaceUri the extension namespace URI that I'm implementing
*/
ExtensionNSHandler::ExtensionNSHandler(XSLTEngineImpl& xslp,
const DOMString&
namespaceUri) :
ExtensionFunctionHandler(namespaceUri),
m_XSLProcessor(xslp),
m_elements(),
m_componentDescLoaded(false)
{
}
/**
* Construct a new extension namespace handler given all the information
* needed.
*
* @param xslp handle to the XSL processor
that I'm working for
* @param namespaceUri the extension namespace URI that I'm implementing
* @param elemNames string containing list of elements of extension
NS
* @param funcNames string containing list of functions of
extension NS
* @param lang language of code implementing
the extension
* @param srcURL value of src attribute (if any) -
treated as a URL
*
or a classname depending on the value of lang. If
*
srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
ExtensionNSHandler::ExtensionNSHandler (
XSLTEngineImpl& xslp,
const DOMString& namespaceUri,
const DOMString& elemNames,
const DOMString& funcNames,
const DOMString& lang,
const DOMString& srcURL,
const DOMString& src) :
ExtensionFunctionHandler (namespaceUri, funcNames, lang,
srcURL, src),
m_XSLProcessor(xslp),
m_elements(),
m_componentDescLoaded(true)
{
setElements (elemNames);
}
/////////////////////////////////////////////////////////////////////////
// Main API
/////////////////////////////////////////////////////////////////////////
/*
* Set function local parts of extension NS. Super does the work; I
* just record that a component desc has been loaded.
*
* @param functions whitespace separated list of function names defined
* by this extension namespace.
*/
void ExtensionNSHandler::setFunctions (const DOMString& funcNames)
{
ExtensionFunctionHandler::setFunctions (funcNames);
m_componentDescLoaded = true;
}
/////////////////////////////////////////////////////////////////////////
/**
* Set the script data for this extension NS. Deferred to super for
* actual work - I only record that a component desc has been loaded.
*
* @param lang language of the script.
* @param srcURL value of src attribute (if any) - treated as a
URL
* or a
classname depending on the value of lang. If
* srcURL
is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
void ExtensionNSHandler::setScript (const DOMString& lang, const DOMString&
srcURL, const DOMString& scriptSrc)
{
ExtensionFunctionHandler::setScript (lang, srcURL, scriptSrc);
m_componentDescLoaded = true;
}
/////////////////////////////////////////////////////////////////////////
/**
* Set element local parts of extension NS.
*
* @param elemNames whitespace separated list of element names defined
* by this extension namespace.
*/
void ExtensionNSHandler::setElements (const DOMString& elemNames)
{
if (elemNames.length() == 0)
return;
StringTokenizer st(elemNames, " \t\n\r", false);
while (st.hasMoreTokens())
{
DOMString tok = st.nextToken();
m_elements.insert(tok); // just stick it in there basically
}
m_componentDescLoaded = true;
}
/////////////////////////////////////////////////////////////////////////
/**
* Tests whether a certain element name is known within this namespace.
* @param element name of the element being tested
* @return true if its known, false if not.
*/
bool ExtensionNSHandler::isElementAvailable (const DOMString& element)
{
return (m_elements.find(element) != m_elements.end());
}
/////////////////////////////////////////////////////////////////////////
/**
* Process a call to this extension namespace via an element. As a side
* effect, the results are sent to the XSLTProcessor's result tree.
*
* @param localPart Element name's local part.
* @param element The extension element being
processed.
* @param processor Handle to XSLTProcessor.
* @param stylesheetTree The compiled stylesheet tree.
* @param mode The current mode.
* @param sourceTree The root of the source tree (but don't assume
*
it's a Document).
* @param sourceNode The current context node.
*
* @exception XSLProcessorException thrown if something goes wrong
* while running the extension
handler.
* @exception MalformedURLException if loading trouble
* @exception FileNotFoundException if loading trouble
* @exception IOException if loading
trouble
* @exception SAXException if parsing
trouble
*/
void ExtensionNSHandler::processElement (
const DOMString& localPart,
const DOM_Element& element,
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
XObject* result = 0;
if (!m_componentStarted)
{
try
{
startupComponent();
ExtensionFunctionHandler::ArgVector argv;
XSLProcessorContext xpc(processor,
stylesheetTree, sourceTree, sourceNode,
mode);
/*
java:
Vector argv = new Vector (2);
argv.addElement (xpc);
argv.addElement (element);
*/
// $$$ ToDo: There's no way this will ever
work...
// argv.push_back(static_cast<void *>(&xpc));
// argv.push_back(static_cast<void *>(&element));
result = ExtensionFunctionHandler::callFunction
(localPart, argv);
}
// catch (XPathProcessorException e)
catch (...)
{
/*
e.printStackTrace ();
throw new XSLProcessorException (e.getMessage
(), e);
*/
//@@ TODO: Error reporting, or throw
}
}
if (result != 0)
{
processor.outputToResultTree (stylesheetTree, result);
}
}
/////////////////////////////////////////////////////////////////////////
// Private/Protected Functions
/////////////////////////////////////////////////////////////////////////
/**
* Start the component up by executing any script that needs to run
* at startup time. This needs to happen before any functions can be
* called on the component.
*
* @exception XPathProcessorException if something bad happens.
*/
void ExtensionNSHandler::startupComponent()
{
if (!m_componentDescLoaded)
{
try
{
loadComponentDescription ();
}
catch (...)
// catch (Exception e)
{
// throw new XPathProcessorException (e.getMessage (),
e);
//@@ TODO: Error reporting, or throw
}
}
ExtensionFunctionHandler::startupComponent ();
}
/////////////////////////////////////////////////////////////////////////
/**
* Load the component spec for this extension namespace taking the URI
* of this namespace as the URL to read from.
*
* @exception XSLProcessorException if something bad happens.
* @exception MalformedURLException if loading trouble
* @exception FileNotFoundException if loading trouble
* @exception IOException if loading
trouble
* @exception SAXException if parsing
trouble
*/
void ExtensionNSHandler::loadComponentDescription ()
{
// First try treaing the URI of the extension as a fully qualified
// class name; if it works then go with treating this an extension
// implemented in "javaclass" for with that class being the srcURL.
// forget about setting elements and functions in that case - so if
// u do extension-{element,function}-available then u get false,
// but that's ok.
assert(0); // Don't try this in C++
// @@ How to do this in C++ ??
/*
try {
String cname = namespaceUri.startsWith ("class:") ?
namespaceUri.substring (6) : namespaceUri;
Class.forName (cname); // does it load?
setScript ("javaclass", namespaceUri, null);
m_componentDescLoaded = true;
return;
} catch (Exception e) {
// oops, it failed .. ok, so this path ain't gonna pan out.
shucks.
}
// parse the document at the URI of the extension, if any
URL url = m_XSLProcessor.getURLFromString(namespaceUri,
m_XSLProcessor.m_stylesheetRoot.m_baseIdent);
m_XSLProcessor.m_parserLiaison.parse(new InputSource(url.toString()));
Document compSpec = m_XSLProcessor.m_parserLiaison.getDocument();
Element componentElement = compSpec.getDocumentElement ();
// determine the functions and elements of this component
setElements (componentElement.getAttribute ("elements"));
setFunctions (componentElement.getAttribute ("functions"));
// is there an lxslt:script element child? [NOTE THAT THIS IS NOT
// PROPER NAMESPACE-WISE .. I'll FIX IT LATER. .. Sanjiva 8/20/99.]
NodeList nl = componentElement.getElementsByTagName ("lxslt:script");
switch (nl.getLength ())
{
case 0:
break;
case 1:
Element scriptElem = (Element) nl.item (0);
String lang = scriptElem.getAttribute ("lang");
Attr srcURLAttr = scriptElem.getAttributeNode ("src");
String srcURL = (srcURLAttr == null) ? null :
srcURLAttr.getValue ();
String src = getScriptString (scriptElem);
setScript (lang, srcURL, src);
break;
default:
throw new XSLProcessorException ("too many <script>s in
component");
}
m_componentDescLoaded = true;
*/
}
/////////////////////////////////////////////////////////////////////////
/**
* extract the text nodes and CDATA content children of the given
* elem and return as a string. Any other types of node children
* are ignored
*
* @param elem element whose text and cdata children are to be
* concatenated together.
*
* @return string resulting from concatanating the text/cdata child
* nodes' values.
*/
DOMString ExtensionNSHandler::getScriptString (const DOM_Element& elem)
{
DOMString strBuf;
for (DOM_Node n = elem.getFirstChild (); n != 0; n = n.getNextSibling
())
{
switch (n.getNodeType())
{
case DOM_Node::TEXT_NODE:
case DOM_Node::CDATA_SECTION_NODE:
strBuf += n.getNodeValue();
break;
default:
break;
}
}
return strBuf;
}
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/ExtensionNSHandler.hpp
Index: ExtensionNSHandler.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_EXTENSIONNSHANDLER_HEADER_GUARD)
#define XALAN_EXTENSIONNSHANDLER_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class
#include "ExtensionFunctionHandler.hpp"
#include "Stylesheet.hpp"
#include <dom/DOMString.hpp>
#include <dom/DOM_Element.hpp>
#include <set>
class XSLTEngineImpl;
class XALAN_XSLT_EXPORT ExtensionNSHandler : public ExtensionFunctionHandler
{
private:
XSLTProcessor& m_XSLProcessor; // xsl processor for whom I'm working
// Extension elements of this namespace
typedef std::set<DOMString> ExtensionSetType;
ExtensionSetType m_elements;
// True when info from the component description has been loaded. This
gets
// set as soon as any of the info has been specified. If this is false,
// when processElement or processFunction is called it will use the
// namespace URI as a URL and try to load that location as the component
// description
bool m_componentDescLoaded;
public:
/**
* Construct a new extension namespace handler for a given extension NS.
* This doesn't do anything - just hang on to the namespace URI.
*
* @param xslp handle to the XSL processor
that I'm working for
* @param namespaceUri the extension namespace URI that I'm implementing
*/
ExtensionNSHandler(XSLTEngineImpl& xslp, const DOMString& namespaceUri);
/**
* Construct a new extension namespace handler given all the information
* needed.
*
* @param xslp handle to the XSL processor
that I'm working for
* @param namespaceUri the extension namespace URI that I'm implementing
* @param elemNames string containing list of elements of
extension NS
* @param funcNames string containing list of functions of
extension NS
* @param lang language of code implementing
the extension
* @param srcURL value of src attribute (if
any) - treated as a URL
*
or a classname depending on the value of lang. If
*
srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
ExtensionNSHandler (
XSLTEngineImpl& xslp,
const DOMString& namespaceUri,
const DOMString& elemNames,
const DOMString& funcNames,
const DOMString& lang,
const DOMString& srcURL,
const DOMString& src);
/////////////////////////////////////////////////////////////////////////
// Main API
/////////////////////////////////////////////////////////////////////////
/*
* Set function local parts of extension NS. Super does the work; I
* just record that a component desc has been loaded.
*
* @param functions whitespace separated list of function names defined
* by this extension namespace.
*/
virtual void setFunctions (const DOMString& funcNames);
/////////////////////////////////////////////////////////////////////////
/**
* Set the script data for this extension NS. Deferred to super for
* actual work - I only record that a component desc has been loaded.
*
* @param lang language of the script.
* @param srcURL value of src attribute (if any) -
treated as a URL
*
or a classname depending on the value of lang. If
*
srcURL is not null, then scriptSrc is ignored.
* @param scriptSrc the actual script code (if any)
*/
virtual void setScript(const DOMString& lang, const DOMString& srcURL,
const DOMString& scriptSrc);
/////////////////////////////////////////////////////////////////////////
/**
* Set element local parts of extension NS.
*
* @param elemNames whitespace separated list of element names defined
* by this extension namespace.
*/
void setElements (const DOMString& elemNames);
/////////////////////////////////////////////////////////////////////////
/**
* Tests whether a certain element name is known within this namespace.
* @param element name of the element being tested
* @return true if its known, false if not.
*/
bool isElementAvailable (const DOMString& element);
/////////////////////////////////////////////////////////////////////////
/**
* Process a call to this extension namespace via an element. As a side
* effect, the results are sent to the XSLTProcessor's result tree.
*
* @param localPart Element name's local part.
* @param element The extension element
being processed.
* @param processor Handle to XSLTProcessor.
* @param stylesheetTree The compiled stylesheet tree.
* @param mode The current mode.
* @param sourceTree The root of the source tree (but don't
assume
*
it's a Document).
* @param sourceNode The current context node.
*
* @exception XSLProcessorException thrown if something goes wrong
* while running the
extension handler.
* @exception MalformedURLException if loading trouble
* @exception FileNotFoundException if loading trouble
* @exception IOException if
loading trouble
* @exception SAXException if
parsing trouble
*/
void processElement (
const DOMString& localPart,
const DOM_Element& element,
XSLTEngineImpl& processor,
Stylesheet& stylesheetTree,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/////////////////////////////////////////////////////////////////////////
// Private/Protected Functions
/////////////////////////////////////////////////////////////////////////
/**
* Start the component up by executing any script that needs to run
* at startup time. This needs to happen before any functions can be
* called on the component.
*
* @exception XPathProcessorException if something bad happens.
*/
protected:
virtual void startupComponent(); //throws
XPathProcessorException;
/////////////////////////////////////////////////////////////////////////
/**
* Load the component spec for this extension namespace taking the URI
* of this namespace as the URL to read from.
*
* @exception XSLProcessorException if something bad happens.
* @exception MalformedURLException if loading trouble
* @exception FileNotFoundException if loading trouble
* @exception IOException if
loading trouble
* @exception SAXException if
parsing trouble
*/
private:
void loadComponentDescription ();
/////////////////////////////////////////////////////////////////////////
/**
* extract the text nodes and CDATA content children of the given
* elem and return as a string. Any other types of node children
* are ignored
*
* @param elem element whose text and cdata children are to be
* concatenated together.
*
* @return string resulting from concatanating the text/cdata child
* nodes' values.
*/
DOMString getScriptString (const DOM_Element& elem);
}; // end ExtensionNSHandler class definition
#endif // XALAN_EXTENSIONNSHANDLER_HEADER_GUARD
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/FunctionCurrent.cpp
Index: FunctionCurrent.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FunctionCurrent.hpp"
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
FunctionCurrent::FunctionCurrent()
{
}
FunctionCurrent::~FunctionCurrent()
{
}
XObject*
FunctionCurrent::execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 0)
{
executionContext.error("The current() function does not take
any arguments!",
context);
return 0;
}
else if (context == 0)
{
executionContext.error("The current() function is not allowed
in patterns!",
context);
return 0;
}
else
{
return
executionContext.getXObjectFactory().createNodeSet(context);
}
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionCurrent*
#endif
FunctionCurrent::clone() const
{
return new FunctionCurrent(*this);
}
1.1 xml-xalan/c/src/XSLT/FunctionCurrent.hpp
Index: FunctionCurrent.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONCURRENT_HEADER_GUARD_1357924680)
#define FUNCTIONCURRENT_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <set>
#include <vector>
#include <XPath/Function.hpp>
class DOM_Node;
class XObject;
class XPathExecutionContext;
// Implements the XSLT current() function.
//
class XALAN_XSLT_EXPORT FunctionCurrent : public Function
{
public:
FunctionCurrent();
virtual
~FunctionCurrent();
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param executionContext The executing context.
* @param context The current context node.
* @param opPos The current op position.
* @param args A vector of pointers to XObject arguments.
* @return A pointer to the result XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionCurrent*
#endif
clone() const;
private:
// Not implemented...
FunctionCurrent&
operator=(const FunctionCurrent&);
bool
operator==(const FunctionCurrent&) const;
};
#endif // FUNCTIONCURRENT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/FunctionDoclocation.cpp
Index: FunctionDoclocation.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XSLT/FunctionDocLocation.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
// XPath FunctionDocLocation implementation.
//
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
XObject*
FunctionDocLocation::execute(
XPathExecutionContext& executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
DOM_Node whereNode;
if(args.size() > 0)
{
XObject* firstArg = args[0];
const NodeRefListBase& nl = firstArg->nodeset();
if(nl.getLength() > 0)
{
whereNode = nl.item(0);
}
else
{
whereNode = 0;
}
}
else
{
whereNode = context;
}
DOMString fileLocation;
if(whereNode != 0)
{
if(DOM_Node::DOCUMENT_FRAGMENT_NODE == whereNode.getNodeType())
{
whereNode = whereNode.getFirstChild();
}
if(whereNode != 0)
{
DOM_Document owner = whereNode.getOwnerDocument();
// java:: fileLocation =
executionContext.m_callbacks.findURIFromDoc(owner);
// @@ JMD: we don't got no steenking callbacks
assert(0);
}
}
// java: return new XString((!isEmpty(fileLocation)) ? fileLocation : "",
path.m_callbacks);
// @@ JMD: we don't got no steenking callbacks
// if (isEmpty(fileLocation)) fileLocation = path.m_callbacks;
return executionContext.getXObjectFactory().createString(fileLocation);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionDocLocation*
#endif
FunctionDocLocation::clone() const
{
return new FunctionDocLocation(*this);
}
1.1 xml-xalan/c/src/XSLT/FunctionDoclocation.hpp
Index: FunctionDoclocation.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONDOCLOCATION_HEADER_GUARD_1357924680)
#define FUNCTIONDOCLOCATION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
#include <PlatformSupport/DOMStringHelper.hpp>
// Base class header file...
#include <XPath/Function.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Node.hpp>
// XPath FunctionDocLocation implementation.
//
class XALAN_XSLT_EXPORT FunctionDocLocation : public Function
{
public:
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionDocLocation*
#endif
clone() const;
private:
// Not implemented...
FunctionDocLocation&
operator=(const FunctionDocLocation&);
bool
operator==(const FunctionDocLocation&) const;
};
#endif // FUNCTIONDOCLOCATION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/FunctionFormatNumber.cpp
Index: FunctionFormatNumber.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FunctionFormatNumber.hpp"
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
FunctionFormatNumber::FunctionFormatNumber()
{
}
FunctionFormatNumber::~FunctionFormatNumber()
{
}
XObject*
FunctionFormatNumber::execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
const std::vector<XObject*>::size_type theSize =
args.size();
if (theSize < 2 || theSize > 3)
{
executionContext.error("The format-number() function takes two
or three arguments!",
context);
return 0;
}
else
{
executionContext.warn("format-number() is not fully
implemented!",
context);
assert(args[0] != 0);
assert(args[1] != 0);
assert(theSize == 2 || args[2] != 0);
const double theNumber = args[0]->num();
const DOMString theFormatString = args[1]->str();
const DOMString theDecimalFormat = theSize == 3 ?
args[2]->str() : DOMString();
// $$$ ToDo: This is not really working according to the spec.
return
executionContext.getXObjectFactory().createString(DoubleToDOMString(theNumber));
}
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionFormatNumber*
#endif
FunctionFormatNumber::clone() const
{
return new FunctionFormatNumber(*this);
}
1.1 xml-xalan/c/src/XSLT/FunctionFormatNumber.hpp
Index: FunctionFormatNumber.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONFORMATNUMBER_HEADER_GUARD_1357924680)
#define FUNCTIONFORMATNUMBER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
#include <XPath/Function.hpp>
class DOM_Node;
class XObject;
class XPathExecutionContext;
// Class that implements the XSLT function format-number.
//
class XALAN_XSLT_EXPORT FunctionFormatNumber : public Function
{
public:
FunctionFormatNumber();
virtual
~FunctionFormatNumber();
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param executionContext The executing context.
* @param context The current context node.
* @param opPos The current op position.
* @param args A vector of pointers to XObject arguments.
* @return A pointer to the result XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
opPos,
const std::vector<XObject*>& args);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionFormatNumber*
#endif
clone() const;
private:
// Not implemented...
FunctionFormatNumber&
operator=(const FunctionFormatNumber&);
bool
operator==(const FunctionFormatNumber&) const;
};
#endif // FUNCTIONFORMATNUMBER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/FunctionGenerateID.cpp
Index: FunctionGenerateID.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FunctionGenerateID.hpp"
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOMString.hpp>
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
FunctionGenerateID::FunctionGenerateID()
{
// do nothing
}
FunctionGenerateID::~FunctionGenerateID()
{
// do nothing
}
XObject* FunctionGenerateID::execute(
XPathExecutionContext& executionContext,
const DOM_Node& context,
int /* opPos */,
const std::vector<XObject*>& args)
{
DOM_Node theContext = context;
if (args.size() > 0)
{
const NodeRefListBase& nl = args[0]->nodeset();
if (nl.getLength() > 0)
theContext = nl.item(0);
else
theContext = DOM_Node();
}
// We're assuming here that each nodes has an implementation with a
// unique address that we can convert into a string
DOMString id;
if (0 != theContext)
{
XALAN_DOM_NodeHack hack(theContext);
NodeImpl *impl = hack.getImplementationObject();
id = "N" + LongToDOMString(reinterpret_cast<long>(impl));
}
return executionContext.getXObjectFactory().createString(id);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionGenerateID*
#endif
FunctionGenerateID::clone() const
{
return new FunctionGenerateID(*this);
}
1.1 xml-xalan/c/src/XSLT/FunctionGenerateID.hpp
Index: FunctionGenerateID.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONGENERATEID_HEADER_GUARD_1357924680)
#define FUNCTIONGENERATEID_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
#include <XPath/Function.hpp>
class DOM_Node;
class XObject;
class XPathExecutionContext;
// Implementation of the XSLT function generate-id().
//
class XALAN_XSLT_EXPORT FunctionGenerateID : public Function
{
public:
FunctionGenerateID();
virtual ~FunctionGenerateID();
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param executionContext The executing context.
* @param context The current context node.
* @param opPos The current op position.
* @param args A vector of pointers to XObject arguments.
* @return A pointer to the result XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionGenerateID*
#endif
clone() const;
private:
// Not implemented...
FunctionGenerateID& operator=(const FunctionGenerateID&);
bool operator==(const FunctionGenerateID&) const;
};
#endif // FUNCTIONGENERATEID_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/FunctionKey.cpp
Index: FunctionKey.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FunctionKey.hpp"
#include <set>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOMString.hpp>
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
FunctionKey::FunctionKey()
{
}
FunctionKey::~FunctionKey()
{
}
XObject*
FunctionKey::execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 2)
{
executionContext.error("The key() function takes two
arguments!",
context);
return 0;
}
else
{
DOM_Document docContext =
DOM_Node::DOCUMENT_NODE ==
context.getNodeType() ?
static_cast<const
DOM_Document&>(context) :
context.getOwnerDocument();
if(0 == docContext)
{
executionContext.error("Context does not have an owner
document!",
context);
}
const DOMString keyname = args[0]->str();
const XObject* const arg = args[1];
assert(arg != 0);
const bool argIsNodeSet =
XObject::eTypeNodeSet == arg->getType() ? true
: false;
MutableNodeRefList theNodeRefList =
executionContext.createMutableNodeRefList();
if(argIsNodeSet == true)
{
const NodeRefListBase& theNodeSet = arg->nodeset();
const int nRefs =
theNodeSet.getLength();
if (nRefs > 0)
{
std::set<DOMString> usedrefs;
const PrefixResolver& thePrefixResolver =
executionContext.getPrefixResolver();
for(int i = 0; i < nRefs; i++)
{
const DOMString ref =
executionContext.getNodeData(theNodeSet.item(i));
if(0 != length(ref))
{
// Make sure we haven't already
processed it...
if(usedrefs.find(ref) ==
usedrefs.end())
{
usedrefs.insert(ref);
const NodeRefListBase*
const nl =
executionContext.getNodeSetByKey(docContext,
keyname,
ref,
thePrefixResolver);
if (nl != 0)
{
theNodeRefList.addNodesInDocOrder(*nl);
}
}
}
}
}
}
else
{
const DOMString ref = arg->str();
const NodeRefListBase* const nl =
executionContext.getNodeSetByKey(docContext,
keyname,
ref,
executionContext.getPrefixResolver());
if (nl != 0)
{
theNodeRefList.addNodesInDocOrder(*nl);
}
}
return
executionContext.getXObjectFactory().createNodeSet(theNodeRefList);
}
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionKey*
#endif
FunctionKey::clone() const
{
return new FunctionKey(*this);
}
1.1 xml-xalan/c/src/XSLT/FunctionKey.hpp
Index: FunctionKey.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONKEY_HEADER_GUARD_1357924680)
#define FUNCTIONKEY_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
#include <XPath/Function.hpp>
class DOM_Node;
class XObject;
class XPathExecutionContext;
// Implementation of the XSLT function key().
//
class XALAN_XSLT_EXPORT FunctionKey : public Function
{
public:
FunctionKey();
virtual
~FunctionKey();
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param executionContext The executing context.
* @param context The current context node.
* @param opPos The current op position.
* @param args A vector of pointers to XObject arguments.
* @return A pointer to the result XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionKey*
#endif
clone() const;
private:
// Not implemented...
FunctionKey&
operator=(const FunctionKey&);
bool
operator==(const FunctionKey&) const;
};
#endif // FUNCTIONKEY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/FunctionSystemProperty.cpp
Index: FunctionSystemProperty.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FunctionSystemProperty.hpp"
#include <set>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOMString.hpp>
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NodeRefListBase.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
FunctionSystemProperty::FunctionSystemProperty()
{
// do nothing
}
FunctionSystemProperty::~FunctionSystemProperty()
{
// do nothing
}
XObject* FunctionSystemProperty::execute(
XPathExecutionContext& executionContext,
const DOM_Node& context,
int /* opPos */,
const std::vector<XObject*>& args)
{
if (args.size() != 1)
{
executionContext.error("The system-property() function takes a
single argument!", context);
return 0;
}
const DOMString fullName = args[0]->str();
const int indexOfNSSep = indexOf(fullName,':');
DOMString result;
if(indexOfNSSep > 0)
{
const DOMString prefix = (indexOfNSSep >= 0) ?
substring(fullName, 0, indexOfNSSep) : DOMString();
//to do:
// const DOMString nspace =
executionContext.getNamespaceForPrefix(prefix);
DOMString nspace = "http://www.w3.org/1999/XSL/Transform";
const DOMString propName = (indexOfNSSep < 0) ? fullName
: substring(fullName,indexOfNSSep+1);
if(startsWith(nspace,"http://www.w3.org/1999/XSL/Transform"))
{
if(equals(propName, "version"))
{
result = "1.0";
}
else if(equals(propName, "vendor"))
{
result = "xml.apache.org";
}
else if(equals(propName, "vendor-url"))
{
result = "http://xml.apache.org/xslt";
}
else
{
executionContext.warn("XSL Property not
supported: "+fullName);
}
}
else
{
executionContext.warn("Don't currently do anything with
namespace " + nspace + " in property: " + fullName);
result =
::getenv(DOMStringToStdString(propName).c_str());
}
}
else
{
result = ::getenv(DOMStringToStdString(fullName).c_str());
}
return executionContext.getXObjectFactory().createString(result);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionSystemProperty*
#endif
FunctionSystemProperty::clone() const
{
return new FunctionSystemProperty(*this);
}
1.1 xml-xalan/c/src/XSLT/FunctionSystemProperty.hpp
Index: FunctionSystemProperty.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONSYSTEMPROPERTY_HEADER_GUARD_1357924680)
#define FUNCTIONSYSTEMPROPERTY_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
#include <XPath/Function.hpp>
class DOM_Node;
class XObject;
class XPathExecutionContext;
// Implementation of the XSLT function sytsem-property().
//
class XALAN_XSLT_EXPORT FunctionSystemProperty : public Function
{
public:
FunctionSystemProperty();
virtual
~FunctionSystemProperty();
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param executionContext The executing context.
* @param context The current context node.
* @param opPos The current op position.
* @param args A vector of pointers to XObject arguments.
* @return A pointer to the result XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionKey*
#endif
clone() const;
private:
// Not implemented...
FunctionSystemProperty&
operator=(const FunctionSystemProperty&);
bool
operator==(const FunctionSystemProperty&) const;
};
#endif // FUNCTIONSYSTEMPROPERTY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/FunctionUnparsedEntityURI.cpp
Index: FunctionUnparsedEntityURI.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "FunctionUnparsedEntityURI.hpp"
#include <XPath/XObject.hpp>
#include <XPath/XObjectFactory.hpp>
#include <XPath/XPathExecutionContext.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Node.hpp>
FunctionUnparsedEntityURI::FunctionUnparsedEntityURI()
{
}
FunctionUnparsedEntityURI::~FunctionUnparsedEntityURI()
{
}
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
XObject*
FunctionUnparsedEntityURI::execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args)
{
if(args.size() != 1)
{
executionContext.error("The unparsed-entity-uri function should
take one argument!");
}
DOMString name = (args.at(0))->str();
DOM_Document doc =
(DOM_Node::DOCUMENT_NODE == context.getNodeType()) ?
static_cast<const DOM_Document&>(context) :
context.getOwnerDocument();
DOMString uri = executionContext.getUnparsedEntityURI(name, doc);
return executionContext.getXObjectFactory().createString(uri);
}
1.1 xml-xalan/c/src/XSLT/FunctionUnparsedEntityURI.hpp
Index: FunctionUnparsedEntityURI.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(FUNCTIONUNPARSEDENTITYURI_HEADER_GUARD_1357924680)
#define FUNCTIONUNPARSEDENTITYURI_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <vector>
// Base class header file...
#include <XPath/Function.hpp>
// XPath FunctionUnparsedEntityURI implementation.
//
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
class XALAN_XSLT_EXPORT FunctionUnparsedEntityURI : public Function
{
public:
FunctionUnparsedEntityURI();
virtual
~FunctionUnparsedEntityURI();
/**
* Execute an XPath function object. The function must return
* a valid object.
* @param path The executing xpath.
* @param context The current context.
* @param opPos The current op position.
* @param args A list of XObject arguments.
* @return A valid XObject.
*/
virtual XObject*
execute(
XPathExecutionContext&
executionContext,
const DOM_Node& context,
int
/* opPos */,
const std::vector<XObject*>& args);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionUnparsedEntityURI*
#endif
clone() const
{
return new FunctionUnparsedEntityURI(*this);
}
private:
// Not implemented...
FunctionUnparsedEntityURI&
operator=(const FunctionUnparsedEntityURI&);
bool
operator==(const FunctionUnparsedEntityURI&) const;
};
#endif // FUNCTIONUNPARSEDENTITYURI_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/GenerateEvent.cpp
Index: GenerateEvent.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "GenerateEvent.hpp"
/**
* Constructor for startDocument, endDocument events.
*
* @param processor The XSLT Processor instance.
* @param eventType One of the EVENTTYPE_XXX constants.
*/
GenerateEvent::GenerateEvent(XSLTEngineImpl* processor, EventType eventType)
: m_pProcessor(processor),
m_eventType(eventType), m_start(0), m_length(0), m_pAtts(0)
{
}
/**
* Constructor for startElement, endElement events.
*
* @param processor The XSLT Processor Instance.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param name The name of the element.
* @param atts The SAX attribute list.
*/
GenerateEvent::GenerateEvent(XSLTEngineImpl* processor, EventType eventType,
DOMString name, AttributeList* atts):
m_name(name), m_pAtts(atts), m_pProcessor(processor),
m_eventType(eventType), m_start(0), m_length(0)
{
}
/**
* Constructor for characters, cdate events.
*
* @param processor The XSLT Processor instance.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param ch The char array from the SAX event.
* @param start The start offset to be used in the char array.
* @param length The end offset to be used in the chara array.
*/
GenerateEvent::GenerateEvent(XSLTEngineImpl* processor, EventType eventType,
DOMString ch, int start, int length) :
m_characters(ch), m_start(start), m_length(length),
m_pProcessor(processor), m_eventType(eventType), m_pAtts(0)
{
}
/**
* Constructor for processingInstruction events.
*
* @param processor The instance of the XSLT processor.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param name The name of the processing instruction.
* @param data The processing instruction data.
*/
GenerateEvent::GenerateEvent(XSLTEngineImpl* processor, EventType eventType,
DOMString name, DOMString data):
m_name(name), m_data(data), m_pProcessor(processor),
m_eventType(eventType)
{
}
/**
* Constructor for comment and entity ref events.
*
* @param processor The XSLT processor instance.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param data The comment or entity ref data.
*/
GenerateEvent::GenerateEvent(XSLTEngineImpl* processor, EventType eventType,
DOMString data):
m_data(data), m_pProcessor(processor), m_eventType(eventType)
{
}
1.1 xml-xalan/c/src/XSLT/GenerateEvent.hpp
Index: GenerateEvent.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_GenerateEvent_HEADER_GUARD)
#define XALAN_GenerateEvent_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
class XSLTEngineImpl;
class AttributeList;
/**
* This is the class for events generated by the XSL processor
* after it generates a new node in the result tree. It responds
* to, and so is modeled from, the SAX events that are sent to the
* FormatterListener classes.
*
* @see org.apache.xml.xpath4j.xml.FormatterListener
*/
class GenerateEvent
{
public:
enum EventType
{
/**
* Event type generated when a document begins.
*
*/
EVENTTYPE_STARTDOCUMENT = 1,
/**
* Event type generated when a document ends.
*/
EVENTTYPE_ENDDOCUMENT = 2,
/**
* Event type generated when an element begins (after the
attributes have been processed but before the children have been added).
*/
EVENTTYPE_STARTELEMENT = 3,
/**
* Event type generated when an element ends, after it's
children have been added.
*/
EVENTTYPE_ENDELEMENT = 4,
/**
* Event type generated for character data (CDATA and Ignorable
Whitespace have their own events).
*/
EVENTTYPE_CHARACTERS = 5,
/**
* Event type generated for ignorable whitespace (I'm not sure
how much this is actually called.
*/
EVENTTYPE_IGNORABLEWHITESPACE = 6,
/**
* Event type generated for processing instructions.
*/
EVENTTYPE_PI = 7,
/**
* Event type generated after a comment has been added.
*/
EVENTTYPE_COMMENT = 8,
/**
* Event type generate after an entity ref is created.
*/
EVENTTYPE_ENTITYREF = 9,
/**
* Event type generated after CDATA is generated.
*/
EVENTTYPE_CDATA = 10
};
/**
* Constructor for startDocument, endDocument events.
*
* @param processor The XSLT Processor instance.
* @param eventType One of the EVENTTYPE_XXX constants.
*/
GenerateEvent(XSLTEngineImpl* processor, EventType eventType);
/**
* Constructor for startElement, endElement events.
*
* @param processor The XSLT Processor Instance.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param name The name of the element.
* @param atts The SAX attribute list.
*/
GenerateEvent(XSLTEngineImpl* processor, EventType eventType, DOMString
name, AttributeList* atts);
/**
* Constructor for characters, cdate events.
*
* @param processor The XSLT Processor instance.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param ch The char array from the SAX event.
* @param start The start offset to be used in the char array.
* @param length The end offset to be used in the chara array.
*/
GenerateEvent(XSLTEngineImpl* processor, EventType eventType, DOMString
ch, int start, int length);
/**
* Constructor for processingInstruction events.
*
* @param processor The instance of the XSLT processor.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param name The name of the processing instruction.
* @param data The processing instruction data.
*/
GenerateEvent(XSLTEngineImpl* processor, EventType eventType, DOMString
name, DOMString data);
/**
* Constructor for comment and entity ref events.
*
* @param processor The XSLT processor instance.
* @param eventType One of the EVENTTYPE_XXX constants.
* @param data The comment or entity ref data.
*/
GenerateEvent(XSLTEngineImpl* processor, EventType eventType, DOMString
data);
/**
* The type of SAX event that was generated, as enumerated in the
EVENTTYPE_XXX constants above.
*/
EventType m_eventType;
/**
* Character data from a character or cdata event.
*/
DOMString m_characters;
/**
* The start position of the current data in m_characters.
*/
int m_start;
/**
* The length of the current data in m_characters.
*/
int m_length;
/**
* The name of the element or PI.
*/
DOMString m_name;
/**
* The string data in the element (comments and PIs).
*/
DOMString m_data;
/**
* The current attribute list.
*/
AttributeList* m_pAtts;
private:
/**
* The XSLT Processor, which either directly or indirectly contains most
needed information. Accessing the m_stylesheetRoot member variable will get
you to the stylesheet information.
*
* @see org.apache.xml.xslt4j.XSLTEngineImpl,
org.apache.xml.xslt4j.StylesheetRoot,
* org.apache.xml.xslt4j.Stylesheet
*/
XSLTEngineImpl* m_pProcessor;
// not implemented
GenerateEvent& operator=(const GenerateEvent &);
};
#endif //XALAN_GenerateEvent_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/Java2STL.hpp
Index: Java2STL.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_JAVA2STL_HEADER_GUARD)
#define XALAN_JAVA2STL_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <map>
#include <vector>
/**
* Helper classes to mimic Java syntax
*/
template <class Val> class Stack : public std::vector<Val>
{
public:
void push(const Val v) { push_back(v); }
Val pop()
{
Val v = back();
pop_back();
return v;
}
};
template <class Key, class Val> class XALAN_hashtable :
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
public hash_map<Key, Val, HashFunction<Key> > MapType;
#else
public std::map<Key, Val>
#endif
{
public:
void put(const Key k, const Val v)
{
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
assert(0); // @@ Need to do something here
#else
insert (std::pair<Key, Val> (k, v));
#endif
}
};
#endif // XALAN_JAVA2STL_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/KeyDeclaration.hpp
Index: KeyDeclaration.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_KEYDECLARATION_HEADER_GUARD)
#define XALAN_KEYDECLARATION_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
class XPath;
/**
* Holds the attribute declarations for the xsl:keys element.
*/
class KeyDeclaration
{
public:
KeyDeclaration(
const DOMString& name,
XPath& matchPattern,
XPath& use) :
m_name(name),
m_match(&matchPattern),
m_use(&use)
{
}
const DOMString&
getName() const
{
return m_name;
}
XPath&
getUse() const
{
return *m_use;
}
XPath&
getMatchPattern() const
{
return *m_match;
}
private:
DOMString m_name;
XPath* m_match;
XPath* m_use;
};
#endif // XALAN_KEYDECLARATION_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/KeyTable.cpp
Index: KeyTable.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "KeyTable.hpp"
#include <memory>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOM_NodeList.hpp>
#include <Include/DOMHelper.hpp>
#include <XPath/XPath.hpp>
#include <XPath/XPathSupport.hpp>
#include "KeyDeclaration.hpp"
KeyTable::KeyTable(
const DOM_Node&
doc,
const DOM_Node&
startNode,
const PrefixResolver&
resolver,
const std::vector<KeyDeclaration>&
keyDeclarations,
XPathSupport&
xpathSupport) :
m_docKey(doc),
m_keys()
{
DOM_Node pos = startNode;
// Do a non-recursive pre-walk over the tree.
while(0 != pos)
{
const int nDeclarations = keyDeclarations.size();
// We're going to have to walk the attribute list
// if it's an element, so get the attributes.
DOM_NamedNodeMap attrs;
int nNodes = 0;
if(DOM_Node::ELEMENT_NODE == pos.getNodeType())
{
attrs = static_cast<const
DOM_Element&>(pos).getAttributes();
nNodes = attrs.getLength();
if(0 == nNodes)
{
attrs = 0;
}
}
// Walk the primary node, and each of the attributes.
// This loop is a little strange... it is meant to always
// execute once, then execute for each of the attributes.
DOM_Node testNode = pos;
for(int nodeIndex = -1; nodeIndex < nNodes;)
{
// Walk through each of the declarations made with
xsl:key
for(int i = 0; i < nDeclarations; i++)
{
const KeyDeclaration& kd = keyDeclarations[i];
// See if our node matches the given key
declaration according to
// the match attribute on xsl:key.
const double score =
kd.getMatchPattern().getMatchScore(testNode);
if(score !=
kd.getMatchPattern().s_MatchScoreNone)
{
// Query from the node, according the
the select pattern in the
// use attribute in xsl:key.
const XObject* const xuse =
// @@ JMD: is this kosher
kd.getUse().execute(testNode,
resolver, NodeRefList());
const NodeRefListBase& nl =
xuse->nodeset();
const int
nUseValues = nl.getLength();
if(0 != nUseValues)
{
// Use each node in the node
list as a key value that we'll be
// able to use to look up the
given node.
for(int k = 0; k < nUseValues;
k++)
{
DOM_Node useNode
= nl.item(k);
// Use getExpr to get
the string value of the given node. I hope
// the string
assumption is the right thing... I can't see how
// it could work any
other way.
const DOMString
exprResult = xpathSupport.getNodeData(useNode);
if(length(exprResult)
!= 0)
{
MutableNodeRefList& keyNodes =
m_keys[kd.getName()][exprResult];
// See if the
matched node is already in the
// table set.
If it is there, we're done, otherwise
// add it.
bool foundit =
false;
const int
nKeyNodes = keyNodes.getLength(); //size();
for(int j = 0;
j < nKeyNodes; j++)
{
if(testNode == keyNodes.item(j))
{
foundit = true;
break;
}
} // end for j
if(foundit ==
false)
{
keyNodes.addNode(testNode);
}
}
} // end for(int k = 0; k <
nUseValues; k++)
} // if(0 != nUseValues)
} // if(score !=
kd.getMatchPattern().s_MatchScoreNone)
} // end for(int i = 0; i < nDeclarations; i++)
nodeIndex++;
if(0 != attrs)
{
testNode = attrs.item(nodeIndex);
}
} // for(int nodeIndex = -1; nodeIndex < nNodes;)
// The rest of this is getting the next prewalk position in
// the tree.
DOM_Node nextNode = pos.getFirstChild();
while(0 == nextNode)
{
if(startNode == pos)
{
break;
}
else
{
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
pos = pos.getParentNode();
if((startNode == pos) || (0 == pos))
{
nextNode = 0;
break;
}
}
}
}
pos = nextNode;
} // while(0 != pos)
} // end buildKeysTable method
KeyTable::~KeyTable()
{
}
const NodeRefListBase*
KeyTable::getNodeSetByKey(
const DOMString& name,
const DOMString& ref) const
{
const MutableNodeRefList* nl =0;
KeysMapType::const_iterator i = m_keys.find(name);
if (i != m_keys.end())
{
const NodeListMapType& theMap =
(*i).second;
NodeListMapType::const_iterator j = theMap.find(ref);
if (j != theMap.end())
{
nl = &(*j).second;
}
}
return nl;
}
1.1 xml-xalan/c/src/XSLT/KeyTable.hpp
Index: KeyTable.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_KEYTABLE_HEADER_GUARD)
#define XALAN_KEYTABLE_HEADER_GUARD
/**
* $Id: KeyTable.hpp,v 1.1 1999/12/18 19:48:04 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
#include <hash_map>
#else
#include <map>
#endif
#include<vector>
// Base class header file.
//#include "UnImplNode.hpp"
//#include "PrefixResolver.hpp"
//#include "Constants.hpp"
// Xerces XML4C header files.
#include <dom/DOM_Node.hpp>
#include <dom/DOMString.hpp>
#include <XPath/MutableNodeRefList.hpp>
class DOM_Element;
class DOM_Node;
class KeyDeclaration;
class NodeRefListBase;
class PrefixResolver;
class XPathSupport;
/**
* Table of element keys, keyed by document node. An instance of this
* class is keyed by a Document node that should be matched with the
* root of the current context. It contains a table of name mappings
* to tables that contain mappings of identifier values to nodes.
*/
class KeyTable
{
public:
/**
* Build a keys table.
* @param doc The owner document key (normally the same as startNode).
* @param startNode The node to start itterating from to build the keys
index.
* @param nscontext The stylesheet's namespace context.
* @param keyDeclarations The stylesheet's xsl:key declarations.
* @param xpathSupport The support for getNodeData(useNode).
*/
KeyTable(
const DOM_Node&
doc,
const DOM_Node&
startNode,
const PrefixResolver&
resolver,
const std::vector<KeyDeclaration>& keyDeclarations,
XPathSupport&
xpathSupport);
virtual
~KeyTable();
/**
* Given a valid element key, return the corresponding node list.
* @param The name of the key, which must match the 'name' attribute on
xsl:key.
* @param ref The value that must match the value found by the 'match'
attribute on xsl:key.
* @return If the name was not declared with xsl:key, this will return
null,
* if the identifier is not found, it will return an empty node set,
* otherwise it will return a nodeset of nodes.
*/
const NodeRefListBase*
getNodeSetByKey(
const DOMString& name,
const DOMString& ref) const;
DOM_Node
getDocKey() const
{
return m_docKey;
}
private:
/**
* The document key. This table should only be used with contexts
* whose Document roots match this key.
*/
DOM_Node m_docKey;
/**
* Hashtable of keys.
* The table is:
* a) keyed by name,
* b) each with a value of a hashtable, keyed by the value returned by
* the use attribute,
* c) each with a value that is a nodelist.
* Thus, for a given key or keyref, look up hashtable by name,
* look up the nodelist by the given reference.
*/
/**
* Table of element keys. The table will be built on demand,
* when a key is requested, or set by the XMLParserLiaison or
* the caller. The table is:
* a) keyed by name,
* b) each with a value of a hashtable, keyed by the value returned by
* the use attribute,
* c) each with a value that is a nodelist.
* Thus, for a given key or keyref, look up hashtable by name,
* look up the nodelist by the given reference.
*/
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef hash_map<DOMString,
MutableNodeRefList,
DOMStringHashFunction,
DOMStringEqualsFunction>
NodeListMapType;
typedef hash_map<DOMString,
NodeListMapType,
DOMStringHashFunction,
DOMStringEqualsFunction>
KeysMapType;
#else
typedef std::map<DOMString,
MutableNodeRefList> NodeListMapType;
typedef std::map<DOMString,
NodeListMapType> KeysMapType;
#endif
KeysMapType m_keys;
};
#endif // XALAN_KEYTABLE_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/NodeSortKey.cpp
Index: NodeSortKey.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
// Class header file.
#include "NodeSortKey.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
NodeSortKey::NodeSortKey(
XSLTProcessor* processor,
const XPath* selectPat,
bool treatAsNumbers,
bool descending,
const DOMString& /* langValue */,
const PrefixResolver& resolver) :
m_processor(processor),
m_selectPat(selectPat),
m_treatAsNumbers(treatAsNumbers),
m_descending(descending),
m_prefixResolver(&resolver)
{
#if 0
// $$$ ToDo: What do we do about this?
if(0 != length(langValue))
{
m_locale = new Locale(langValue.toUpperCase(),
Locale.getDefault().getDisplayCountry());
if(null == m_locale)
{
// m_processor.warn("Could not find locale for <sort
xml:lang="+langValue);
m_locale = Locale.getDefault();
}
}
else
{
m_locale = Locale.getDefault();
}
m_col = Collator.getInstance(m_locale);
if(null == m_col)
{
m_processor.warn("Could not find Collator for <sort xml:lang="
+ langValue);
m_col = Collator.getInstance();
}
#endif
}
NodeSortKey::~NodeSortKey()
{
m_processor = 0;
m_prefixResolver = 0;
}
NodeSortKey&
NodeSortKey::operator=(const NodeSortKey& theRHS)
{
if (this != &theRHS)
{
m_processor = theRHS.m_processor;
m_selectPat = theRHS.m_selectPat;
m_treatAsNumbers = theRHS.m_treatAsNumbers;
m_descending = theRHS.m_descending;
m_prefixResolver = theRHS.m_prefixResolver;
}
return *this;
}
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/NodeSortKey.hpp
Index: NodeSortKey.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_NODESORTKEY_HEADER_GUARD)
#define XALAN_NODESORTKEY_HEADER_GUARD
/**
*
* @author Scott Boag ([EMAIL PROTECTED])
* @author David N. Bertoni ([email protected])
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include "XSLTProcessor.hpp"
class PrefixResolver;
class XPath;
/**
* Simple data structure class for use by the
* NodeSorter class.
*/
class NodeSortKey
{
public:
NodeSortKey(
XSLTProcessor* processor,
const XPath* selectPat,
bool treatAsNumbers,
bool descending,
const DOMString& langValue,
const PrefixResolver& resolver);
~NodeSortKey();
NodeSortKey&
operator=(const NodeSortKey& theRHS);
const XPath*
getSelectPattern() const
{
return m_selectPat;
}
bool
getTreatAsNumbers() const
{
return m_treatAsNumbers;
}
bool
getDescending() const
{
return m_descending;
}
const PrefixResolver&
getPrefixResolver() const
{
return *m_prefixResolver;
}
private:
XSLTProcessor* m_processor; // needed for error
reporting.
bool m_treatAsNumbers;
bool m_descending;
const XPath* m_selectPat;
const PrefixResolver* m_prefixResolver;
// $$$ ToDo:How do we do this in C++?
// Collator m_col;
// Locale m_locale;
};
#endif
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/NodeSorter.cpp
Index: NodeSorter.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*/
/**
*
* @author Scott Boag ([EMAIL PROTECTED])
* @author David N. Bertoni ([email protected])
*/
// Class header file.
#include "NodeSorter.hpp"
//@@ DEBUGGING
#include <cstdio>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
#include "XSLTProcessor.hpp"
NodeSorter::NodeSorter(XSLTProcessor& p) :
m_xslp(p),
m_keys()
{
}
NodeSorter::~NodeSorter()
{
}
void
NodeSorter::sort(
std::vector<DOM_Node>&
v,
const std::vector<NodeSortKey>& keys)
{
m_keys = keys;
NodeSortKeyCompare theComparer(m_xslp,
v,
keys);
// Use the stl sort algorithm, which will use our compare functor,
// which returns true if first less than second
std::stable_sort(v.begin(),
v.end(),
theComparer);
}
void
NodeSorter::sort(
MutableNodeRefList&
theList,
const std::vector<NodeSortKey>& keys)
{
const int theLength = theList.getLength();
// Copy the nodes to a vector...
std::vector<DOM_Node> theNodes(theLength);
for (int i = 0; i < theLength; i++)
{
DOM_Node theNode = theList.item(i);
theNodes[i] = theNode;
}
sort(theNodes,
keys);
assert(theNodes.size() ==
static_cast<std::vector<DOM_Node>::size_type>(theLength));
theList.clear();
for (i = 0; i < theLength; i++)
{
theList.addNode(theNodes[i]);
}
assert(theList.getLength() == theLength);
}
NodeSorter::NodeSortKeyCompare::result_type
NodeSorter::NodeSortKeyCompare::operator()(
first_argument_type theLHS,
second_argument_type theRHS,
unsigned int theKeyIndex) const
{
assert(theKeyIndex < UINT_MAX);
result_type theResult = false;
const NodeSortKey& theKey = m_nodeSortKeys[theKeyIndex];
// @@ JMD: is this right to provide a default NodeRefList instead of 0
??
// @@ execute can't work on a const XPath
XPath* xpath = const_cast<XPath*>(theKey.getSelectPattern());
XObject* r1 = xpath->execute(theLHS, theKey.getPrefixResolver(),
NodeRefList());
XObject* r2 = xpath->execute(theRHS, theKey.getPrefixResolver(),
NodeRefList());
// Compare as numbers
if(theKey.getTreatAsNumbers() == true)
{
double n1Num = r1->num();
double n2Num = r2->num();
if (DoubleSupport::isNaN(n1Num))
n1Num = 0.0;
if (DoubleSupport::isNaN(n2Num))
n2Num = 0.0;
if(n1Num == n2Num &&
(theKeyIndex + 1 ) < m_nodeSortKeys.size())
{
theResult = operator()(theLHS, theRHS, theKeyIndex + 1);
}
else
{
const double diff = n1Num - n2Num;
theResult = diff < 0.0 ? true : false;
if (theKey.getDescending() == true)
{
theResult = !theResult;
}
}
}
// Compare as strings
else
{
const int theCompareResult = compare(r1->str(),
r2->str());
if(0 == theCompareResult)
{
if ((theKeyIndex + 1 ) < m_nodeSortKeys.size())
{
theResult = operator()(theLHS, theRHS,
theKeyIndex + 1);
}
}
else
{
theResult = theCompareResult < 0 ? true : false;
if (theKey.getDescending() == true)
{
theResult = !theResult;
}
}
}
return theResult;
}
1.1 xml-xalan/c/src/XSLT/NodeSorter.hpp
Index: NodeSorter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_NODESORTER_HEADER_GUARD)
#define XALAN_NODESORTER_HEADER_GUARD
/**
* @author Scott Boag ([EMAIL PROTECTED])
* @author David N. Bertoni ([email protected])
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <functional>
#include <vector>
#include <dom/DOM_Node.hpp>
#include <XPath/XPath.hpp>
#include <XPath/XObject.hpp>
#include "NodeSortKey.hpp"
class MutableNodeRefList;
class XSLTProcessor;
/**
* This class can sort vectors of DOM nodes according to a select pattern.
* TODO: Optimize this so it can reuse queries for each of the nodes.
*/
class NodeSorter
{
public:
/**
* Construct a NodeSorter, passing in the XSL Processor
* so it can know how to get the node data according to
* the proper whitespace rules.
*/
NodeSorter(XSLTProcessor& p);
~NodeSorter();
/**
* Given a vector of nodes, sort each node according to
* the criteria in the keys.
* @param v an vector of Nodes.
* @param keys a vector of NodeSortKeys.
*/
void
sort(
std::vector<DOM_Node>& v,
const std::vector<NodeSortKey>& keys);
/*
throws XSLProcessorException,
java.net.MalformedURLException,
java.io.FileNotFoundException,
java.io.IOException
*/
/**
* Given a vector of nodes, sort each node according to
* the criteria in the keys.
* @param v an vector of Nodes.
* @param keys a vector of NodeSortKeys.
*/
void
sort(
MutableNodeRefList&
theList,
const std::vector<NodeSortKey>& keys);
/**
* Return the results of a compare of two nodes.
* TODO: Optimize compare -- cache the getStringExpr results,
* key by m_selectPat + hash of node.
*/
struct NodeSortKeyCompare : public std::binary_function<const
DOM_Node&, const DOM_Node&, bool>
{
public:
NodeSortKeyCompare(XSLTProcessor&
theProcessor,
const std::vector<DOM_Node>&
theNodes,
const
std::vector<NodeSortKey>& theNodeSortKeys) :
m_processor(theProcessor),
m_nodes(theNodes),
m_nodeSortKeys(theNodeSortKeys)
// java: compare
{
}
result_type
operator()(first_argument_type theLHS,
second_argument_type theRHS,
unsigned int
theKeyIndex = 0) const;
XSLTProcessor&
m_processor;
const std::vector<DOM_Node>& m_nodes;
const std::vector<NodeSortKey>& m_nodeSortKeys;
};
private:
XSLTProcessor& m_xslp;
std::vector<NodeSortKey> m_keys; // vector of NodeSortKeys
/**
* @@ TODO: Adjust this for locale.
* JMD: java: not used yet, placeholder
*/
// NumberFormat m_formatter = NumberFormat.getNumberInstance();
};
#endif // XALAN_NODESORTER_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/NumeratorFormatter.cpp
Index: NumeratorFormatter.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NumeratorFormatter.hpp"
#include <climits>
#include <PlatformSupport/DOMStringHelper.hpp>
#include "XSLTEngineImpl.hpp"
std::vector<DecimalToRoman>
InitializeDecimalToRomanTable()
{
std::vector<DecimalToRoman> theVector(7);
theVector[0] = DecimalToRoman(1000L, "M", 900L, "CM");
theVector[1] = DecimalToRoman(500L, "D", 400L, "CD");
theVector[2] = DecimalToRoman(100L, "C", 90L, "XC");
theVector[3] = DecimalToRoman(50L, "L", 40L, "XL");
theVector[4] = DecimalToRoman(10L, "X", 9L, "IX");
theVector[5] = DecimalToRoman(5L, "V", 4L, "IV");
theVector[6] = DecimalToRoman(1L, "I", 1L, "I");
return theVector;
}
const std::vector<DecimalToRoman> NumeratorFormatter::m_romanConvertTable
=
InitializeDecimalToRomanTable();
const XMLCh
NumeratorFormatter::m_alphaCountTable[] =
{
'Z', // z for zero
'A' , 'B' , 'C' , 'D' , 'E' , 'F' ,
'G' , 'H' , 'I' , 'J' , 'K' , 'L' ,
'M' , 'N' , 'O' , 'P' , 'Q' , 'R' ,
'S' , 'T' , 'U' , 'V' , 'W' , 'X' ,
'Y'
};
const size_t
NumeratorFormatter::m_alphaCountTableSize =
sizeof(NumeratorFormatter::m_alphaCountTable) /
sizeof
(NumeratorFormatter::m_alphaCountTable[0]);
NumeratorFormatter::NumeratorFormatter(
DOM_Element xslNumberElement,
XSLTProcessor* xslProcessor) :
m_xslProcessor(xslProcessor),
m_xslNumberElement(xslNumberElement),
m_formatTokenizer()
{
}
NumeratorFormatter::~NumeratorFormatter()
{
m_xslProcessor = 0;
}
void
NumeratorFormatter::processAttributes(const DOM_Node& contextNode)
{
/*
@@ java: commented out
assert(m_xslProcessor != 0);
// See http://www.w3.org/TR/WD-xsl#convert for the form
// of the format string, which tells how the numbers should be
// formatted.
DOMString formatValue =
m_xslProcessor->getProcessedAttrVal(m_xslNumberElement,
Constants::ATTRNAME_FORMAT,
contextNode);
if(0 == length(formatValue))
{
formatValue = "1";
}
m_formatTokenizer.setString(formatValue);
// The letter-value attribute disambiguates between numbering schemes
// that use letters. A value of "alphabetic" specifies the alphabetic
// sequence; a value of "other" specifies the other sequence.
// TODO: Handle letter-value attribute.
const DOMString letterValue =
m_xslProcessor->getProcessedAttrVal(m_xslNumberElement,
Constants::ATTRNAME_LETTERVALUE,
contextNode);
if(0 != length(letterValue))
{
m_xslProcessor->warn(DOM_Node(),
contextNode,
DOMString(Constants::ATTRNAME_LETTERVALUE) +
" not supported
yet!");
}
// When numbering with an alphabetic sequence, the xml:lang
// attribute specifies which language's alphabet is to be used.
const DOMString langValue =
m_xslProcessor->getAttrVal(m_xslNumberElement, "xml:lang");
#if 0
if(0 != length(langValue))
{
// Not really sure what to do about the country code, so I use
the
// default from the system.
// TODO: fix xml:lang handling.
m_locale = new Locale(langValue.toUpperCase(),
Locale.getDefault().getDisplayCountry());
if(null == m_locale)
{
warn(null, contextNode, "Warning: Could not find locale for
xml:lang="+langValue);
m_locale = Locale.getDefault();
}
}
else
{
m_locale = Locale.getDefault();
}
// Helper to format local specific numbers to strings.
m_formatter = java.text.NumberFormat.getNumberInstance(m_locale);
#endif
// The digit-group-sep attribute gives the separator between groups
// of digits, and the optional n-digits-per-group specifies the
// number of digits per group. For example, digit-group-sep=","
// and n-digits-per-group="3" would produce numbers of the form
1,000,000.
const DOMString digitGroupSepValue =
m_xslProcessor->getProcessedAttrVal(m_xslNumberElement,
Constants::ATTRNAME_DIGITGROUPSEP,
contextNode);
const DOMString nDigitsPerGroupValue =
m_xslProcessor->getProcessedAttrVal(m_xslNumberElement,
Constants::ATTRNAME_NDIGITSPERGROUP,
contextNode);
const long nDigitsPerGroup = DOMStringToLong(nDigitsPerGroupValue);
// TODO: Handle digit-group attributes
if(0 != length(digitGroupSepValue) || 0 != length(nDigitsPerGroupValue))
{
// m_formatter.setGroupingUsed(true);
}
// The sequence-src attribute gives the URI of a text resource
// that contains a whitespace separated list of the members of
// the numbering sequence.
// (Used with letter-value="other", I think.)
const DOMString sequenceSrcValue =
m_xslProcessor->getProcessedAttrVal(m_xslNumberElement,
Constants::ATTRNAME_SEQUENCESRC,
contextNode);
if(0 != length(sequenceSrcValue))
{
m_xslProcessor->warn(DOM_Node(),
contextNode,
DOMString(Constants::ATTRNAME_SEQUENCESRC) +
" not supported
yet!");
}
*/
}
DOMString
NumeratorFormatter::formatNumberList(const IntVectorType& theList)
{
DOMString formattedNumber;
const int nNumbers = theList.size();
XMLCh numberType = '1';
int numberWidth = 1;
DOMString formatToken;
DOMString sepString;
DOMString lastSepString;
// $$$ ToDo: Fix this!
// DOMString padString = m_formatter.format(0);
DOMString padString = LongToDOMString(0);
DOMString lookahead; // next token
m_formatTokenizer.reset();
for(int i = 0; i < nNumbers; i++)
{
while(m_formatTokenizer.hasMoreTokens() == true)
{
if(length(lookahead) != 0)
{
formatToken = lookahead;
lookahead = "";
}
else
{
formatToken = m_formatTokenizer.nextToken();
}
if(isLetterOrDigit(charAt(formatToken,
formatToken.length() - 1)) == true)
{
numberWidth = formatToken.length();
numberType = charAt(formatToken, numberWidth -
1);
break; // from
while(m_formatTokenizer.hasMoreTokens())
}
else
{
sepString = formatToken;
while(m_formatTokenizer.hasMoreTokens() == true)
{
lookahead =
m_formatTokenizer.nextToken();
if(isLetterOrDigit(charAt(lookahead,
0)) == false)
{
sepString += lookahead;
lookahead = ""; // consume
}
else
{
break; // from inner while loop
}
}
if(m_formatTokenizer.hasMoreTokens() == false)
{
lastSepString = sepString;
// crufty bit to strip whitespace off
of separator
// if it is the end string.
// This probably isn't right.
const int lastPos =
sepString.length() - 1;
int k = lastPos;
for(; k >= 0; k--)
{
if(isSpace(charAt(sepString,
k)) == false)
{
break; // from for loop
}
}
sepString = substring(sepString, 0, k +
1);
}
}
} // end while
switch(numberType)
{
case 'A':
formattedNumber += (sepString +
int2alphaCount(theList[i],
m_alphaCountTable,
m_alphaCountTableSize));
break;
case 'a':
// $$$ ToDo: Fix this!!!
// formattedNumber += (sepString +
int2alphaCount(theList[i], m_alphaCountTable).toLowerCase(m_locale));
formattedNumber += toLowerCase(sepString +
int2alphaCount(theList[i],
m_alphaCountTable,
m_alphaCountTableSize));
break;
case 'I':
formattedNumber += (sepString + long2roman(theList[i],
true));
break;
case 'i':
// $$$ ToDo: Fix this!!!
// formattedNumber += (sepString + long2roman(theList[i],
true).toLowerCase(m_locale));
formattedNumber += toLowerCase(sepString +
long2roman(theList[i], true));
break;
default: // "1"
{
// $$$ ToDo: Fix this!!!
// DOMString numString =
m_formatter.format(theList[i]);
DOMString
numString(LongToDOMString(theList[i]));
const int nPadding = numberWidth -
numString.length();
formattedNumber += sepString;
for(int k = 0; k < nPadding; k++)
{
formattedNumber += padString;
}
formattedNumber += numString;
}
} // end switch
} // end for
// Check to see if we finished up the format string...
if(0 == length(lastSepString))
{
lastSepString = "";
while(m_formatTokenizer.hasMoreTokens() == true)
{
lookahead = m_formatTokenizer.nextToken();
// was: if(isLetterOrDigit(charAt(lookahead, 0)))
if( ! isLetterOrDigit(charAt(lookahead, 0)))
{
lastSepString += lookahead;
}
else
{
lastSepString = "";
}
}
}
if(0 != length(lastSepString))
{
formattedNumber += lastSepString;
}
return formattedNumber;
}
DOMString
NumeratorFormatter::int2alphaCount(
int val,
const XMLCh table[],
size_t theTableSize)
{
assert(theTableSize < INT_MAX);
const int radix = static_cast<int>(theTableSize);
// Create a buffer to hold the result
// $$$ ToDo: size of the table can be determined by computing
// logs of the radix. For now, we fake it.
XMLCh buf[100];
// next character to set in the buffer
int charPos = (sizeof(buf) / sizeof(buf[0])) - 1 ; // work backward
through buf[]
buf[charPos--] = 0;
// index in table of the last character that we stored
int lookupIndex = 1; // start off with anything other than zero to
make correction work
// Correction number
//
// Correction can take on exactly two values:
//
// 0 if the next character is to be emitted is usual
//
// radix - 1
// if the next char to be emitted should be one
less than
// you would expect
//
// For example, consider radix 10, where 1="A" and 10="J"
//
// In this scheme, we count: A, B, C ... H, I, J (not A0 and
certainly
// not AJ), A1
//
// So, how do we keep from emitting AJ for 10? After correctly
emitting the
// J, lookupIndex is zero. We now compute a correction number of 9
(radix-1).
// In the following line, we'll compute (val+correction) % radix, which
is,
// (val+9)/10. By this time, val is 1, so we compute (1+9) % 10, which
// is 10 % 10 or zero. So, we'll prepare to emit "JJ", but then we'll
// later suppress the leading J as representing zero (in the mod
system,
// it can represent either 10 or zero). In summary, the correction
value of
// "radix-1" acts like "-1" when run through the mod operator, but with
the
// desireable characteristic that it never produces a negative number.
int correction = 0;
// TODO: throw error on out of range input
do
{
// most of the correction calculation is explained above, the
reason for the
// term after the "|| " is that it correctly propagates carries
across
// multiple columns.
correction = ((lookupIndex == 0) ||
(correction != 0 && lookupIndex ==
radix - 1 )) ? (radix - 1) : 0;
// index in "table" of the next char to emit
lookupIndex = (val + correction) % radix;
// shift input by one "column"
val = (val / radix);
// if the next value we'd put out would be a leading zero,
we're done.
if (lookupIndex == 0 && val == 0)
break;
// put out the next character of output
buf[charPos--] = table[lookupIndex];
}
while (val > 0);
return DOMString(&buf[charPos + 1]);
}
DOMString
NumeratorFormatter::long2roman(
long val,
bool prefixesAreOK)
{
DOMString roman;
if(val <= 0)
{
roman = DOMString("#E(") + DOMString(val) + DOMString(")");
}
else
{
int place = 0;
if (val <= 3999L)
{
do
{
while (val >=
m_romanConvertTable[place].m_postValue)
{
roman +=
m_romanConvertTable[place].m_postLetter;
val -=
m_romanConvertTable[place].m_postValue;
}
if (prefixesAreOK)
{
if (val >=
m_romanConvertTable[place].m_preValue)
{
roman +=
m_romanConvertTable[place].m_preLetter;
val -=
m_romanConvertTable[place].m_preValue;
}
}
place++;
}
while (val > 0);
}
else
{
roman = "#error";
}
}
return roman;
} // end long2roman
NumeratorFormatter::NumberFormatStringTokenizer::NumberFormatStringTokenizer(
const DOMString& theStr) :
m_currentPosition(0),
m_maxPosition(length(theStr)),
m_str(theStr)
{
}
void
NumeratorFormatter::NumberFormatStringTokenizer::setString(const DOMString&
theString)
{
m_str = theString;
m_currentPosition = 0;
m_maxPosition = length(theString);
}
DOMString
NumeratorFormatter::NumberFormatStringTokenizer::nextToken()
{
if (m_currentPosition >= m_maxPosition)
{
// $$$ Todo: Implement!
// throw new NoSuchElementException();
}
const int start = m_currentPosition;
while ((m_currentPosition < m_maxPosition) &&
isLetterOrDigit(charAt(m_str, m_currentPosition)))
{
m_currentPosition++;
}
if ((start == m_currentPosition) &&
(!isLetterOrDigit(charAt(m_str, m_currentPosition))))
{
m_currentPosition++;
}
return substring(m_str, start, m_currentPosition);
}
int
NumeratorFormatter::NumberFormatStringTokenizer::countTokens() const
{
int count = 0;
int currpos = m_currentPosition;
while (currpos < m_maxPosition)
{
const int start = currpos;
while ((currpos < m_maxPosition) &&
isLetterOrDigit(charAt(m_str, currpos)))
{
currpos++;
}
if ((start == currpos) &&
(isLetterOrDigit(charAt(m_str, currpos)) == false))
{
currpos++;
}
count++;
}
return count;
}
1.1 xml-xalan/c/src/XSLT/NumeratorFormatter.hpp
Index: NumeratorFormatter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_NUMERATORFORMATTER_HEADER_GUARD)
#define XALAN_NUMERATORFORMATTER_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <cstddef>
#include <memory>
#include <vector>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOMString.hpp>
#include "DecimalToRoman.hpp"
class XSLTProcessor;
/**
* Class to help in converting enumerated numbers
* into strings, using the XSL conversion attributes.
* Having this in a class helps to not have to extract
* the attributes everytime.
*/
class NumeratorFormatter
{
public:
/**
* Construct a NumeratorFormatter using an element
* that contains XSL number conversion attributes -
* format, letter-value, xml:lang, digit-group-sep,
* n-digits-per-group, and sequence-src.
*/
NumeratorFormatter(
DOM_Element xslNumberElement =
DOM_Element(),
XSLTProcessor* xslProcessor = 0);
virtual
~NumeratorFormatter();
/**
* Process the attributes of the node with number formatting
* attributes. I'd like to
* do this at construction time, but I have to do it every
* time because the elements may have attribute templates embedded
* in them, and so must be processed only when the node is
* actually called.
* TODO: Can I just do NumeratorFormatter.processAttributes up front
now?
*/
virtual void
processAttributes(const DOM_Node& contextNode);
// throws XSLProcessorException,
// java.net.MalformedURLException,
// java.io.FileNotFoundException,
// java.io.IOException
/**
* Format a vector of numbers into a formatted string.
* @param xslNumberElement Element that takes %conversion-atts;
attributes.
* @param list Array of one or more integer numbers.
* @return String that represents list according to
* %conversion-atts; attributes.
* TODO: Optimize formatNumberList so that it caches the last count and
* reuses that info for the next count.
*/
typedef std::vector<int> IntVectorType;
DOMString
formatNumberList(const IntVectorType& theList);
XSLTProcessor*
getXSLProcessor() const
{
return m_xslProcessor;
}
void
setXSLProcessor(XSLTProcessor* theProcessor)
{
m_xslProcessor = theProcessor;
}
protected:
/**
* Convert a long integer into alphabetic counting, in other words
* count using the sequence A B C ... Z AA AB AC.... etc.
* @param val Value to convert -- must be greater than zero.
* @param table a table containing one character for each digit in the
radix
* @return String representing alpha count of number.
* @see XSLTProcessor#DecimalToRoman
*
* Note that the radix of the conversion is inferred from the size
* of the table.
*/
DOMString
int2alphaCount(
int val,
const XMLCh table[],
size_t theTableSize);
/**
* Convert a long integer into roman numerals.
* @param val Value to convert.
* @param prefixesAreOK true_ to enable prefix notation (e.g. 4 = "IV"),
* false_ to disable prefix notation (e.g. 4 = "IIII").
* @return Roman numeral string.
* @see DecimalToRoman
* @see m_romanConvertTable
*/
DOMString
long2roman(
long val,
bool prefixesAreOK);
XSLTProcessor* m_xslProcessor;
DOM_Element m_xslNumberElement;
// $$$ ToDo: How do we implement this in C++?
// NumberFormatStringTokenizer m_formatTokenizer;
// Locale m_locale;
// java.text.NumberFormat m_formatter;
public:
/**
* This class returns tokens using non-alphanumberic
* characters as delimiters.
*/
class NumberFormatStringTokenizer
{
public:
/**
* Construct a NumberFormatStringTokenizer.
*/
explicit
NumberFormatStringTokenizer(const DOMString& theStr =
DOMString());
void
setString(const DOMString& theString);
/**
* Reset tokenizer so that nextToken() starts from the
beginning.
*/
void
reset()
{
m_currentPosition = 0;
}
/**
* Returns the next token from this string tokenizer.
*
* @return the next token from this string tokenizer.
* @exception NoSuchElementException if there are no more
tokens in this
* tokenizer's string.
*/
DOMString
nextToken();
/**
* Tells if <code>nextToken</code> will throw an exception
* if it is called.
*
* @return true if <code>nextToken</code> can be called
* without throwing an exception.
*/
bool
hasMoreTokens() const
{
return (m_currentPosition >= m_maxPosition) ? false :
true;
}
/**
* Calculates the number of times that this tokenizer's
* <code>nextToken</code> method can be called before it
generates an
* exception.
*
* @return the number of tokens remaining in the string using
the current
* delimiter set.
* @see java.util.StringTokenizer#nextToken()
*/
int
countTokens() const;
private:
int m_currentPosition;
int m_maxPosition;
DOMString m_str;
}; // end NumberFormatStringTokenizer
NumberFormatStringTokenizer m_formatTokenizer;
/**
* Table to help in converting decimals to roman numerals.
*/
static const std::vector<DecimalToRoman> m_romanConvertTable;
/**
* Chars for converting integers into alpha counts.
*/
static const XMLCh m_alphaCountTable[];
static const size_t m_alphaCountTableSize;
};
#endif // XALAN_NUMERATORFORMATTER_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ProblemListener.cpp
Index: ProblemListener.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*/
/**
* @author David N. Bertoni ([email protected])
*/
// Class header file.
#include "ProblemListener.hpp"
ProblemListener::ProblemListener()
{
}
ProblemListener::~ProblemListener()
{
}
1.1 xml-xalan/c/src/XSLT/ProblemListener.hpp
Index: ProblemListener.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: ProblemListener.hpp,v 1.1 1999/12/18 19:48:04 robweir Exp $
*/
#if !defined(XALAN_PROBLEMLISTENER_HEADER_GUARD)
#define XALAN_PROBLEMLISTENER_HEADER_GUARD
/**
* @author Scott Boag ([EMAIL PROTECTED])
* @author David N. Bertoni ([email protected])
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
class DOMString;
class DOM_Node;
class PrintWriter;
/**
* This is the abstract class that the XSL processor uses when it
* has a problem of some kind, either an error or a warning.
* Users should ask the XSLTProcessor class to setProblemListener
* if they wish an object instance to be called when a problem
* event occurs.
*/
class XALAN_XSLT_EXPORT ProblemListener
{
public:
enum eProblemSource { eXMLPARSER = 1,
eXSLPROCESSOR = 2,
eQUERYENGINE = 3 };
enum eClassification { eMESSAGE = 0,
eWARNING = 1,
eERROR
= 2 };
ProblemListener();
virtual
~ProblemListener();
virtual void
setPrintWriter(PrintWriter* pw) = 0;
/**
* Function that is called when a problem event occurs.
*
* @param where Either and XMLPARSER, XSLPROCESSOR, or
QUERYENGINE.
* @param classification Either ERROR or WARNING.
* @param styleNode The style tree node where the problem
* occurred. May be null.
* @param sourceNode The source tree node where the problem
* occurred. May be null.
* @param msg A string message explaining the problem.
* @param lineNo The line number where the problem occurred,
* if it is known. May be zero.
* @param charOffset The character offset where the problem,
* occurred if it is known. May be zero.
*
* @return true if the return is an ERROR, in which case
* exception will be thrown. Otherwise the processor will
* continue to process.
*/
virtual bool
problem(
eProblemSource where,
eClassification classification,
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
const XMLCh* id,
int lineNo,
int charOffset) = 0;
};
#endif // XALAN_PROBLEMLISTENER_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/ProblemListenerDefault.cpp
Index: ProblemListenerDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*/
/**
*
* @author David N. Bertoni ([email protected])
* */
// Base class header file.
#include "ProblemListenerDefault.hpp"
// Xerces XML4C header files
#include <dom/DOM_Node.hpp>
#include <dom/DOMString.hpp>
#include <util/StdOut.hpp>
// XSL header files.
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/PrintWriter.hpp>
#include <Include/DOMHelper.hpp>
namespace
{
const char* const errorHeader = "Error: ";
const char* const warningHeader = "Warning: ";
const char* const xslHeader = "XSL ";
const char* const xmlHeader = "XML ";
const char* const queryHeader = "PATTERN ";
const char* const styleTreeNodeHeader = ", style tree node: ";
const char* const sourceTreeNodeHeader = ", source tree node: ";
const char* const lineNoHeader = ", line ";
const char* const charOffsetHeader = ", offset ";
};
ProblemListenerDefault::ProblemListenerDefault(PrintWriter* pw) :
ProblemListener(),
m_pw(pw)
{
}
ProblemListenerDefault::~ProblemListenerDefault()
{
m_pw = 0;
}
void
ProblemListenerDefault::setPrintWriter(PrintWriter* pw)
{
m_pw = pw;
}
bool
ProblemListenerDefault::problem(
eProblemSource where,
eClassification classification,
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
const XMLCh* /* id */,
int lineNo,
int charOffset)
{
if (m_pw != 0)
{
if (eXMLPARSER == where)
{
m_pw->print(xmlHeader);
}
else if (eQUERYENGINE == where)
{
m_pw->print(queryHeader);
}
else
{
m_pw->print(xslHeader);
}
if (eERROR == classification)
{
m_pw->print(errorHeader);
}
else
{
m_pw->print(warningHeader);
}
m_pw->print(msg);
if (0 != styleNode)
{
m_pw->print(styleTreeNodeHeader);
m_pw->print(styleNode.getNodeName());
}
if (0 != sourceNode)
{
m_pw->print(sourceTreeNodeHeader);
m_pw->print(sourceNode.getNodeName());
}
if (0 != lineNo)
{
m_pw->print(lineNoHeader);
m_pw->print(lineNo);
}
if (0 != charOffset)
{
m_pw->print(charOffsetHeader);
m_pw->print(charOffset);
}
m_pw->println();
}
return classification == eERROR ? true : false;
}
1.1 xml-xalan/c/src/XSLT/ProblemListenerDefault.hpp
Index: ProblemListenerDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_PROBLEMLISTENERDEFAULT_HEADER_GUARD)
#define XALAN_PROBLEMLISTENERDEFAULT_HEADER_GUARD
/**
* $State: Exp $
*
* @author Scott Boag ([EMAIL PROTECTED])
* */
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Xalan header files.
#include "ProblemListener.hpp"
class DOMString;
/**
* The implementation of the default error handling for
* Xalan.
*/
class XALAN_XSLT_EXPORT ProblemListenerDefault : public ProblemListener
{
public:
ProblemListenerDefault(PrintWriter* pw = 0);
virtual
~ProblemListenerDefault();
virtual void
setPrintWriter(PrintWriter* pw);
/**
* The default problem listener.
*/
virtual bool
problem(
eProblemSource where,
eClassification classification,
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
const XMLCh* id,
int lineNo,
int charOffset);
private:
PrintWriter* m_pw;
};
#endif // XALAN_PROBLEMLISTENERDEFAULT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/SelectionEvent.cpp
Index: SelectionEvent.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "SelectionEvent.hpp"
/**
* Create an event originating at the given node of the style tree.
* @param processor The XSLT Processor.
* @param sourceTree The input source tree.
* @param sourceNode The current context node.
* @param mode The current mode.
* @param m_styleNode node in the style tree reference for the event.
* Should not be null. That is not enforced.
*/
SelectionEvent::SelectionEvent(const XSLTEngineImpl* processor,
const DOM_Node& sourceNode,
const ElemTemplateElement* styleNode,
const DOMString& attributeName,
const XPath* xpath,
const XObject* selection): m_pProcessor(processor),
m_sourceNode(sourceNode),
m_pStyleNode(styleNode), m_attributeName(attributeName),
m_pXPath(xpath),
m_pSelection(selection)
{
}
1.1 xml-xalan/c/src/XSLT/SelectionEvent.hpp
Index: SelectionEvent.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_SelectionEvent_HEADER_GUARD)
#define XALAN_SelectionEvent_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
class XSLTEngineImpl;
class DOM_Node;
class ElemTemplateElement;
class DOMString;
class XPath;
class XObject;
class SelectionEvent
{
public:
/**
* Create an event originating at the given node of the style tree.
* @param processor The XSLT Processor.
* @param sourceTree The input source tree.
* @param sourceNode The current context node.
* @param mode The current mode.
* @param m_styleNode node in the style tree reference for the event.
* Should not be null. That is not enforced.
*/
SelectionEvent(const XSLTEngineImpl* processor,
const DOM_Node& sourceNode,
const ElemTemplateElement* styleNode,
const DOMString& attributeName,
const XPath* xpath,
const XObject* selection);
/**
* The node in the style tree where the event occurs.
*/
const ElemTemplateElement* m_pStyleNode;
/**
* The XSLT processor instance.
*/
const XSLTEngineImpl* m_pProcessor;
/**
* The current context node.
*/
const DOM_Node& m_sourceNode;
/**
* The attribute name from which the selection is made.
*/
const DOMString& m_attributeName;
/**
* The XPath that executed the selection.
*/
const XPath* m_pXPath;
/**
* The result of the selection.
*/
const XObject* m_pSelection;
private:
// unimplemented for now
SelectionEvent& operator=(const SelectionEvent& other);
};
#endif //XALAN_SelectionEvent_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/StackEntry.cpp
Index: StackEntry.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "StackEntry.hpp"
StackEntry::StackEntry(eStackEntryType theType) :
m_type(theType)
{
}
StackEntry::StackEntry(const StackEntry& theSource) :
m_type(theSource.m_type)
{
}
StackEntry::~StackEntry()
{
}
1.1 xml-xalan/c/src/XSLT/StackEntry.hpp
Index: StackEntry.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_STACKENTRY_HEADER_GUARD)
#define XALAN_STACKENTRY_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Base class for all stack items.
class StackEntry
{
public:
virtual
~StackEntry();
enum eStackEntryType { eContextState,
eContextMarker,
eElementMarker,
eArgument };
eStackEntryType
getType() const
{
return m_type;
}
virtual StackEntry*
clone() const = 0;
virtual bool
equals(const StackEntry& rhs) const = 0;
bool
operator==(const StackEntry& theRHS) const
{
return equals(theRHS);
}
protected:
StackEntry(eStackEntryType theType);
StackEntry(const StackEntry& theSource);
private:
// Data members...
eStackEntryType m_type;
};
#endif // XALAN_STACKENTRY_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/Stylesheet.cpp
Index: Stylesheet.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
// Class header file.
#include "Stylesheet.hpp"
#include <dom/DOM_Node.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include "XSLTEngineImpl.hpp"
#include <XPath/ElementPrefixResolverProxy.hpp>
#include <XPath/XString.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "StylesheetRoot.hpp"
// @@ JMD: ?? why do we need this ??
typedef std::vector<NameSpace> NamespaceVectorType;
/**
* This class represents the base stylesheet or an "import" stylesheet.
* "include" stylesheets are combined with the including stylesheet. At the
* moment these stylesheets can not be reused within the stylesheet tree or
* between trees. This needs to be fixed in the future.
*/
double Stylesheet::m_XSLTVerDeclared = 1.0;
NamespaceVectorType Stylesheet::m_emptyNamespace;
/**
* Constructor for a Stylesheet needs a Document.
* XSLProcessorException thrown if the active ProblemListener and
* XMLParserLiaison decide the error condition is severe enough to halt
* processing.
*/
Stylesheet::Stylesheet(
StylesheetRoot& root,
XSLTEngineImpl* theXSLProcessor,
const DOMString& baseIdentifier) :
UnimplementedDocument(),
UnimplementedElement(&root),
m_processor(theXSLProcessor),
m_stylesheetRoot(&root),
m_imports(),
m_patternTable(),
m_attributeSets(),
m_baseIdent(baseIdentifier),
m_tablesAreInvalid(true),
m_key_tables(0),
m_keyDeclarations(),
m_needToBuildKeysTable(false),
m_defaultATXpath(0),
m_firstTemplate(0),
m_defaultSpace(true),
m_namespaces(),
m_namespaceDecls(),
m_wrapperlessTemplate(0),
m_isWrapperless(false)
// throws XSLProcessorException, MalformedURLException,
// FileNotFoundException, IOException, SAXException
{
// Java: second argument null
URL* u = m_processor->getURLFromString(m_baseIdent, DOMString());
if (u != 0)
{
m_includeStack.push_back(*u);
delete u;
}
// Register the java namespace as being implemented by the
xslt-javaclass
// engine. Note that there's no real code per se for this extension as
the
// functions carry the object on which to call etc. and all the logic
of
// breaking that up is in the xslt-javaclass engine.
/*
@@ LATER
ExtensionFunctionHandler doesn't exist yet
string uri("http://xml.apache.org");
ExtensionFunctionHandler fh =
new ExtensionFunctionHandler (uri, 0, "xslt-javaclass", 0, 0);
XMLParserLiaisonDefault xld =
reinterpret_cast<XMLParserLiaisonDefault> m_processor.m_parserLiaison;
xld.addExtensionNamespace (uri, fh);
*/
}
Stylesheet::~Stylesheet()
{
// Clean up all entries in the vector.
std::for_each(m_imports.begin(),
m_imports.end(),
DeleteFunctor<Stylesheet>());
// Clean up the key table vector
std::for_each(m_key_tables.begin(),
m_key_tables.end(),
DeleteFunctor<KeyTable>());
// Clean up the match pattern vector
PatternTableMapType::iterator it = m_patternTable.begin();
for ( ; it != m_patternTable.end(); it++)
{
PatternTableListType theList = (*it).second;
std::for_each(theList.begin(),
theList.end(),
DeleteFunctor<MatchPattern2>());
}
m_stylesheetRoot = 0;
m_processor = 0;
m_defaultATXpath = 0;
m_wrapperlessTemplate = 0;
m_firstTemplate = 0;
}
bool
Stylesheet::isXSLTagOfType(
const DOM_Node& node,
int tagType) const
{
return m_processor->isXSLTagOfType(node, tagType);
}
DOMString
Stylesheet::getAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& contextNode)
{
return m_processor->getAttrVal(el, key, contextNode);
}
DOMString
Stylesheet::getAttrVal(
const DOM_Element& el,
const DOMString& key)
{
return m_processor->getAttrVal(el, key);
}
bool Stylesheet::isRoot() const { return false; }
DOMString
Stylesheet::getProcessedAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& contextNode)
{
return m_processor->getProcessedAttrVal(el, key, contextNode);
}
DOMString
Stylesheet::getNodeData(const DOM_Node& node) const
{
return m_processor->getNodeData(node);
}
/**
* Process the xsl:key element.
*
* (Notes to myself)
* What we need to do is:
* 1) As this function is called, build a table of KeyDeclarations.
* 2) During either XML processing, or upon request, walk the XML
* document tree, and build a hash table:
* a) keyed by name,
* b) each with a value of a hashtable, keyed by the value returned by
* the use attribute,
* c) each with a value that is a nodelist.
* Thus, for a given key or keyref, look up hashtable by name,
* look up the nodelist by the given reference.
*/
void Stylesheet::processKeyElement(ElemTemplateElement *nsContext, const
AttributeList& atts)
// throws XSLProcessorException
{
const XMLCh* nameAttr = 0;
XPath *matchAttr = 0;
XPath *useAttr = 0;
int nAttrs = atts.getLength();
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname = atts.getName(i);
if (equals(aname, Constants::ATTRNAME_NAME))
nameAttr = atts.getValue(i);
else if(equals(aname, Constants::ATTRNAME_MATCH))
{
matchAttr =
m_processor->createMatchPattern(DOMString(atts.getValue(i)),
*nsContext);
}
else if(equals(aname, Constants::ATTRNAME_USE))
useAttr = m_processor->createXPath(atts.getValue(i),
*nsContext);
else
m_processor->error(
DOMString("xsl:key, unrecognized keyword
'")+Constants::ATTRNAME_NAME+DOMString("'!"));
}
if(0 == nameAttr)
m_processor->error(DOMString("xsl:key requires a
")+Constants::ATTRNAME_NAME+" attribute!");
if(0 == matchAttr)
m_processor->error(DOMString("xsl:key requires a
")+Constants::ATTRNAME_MATCH+DOMString(" attribute!"));
if(0 == useAttr)
m_processor->error(DOMString("xsl:key requires a
")+Constants::ATTRNAME_USE+DOMString(" attribute!"));
m_keyDeclarations.push_back(KeyDeclaration(nameAttr, *matchAttr,
*useAttr));
m_needToBuildKeysTable = true;
}
/**
* Push the namespace declarations from the current attribute
* list onto the namespace stack.
*/
void Stylesheet::pushNamespaces(const AttributeList& atts)
{
int nAttrs = atts.getLength();
NamespaceVectorType namespaces;
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname = atts.getName(i);
const DOMString value = atts.getValue(i);
bool isPrefix = startsWith(aname, "xmlns:");
if (equals(aname, "xmlns") || isPrefix)
{
DOMString p = isPrefix ? substring(aname,6) :
DOMString();
NameSpace ns(p, value);
namespaces.push_back(ns);
}
}
m_namespaces.push_back(namespaces);
}
void Stylesheet::popNamespaces()
{
assert(m_namespaces.size());
m_namespaces.pop_back();
}
/**
* See if this is a xmlns attribute or in a non-XSLT.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not used at
* this time).
* @param which The index into the attribute list (not used at this time).
* @return True if this attribute should not be flagged as an error.
*/
bool Stylesheet::isAttrOK(const DOMString& attrName, const AttributeList&
atts, int /*which*/)
{
bool attrOK = equals(attrName, "xmlns") || startsWith(attrName,
"xmlns:");
if(!attrOK)
{
int indexOfNSSep = indexOf(attrName, ':');
if(indexOfNSSep >= 0)
{
DOMString prefix = substring(attrName, 0, indexOfNSSep);
DOMString ns = getNamespaceForPrefixFromStack(prefix);
attrOK = (indexOf(ns,
m_processor->getXSLNameSpaceURLPre()) >= 0);
}
}
return attrOK;
}
/**
* Get the namespace from a qualified name.
*/
DOMString Stylesheet::getNamespaceFromStack(const DOMString& nodeName)
{
int indexOfNSSep = indexOf(nodeName, ':');
DOMString prefix = (indexOfNSSep >= 0) ?
substring(nodeName, 0, indexOfNSSep) : DOMString();
return getNamespaceForPrefixFromStack(prefix);
}
/**
* Get the namespace from a prefix.
*/
DOMString Stylesheet::getNamespaceForPrefix(const DOMString& prefix)
{
return QName::getNamespaceForPrefix(m_namespaceDecls, prefix);
}
/**
* Get the namespace from a prefix.
*/
DOMString Stylesheet::getNamespaceForPrefixFromStack(const DOMString& prefix)
const
{
return QName::getNamespaceForPrefix(m_namespaces, prefix);
}
bool Stylesheet::getYesOrNo(const DOMString& aname, const DOMString& val)
const
{
if(val.equals(Constants::ATTRVAL_YES))
return true;
else if(val.equals(Constants::ATTRVAL_NO))
return false;
else
m_processor->error(val+" is unknown value for "+aname);
return false;
}
/**
* Add a template to the template list.
*/
void Stylesheet::addTemplate(ElemTemplate *tmpl)
{
int pos = 0;
if(0 == m_firstTemplate)
m_firstTemplate = tmpl;
else
{
// @@ JMD: was: can't make this an UnimplementedElement because there's
not a
// setNextSibling method -- is this right ??
ElemTemplateElement *next = m_firstTemplate;
while(0 != next)
{
if(0 == next->getNextSibling())
{
next->setNextSibling(tmpl);
tmpl->setNextSibling(0); // just to play it
safe.
break;
}
pos++;
next = dynamic_cast<ElemTemplateElement
*>(next->getNextSibling());
}
}
if(0 != tmpl->getName())
{
m_namedTemplates.insert(std::make_pair(*tmpl->getName(), tmpl));
}
XPath* xp = tmpl->getMatchPattern();
if(0 != xp)
{
std::vector<DOMString> strings;
xp->getTargetElementStrings(strings);
/* 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
* NOTE: C++ version uses a map keyed on string to a vector of match
patterns
* while the java version uses a map to a linked list
*/
if(0 != strings.size())
{
int nTargets = strings.size();
for(int stringIndex = 0; stringIndex < nTargets;
stringIndex++)
{
DOMString& target = strings[stringIndex];
MatchPattern2* newMatchPat =
new
MatchPattern2(xp->getExpression().getCurrentPattern(),
*xp, *tmpl, pos, target, this);
// See if there's already one there
PatternTableMapType::iterator it =
m_patternTable.find(target);
// New one
if(it == m_patternTable.end())
{
PatternTableListType patternlist;
patternlist.push_back(newMatchPat);
m_patternTable.insert(PatternTableMapType::value_type(target, patternlist));
}
else
{
// Add it to the end of the list
PatternTableListType& patternlist =
(*it).second;
patternlist.push_back(newMatchPat);
}
}
}
}
}
// JMD: removed buildStylesheetTables
// JMD: removed initIncludes
// JMD: removed initImports
/**
* Locate a macro via the "name" attribute.
* @exception XSLProcessorException thrown if the active ProblemListener and
XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
ElemTemplateElement* Stylesheet::findNamedTemplate(const DOMString& name)
const
//throws XSLProcessorException
{
QName qname(name, m_namespaces);
return findNamedTemplate(qname);
}
/**
* Locate a macro via the "name" attribute.
* @exception XSLProcessorException thrown if the active ProblemListener and
XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
ElemTemplateElement* Stylesheet::findNamedTemplate(const QName& qname)
const
//throws XSLProcessorException
{
ElemTemplateElement *namedTemplate = 0;
ElemTemplateElementMapType::const_iterator it =
m_namedTemplates.find(qname);
// Look for the template in the imports
if(it == m_namedTemplates.end())
{
const int nImports = m_imports.size();
for(int i = 0; i < nImports; i++)
{
const Stylesheet* const stylesheet = m_imports[i];
namedTemplate = stylesheet->findNamedTemplate(qname);
if(0 != namedTemplate)
break;
}
}
else
namedTemplate = (*it).second;
if(0 == namedTemplate)
m_processor->warn(DOMString("Could not find macro def named: ")
+
qname.getLocalPart());
return namedTemplate;
}
XString*
Stylesheet::getTopLevelVariable(const DOMString& name) const
{
XString* theResult = m_processor->getTopLevelVariable(name);
if(0 == theResult)
{
const int nImports = m_imports.size();
for(int i = 0; i < nImports; i++)
{
Stylesheet* const stylesheet = m_imports[i];
assert(stylesheet != 0);
theResult = stylesheet->getTopLevelVariable(name);
if(0 != theResult)
{
break;
}
}
}
if(0 == theResult)
{
m_processor->warn(DOMString("Could not find variable def for:
") + name);
}
return theResult;
}
/**
* Given a target element, find the tmpl that best
* matches in the given XSL document, according
* to the rules specified in the xsl draft.
* @param stylesheetTree Where the XSL rules are to be found.
* @param sourceTree Where the targetElem is to be found.
* @param targetElem The element that needs a rule.
* @param mode A string indicating the display mode.
* @param useImports means that this is an xsl:apply-imports commend.
* @param foundStylesheet If non-0, the Stylesheet that the found tmpl
* belongs to will be returned in the foundStylesheet[0].
* @return Rule that best matches targetElem.
* @exception XSLProcessorException thrown if the active ProblemListener and
XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
ElemTemplateElement* Stylesheet::findTemplate(
// java: DOM_Document sourceTree,
const DOM_Node& sourceTree,
const DOM_Node& targetNode) const
{
return findTemplate(sourceTree, targetNode, 0, false, 0);
}
ElemTemplateElement* Stylesheet::findTemplate(
const DOM_Node& sourceTree,
const DOM_Node& targetNode,
const QName* mode,
bool useImports,
Stylesheet* foundStylesheet) const
/*
throws XSLProcessorException,
java.net.MalformedURLException,
java.io.FileNotFoundException,
java.io.IOException
*/
{
bool usedWildcard = false;
if(m_isWrapperless) return m_wrapperlessTemplate;
const ElemTemplateElement* bestMatchedRule = 0;
const MatchPattern2* bestMatchedPattern = 0;
// Syncs with bestMatchedRule
std::vector<const MatchPattern2*> conflicts;
if(useImports == false)
{
//odd that this variable is only set, never read
double highScore = XPath::s_MatchScoreNone;
// Points to the current list of match patterns. Note
// that this may point to more than one table.
const PatternTableListType* matchPatternList = 0;
int targetNodeType = targetNode.getNodeType();
switch(targetNodeType)
{
case DOM_Node::ELEMENT_NODE:
{
//java: DOMString targetName =
m_processor->getParserLiaison().getLocalNameOfNode(targetNode);
DOMString targetName =
DOMServices::getLocalNameOfNode(targetNode);
matchPatternList =
locateMatchPatternList2(targetName, true);
}
break;
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
case DOM_Node::ATTRIBUTE_NODE:
matchPatternList =
locateMatchPatternList2(targetNode.getNodeName(), true);
break;
case DOM_Node::CDATA_SECTION_NODE:
case DOM_Node::TEXT_NODE:
matchPatternList =
locateMatchPatternList2(XPath::PSEUDONAME_TEXT, false);
break;
case DOM_Node::COMMENT_NODE:
matchPatternList =
locateMatchPatternList2(XPath::PSEUDONAME_COMMENT, false);
break;
case DOM_Node::DOCUMENT_NODE:
matchPatternList =
locateMatchPatternList2(XPath::PSEUDONAME_ROOT, false);
break;
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
matchPatternList =
locateMatchPatternList2(XPath::PSEUDONAME_ANY, false);
break;
default:
{
matchPatternList =
locateMatchPatternList2(targetNode.getNodeName(), false);
}
}
if (matchPatternList != 0)
{
DOMString prevPat;
// These are iterators into the current table.
// Note that we may re-seat these iterators to
// point into a different table, if we have
// to match wildcards.
PatternTableListType::const_iterator theCurrentEntry
=
matchPatternList->begin();
PatternTableListType::const_iterator theTableEnd =
matchPatternList->end();
while(theCurrentEntry != theTableEnd)
{
const MatchPattern2* matchPat =
*theCurrentEntry;
const ElemTemplate* rule =
&matchPat->getTemplate();
// We'll be needing to match rules according to
what
// mode we're in.
const QName* 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.
bool haveMode = (0!=mode && !mode->isEmpty());
bool haveRuleMode = (0!=ruleMode &&
!ruleMode->isEmpty());
if ( (!haveMode && !haveRuleMode) || (haveMode
&& haveRuleMode && ruleMode->equals(*mode)) )
{
const DOMString patterns =
matchPat->getPattern();
if((!isEmpty(patterns)) &&
!(!isEmpty(prevPat) &&
equals(prevPat, patterns)))
{
prevPat = patterns;
XPath& xpath =
matchPat->getExpression();
double score = xpath.getMatchScore(targetNode);
if(XPath::s_MatchScoreNone !=
score)
{
const double
priorityVal = rule->getPriority();
const double
priorityOfRule
= (XPath::s_MatchScoreNone !=
priorityVal)
? priorityVal : score;
matchPat->setPriority(priorityOfRule);
const double
priorityOfBestMatched =
(0 !=
bestMatchedPattern) ?
bestMatchedPattern->getPriority() :
XPath::s_MatchScoreNone;
if(priorityOfRule >
priorityOfBestMatched)
{
conflicts.clear();
highScore =
score;
bestMatchedRule
= rule;
bestMatchedPattern = matchPat;
}
else if(priorityOfRule
== priorityOfBestMatched)
{
addObjectIfNotFound(bestMatchedPattern, conflicts);
conflicts.push_back(matchPat);
highScore =
score;
bestMatchedRule
= rule;
bestMatchedPattern = matchPat;
}
}
} // end if(0 != length(patterns))
} // end if if(targetModeString.equals(mode))
theCurrentEntry++;
// We also have to consider wildcard matches.
if(theCurrentEntry == theTableEnd &&
equals(matchPat->getTargetString(), "*") ==
false
&& (DOM_Node::ELEMENT_NODE ==
targetNodeType ||
DOM_Node::ATTRIBUTE_NODE ==
targetNodeType ||
DOM_Node::PROCESSING_INSTRUCTION_NODE == targetNodeType)
)
{
{
assert(usedWildcard==false);
// Should only be here once ??
usedWildcard = true;
PatternTableMapType::const_iterator theTableIterator =
m_patternTable.find("*");
assert(m_patternTable.size());
if (theTableIterator !=
m_patternTable.end())
{
// Re-seat the
iterators...
theCurrentEntry =
(*theTableIterator).second.begin();
theTableEnd =
(*theTableIterator).second.end();
}
}
}
} // end while
} // end if (matchPatternList != 0)
} // end if(useImports == false)
// @@ JMD: Here we are using the imports anyway if bestMatchedRule is
zero,
// instead of just doing if (useImports) {...} else. Is this right ??
// Does this assume that bestMatchedRule will always be non-zero exit
the
// if clause, and, if so, is it an error if it's not ?
// else
if(0 == bestMatchedRule)
{
const int nImports = m_imports.size();
for(int i = 0; i < nImports; i++)
{
const Stylesheet* const stylesheet =
m_imports[i];
bestMatchedRule = stylesheet->findTemplate(sourceTree,
targetNode,
mode,
false,
foundStylesheet);
if(0 != bestMatchedRule)
break;
}
}
const int nConflicts = conflicts.size();
if(nConflicts > 0)
{
const bool quietConflictWarnings =
m_processor->getQuietConflictWarnings();
DOMString conflictsString = (quietConflictWarnings ==
false)
? "Specificity
conflicts found: " : DOMString();
for(int i = 0; i < nConflicts; i++)
{
const MatchPattern2* const conflictPat =
conflicts[i];
if(0 != i)
{
if(quietConflictWarnings == false)
{
conflictsString += ", ";
}
// Find the furthest one towards the bottom of
the document.
if(conflictPat->getPositionInStylesheet() >
bestMatchedPattern->getPositionInStylesheet())
{
bestMatchedPattern = conflictPat;
}
}
else
{
bestMatchedPattern = conflictPat;
}
if(quietConflictWarnings == false)
{
conflictsString += DOMString("\"") +
conflictPat->getPattern() + DOMString("\"");
}
}
bestMatchedRule = &bestMatchedPattern->getTemplate();
if(quietConflictWarnings == false)
{
conflictsString += " ";
conflictsString += "Last found in stylesheet will be
used.";
m_processor->warn(conflictsString);
}
}
if((0 != bestMatchedPattern) && (0 != foundStylesheet))
{
foundStylesheet = bestMatchedPattern->getStylesheet();
}
return const_cast<ElemTemplateElement *>(bestMatchedRule);
}
/**
* Add object to vector if not already there.
*/
void Stylesheet::addObjectIfNotFound(
const MatchPattern2* thePattern,
std::vector<const MatchPattern2*>& theVector)
{
const int n = theVector.size();
bool addIt = true;
for(int i = 0; i < n; i++)
{
if(theVector[i] == thePattern)
{
addIt = false;
break;
}
}
if(addIt == true)
{
theVector.push_back(thePattern);
}
}
const Stylesheet::PatternTableListType*
Stylesheet::locateMatchPatternList2(DOM_Node sourceNode) const
{
assert(sourceNode != 0);
const PatternTableListType* matchPatternList = 0;
switch(sourceNode.getNodeType())
{
case DOM_Node::ELEMENT_NODE:
{
// String targetName =
m_parserLiaison.getExpandedElementName((Element)targetNode);
const DOMString targetName =
DOMServices::getLocalNameOfNode(sourceNode);
matchPatternList = locateMatchPatternList2(targetName,
true);
}
break;
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
case DOM_Node::ATTRIBUTE_NODE:
matchPatternList =
locateMatchPatternList2(sourceNode.getNodeName(), true);
break;
case DOM_Node::CDATA_SECTION_NODE:
case DOM_Node::TEXT_NODE:
matchPatternList =
locateMatchPatternList2(Constants::PSEUDONAME_TEXT, false);
break;
case DOM_Node::COMMENT_NODE:
matchPatternList =
locateMatchPatternList2(Constants::PSEUDONAME_COMMENT, false);
break;
case DOM_Node::DOCUMENT_NODE:
matchPatternList =
locateMatchPatternList2(Constants::PSEUDONAME_ROOT, false);
break;
default:
matchPatternList =
locateMatchPatternList2(sourceNode.getNodeName(), false);
break;
}
return matchPatternList;
}
/**
* Given an element type, locate the start of a linked list of
* possible tmpl matches.
*/
const Stylesheet::PatternTableListType*
Stylesheet::locateMatchPatternList2(
const DOMString& sourceElementType,
bool tryWildCard) const
{
const PatternTableListType* theMatchList = 0;
PatternTableMapType::const_iterator i =
m_patternTable.find(sourceElementType);
if (i != m_patternTable.end())
{
theMatchList = &(*i).second;
assert(theMatchList != 0);
}
else if(tryWildCard == true)
{
i = m_patternTable.find("*");
if (i != m_patternTable.end())
{
theMatchList = &(*i).second;
assert(theMatchList != 0);
}
}
return theMatchList;
}
/**
* Given a valid element key, return the corresponding node list.
*/
const NodeRefListBase*
Stylesheet::getNodeSetByKey(
const DOM_Node&
doc,
const DOMString&
name,
const DOMString&
ref,
const PrefixResolver&
resolver) const
{
const NodeRefListBase *nl = 0;
if(0 != m_keyDeclarations.size())
{
bool foundDoc = false;
int nKeyTables = m_key_tables.size();
for(int i = 0; i < nKeyTables; i++)
{
KeyTable* kt = m_key_tables[i];
if(doc == kt->getDocKey())
{
foundDoc = true;
nl = kt->getNodeSetByKey(name, ref);
break;
}
}
if((0 == nl) && !foundDoc && m_needToBuildKeysTable)
{
KeyTable* kt = new KeyTable(doc,
doc,
resolver,
m_keyDeclarations,
m_processor->getXPathSupport());
m_key_tables.push_back(kt);
if(doc == kt->getDocKey())
{
foundDoc = true;
nl = kt->getNodeSetByKey(name, ref);
}
}
}
// If the nodelist is null at this point, it should
// mean there wasn't an xsl:key declared with the
// given name. So go up the import hierarchy and
// see if one of the imported stylesheets declared it.
if(0 == nl)
{
const int nImports = m_imports.size();
for(int i = 0; i < nImports; i++)
{
Stylesheet* stylesheet = m_imports[i];
nl = stylesheet->getNodeSetByKey(doc, name, ref,
resolver);
if(0 != nl)
break;
}
}
return nl;
}
/**
* Construct a match pattern from a pattern and template.
* @param pat For now a Nodelist that contains old-style element patterns.
* @param template The node that contains the template for this pattern.
* @param isMatchPatternsOnly tells if pat param contains only match
* patterns (for compatibility with old syntax).
*/
Stylesheet::MatchPattern2::MatchPattern2(
const DOMString& pat,
XPath& exp,
// was: a DOM_Element,but is now an ElemTemplate
ElemTemplate& theTemplate,
int
posInStylesheet,
const DOMString& targetString,
Stylesheet* stylesheet) :
m_stylesheet(stylesheet),
m_targetString(targetString),
m_expression(exp),
m_posInStylesheet(posInStylesheet),
m_priority(XPath::s_MatchScoreNone),
m_pattern(pat),
m_template(theTemplate)
{
}
Stylesheet::MatchPattern2::~MatchPattern2()
{
}
// JMD added Thu Sep 30 08:20:29 EDT 1999
/**
* Set the XSLTProcessor of this and all imported stylesheets.
*/
void Stylesheet::setXSLProcessor(XSLTEngineImpl *processor)
{
m_processor = processor;
if(0 != m_topLevelVariables.size())
{
ElemVariableVectorType::const_iterator it;
for(it = m_topLevelVariables.begin();
it != m_topLevelVariables.end(); it++)
{
ElemVariable* var = (*it);
ElemTemplateElement* ete = var;
ete->setXSLProcessor(processor);
}
}
ElemTemplateElement* next = m_firstTemplate;
while(0 != next)
{
next->setXSLProcessor(processor);
next = dynamic_cast<ElemTemplateElement
*>(next->getNextSibling());
}
if (0 != m_whitespaceStrippingElements.size())
{
XPathVectorType::const_iterator it;
for(it = m_whitespaceStrippingElements.begin();
it != m_whitespaceStrippingElements.end(); it++)
{
const XPath* xpath = (*it);
// @@ LATER
// xpath.m_callbacks = processor->m_parserLiaison;
}
}
if (0 != m_whitespacePreservingElements.size())
{
XPathVectorType::const_iterator it;
for(it = m_whitespacePreservingElements.begin();
it != m_whitespacePreservingElements.end(); it++)
{
const XPath* xpath = (*it);
// @@ LATER
// xpath.m_callbacks = processor->m_parserLiaison;
}
}
if (0 != m_imports.size())
{
StylesheetVectorType::const_iterator it;
for(it = m_imports.begin(); it != m_imports.end(); it++)
{
Stylesheet &stylesheet = (**it);
stylesheet.setXSLProcessor(processor);
}
}
}
void Stylesheet::addExtensionNamespace (const DOMString& uri,
ExtensionNSHandler* nsh)
{
m_extensionNamespaces.insert(std::make_pair(uri, nsh));
/*
@@ JMD: Not in XMLParserLiaisonDefault
XMLParserLiaisonDefault xld =
((XMLParserLiaisonDefault)m_XSLProcessor->m_parserLiaison);
xld.addExtensionNamespace (uri, (ExtensionFunctionHandler) nsh);
*/
}
/**
* Add this and all included stylesheets to the source docs table.
*/
void Stylesheet::addToDocTables(const DOMString& styleBaseURI)
// throws SAXException
{
XSLTEngineImpl::SourceDocumentsMapType sourceDocs =
m_processor->getSourceDocsTable();
URL* url = m_processor->getURLFromString(m_baseIdent, styleBaseURI);
sourceDocs.insert(XSLTEngineImpl::SourceDocumentsMapType::value_type(url->getURL(),
DOM_UnimplementedDocument(m_stylesheetRoot)));
// @@ TODO: Include base dirs are lost right now... need to fix this.
if (0 != m_imports.size())
{
StylesheetVectorType::const_iterator it;
for(it = m_imports.begin(); it != m_imports.end(); it++)
{
Stylesheet &stylesheet = (**it);
stylesheet.addToDocTables(DOMString(url->getURL()));
}
}
delete url;
}
void Stylesheet::pushTopLevelVariables(ParamVectorType& topLevelParams)
{
// try
{
int i, nImports = m_imports.size();
for(i = 0; i < nImports; i++)
{
Stylesheet* const stylesheet = m_imports[i];
stylesheet->pushTopLevelVariables(topLevelParams);
}
int nVars = m_topLevelVariables.size();
for(i = 0; i < nVars; i++)
{
ElemVariable* var = m_topLevelVariables[i];
bool isParam = (Constants::ELEMNAME_PARAMVARIABLE ==
var->getXSLToken());
if(isParam)
{
isParam = false;
int n = topLevelParams.size();
for(int k = 0; k < n; k++)
{
Arg& a = topLevelParams[k];
if(a.getName().equals(*(var->getName())))
{
isParam = true;
XObject *pXO = 0;
const DOMString& expr =
a.getExpression();
if(length(expr) != 0)
{
ElementPrefixResolverProxy theProxy(DOM_UnimplementedElement(this),
m_processor->getXPathSupport());
XPath* selectPattern =
m_processor->createXPath(expr,
theProxy);
pXO =
selectPattern->execute(m_processor->getRootDoc(),
theProxy,
m_processor->getContextNodeList());
a.setXObjectPtr(pXO);
a.setExpression(0);
}
m_processor->getVariableStacks().pushVariable(a.getName(),
pXO,
DOM_UnimplementedElement(this));
break;
}
}
}
else
{
DOM_Document& doc = m_processor->m_rootDoc;
// java: var->execute(*m_processor, doc, doc, 0);
var->execute(*m_processor, doc, doc, QName());
}
}
}
/*
catch(Exception e)
{
// Turn it into a runtime exception.
throw new XSLProcessorException(e);
}
*/
}
/**
* Add an attribute set to the list.
*/
void Stylesheet::addAttributeSet(
const QName& /*qname */,
ElemAttributeSet* attrSet)
{
m_attributeSets.push_back(attrSet);
}
/**
* Add the attributes from the named attribute sets to the attribute list.
* TODO: Error handling for: "It is an error if there are two attribute sets
* with the same expanded-name and with equal import precedence and that both
* contain the same attribute unless there is a definition of the attribute
* set with higher import precedence that also contains the attribute."
*/
void Stylesheet::applyAttrSets(
const QNameVectorType& attributeSetsNames,
XSLTEngineImpl* processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
/*
java: Difference from Java code is we have map of qnames to attribute
sets
instead of a vector where we look for the matching qname in the vector
@@ Is this right ??
*/
int nNames = attributeSetsNames.size();
if(0 != nNames)
{
int i;
// Process up the import chain...
const int nImports = m_imports.size();
for(i = 0; i < nImports; i++)
{
Stylesheet* const stylesheet = m_imports[i];
stylesheet->applyAttrSets(attributeSetsNames,
processor, sourceTree, sourceNode, mode);
}
for(i = 0; i < nNames; i++)
{
const QName& qname = attributeSetsNames[i];
int nSets = m_attributeSets.size();
for(int k = 0; k < nSets; k++)
{
ElemAttributeSet* attrSet =
m_attributeSets[k];
if(qname.equals(attrSet->getQName()))
attrSet->execute(*processor,
sourceTree, sourceNode, mode);
}
}
}
}
void Stylesheet::error(const DOMString& msg) const
{
getProcessor()->error(msg);
}
const NamespaceVectorType& Stylesheet::getNamespaceDecls() const
{
return m_namespaceDecls;
}
void Stylesheet::setNamespaceDecls(const NamespaceVectorType& ns)
{
m_namespaceDecls = ns;
}
NamespaceVectorType Stylesheet::getCurrentNamespace() const
{
assert (m_namespaces.size() > 0);
if (m_namespaces.size() > 0)
return m_namespaces.back();
else
return m_emptyNamespace;
}
////////////////////////////////////////////////////////////////////
// JAVA Code not implemented
////////////////////////////////////////////////////////////////////
#ifdef JAVANOTIMPLEMENTED
/**
* Extension to be used when serializing to disk.
*/
const std::string STYLESHEET_EXT(".lxc");
/**
* Read the stylesheet from a serialization stream.
*/
private void readObject(ObjectInputStream stream)
throws IOException
{
try
{
stream.defaultReadObject();
}
catch(ClassNotFoundException cnfe)
{
throw new XSLProcessorException(cnfe);
}
m_includeStack.clear();
}
private void writeObject(ObjectOutputStream stream)
throws IOException
{
stream.defaultWriteObject();
}
#endif // JAVANOTIMPLEMENTED
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/Stylesheet.hpp
Index: Stylesheet.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_STYLESHEET_HEADER_GUARD)
#define XALAN_STYLESHEET_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <list>
#include <map>
#include <vector>
#include <stack>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOMString.hpp>
#include <util/URL.hpp>
#include "KeyTable.hpp"
#include "ElemTemplate.hpp"
#include "ElemVariable.hpp"
#include "ElemAttributeSet.hpp"
#include "Arg.hpp"
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NameSpace.hpp>
#include <XPath/QName.hpp>
#include <XPath/XPath.hpp>
#include <DOMSupport/UnimplementedDocument.hpp>
#include <DOMSupport/UnimplementedElement.hpp>
#include "XSLTEngineImpl.hpp"
#include "Constants.hpp"
class AttributeListImpl;
class NodeRefListBase;
class PrefixResolver;
class XString;
class StylesheetRoot;
class ExtensionNSHandler;
/**
* This class represents the base stylesheet or an
* "import" stylesheet. "include" stylesheets are
* combined with the including stylesheet.
*/
class XALAN_XSLT_EXPORT Stylesheet : public UnimplementedDocument, public
UnimplementedElement
{
protected:
/**
* The root of the stylesheet, where all the tables common to all
* stylesheets are kept.
*/
StylesheetRoot* m_stylesheetRoot;
/**
* Reference back to the owning XSLTProcessor object.
* JMD: This has to be a pointer,not a reference because of
setXSLProcessor
*/
XSLTEngineImpl* m_processor;
/**
* The base URL of the XSL document.
*/
DOMString m_baseIdent;
private:
/**
* The root XSL stylesheet.
*/
DOM_Document m_document;
/**
* Table of tables of element keys. See KeyTable.
*/
typedef std::vector<KeyTable*> KeyTableVectorType;
mutable KeyTableVectorType m_key_tables;
/**
* Table of KeyDeclaration objects, which are set by the
* xsl:key element.
*/
typedef std::vector<KeyDeclaration>
KeyDeclarationVectorType;
KeyDeclarationVectorType m_keyDeclarations;
/**
* This is set to true if an xsl:key directive is found.
* Mainly for use by the XMLParserLiaison classes for
* optimized processing of ids.
* @serial
*/
bool m_needToBuildKeysTable;
public: // @@ JMD: temporary, needs accessor method
/**
* A vector of the -imported- XSL Stylesheets.
*/
typedef std::vector<Stylesheet*> StylesheetVectorType;
typedef std::vector<URL> URLStackType;
typedef std::vector<NameSpace> NamespaceVectorType;
typedef std::vector<NamespaceVectorType>
NamespacesStackType;
// @@ JMD: temporary
virtual NodeImpl* cloneNode(bool /*deep*/) { return 0; }
private:
StylesheetVectorType m_imports;
/**
* The default template to use for xsl:apply-templates when
* a select attribute is not found.
*/
XPath* m_defaultATXpath;
/**
* A stack to keep track of the result tree namespaces.
*/
NamespacesStackType m_namespaces;
/**
* A list of namespace declarations,
* for mapping from prefix to namespace URI.
*/
NamespaceVectorType m_namespaceDecls;
/**
* This is pushed on the m_resultNameSpaces stack 'till a xmlns
attribute is
* found.
*/
static NamespaceVectorType m_emptyNamespace;
virtual bool isXSLTagOfType(
const DOM_Node& node,
int tagType) const;
/**
* Given an element, return an attribute value in the form of a string.
* @param el The element from where to get the attribute.
* @param key The name of the attribute.
* @param contextNode The context to evaluate the
* attribute value template.
* @return Attribute value.
*/
virtual DOMString getAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& contextNode);
/**
* Given an element, return an attribute value in the form of a string.
*/
virtual DOMString getAttrVal(
const DOM_Element& el,
const DOMString& key);
/**
* Given an element, return an attribute value in the form of a string,
* processing attributes as need be.
* @param el The element from where to get the attribute.
* @param key The name of the attribute.
* @param contextNode The context to evaluate the
* attribute value template.
* @return Attribute value.
*/
virtual DOMString getProcessedAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& contextNode);
virtual DOMString getNodeData(const DOM_Node& node) const;
/**
* Tells if the stylesheet tables need to be rebuilt.
*/
bool m_tablesAreInvalid;
/**
* Tells if the stylesheet is without an xsl:stylesheet and xsl:template
* wrapper.
*/
bool m_isWrapperless;
/**
* The manufactured template if there is no wrapper.
*/
//@@ reference or pointer?
ElemTemplate *m_wrapperlessTemplate;
/**
* The table of extension namespaces.
*/
typedef std::map<DOMString, ExtensionNSHandler *> ExtensionNamespacesMap;
ExtensionNamespacesMap m_extensionNamespaces;
/**
* The first template of the template children.
*/
ElemTemplateElement *m_firstTemplate;
/**
* A stack of who's including who is needed in order to support "It is an
* error if a stylesheet directly or indirectly includes itself."
*/
//typedef std::vector<URL> URLStackType;
URLStackType m_includeStack;
/**
* Tell if this stylesheet has the default space handling
* turned off or on according to the xml:space attribute.
* @serial
*/
bool m_defaultSpace;
// @@ JMD: temporary -- needs accessor
public:
/**
* A lookup table of all space preserving elements.
*/
typedef std::vector<XPath*> XPathVectorType;
XPathVectorType m_whitespacePreservingElements;
/**
* A lookup table of all space stripping elements.
*/
XPathVectorType m_whitespaceStrippingElements;
private:
/**
* Keyed on string macro names, and holding values that are macro
elements
* in the XSL DOM tree. Initialized in initMacroLookupTable, and used in
* findNamedTemplate.
*/
typedef std::map<QName, ElemTemplateElement*> ElemTemplateElementMapType;
ElemTemplateElementMapType m_namedTemplates;
/**
* Table for defined constants, keyed on the names.
*/
typedef std::vector<ElemVariable*> ElemVariableVectorType;
ElemVariableVectorType m_topLevelVariables;
/**
* The version of XSL that was declared.
*/
static double m_XSLTVerDeclared;
public:
static double getXSLTVerDeclared()
{
return m_XSLTVerDeclared;
}
static void setXSLTVerDeclared(double ver)
{
m_XSLTVerDeclared = ver;
}
/**
* Constructor for a Stylesheet needs a Document.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
Stylesheet(
StylesheetRoot& root,
XSLTEngineImpl* processor,
const DOMString& baseIdentifier);
virtual ~Stylesheet();
XSLTEngineImpl* getProcessor() const { return m_processor; }
void setProcessor(XSLTEngineImpl* processor) { m_processor = processor;
}
StylesheetRoot* getStylesheetRoot() { return m_stylesheetRoot; }
XPath* getDefaultATXpath () const
{
return m_defaultATXpath;
}
void
setDefaultATXpath (XPath* defaultATXpath)
{
m_defaultATXpath = defaultATXpath;
}
const NamespacesStackType& getNamespaces() const { return m_namespaces;
}
const NamespaceVectorType& getNamespaceDecls() const;
void setNamespaceDecls(const NamespaceVectorType& ns);
/*
* Get the top entry on the namespace stack, or 0, if
* there is nothing on the stack.
*/
NamespaceVectorType getCurrentNamespace() const;
/**
* Push the namespace declarations from the current attribute
* list onto the namespace stack.
*/
void pushNamespaces(const AttributeList& atts);
/**
* Pop a namespace declaration from the namespace stack.
*/
void popNamespaces();
// See if this is a xmlns attribute or in a non-XSLT.
bool isAttrOK(const DOMString& attrName, const AttributeList& atts, int
which);
// Get the namespace from a qualified name.
DOMString getNamespaceFromStack(const DOMString& nodeName);
// Get the namespace from a prefix.
DOMString getNamespaceForPrefix(const DOMString& prefix);
// Get the namespace from a prefix.
DOMString getNamespaceForPrefixFromStack(const DOMString& prefix) const;
void addTemplate(ElemTemplate *tmpl);
/**
* Process an attribute that has the value of 'yes' or 'no'.
*/
virtual bool getYesOrNo( const DOMString& aname, const DOMString&
val) const;
/**
* Tell if this is the root of the stylesheet tree.
*/
virtual bool isRoot() const;
// JMD added Thu Sep 30 08:20:29 EDT 1999
// Get the base identifier with which this stylesheet is associated.
const DOMString getBaseIdentifier() { return m_baseIdent; }
void setBaseIdentifier(const DOMString& str) { m_baseIdent = str; }
// Add this and all included stylesheets to the source docs table.
void addToDocTables(const DOMString& styleBaseURI);
/**
* Add an attribute set to the list.
*
*/
void addAttributeSet(
const QName& qname,
ElemAttributeSet* attrSet);
typedef std::vector<QName> QNameVectorType;
void
applyAttrSets(
const QNameVectorType& attributeSetsNames,
XSLTEngineImpl* processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
const DOMString& getBaseURL() const
{
return m_baseIdent;
}
bool isDefaultSpaceProcessing() const
{
return m_defaultSpace;
}
void setDefaultSpaceProcessing(bool bEnabled)
{
m_defaultSpace = bEnabled;
}
StylesheetVectorType& getImports()
{
return m_imports;
}
ElemTemplate *getWrapperlessTemplate()
{
return m_wrapperlessTemplate;
}
void setWrapperlessTemplate(ElemTemplate * templ)
{
m_wrapperlessTemplate = templ;
}
bool isWrapperless() const
{
return m_isWrapperless;
}
void setWrapperless(bool b)
{
m_isWrapperless = b;
}
URLStackType& getIncludeStack()
{
return m_includeStack;
}
/**
* Process the xsl:key element.
*
* (Notes to myself)
* What we need to do is:
* 1) As this function is called, build a table of KeyDeclarations.
* 2) During either XML processing, or upon request, walk the XML
* document tree, and build a hash table:
* a) keyed by name,
* b) each with a value of a hashtable, keyed by the value returned by
* the use attribute,
* c) each with a value that is a nodelist.
* Thus, for a given key or keyref, look up hashtable by name,
* look up the nodelist by the given reference.
*/
virtual void processKeyElement(ElemTemplateElement *nsContext, const
AttributeList& atts);
// throws XSLProcessorException
private:
#if OUT
/**
* Process imports, includes, macros, templates, etc.
* into tables of various types.
* @param stylesheet Probably a stylesheet element,
* though this may later be an xsl:module element.
*/
virtual
void
buildStylesheetTables(
const DOM_Element& stylesheet,
const DOMString& base);
@@ OUT ?
/**
* Get a list of the included documents into a vector.
*/
virtual
void
initIncludes(
const DOM_Element& includedStyles,
const DOMString& base);
/**
* Get a list of the imported documents into a vector.
*/
virtual
void
initImports(const DOM_Element& includedStyles);
#endif // OUT
public:
/**
* Locate a macro via the "name" attribute.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual ElemTemplateElement* findNamedTemplate(const DOMString& name)
const;
/**
* Locate a macro via the "name" attribute.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual ElemTemplateElement* findNamedTemplate(const QName& qname)
const;
/**
* Given the name of a constant, return a string value.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual
XString*
getTopLevelVariable(const DOMString& name) const;
/**
* Given a target element, find the template that best
* matches in the given XSL document, according
* to the rules specified in the xsl draft.
* @param stylesheetTree Where the XSL rules are to be found.
* @param sourceTree Where the targetElem is to be found.
* @param targetElem The element that needs a rule.
* @return Rule that best matches targetElem.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual
ElemTemplateElement*
findTemplate(
// java: DOM_Document sourceTree,
const DOM_Node& sourceTree,
const DOM_Node& targetNode) const;
/**
* Given a target element, find the template that best
* matches in the given XSL document, according
* to the rules specified in the xsl draft.
* @param stylesheetTree Where the XSL rules are to be found.
* @param sourceTree Where the targetElem is to be found.
* @param targetElem The element that needs a rule.
* @param mode A string indicating the display mode.
* @param useImports means that this is an xsl:apply-imports commend.
* @param foundStylesheet If non-null, the Stylesheet that the found
template
* belongs to will be returned in the foundStylesheet[0].
* @return Rule that best matches targetElem.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual
ElemTemplateElement*
findTemplate(
const DOM_Node& sourceTree,
const DOM_Node& targetNode,
const QName* mode,
bool useImports,
// @@ java: this is an array, although only first
element seems to be
// used
Stylesheet* foundStylesheet) const;
/**
* A class to contain a match pattern and it's corresponding template.
* This class also defines a node in a match pattern linked list.
*/
class MatchPattern2
{
public:
/**
* Construct a match pattern from a pattern and template.
* @param pat For now a Nodelist that contains old-style
element patterns.
* @param template The node that contains the template for this
pattern.
* @param isMatchPatternsOnly tells if pat param contains only
match
* patterns (for compatibility with old syntax).
*/
MatchPattern2(
const DOMString& pat,
XPath& exp,
// JMD: Was DOM_Element theTemplate,
ElemTemplate& theTemplate,
int
posInStylesheet,
const DOMString& targetString,
Stylesheet* stylesheet);
~MatchPattern2();
Stylesheet* getStylesheet() const { return m_stylesheet; }
const DOMString& getTargetString() const { return
m_targetString; }
XPath& getExpression() const { return m_expression; }
int getPositionInStylesheet() const { return m_posInStylesheet;
}
const DOMString& getPattern() const { return m_pattern; }
const ElemTemplate& getTemplate() const { return m_template; }
double getPriority() const { return m_priority; }
// This is const because m_priority is mutable, which is an
artifact of
// the design and our Java heritage.
void setPriority(double thePriority) const { m_priority =
thePriority; }
private:
Stylesheet* const m_stylesheet;
const DOMString m_targetString;
XPath& m_expression;
const int m_posInStylesheet;
const DOMString m_pattern;
ElemTemplate& m_template; // ref to the
corresponding template
/**
* Transient... only used to track priority while processing.
*/
mutable double m_priority;
private:
// Not implemented...
MatchPattern2();
MatchPattern2& operator=(const MatchPattern2&);
};
static void
addObjectIfNotFound(
const MatchPattern2*
thePattern,
std::vector<const MatchPattern2*>& theVector);
private:
/**
* This table is keyed on the target elements
* of patterns, and contains linked lists of
* the actual patterns that match the target element
* to some degree of specifity.
*/
// VC++ seems to have some issues with typedefs and scoping.
#if defined(_MSC_VER)
public:
#endif
typedef std::list<MatchPattern2*>
PatternTableListType;
typedef std::map<DOMString, PatternTableListType>
PatternTableMapType;
#if defined(_MSC_VER)
private:
#endif
/**
* This table is keyed on the target elements of patterns, and contains
linked
* lists of the actual patterns that match the target element to some
degree
* of specifity.
*/
PatternTableMapType m_patternTable;
/**
* Table of attribute sets, keyed by set name.
*/
// This can't be a map, since you can have multiple attribute sets of
the
// same name, could be a multimap but why bother
typedef std::vector<ElemAttributeSet*> AttributeSetMapType;
AttributeSetMapType m_attributeSets;
public:
/**
* Given a source node, locate the start of a list of
* possible template matches, according to its type.
*/
const PatternTableListType*
locateMatchPatternList2(DOM_Node sourceNode) const;
/**
* Given an element type, locate the start of a list of
* possible template matches.
*/
const PatternTableListType*
locateMatchPatternList2(
const DOMString& sourceElementType,
bool tryWildCard = false)
const;
/**
* Given an element cloned into the result tree, and a value
* from an xsl:use attribute, then add the attributes
* from the defined attribute sets named.
* @param xslUseValue The value obtained from an xsl:use attribute.
* @param resultTreeElem An element cloned from a template
* element.
*/
/**
* Given a valid element key, return the corresponding node list.
*/
const NodeRefListBase* getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const;
/**
* Set the XSLTProcessor of this and all imported stylesheets.
*/
void setXSLProcessor(XSLTEngineImpl *processor);
/**
* Add an extension namespace handler. This provides methods for calling
* an element extension as well as for function stuff (which is passed
* on to XPath).
*
* @param uri the URI of the extension namespace.
* @param nsh handler
*/
void addExtensionNamespace (const DOMString& uri, ExtensionNSHandler*
nsh);
/**
* Return the handler for a given extension namespace.
*
* @param uri the URI of the extension namespace.
*/
ExtensionNSHandler* lookupExtensionNSHandler (const DOMString& uri)
{
ExtensionNamespacesMap::const_iterator it =
m_extensionNamespaces.find(uri);
return it == m_extensionNamespaces.end() ? 0 : (*it).second;
}
/**
* Get the type of the node. We'll pretend we're a Document.
*/
virtual short getNodeType() { return DOM_Node::DOCUMENT_NODE; }
void error(const DOMString& msg) const;
/** Unimplemented. */
/*
DOM_DocumentType* getDoctype()
{ error("getDoctype not supported!"); return 0; }
DOM_DOMImplementation* getImplementation()
{ error("getImplementation not supported!"); return 0; }
DOM_Element* getDocumentElement()
{ error("getDocumentElement not supported!"); return 0; }
DOM_Element* createElement(DOMString tagName)
// throws DOMException
{ error("createElement not supported!"); return 0; }
DOM_DocumentFragment* createDocumentFragment()
{ error("createDocumentFragment not supported!"); return 0; }
DOM_Text* createTextNode(DOMString data)
{ error("createTextNode not supported!"); return 0; }
DOM_Comment* createComment(DOMString data)
{ error("createComment not supported!"); return 0; }
DOM_CDATASection* createCDATASection(DOMString data)
//throws DOMException
{ error("createCDATASection not supported!"); return 0; }
DOM_ProcessingInstruction* createProcessingInstruction(DOMString&
target,
DOMString& data)
//throws DOMException
{ error("createProcessingInstruction not supported!"); return 0; }
DOM_Attr* createAttribute(DOMString& name) // throws DOMException
{ error("createAttribute not supported!"); return 0; }
DOM_EntityReference* createEntityReference(DOMString& name) // throws
DOMException
{ error("createEntityReference not suppo->ted!"); return 0; }
DOM_NodeList* getElementsByTagName(DOMString& tagname)
{ error("getElementsByTagName not supported!"); return 0; }
*/
/**
* Set a top level variable, to be serialized with the rest of
* the stylesheet.
* @param var A top-level variable declared with xsl:variable or
xsl:param-variable.
*/
void setTopLevelVariable(ElemVariable* var) {
m_topLevelVariables.push_back(var); }
typedef std::vector<Arg> ParamVectorType;
void pushTopLevelVariables(ParamVectorType& topLevelParams);
}; // end Stylesheet class definition
#endif // XALAN_STYLESHEET_HEADER_GUARD
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/StylesheetHandler.cpp
Index: StylesheetHandler.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "StylesheetHandler.hpp"
#include <sax/SaxException.hpp>
#include <XMLSupport/Formatter.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include "ElemLiteralResult.hpp"
#include "ElemText.hpp"
#include "ElemTextLiteral.hpp"
#include "ElemParam.hpp"
#include "ElemEmpty.hpp"
#include "ElemApplyTemplates.hpp"
#include "ElemCallTemplate.hpp"
#include "ElemWithParam.hpp"
#include "ElemForEach.hpp"
#include "ElemApplyImport.hpp"
#include "ElemValueOf.hpp"
#include "ElemNumber.hpp"
#include "ElemIf.hpp"
#include "ElemChoose.hpp"
#include "ElemWhen.hpp"
#include "ElemOtherwise.hpp"
#include "ElemCopyOf.hpp"
#include "ElemCopy.hpp"
#include "ElemText.hpp"
#include "ElemUse.hpp"
#include "ElemElement.hpp"
#include "ElemPI.hpp"
#include "ElemComment.hpp"
#include "ElemMessage.hpp"
#include "ElemAttribute.hpp"
#include "ElemExtensionCall.hpp"
#include "StylesheetRoot.hpp"
#include "ExtensionNSHandler.hpp"
/**
* This class processes a stylesheet via SAX events, and inits
* the given stylesheet. If you need to alter the code in here,
* it is not for the faint-of-heart, due to the state tracking
* that has to be done due to the SAX event model.
*/
StylesheetHandler::StylesheetHandler(XSLTEngineImpl& processor,
Stylesheet& stylesheetTree) :
FormatterListener(),
m_processor(processor),
m_stylesheet(stylesheetTree),
m_includeBase(m_stylesheet.getBaseIdentifier()),
m_pTemplate(0),
m_pLastPopped(0),
m_inTemplate(false),
m_foundStylesheet(false),
m_foundNotImport(false),
m_inLXSLTScript(false),
m_LXSLTScriptBody(),
m_LXSLTScriptLang(),
m_LXSLTScriptSrcURL(),
m_pLXSLTExtensionNSH(0),
m_pElemStack(new ElemTemplateStackType())
{
}
StylesheetHandler::~StylesheetHandler()
{
m_pElemStack = 0;
m_pTemplate = 0;
m_pLastPopped = 0;
m_pLXSLTExtensionNSH = 0;
}
/**
* Receive an object for locating the origin of SAX document events.
*
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.</p>
*
* <p>Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.</p>
*
* @param locator An object that can return the location of
* any SAX document event.
* @see org.xml.sax.Locator
*/
void StylesheetHandler::setDocumentLocator(Locator* const locator)
{
m_processor.m_stylesheetLocatorStack.push_back(locator);
}
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
void StylesheetHandler::startDocument()
{
m_pendingException = "";
// No other action for the moment.
}
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
void StylesheetHandler::endDocument()
{
if(!m_processor.m_stylesheetLocatorStack.empty())
{
m_processor.m_stylesheetLocatorStack.pop_back();
}
if (!isEmpty(m_pendingException))
{
throw SAXException(toCharArray(m_pendingException));
}
}
/**
* See if this is a xmlns attribute, and, if so, process it.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not used at
* this time).
* @param which The index into the attribute list (not used at this time).
* @return True if this is a namespace name.
*/
bool StylesheetHandler::isAttrOK(const DOMString& attrName, const
AttributeList& atts, int which)
{
return m_stylesheet.isAttrOK(attrName, atts, which);
}
/**
* Tell whether or not this is a xml:space attribute and, if so, process it.
*
* @param aname The name of the attribute in question.
* @param atts The attribute list that owns the attribute.
* @param which The index of the attribute into the attribute list.
* @return True if this is a xml:space attribute.
*/
bool StylesheetHandler::processSpaceAttr(const DOMString& aname, const
AttributeList& atts, int which)
{
bool isSpaceAttr = equals(aname, "xml:space");
if(isSpaceAttr)
{
const DOMString spaceVal = atts.getValue(which);
if(equals(spaceVal, "default"))
{
m_stylesheet.setDefaultSpaceProcessing(true);
}
else if(equals(spaceVal, "preserve"))
{
m_stylesheet.setDefaultSpaceProcessing(false);
}
else
{
throw SAXException("xml:space has an illegal value");
}
}
return isSpaceAttr;
}
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param atts The attributes attached to the element, if any.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see org.xml.sax.AttributeList
*/
void StylesheetHandler::startElement (const XMLCh* const name, AttributeList&
atts)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
try
{
m_whiteSpaceElems.erase(m_whiteSpaceElems.begin(),m_whiteSpaceElems.end());
Locator* locator = m_processor.m_stylesheetLocatorStack.empty() ? 0 :
(m_processor.m_stylesheetLocatorStack.back());
int lineNumber = (0 != locator) ? locator->getLineNumber() : 0;
int columnNumber = (0 != locator) ? locator->getColumnNumber() : 0;
if(false)
{
DOMString id;
if (locator)
if (locator->getPublicId())
id = locator->getPublicId();
else
id = locator->getSystemId();
assert(locator);
// if(0 != locator)
// System.out.println(id + "; line " + lineNumber +
"; "+columnNumber);
}
// First push namespaces
m_stylesheet.pushNamespaces(atts);
DOMString ns = m_stylesheet.getNamespaceFromStack(name);
int index = indexOf(name,':');
DOMString localName = (index < 0) ? DOMString(name) :
substring(name,index+1);
ElemTemplateElement* elem = 0;
unsigned origStackSize = m_pElemStack->size();
if(startsWith(ns,m_processor.getXSLNameSpaceURLPre()))
{
if(!isEmpty(m_processor.getXSLNameSpaceURL()))
m_processor.setXSLNameSpaceURL(ns);
if(false == m_foundStylesheet)
{
m_stylesheet.getStylesheetRoot()->initDefaultRule();
m_stylesheet.setWrapperless(false);
}
XSLTEngineImpl::AttributeKeysMapType::const_iterator iter=
XSLTEngineImpl::getElementKeys().find(localName);
int xslToken = (iter!= XSLTEngineImpl::getElementKeys().end())
? (*iter).second : -2;
if(!m_inTemplate)
{
if(m_foundStylesheet && (Constants::ELEMNAME_IMPORT !=
xslToken))
{
m_foundNotImport = true;
}
switch(xslToken)
{
case Constants::ELEMNAME_TEMPLATE:
m_pTemplate = new ElemTemplate(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
m_pElemStack->push_back(m_pTemplate);
m_inTemplate = true;
m_stylesheet.addTemplate(m_pTemplate);
break;
case Constants::ELEMNAME_CSSSTYLECONVERSION:
m_processor.setTranslateCSS(true);
break;
case Constants::ELEMNAME_EXTENSION:
{
if(!equalsIgnoreCase(ns,m_processor.getXSLT4JNameSpaceURL()))
{
m_processor.warn("Old syntax: the functions instruction should
use a url of "+m_processor.getXSLT4JNameSpaceURL());
}
// m_processor.handleFunctionsInstruction((Element)child);
}
break;
case Constants::ELEMNAME_VARIABLE:
case Constants::ELEMNAME_PARAMVARIABLE:
{
ElemVariable* varelem =
(Constants::ELEMNAME_PARAMVARIABLE == xslToken)
? new ElemParam(m_processor,
m_stylesheet,
name, atts,
lineNumber, columnNumber)
: new ElemVariable(m_processor,
m_stylesheet,
name, atts,
lineNumber,
columnNumber);
m_pElemStack->push_back(varelem);
m_inTemplate = true; // fake it out
m_stylesheet.setTopLevelVariable(varelem);
varelem->setTopLevel(true);
}
break;
case Constants::ELEMNAME_LOCALE:
m_processor.warn("xsl:locale not yet supported!");
break;
case Constants::ELEMNAME_PRESERVESPACE:
case Constants::ELEMNAME_STRIPSPACE:
{
ElemEmpty nsNode(m_processor, m_stylesheet, name, atts,
lineNumber, columnNumber);
int nAttrs = atts.getLength();
bool foundIt = false;
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname = atts.getName(i);
if(equals(aname, Constants::ATTRNAME_ELEMENTS))
{
foundIt = true;
StringTokenizer tokenizer(atts.getValue(i), " \t\n\r");
while(tokenizer.hasMoreTokens())
{
// Use only the root, at least for right now.
const DOMString wildcardName = tokenizer.nextToken();
/**
* Creating a match pattern is too much overhead, but it's a
reasonably
* easy and safe way to do this right now. TODO: Validate
the pattern
* to make sure it's a WildcardName.
*/
XPath* matchPat =
m_processor.createMatchPattern(wildcardName, nsNode);
if(Constants::ELEMNAME_PRESERVESPACE == xslToken)
{
m_stylesheet.getStylesheetRoot()->m_whitespacePreservingElements.push_back(matchPat);
}
else
{
m_stylesheet.getStylesheetRoot()->m_whitespaceStrippingElements.push_back(matchPat);
}
}
}
else if(!isAttrOK(aname, atts, i))
{
m_stylesheet.error(DOMString(name) + " has an
illegal attribute: " + aname);
}
}
if(!foundIt)
{
DOMString msg("(StylesheetHandler) " +
DOMString(name) +
" requires a " +
Constants::ATTRNAME_ELEMENTS + " attribute!");
throw SAXException(toCharArray(msg));
}
}
break;
case Constants::ELEMNAME_KEY:
{
ElemEmpty nsContext(m_processor, m_stylesheet, name, atts,
lineNumber, columnNumber);
m_stylesheet.processKeyElement(&nsContext, atts);
}
break;
case Constants::ELEMNAME_DEFINEATTRIBUTESET:
{
m_inTemplate = true; // fake it out
ElemAttributeSet* attrSet = new ElemAttributeSet(m_processor,
m_stylesheet,
name, atts,
lineNumber,
columnNumber);
m_pElemStack->push_back(attrSet);
}
break;
case Constants::ELEMNAME_INCLUDE:
processInclude(name, atts);
break;
case Constants::ELEMNAME_IMPORT:
processImport(name, atts);
break;
case Constants::ELEMNAME_OUTPUT:
m_stylesheet.getStylesheetRoot()->processOutputSpec(name, atts);
break;
case Constants::ELEMNAME_WITHPARAM:
case Constants::ELEMNAME_ATTRIBUTE:
case Constants::ELEMNAME_APPLY_TEMPLATES:
case Constants::ELEMNAME_USE:
case Constants::ELEMNAME_CHILDREN:
case Constants::ELEMNAME_CHOOSE:
case Constants::ELEMNAME_COMMENT:
case Constants::ELEMNAME_CONSTRUCT:
case Constants::ELEMNAME_CONTENTS:
case Constants::ELEMNAME_COPY:
case Constants::ELEMNAME_COPY_OF:
case Constants::ELEMNAME_DISPLAYIF:
case Constants::ELEMNAME_EVAL:
case Constants::ELEMNAME_EXPECTEDCHILDREN:
case Constants::ELEMNAME_FOREACH:
case Constants::ELEMNAME_IF:
case Constants::ELEMNAME_CALLTEMPLATE:
case Constants::ELEMNAME_MESSAGE:
case Constants::ELEMNAME_NUMBER:
case Constants::ELEMNAME_OTHERWISE:
case Constants::ELEMNAME_PI:
case Constants::ELEMNAME_REMOVEATTRIBUTE:
case Constants::ELEMNAME_SORT:
case Constants::ELEMNAME_TEXT:
case Constants::ELEMNAME_VALUEOF:
case Constants::ELEMNAME_WHEN:
case Constants::ELEMNAME_ELEMENT:
case Constants::ELEMNAME_COUNTER:
case Constants::ELEMNAME_COUNTERS:
case Constants::ELEMNAME_COUNTERINCREMENT:
case Constants::ELEMNAME_COUNTERRESET:
case Constants::ELEMNAME_COUNTERSCOPE:
case Constants::ELEMNAME_APPLY_IMPORTS:
{
DOMString msg("(StylesheetHandler) " + DOMString(name)
+ " not allowed inside a stylesheet!");
throw SAXException(toCharArray(msg));
}
// break;
case Constants::ELEMNAME_STYLESHEET:
{
m_stylesheet.setWrapperless(false);
m_foundStylesheet = true;
int nAttrs = atts.getLength();
// bool didSpecifiyIndent = false; //doesn't seem to be used
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname = atts.getName(i);
if(equals(aname, "result-ns"))
{
throw SAXException("result-ns no longer supported! Use
xsl:output instead.");
}
else if(equals(aname, Constants::ATTRNAME_DEFAULTSPACE))
{
throw SAXException("default-space no longer supported! Use
xsl:strip-space or xsl:preserve-space instead.");
}
else if(equals(aname,
Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES))
{
// BEGIN SANJIVA CODE
StringTokenizer tokenizer(atts.getValue (i), " \t\n\r", false);
while(tokenizer.hasMoreTokens ())
{
const DOMString prefix = tokenizer.nextToken ();
// SANJIVA: ask Scott: is the line below correct?
const DOMString extns =
m_stylesheet.getNamespaceForPrefixFromStack (prefix);
ExtensionNSHandler* nsh = new ExtensionNSHandler
(m_processor, extns);
m_stylesheet.addExtensionNamespace(extns, nsh);
}
// END SANJIVA CODE
}
else if(equals(aname, "id"))
{
//
}
else if(equals(aname, "indent-result"))
{
throw SAXException("indent-result no longer supported! Use
xsl:output instead.");
}
else if(equals(aname, "version"))
{
const DOMString versionStr = atts.getValue(i);
Stylesheet::setXSLTVerDeclared(DOMStringToDouble(versionStr));
}
else if(!(isAttrOK(aname, atts, i) || processSpaceAttr(aname,
atts, i)))
{
if(false == m_stylesheet.isWrapperless())
{
DOMString msg("(StylesheetHandler) " +
DOMString(name) +
" has an illegal attribute: " + aname);
throw SAXException(toCharArray(msg));
}
}
else if(startsWith(aname,"xmlns:"))
{
// rcw to do: in the final recommendation version is specified as an attribute
#if 0
const DOMString nsDeclVal = atts.getValue(i);
if(startsWith(nsDeclVal,m_processor.getXSLNameSpaceURLPre()))
{
int lenOfPre =
m_processor.getXSLNameSpaceURLPre().length();
const DOMString versionStr =
substring(nsDeclVal,lenOfPre+1);
if(versionStr.length() > 1)
{
Stylesheet::setXSLTVerDeclared(DOMStringToDouble(versionStr));
}
}
#endif
}
if(!m_stylesheet.getNamespaces().empty())
{
m_stylesheet.setNamespaceDecls(m_stylesheet.getNamespaces().back());
}
/*
default:
if((null != ns) &&
(ns.equalsIgnoreCase(m_processor.m_XSLNameSpaceURL) ||
ns.equalsIgnoreCase(m_processor.m_XML4JNameSpaceURL)))
{
m_processor.warn(name
+" unknown XSL instruction inside context of the stylesheet
element!");
}
// be tolerant of other namespaces
break;
*/
}
}
break;
default:
{
DOMString msg("Unknown XSL element: " + localName);
throw SAXException(toCharArray(msg));
}
}
}
else
{
switch(xslToken)
{
case Constants::ELEMNAME_APPLY_TEMPLATES:
elem = new ElemApplyTemplates(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_CALLTEMPLATE:
elem = new ElemCallTemplate(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_WITHPARAM:
elem = new ElemWithParam(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_FOREACH:
elem = new ElemForEach(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber, true);
break;
case Constants::ELEMNAME_SORT:
{
ElemForEach* foreach =
dynamic_cast<ElemForEach*>(m_pElemStack->back());
ElemSort* sortElem = new ElemSort(m_processor,
m_stylesheet,
name, atts, lineNumber,
columnNumber);
foreach->getSortElems().push_back(sortElem);
sortElem->setParentNode(foreach);
}
break;
case Constants::ELEMNAME_APPLY_IMPORTS:
elem = new ElemApplyImport(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_VALUEOF:
elem = new ElemValueOf(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_NUMBER:
elem = new ElemNumber(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_VARIABLE:
elem = new ElemVariable(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_PARAMVARIABLE:
elem = new ElemParam(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_IF:
elem = new ElemIf(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_CHOOSE:
elem = new ElemChoose(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_WHEN:
{
ElemTemplateElement* parent = m_pElemStack->back();
if(Constants::ELEMNAME_CHOOSE == parent->getXSLToken())
{
ElemTemplateElement* lastChild =
dynamic_cast<ElemTemplateElement*>(parent->getLastChild());
if((0 == lastChild) ||
(Constants::ELEMNAME_WHEN == lastChild->getXSLToken()))
{
elem = new ElemWhen(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
}
else
{
throw SAXException("(StylesheetHandler) misplaced xsl:when!");
}
}
else
{
throw SAXException("(StylesheetHandler) xsl:when not parented
by xsl:choose!");
}
}
break;
case Constants::ELEMNAME_OTHERWISE:
{
ElemTemplateElement* parent = m_pElemStack->back();
if(Constants::ELEMNAME_CHOOSE == parent->getXSLToken())
{
ElemTemplateElement* lastChild =
dynamic_cast<ElemTemplateElement*>(parent->getLastChild());
if((0 == lastChild) ||
(Constants::ELEMNAME_WHEN == lastChild->getXSLToken()))
{
elem = new ElemOtherwise(m_processor,
m_stylesheet,
name, atts, lineNumber,
columnNumber);
}
else
{
throw SAXException("(StylesheetHandler) misplaced
xsl:otherwise!");
}
}
else
{
throw SAXException("(StylesheetHandler) xsl:otherwise not
parented by xsl:choose!");
}
}
break;
case Constants::ELEMNAME_COPY_OF:
elem = new ElemCopyOf(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_COPY:
elem = new ElemCopy(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_TEXT:
// Just push the element on the stack to signal
// that space should be preserved.
m_pElemStack->push_back(new ElemText(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber));
break;
case Constants::ELEMNAME_USE:
elem = new ElemUse(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_ATTRIBUTE:
elem = new ElemAttribute(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_ELEMENT:
elem = new ElemElement(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_PI:
elem = new ElemPI(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_COMMENT:
elem = new ElemComment(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_MESSAGE:
elem = new ElemMessage(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber);
break;
case Constants::ELEMNAME_TEMPLATE:
case Constants::ELEMNAME_LOCALE:
case Constants::ELEMNAME_DEFINEATTRIBUTESET:
case Constants::ELEMNAME_DEFINESCRIPT:
case Constants::ELEMNAME_EXTENSION:
case Constants::ELEMNAME_EXTENSIONHANDLER:
case Constants::ELEMNAME_KEY:
case Constants::ELEMNAME_IMPORT:
case Constants::ELEMNAME_INCLUDE:
case Constants::ELEMNAME_PRESERVESPACE:
case Constants::ELEMNAME_STRIPSPACE:
{
DOMString msg("(StylesheetHandler) " + DOMString(name)
+ " is not allowed inside a template!");
throw SAXException(toCharArray(msg));
break;
}
default:
// If this stylesheet is declared to be of a higher version than
the one
// supported, don't flag an error.
if(XSLTEngineImpl::getXSLTVerSupported() <
Stylesheet::getXSLTVerDeclared())
{
DOMString msg("Unknown XSL element: " +
localName);
throw SAXException(toCharArray(msg));
}
}
}
}
// BEGIN SANJIVA CODE
else if (!m_inTemplate &&
startsWith(ns,m_processor.getXSLT4JNameSpaceURL()))
{
if (localName.equals ("component"))
{
DOMString prefix;
DOMString elements;
DOMString functions;
int nAttrs = atts.getLength ();
for (int i = 0; i < nAttrs; i++)
{
DOMString aname = atts.getName (i);
if (aname.equals ("prefix"))
{
prefix = atts.getValue (i);
}
else if (aname.equals ("elements"))
{
elements = atts.getValue (i);
}
else if (aname.equals ("functions"))
{
functions = atts.getValue (i);
}
else if(!isAttrOK(aname, atts, i))
{
m_stylesheet.error(DOMString(name) + " has an illegal attribute:
" + aname);
}
}
if (isEmpty(prefix))
{
DOMString msg("StylesheetHandler) " + DOMString(name) +
" attribute 'prefix' is missing");
throw SAXException(toCharArray(msg));
}
// SCOTT: is the line below correct?
DOMString extns = m_stylesheet.getNamespaceForPrefixFromStack
(prefix);
ExtensionNSHandler* nsh =
m_stylesheet.lookupExtensionNSHandler(extns);
if (nsh == 0)
{
DOMString msg("(StylesheetHandler) " + DOMString(name)
+ " extension namespace prefix '" + prefix + "' unknown");
throw SAXException(toCharArray(msg));
}
if (!isEmpty(elements))
{
nsh->setElements(elements);
}
if (!isEmpty(functions))
{
nsh->setFunctions(functions);
}
m_pLXSLTExtensionNSH = nsh; // hang on to it for processing
// endElement on lxslt:script
}
else if (localName.equals ("script"))
{
// process this in end element so that I can see whether I had
// a body as well. The default pushing logic will save the
// attributes for me. The body will be accumulated into the
// following string buffer
m_inLXSLTScript = true;
m_LXSLTScriptBody = DOMString();
int nAttrs = atts.getLength ();
for (int i = 0; i < nAttrs; i++)
{
DOMString aname = atts.getName (i);
if (aname.equals ("lang"))
{
m_LXSLTScriptLang = atts.getValue (i);
}
else if (aname.equals ("src"))
{
m_LXSLTScriptSrcURL = atts.getValue (i);
}
else if(!isAttrOK(aname, atts, i))
{
m_stylesheet.error(DOMString(name) + " has an illegal attribute:
" + aname);
}
}
}
else
{
// other xslt4j: element. Not my business.
}
}
// END SANJIVA CODE
else
{
if(!m_inTemplate && !m_foundStylesheet)
{
elem = initWrapperless(name, atts, lineNumber, columnNumber);
}
else
{
// BEGIN SANJIVA CODE
// is this an extension element call?
ExtensionNSHandler* nsh = 0;
if (!isEmpty(ns) &&
((nsh = m_stylesheet.lookupExtensionNSHandler (ns)) != 0))
{
elem = new ElemExtensionCall (m_processor,
m_stylesheet,
*nsh,
name,
localName,
atts, lineNumber, columnNumber);
}
else
{
elem = new ElemLiteralResult(m_processor,
m_stylesheet,
name,
atts, lineNumber, columnNumber);
}
// BEGIN SANJIVA CODE
}
// END SANJIVA CODE
}
if(m_inTemplate && (0 != elem))
{
if(!m_pElemStack->empty())
{
ElemTemplateElement* parent = m_pElemStack->back();
parent->appendChild(elem);
}
m_pElemStack->push_back(elem);
}
// If for some reason something didn't get pushed, push an empty
// object.
if(origStackSize == m_pElemStack->size())
{
m_pElemStack->push_back(new ElemEmpty(m_processor,
m_stylesheet,
name, atts, lineNumber, columnNumber));
}
} // end try
// Here's the story. startElement throws exceptions for certain
malformed constructs. These
// exceptions need to reach the end user. But the parser eats all
exceptions and we lose
// the error messages and exit silently. So, I'll eat the exceptions
first, store the message
// and then throw the exception during endDocument
catch(SAXException& e)
{
m_pendingException = e.getMessage();
}
}
/**
* Init the wrapperless template
*/
ElemTemplateElement* StylesheetHandler::initWrapperless (const DOMString&
name,
const AttributeList& atts, int lineNumber, int columnNumber)
{
m_stylesheet.getStylesheetRoot()->initDefaultRule();
AttributeListImpl templateAttrs;
templateAttrs.addAttribute(c_wstr("name"), c_wstr("CDATA"),
c_wstr("simple"));
m_pTemplate = new ElemTemplate(m_processor, m_stylesheet,
"xsl:template",
templateAttrs, lineNumber, columnNumber);
ElemTemplateElement* pElem = new ElemLiteralResult(m_processor,
m_stylesheet, name, atts, lineNumber, columnNumber);
m_pTemplate->appendChild(pElem);
m_inTemplate = true;
m_stylesheet.setWrapperlessTemplate(m_pTemplate);
m_foundStylesheet = true;
m_stylesheet.setWrapperless(true);
if(name.equals("HTML"))
{
m_stylesheet.getStylesheetRoot()->setIndentResult(true);
m_stylesheet.getStylesheetRoot()->setOutputMethod(Formatter::OUTPUT_METH_HTML);
}
return pElem;
}
/**
* Process xsl:import.
*/
void StylesheetHandler::processImport(const DOMString& name, const
AttributeList& atts)
{
int nAttrs = atts.getLength();
bool foundIt = false;
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname = atts.getName(i);
if(aname.equals(Constants::ATTRNAME_HREF))
{
foundIt = true;
if(m_foundNotImport)
{
throw SAXException("Imports can only occur as
the first elements in the stylesheet!");
}
const DOMString saved_XSLNameSpaceURL =
m_processor.getXSLNameSpaceURL();
const DOMString href = atts.getValue(i);
const URL& hrefUrl =
*(m_processor.getURLFromString(href, m_stylesheet.getBaseIdentifier()));
StylesheetRoot::ImportStackType& importStack =
m_stylesheet.getStylesheetRoot()->getImportStack();
if(stackContains(importStack, hrefUrl))
{
DOMString msg(DOMString(hrefUrl.getURL()) + "
is directly or indirectly importing itself!");
throw SAXException(toCharArray(msg));
}
importStack.push_back(hrefUrl);
Stylesheet* pImportedStylesheet = new Stylesheet(
*(m_stylesheet.getStylesheetRoot()),
&m_processor,
m_stylesheet.getBaseIdentifier());
StylesheetHandler tp(m_processor, *pImportedStylesheet);
pImportedStylesheet->setBaseIdentifier(hrefUrl.getURL());
m_processor.parseXML(hrefUrl, &tp,
DOM_UnimplementedDocument(pImportedStylesheet));
// I'm going to insert the elements in backwards order,
// so I can walk them 0 to n.
m_stylesheet.getImports().insert(m_stylesheet.getImports().begin(),
pImportedStylesheet);
importStack.pop_back();
m_processor.setXSLNameSpaceURL(saved_XSLNameSpaceURL);
}
else if(!isAttrOK(aname, atts, i))
{
m_stylesheet.error(name + " has an illegal attribute: "
+ aname);
}
}
if(!foundIt)
{
DOMString msg("Could not find href attribute for " + name);
throw SAXException(toCharArray(msg));
}
}
/**
* Test to see if the stack contains the given URL.
*/
bool StylesheetHandler::stackContains(const Stylesheet::URLStackType& stack,
const URL& url) const
{
int n = stack.size();
bool contains = false;
for(int i = 0; i < n; i++)
{
URL url2 = stack[i];
if(url2 == url)
{
contains = true;
break;
}
}
return contains;
}
/**
* Process xsl:include.
*/
void StylesheetHandler::processInclude(const DOMString& name, const
AttributeList& atts)
{
int nAttrs = atts.getLength();
bool foundIt = false;
for(int i = 0; i < nAttrs; i++)
{
const DOMString aname = atts.getName(i);
if(equals(aname, Constants::ATTRNAME_HREF))
{
foundIt = true;
// Save state, so this class can be reused.
ElemTemplateStackType* saved_pElemStack = m_pElemStack;
m_pElemStack = new ElemTemplateStackType();
ElemTemplate* saved_pTemplate = m_pTemplate;
m_pTemplate = 0;
ElemTemplateElement* saved_pLastPopped = m_pLastPopped;
m_pLastPopped = 0;
bool saved_inTemplate = m_inTemplate;
m_inTemplate = false;
bool saved_foundStylesheet = m_foundStylesheet;
m_foundStylesheet = false;
DOMString saved_XSLNameSpaceURL =
m_processor.getXSLNameSpaceURL();
bool saved_foundNotImport = m_foundNotImport;
m_foundNotImport = false;
const DOMString href = atts.getValue(i);
const URL* hrefUrl = m_processor.getURLFromString(href,
m_stylesheet.getIncludeStack().back().getURL());
if(stackContains(m_stylesheet.getIncludeStack(),
*hrefUrl))
{
DOMString msg(DOMString(hrefUrl->getURL()) + "
is directly or indirectly including itself!");
throw SAXException(toCharArray(msg));
}
m_stylesheet.getIncludeStack().push_back(*hrefUrl);
m_processor.parseXML(*hrefUrl, this,
DOM_UnimplementedDocument(&m_stylesheet));
m_stylesheet.getIncludeStack().pop_back();
delete m_pElemStack;
m_pElemStack = saved_pElemStack;
m_pTemplate = saved_pTemplate;
m_pLastPopped = saved_pLastPopped;
m_inTemplate = saved_inTemplate;
m_foundStylesheet = saved_foundStylesheet;
m_processor.setXSLNameSpaceURL(saved_XSLNameSpaceURL);
m_foundNotImport = saved_foundNotImport;
}
else if(!isAttrOK(aname, atts, i))
{
m_stylesheet.error(name+ " has an illegal attribute: "
+ aname);
}
}
if(!foundIt)
{
DOMString msg("Could not find href attribute for " +
DOMString(name));
throw SAXException(toCharArray(msg));
}
}
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
void StylesheetHandler::endElement(const XMLCh* const name)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
m_stylesheet.popNamespaces();
m_pLastPopped = m_pElemStack->back();
m_pElemStack->pop_back();
m_pLastPopped->setFinishedConstruction(true);
int tok = m_pLastPopped->getXSLToken();
if(Constants::ELEMNAME_TEMPLATE == tok)
{
m_inTemplate = false;
}
else if((Constants::ELEMNAME_PARAMVARIABLE == tok) ||
Constants::ELEMNAME_VARIABLE == tok)
{
ElemVariable* var = dynamic_cast<ElemVariable *>(m_pLastPopped);
if(var->isTopLevel())
{
// Top-level param or variable
m_inTemplate = false;
}
}
else if(Constants::ELEMNAME_DEFINEATTRIBUTESET == tok)
{
m_inTemplate = false;
}
// BEGIN SANJIVA CODE
if (m_inLXSLTScript)
{
if (isEmpty(m_LXSLTScriptLang))
{
DOMString msg(DOMString(name) + " attribute \'lang\' is
missing");
throw SAXException(toCharArray(msg));
}
if (m_pLXSLTExtensionNSH == 0)
{
DOMString msg("(StylesheetHandler) misplaced " +
DOMString(name) + " element?? Missing container element " + "'component'");
throw SAXException(toCharArray(msg));
}
m_pLXSLTExtensionNSH->setScript(m_LXSLTScriptLang,
m_LXSLTScriptSrcURL, m_LXSLTScriptBody);
// reset state
m_inLXSLTScript = false;
m_LXSLTScriptLang = 0;
m_LXSLTScriptSrcURL = 0;
m_LXSLTScriptBody = 0;
m_pLXSLTExtensionNSH = 0;
}
// END SANJIVA CODE
}
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
void StylesheetHandler::characters (const XMLCh* const chars, const unsigned
int length)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
if(m_inTemplate)
{
ElemTemplateElement* parent = m_pElemStack->back();
bool preserveSpace = false;
bool disableOutputEscaping = false;
if(Constants::ELEMNAME_TEXT == parent->getXSLToken())
{
disableOutputEscaping =
(dynamic_cast<ElemText*>(parent))->getDisableOutputEscaping();
parent = (*m_pElemStack)[m_pElemStack->size()-2];
preserveSpace = true;
}
Locator* locator = (m_processor.m_stylesheetLocatorStack.size()
== 0)
? 0 : m_processor.m_stylesheetLocatorStack.back();
int lineNumber = (0 != locator) ? locator->getLineNumber() : 0;
int columnNumber = (0 != locator) ? locator->getColumnNumber()
: 0;
ElemTextLiteral *elem = new ElemTextLiteral(m_processor,
m_stylesheet,
chars, 0, length,
true, preserveSpace,
disableOutputEscaping,
lineNumber, columnNumber);
bool isWhite = isWhiteSpace(chars, 0, length);
if(preserveSpace || (!preserveSpace && !isWhite))
{
while(!m_whiteSpaceElems.empty())
{
ElemTextLiteral* whiteElem =
m_whiteSpaceElems.back();
m_whiteSpaceElems.pop_back();
parent->appendChild(whiteElem);
}
parent->appendChild(elem);
elem=0;
}
else if(isWhite)
{
bool shouldPush = true;
NodeImpl* last = parent->getLastChild();
if(0 != last)
{
ElemTemplateElement* lastElem =
dynamic_cast<ElemTemplateElement *>(last);
if(Constants::ELEMNAME_TEXTLITERALRESULT ==
lastElem->getXSLToken() &&
!(dynamic_cast<ElemTextLiteral
*>(lastElem))->isPreserveSpace())
{
parent->appendChild(elem);
shouldPush = false;
}
}
if(shouldPush)
{
m_whiteSpaceElems.push_back(elem);
elem=0;
}
}
delete elem;
}
// BEGIN SANJIVA CODE
else if (m_inLXSLTScript)
{
DOMString tmpStr(chars, length);
append(m_LXSLTScriptBody,tmpStr);
}
// END SANJIVA CODE
// TODO: Flag error if text inside of stylesheet
}
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
void StylesheetHandler::cdata(const XMLCh* const chars, const unsigned int
length)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
if(m_inTemplate)
{
ElemTemplateElement* parent = m_pElemStack->back();
bool preserveSpace = false;
bool disableOutputEscaping = false;
if(Constants::ELEMNAME_TEXT == parent->getXSLToken())
{
disableOutputEscaping =
(static_cast<ElemText*>(parent))->getDisableOutputEscaping();
parent = (*m_pElemStack)[m_pElemStack->size()-2];
preserveSpace = true;
}
Locator* locator =
(m_processor.m_stylesheetLocatorStack.size()==0)
? 0 : m_processor.m_stylesheetLocatorStack.back();
int lineNumber = (0 != locator) ? locator->getLineNumber() : 0;
int columnNumber = (0 != locator) ? locator->getColumnNumber()
: 0;
ElemTextLiteral* elem = new ElemTextLiteral(m_processor,
m_stylesheet,
chars, 0, length,
true, preserveSpace,
disableOutputEscaping,
lineNumber, columnNumber);
bool isWhite = isWhiteSpace(chars, 0, length);
if(preserveSpace || (!preserveSpace && !isWhite))
{
while(!m_whiteSpaceElems.empty())
{
ElemTextLiteral *whiteElem =
m_whiteSpaceElems.back();
m_whiteSpaceElems.pop_back();
parent->appendChild(whiteElem);
}
parent->appendChild(elem);
}
else if(isWhite)
{
bool shouldPush = true;
NodeImpl* last = parent->getLastChild();
if(0 != last)
{
ElemTemplateElement* lastElem =
dynamic_cast<ElemTemplateElement*>(last);
if(Constants::ELEMNAME_TEXTLITERALRESULT ==
lastElem->getXSLToken() &&
!dynamic_cast<ElemTextLiteral*>(lastElem)->isPreserveSpace())
{
parent->appendChild(elem);
shouldPush = false;
}
}
if(shouldPush)
m_whiteSpaceElems.push_back(elem);
}
}
// BEGIN SANJIVA CODE
else if (m_inLXSLTScript)
{
append(m_LXSLTScriptBody, chars);
}
// END SANJIVA CODE
// TODO: Flag error if text inside of stylesheet
}
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
void StylesheetHandler::ignorableWhitespace (const XMLCh* const /*chars*/,
const unsigned int /*length*/)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
// Ignore!
}
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
void StylesheetHandler::processingInstruction (const XMLCh* const /*target*/,
const XMLCh* const /*data*/)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
// No action for the moment.
}
/**
* Called when a Comment is to be constructed.
* @param data The comment data.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
void StylesheetHandler::comment(const XMLCh* const /*data*/)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
// No action for the moment.
}
/**
* Receive notification of a entityReference.
*/
void StylesheetHandler::entityReference(const XMLCh* const /*name*/)
{
// if we have apending exception, we don't want to even try to process
this
if (!isEmpty(m_pendingException))
return;
// No action for the moment.
}
1.1 xml-xalan/c/src/XSLT/StylesheetHandler.hpp
Index: StylesheetHandler.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_STYLESHEETHANDLER_HEADER_GUARD)
#define XALAN_STYLESHEETHANDLER_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include "XSLTEngineImpl.hpp"
#include "Stylesheet.hpp"
#include "Java2STL.hpp"
#include <XMLSupport/FormatterListener.hpp>
class ElemTemplate;
class ElemTemplateElement;
class ElemTextLiteral;
/**
* This class processes a stylesheet via SAX events, and inits
* the given stylesheet. If you need to alter the code in here,
* it is not for the faint-of-heart, due to the state tracking
* that has to be done due to the SAX event model.
*/
class XALAN_XSLT_EXPORT StylesheetHandler : public FormatterListener
{
private:
// not implemented
StylesheetHandler(const StylesheetHandler &);
StylesheetHandler& operator=(const StylesheetHandler &);
DOMString m_pendingException;
typedef std::vector<ElemTemplateElement*> ElemTemplateStackType;
/**
* Need to keep a stack of found whitespace elements so that
* whitespace elements next to non-whitespace elements can
* be merged. For instance: <out> <![CDATA[test]]> </out>
*/
typedef std::vector<ElemTextLiteral*> ElemTextLiteralStackType;
/**
* The XSLT Processor for needed services.
*/
XSLTEngineImpl& m_processor;
/**
* The owning stylesheet.
*/
Stylesheet& m_stylesheet;
/**
* The stack of elements, pushed and popped as events occur.
*/
ElemTemplateStackType* m_pElemStack;
/**
* Need to keep a stack of found whitespace elements so that
* whitespace elements next to non-whitespace elements can
* be merged. For instance: <out> <![CDATA[test]]> </out>
*/
ElemTextLiteralStackType m_whiteSpaceElems;
/**
* The current template.
*/
ElemTemplate* m_pTemplate;
/**
* The last element popped from the stack. I'm not totally clear
* anymore as to why this is needed.
*/
ElemTemplateElement* m_pLastPopped;
/**
* True if the process is in a template context.
*/
bool m_inTemplate;
/**
* True if the stylesheet element was found, or if it was determined
that
* the stylesheet is wrapperless.
*/
bool m_foundStylesheet;
/**
* Flag to let us know when we've found an element inside the
* stylesheet that is not an xsl:import, so we can restrict imports
* to being the first elements.
*/
bool m_foundNotImport;
// BEGIN SANJIVA CODE
bool m_inLXSLTScript;
DOMString m_LXSLTScriptBody;
DOMString m_LXSLTScriptLang;
DOMString m_LXSLTScriptSrcURL;
ExtensionNSHandler* m_pLXSLTExtensionNSH;
// END SANJIVA CODE
public:
/**
* This will act as a stack of sorts to keep track of the
* current include base.
*/
DOMString m_includeBase;
/**
* FormatterToText instance constructor... it will add the DOM nodes
* to the document fragment.
*/
StylesheetHandler(XSLTEngineImpl& processor, Stylesheet&
stylesheetTree);
virtual
~StylesheetHandler();
/**
* Receive an object for locating the origin of SAX document events.
*
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.</p>
*
* <p>Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.</p>
*
* @param locator An object that can return the location of
* any SAX document event.
* @see org.xml.sax.Locator
*/
virtual void setDocumentLocator(Locator* const locator);
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void startDocument();
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endDocument ();
protected:
/**
* See if this is a xmlns attribute, and, if so, process it.
*
* @param attrName Qualified name of attribute.
* @param atts The attribute list where the element comes from (not
used at
* this time).
* @param which The index into the attribute list (not used at this
time).
* @return True if this is a namespace name.
*/
bool isAttrOK(const DOMString& attrName, const AttributeList& atts, int
which);
/**
* Tell whether or not this is a xml:space attribute and, if so,
process it.
*
* @param aname The name of the attribute in question.
* @param atts The attribute list that owns the attribute.
* @param which The index of the attribute into the attribute list.
* @return True if this is a xml:space attribute.
*/
bool processSpaceAttr(const DOMString& aname, const AttributeList&
atts, int which);
private:
/**
* Init the wrapperless template
*/
ElemTemplateElement* initWrapperless (const DOMString& name,
const AttributeList&
atts,
int lineNumber,
int columnNumber);
/**
* Test to see if the stack contains the given URL.
*/
bool stackContains(const Stylesheet::URLStackType& stack, const URL&
url) const;
protected:
/**
* Process xsl:import.
*/
void processImport(const DOMString& name, const AttributeList& atts);
/**
* Process xsl:include.
*/
void processInclude(const DOMString& name, const AttributeList& atts);
public:
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param atts The attributes attached to the element, if any.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see org.xml.sax.AttributeList
*/
virtual void startElement (const XMLCh* const name, AttributeList&
attrs);
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endElement(const XMLCh* const name);
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void characters (const XMLCh* const chars, const unsigned int
length);
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
virtual void cdata(const XMLCh* const ch, const unsigned int length);
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
virtual void ignorableWhitespace (const XMLCh* const chars, const
unsigned int length);
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void processingInstruction (const XMLCh* const target, const
XMLCh* const data);
/**
* Called when a Comment is to be constructed.
* @param data The comment data.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void comment(const XMLCh* const);
/**
* Receive notification of a entityReference.
*/
virtual void entityReference(const XMLCh* const);
// pure virtual in DocumentHandler
virtual void resetDocument() {}
// pure virtual in FormatterListener
virtual void charactersRaw(const XMLCh* const chars, const unsigned int
length) {}
};
#endif // XALAN_STYLESHEETHANDLER_HEADER_GUARD
// $ Log: $
1.1 xml-xalan/c/src/XSLT/StylesheetRoot.cpp
Index: StylesheetRoot.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
// Class header file
#include "StylesheetRoot.hpp"
#include <memory>
#include <vector>
#include <XMLSupport/Formatter.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include <PlatformSupport/AttributeListimpl.hpp>
#include "ElemApplyTemplates.hpp"
#include "ElemValueOf.hpp"
#include "Constants.hpp"
#include <sax/SAXException.hpp>
#include <XercesPlatformSupport/XercesDOMPrintWriter.hpp>
#include <util/StdOut.hpp>
/**
* Constructor for a Stylesheet needs a Document.
* @exception XSLProcessorException thrown if the active ProblemListener and
* XMLParserLiaison decide the error condition is severe enough to
* halt processing.
*/
StylesheetRoot::StylesheetRoot(
XSLTEngineImpl* processor,
const DOMString& baseIdentifier):
Stylesheet(*this, processor, baseIdentifier),
m_importStack(),
m_outputmethod(Formatter::OUTPUT_METH_XML),
m_version(baseIdentifier),
m_indentResult(false),
m_encoding(),
m_mediatype(),
m_doctypeSystem(),
m_doctypePublic(),
m_xmlDecl(true),
m_standalone(),
m_cdataSectionElems(),
m_defaultTextRule(0),
m_defaultRule(0),
m_defaultRootRule(0),
m_resultNameSpaceURL()
{
// For some reason, the imports aren't working right if I
// don't set the baseIdent to full url. I think this is OK,
// and probably safer and faster in general.
URL* url = m_processor->getURLFromString(m_baseIdent, DOMString());
if (url != 0)
{
m_baseIdent = url->getURL();
delete url;
url = m_processor->getURLFromString(m_baseIdent, DOMString());
if (url != 0)
{
m_importStack.push_back(*url);
delete url;
}
}
m_stylesheetRoot = this;
//init();
}
StylesheetRoot::~StylesheetRoot()
{
if (m_defaultRule != 0)
{
NodeImpl *child = m_defaultRule->getFirstChild();
m_defaultRule->removeChild(child);
delete child;
delete m_defaultRule;
m_defaultRule = 0;
}
if (m_defaultTextRule != 0)
{
NodeImpl *child = m_defaultTextRule->getFirstChild();
m_defaultTextRule->removeChild(child);
delete child;
delete m_defaultTextRule;
m_defaultTextRule = 0;
}
if (m_defaultRootRule != 0)
{
NodeImpl *child = m_defaultRootRule->getFirstChild();
m_defaultRootRule->removeChild(child);
delete child;
delete m_defaultRootRule;
m_defaultRootRule = 0;
}
}
void StylesheetRoot::process(const DOM_Node& sourceTree,
XSLTResultTarget* outputTarget)
{
// synchronized(this)
// {
// Find the root pattern in the XSL.
ElemTemplate* rootRule =
dynamic_cast<ElemTemplate*>(findTemplate(sourceTree,
sourceTree));
if(0 == rootRule)
{
rootRule = m_defaultRootRule;
assert(rootRule);
}
m_processor->setStylesheetRoot(this);
FormatterListener* flistener = 0;
bool newListener = false;
// $$$ ToDo: Why is this Xerces-specific?
XercesDOMPrintWriter* pw = 0;
bool newPW = false;
/*
* Output target has a document handler
*/
if(0 != outputTarget->getDocumentHandler())
{
// Stuff a DocumentHandler into a FormatterListener
FormatterListener* pFL = dynamic_cast<FormatterListener
*>(outputTarget->getDocumentHandler());
m_processor->m_formatter->setFormatterListener(pFL);
flistener =
m_processor->m_formatter->getFormatterListener();
}
/*
* Output target has a character or byte stream or file
*/
else if((0 != outputTarget->getCharacterStream()) ||
(0 !=
outputTarget->getByteStream()) ||
(0 !=
outputTarget->getFileName().length()))
{
if(0 != outputTarget->getCharacterStream())
{
// @@ JMD: is this right ??
// java: pw = new
PrintWriter(outputTarget->getCharacterStream());
pw = static_cast<XercesDOMPrintWriter*>
(outputTarget->getCharacterStream());
}
else
{
/*
java:
DOMString mimeEncoding;
DOMString encoding;
mimeEncoding = getOutputEncoding();
encoding = getJavaOutputEncoding();
if(0 == encoding)
{
m_processor->m_diagnosticsPrintWriter.println("Encoding not supported:
"+mimeEncoding);
mimeEncoding = "UTF-8";
encoding =
FormatterToXML.convertMime2JavaEncoding(mimeEncoding);
}
*/
if(0 != outputTarget->getByteStream())
{
assert(0); // @@ JMD: not
supported yet ??
// java: OutputStreamWriter osw = new
OutputStreamWriter(outputTarget->getByteStream(), encoding);
// java: pw = new PrintWriter( new
BufferedWriter(osw) );
}
else if(! isEmpty(outputTarget->getFileName()))
{
assert(0); // @@ JMD: not
supported yet ??
/*
FileOutputStream fos = new
FileOutputStream(outputTarget->getFileName());
try
{
// pw = new PrintWriter( new
BufferedWriter(new FileWriter(outputTarget->getFileName())) );
OutputStreamWriter osw = new
OutputStreamWriter(fos, encoding);
pw = new PrintWriter( new
BufferedWriter(osw) );
}
catch(java.io.UnsupportedEncodingException uee)
{
mimeEncoding = "UTF-8";
encoding =
FormatterToXML.convertMime2JavaEncoding(mimeEncoding);
OutputStreamWriter osw = new
OutputStreamWriter(fos, encoding);
pw = new PrintWriter( new
BufferedWriter(osw) );
}
m_processor->setOutputFileName(outputTarget->getFileName());
*/
}
else
{
// $$$ ToDo: THIS MUST BE FIXED!!!!
WE CAN'T PASS
// A REFERENCE TO A STACK-BASED
INSTANCE.
XMLStdOut
theStdOut;
pw = new XercesDOMPrintWriter(
theStdOut );
newPW = true;
}
}
/*
*/
int indentAmount =
m_processor->getXMLProcessorLiaison().getIndent();
bool doIndent = (indentAmount > -1) ? true :
m_indentResult;
switch(m_outputmethod)
{
case Formatter::OUTPUT_METH_HTML:
flistener = new FormatterToHTML(
*pw, m_version, doIndent, indentAmount,
m_encoding, m_mediatype,
m_doctypeSystem, m_doctypePublic,
m_xmlDecl, m_standalone,
&m_cdataSectionElems);
newListener = true;
break;
case Formatter::OUTPUT_METH_TEXT:
flistener = new FormatterToText(*pw);
newListener = true;
break;
case Formatter::OUTPUT_METH_XML:
default:
flistener = new FormatterToXML(
*pw, m_version, doIndent, indentAmount,
m_encoding, m_mediatype,
m_doctypeSystem, m_doctypePublic,
m_xmlDecl, m_standalone,
&m_cdataSectionElems);
newListener = true;
break;
}
m_processor->m_formatter->setFormatterListener(flistener);
}
/*
* Output target has a node
*/
else if(0 != outputTarget->getNode())
{
switch(outputTarget->getNode().getNodeType())
{
case DOM_Node::DOCUMENT_NODE:
flistener = new
FormatterToDOM(static_cast<DOM_Document&>(outputTarget->getNode()));
newListener = true;
break;
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
flistener = new
FormatterToDOM(m_processor->getXMLProcessorLiaison().createDocument(),
static_cast<DOM_DocumentFragment&>(outputTarget->getNode()));
newListener = true;
break;
case DOM_Node::ELEMENT_NODE:
flistener = new
FormatterToDOM(m_processor->getXMLProcessorLiaison().createDocument(),
static_cast<DOM_Element&>(outputTarget->getNode()));
newListener = true;
break;
default:
error("Can only output to an Element,
DocumentFragment, Document, or PrintWriter.");
}
}
/*
* Create an empty document and set the output target node to
this
*/
else
{
outputTarget->setNode(m_processor->getXMLProcessorLiaison().createDocument());
flistener = new
FormatterToDOM(static_cast<DOM_Document&>(outputTarget->getNode()));
newListener = true;
}
m_processor->setFormatterListener(flistener);
m_processor->resetCurrentState(sourceTree, sourceTree);
// @@ JMD: Is this OK ??
m_processor->setRootDoc(static_cast<const
DOM_Document&>(sourceTree));
if(m_processor->doDiagnosticsOutput())
{
m_processor->diag("=============================");
m_processor->diag("Transforming...");
m_processor->pushTime(&sourceTree);
}
m_processor->getVariableStacks().pushContextMarker(DOM_Node(),
DOM_Node());
try
{
m_processor->resolveTopLevelParams();
}
// java: catch(Exception e)
catch(...)
{
throw SAXException("StylesheetRoot.process error");
}
m_processor->startDocument();
// Output the action of the found root rule. All processing
// occurs from here. buildResultFromTemplate is highly
recursive.
// java: rootRule->execute(*m_processor, sourceTree,
sourceTree, 0);
rootRule->execute(*m_processor, sourceTree, sourceTree,
QName());
m_processor->endDocument();
// Reset the top-level params for the next round.
m_processor->clearTopLevelParams();
if(m_processor->doDiagnosticsOutput())
{
m_processor->displayDuration("transform", &sourceTree);
}
if (newListener) delete flistener;
// Can't release this until flistener is gone, since it
contains a
// reference to it
if (newPW != 0) delete pw;
// }
}
/**
* Return the output method that was specified in the stylesheet.
* The returned value is one of Formatter.OUTPUT_METH_XML,
* Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
*/
int
StylesheetRoot::getOutputMethod() const
{
return m_outputmethod;
}
/**
* Tell if this is the root of the stylesheet tree.
*/
bool StylesheetRoot::isRoot() const { return true; }
/** Get the version string that was specified in the stylesheet. */
DOMString
StylesheetRoot::getOutputVersion() const
{
return m_version;
}
/** Get the media-type string that was specified in the stylesheet. */
bool
StylesheetRoot::getOutputIndent() const
{
return m_indentResult;
}
/** Get the encoding string that was specified in the stylesheet. */
DOMString
StylesheetRoot::getOutputEncoding() const
{
return m_encoding;
}
/** Get the encoding string that was specified in the stylesheet. */
DOMString
StylesheetRoot::getJavaOutputEncoding() const
{
DOMString encoding;
if(isEmpty(m_encoding))
encoding = DOMString("UTF8");
else if( equalsIgnoreCase(m_encoding, DOMString("UTF-16") ) )
encoding = DOMString("Unicode");
// @@ JMD: do we need this ??
// else
// @@ to do encoding = FormatterToXML.convertMime2JavaEncoding(
m_encoding );
return encoding;
}
/** Get the media-type string that was specified in the stylesheet. */
DOMString
StylesheetRoot::getOutputMediaType() const
{
return m_mediatype;
}
/** Get the doctype-system-id string that was specified in the stylesheet. */
DOMString
StylesheetRoot::getOutputDoctypeSystem() const
{
return m_doctypeSystem;
}
/** Get the doctype-public-id string that was specified in the stylesheet. */
DOMString
StylesheetRoot::getOutputDoctypePublic() const
{
return m_doctypePublic;
}
/**
* Process the xsl:output element.
*/
void
StylesheetRoot::processOutputSpec(
const DOMString&
name,
const AttributeList& atts)
{
int nAttrs = atts.getLength();
bool didSpecifyIndent = false;
for(int i = 0; i < nAttrs; i++)
{
DOMString aname = atts.getName(i);
if(equals(aname, Constants::ATTRNAME_OUTPUT_METHOD))
{
DOMString method = atts.getValue(i);
if(equals(method,
Constants::ATTRVAL_OUTPUT_METHOD_HTML))
m_outputmethod = Formatter::OUTPUT_METH_HTML;
else if(equals(method,
Constants::ATTRVAL_OUTPUT_METHOD_XML))
m_outputmethod = Formatter::OUTPUT_METH_XML;
else if(equals(method,
Constants::ATTRVAL_OUTPUT_METHOD_TEXT))
m_outputmethod = Formatter::OUTPUT_METH_TEXT;
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_VERSION))
{
m_version = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_INDENT))
{
m_indentResult = getYesOrNo(aname, atts.getValue(i));
didSpecifyIndent = true;
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_ENCODING))
{
m_encoding = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_MEDIATYPE))
{
m_mediatype = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_DOCTYPE_SYSTEM))
{
m_doctypeSystem = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_DOCTYPE_PUBLIC))
{
m_doctypePublic = atts.getValue(i);
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_XMLDECL))
{
m_xmlDecl = getYesOrNo(aname, atts.getValue(i));
}
else if(equals(aname,Constants::ATTRNAME_OUTPUT_STANDALONE))
{
m_standalone = atts.getValue(i);
}
else
if(equals(aname,Constants::ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS))
{
StringTokenizer tokenizer(atts.getValue(i));
while(tokenizer.hasMoreTokens())
{
DOMString token = tokenizer.nextToken();
QName qname(token, getNamespaces());
m_cdataSectionElems.push_back(qname);
}
}
else
{
m_processor->error(name+DOMString(" has an illegal
attribute: ")+aname);
}
}
if((Formatter::OUTPUT_METH_HTML == m_outputmethod) &&
(false == didSpecifyIndent))
{
m_indentResult = true;
}
}
/**
* Create the default rule if needed.
*/
void
StylesheetRoot::initDefaultRule()
{
int lineNumber = 0;
int columnNumber = 0;
// Then manufacture a default
AttributeListImpl attrs;
//const AttributeListImpl attrs() ;
attrs.addAttribute(c_wstr(Constants::ATTRNAME_MATCH),
c_wstr(DOMString("CDATA")),
c_wstr(DOMString("*")));
m_defaultRule = new ElemTemplate(*m_processor, // @@ JMD: should be
null
*this,
DOMString("xsl:")+Constants::ELEMNAME_TEMPLATE_STRING,
attrs, lineNumber, columnNumber);
attrs.clear();
ElemApplyTemplates* childrenElement
= new ElemApplyTemplates(*m_processor, *this,
DOMString("xsl:")+Constants::ELEMNAME_APPLY_TEMPLATES_STRING,
attrs, lineNumber, columnNumber);
childrenElement->setDefaultTemplate(true);
m_defaultRule->appendChild(childrenElement);
// -----------------------------
attrs.clear();
attrs.addAttribute(c_wstr(Constants::ATTRNAME_MATCH),
c_wstr(DOMString("CDATA")),
c_wstr(DOMString("text() | @*")));
m_defaultTextRule = new ElemTemplate(*m_processor,
*this,
DOMString("xsl:")+Constants::ELEMNAME_TEMPLATE_STRING,
attrs, lineNumber, columnNumber);
attrs.clear();
attrs.addAttribute(c_wstr(Constants::ATTRNAME_SELECT),
c_wstr(DOMString("CDATA")),
c_wstr(DOMString(".")));
ElemValueOf* elemValueOf
= (new ElemValueOf(*m_processor, *this,
DOMString("xsl:")+Constants::ELEMNAME_VALUEOF_STRING,
attrs, lineNumber, columnNumber));
m_defaultTextRule->appendChild(elemValueOf);
//--------------------------------
attrs.clear();
attrs.addAttribute(c_wstr(Constants::ATTRNAME_MATCH),
c_wstr(DOMString("CDATA")),
c_wstr(DOMString("/")));
m_defaultRootRule = new ElemTemplate(*m_processor, *this,
DOMString("xsl:")+Constants::ELEMNAME_TEMPLATE_STRING,
attrs, lineNumber, columnNumber);
attrs.clear();
childrenElement
= (new ElemApplyTemplates(*m_processor, *this,
DOMString("xsl:")+Constants::ELEMNAME_APPLY_TEMPLATES_STRING,
attrs,
lineNumber, columnNumber));
childrenElement->setDefaultTemplate(true);
m_defaultRootRule->appendChild(childrenElement);
}
/**
* Read the stylesheet root from a serialization stream.
* to do
void
readObject(
ObjectInputStream stream)
{
// System.out.println("Reading Stylesheet");
try
{
stream.defaultReadObject();
}
catch(ClassNotFoundException cnfe)
{
throw new XSLProcessorException(cnfe);
}
m_traceListeners = null;
m_stringbuf = new StringBuffer();
m_attrSetStack = null;
// System.out.println("Done reading Stylesheet");
}
*/
/*
* Returns the number of trace listeners
*/
int StylesheetRoot::getTraceListeners()
{
return m_traceListeners.size();
}
/**
* Add a trace listener for the purposes of debugging and diagnosis.
*/
void
StylesheetRoot::addTraceListener(TraceListener* tl)
{
m_traceListeners.push_back(tl);
}
/**
* Remove a trace listener.
*/
void
StylesheetRoot::removeTraceListener(TraceListener* theListener)
{
ListenersVectorType::iterator it;
for (it = m_traceListeners.begin(); it != m_traceListeners.end(); it++)
{
TraceListener* tl = (*it);
if (tl == theListener)
{
m_traceListeners.erase(it);
return;
}
}
}
/**
* Fire a trace event.
*/
void StylesheetRoot::fireTraceEvent(const TracerEvent& te) const
{
int nListeners = m_traceListeners.size();
for(int i = 0; i < nListeners; i++)
{
TraceListener* tl = m_traceListeners.at(i);
tl->trace(te);
}
}
/**
* Fire a selection event.
*/
void StylesheetRoot::fireSelectedEvent(const SelectionEvent& se) const
{
int nListeners = m_traceListeners.size();
for(int i = 0; i < nListeners; i++)
{
TraceListener* tl = m_traceListeners.at(i);
tl->selected(se);
}
}
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/StylesheetRoot.hpp
Index: StylesheetRoot.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_STYLESHEETROOT_HEADER_GUARD)
#define XALAN_STYLESHEETROOT_HEADER_GUARD
/**
* $Id: StylesheetRoot.hpp,v 1.1 1999/12/18 19:48:05 robweir Exp $
*
* $State: Exp $
*
* @author Myriam Midy (Myriam_Midy @lotus.com
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include "Stylesheet.hpp"
#include "ElemAttributeSet.hpp"
#include "ElemTemplate.hpp"
#include <util/URL.hpp>
#include <XMLSupport/FormatterToHTML.hpp>
#include <XMLSupport/FormatterToText.hpp>
#include <XMLSupport/FormatterToXML.hpp>
#include <XMLSupport/FormatterToDOM.hpp>
#include <PlatformSupport/PrintWriter.hpp>
#include <PlatformSupport/DOMStringPrintWriter.hpp>
#include <DOMSupport/UnimplementedDocument.hpp>
#include "TraceListener.hpp"
#include "TracerEvent.hpp"
#include "SelectionEvent.hpp"
#include "XSLTResultTarget.hpp"
/**
* This acts as the stylesheet root of the stylesheet
* tree, and holds values that are shared by all
* stylesheets in the tree.
*/
class XALAN_XSLT_EXPORT StylesheetRoot : public Stylesheet
{
public:
/**
* Constructor for a Stylesheet needs a Document.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
StylesheetRoot(
XSLTEngineImpl* processor,
const DOMString& baseIdentifier);
/*
throws XSLProcessorException,
MalformedURLException,
FileNotFoundException,
IOException,
SAXException
*/
virtual
~StylesheetRoot();
/**
* Transform the source tree to the output in the given
* result tree target.
* @param inputSource The input source tree.
* @param outputTarget The output source tree.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void process(const DOM_Node& sourceTree, XSLTResultTarget* outputTarget);
/*
throws XSLProcessorException,
MalformedURLException,
FileNotFoundException,
IOException,
SAXException
*/
/**
* A stack to keep track of the attribute elements.
*/
typedef std::vector<ElemAttributeSet*> AttrStackType;
/**
* A stack to keep track of URLs.
*/
typedef std::vector<URL> ImportStackType;
/**
* Return the output method that was specified in the stylesheet.
* The returned value is one of Formatter.OUTPUT_METH_XML,
* Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
*/
int
getOutputMethod() const;
/** Get the version string that was specified in the stylesheet. */
DOMString
getOutputVersion() const;
/** Get the media-type string that was specified in the stylesheet. */
bool
getOutputIndent() const;
/** Get the encoding string that was specified in the stylesheet. */
DOMString
getOutputEncoding() const;
/** Get the encoding string that was specified in the stylesheet. */
DOMString
getJavaOutputEncoding() const;
/** Get the doctype-system-id string that was specified in the
stylesheet. */
DOMString
getOutputDoctypeSystem() const;
/** Get the media-type string that was specified in the stylesheet. */
DOMString
getOutputMediaType() const;
/** Get the doctype-public-id string that was specified in the
stylesheet. */
DOMString
getOutputDoctypePublic() const;
/** Get the XML Declaration that was specified in the stylesheet. */
bool getOutputXMLDecl() { return m_xmlDecl; }
/** Get the standalone string that was specified in the stylesheet. */
DOMString getOutputStandalone() const { return m_standalone; }
AttrStackType &
getAttrSetStack()
{
return m_attrSetStack;
}
void
setAttrSetStack() const
{
// to do m_AttrSetStack = new AttrStackType();
}
ElemTemplate*
getDefaultTextRule() const
{
return m_defaultTextRule;
}
ElemTemplate*
getDefaultRule() const
{
return m_defaultRule;
}
ElemTemplate*
getDefaultRootRule() const
{
return m_defaultRootRule;
}
/**
* Process the xsl:output element.
*/
void
processOutputSpec(
const DOMString&
name,
const AttributeList& atts);
/**
* Tell if this is the root of the stylesheet tree.
*/
virtual bool
isRoot() const;
/**
* Create the default rule if needed.
*/
void
initDefaultRule();
private:
/**
* The URL that belongs to the result namespace.
* @serial
*/
DOMString m_resultNameSpaceURL; // = null;
/**
* List of listeners who are interested in tracing what's going on.
*/
//transient
typedef std::vector<TraceListener*> ListenersVectorType;
ListenersVectorType m_traceListeners; // = null;
/**
* String buffer for use by AVTs and the like.
*/
//java: transient DOMStringBuffer m_stringbuf = new StringBuffer();
/**
* Stack for the purposes of flagging infinite recursion with
* attribute sets.
*/
//transient
// to do
AttrStackType m_attrSetStack; // = null;
/**
* The output method as specified in xsl:output.
*/
int m_outputmethod; // = Formatter.OUTPUT_METH_XML;
// @@ JMD: Need accessors LATER
public:
/**
* The version tells the version of XML to be used for outputting the
result tree,
* as specified in xsl:output.
*/
DOMString m_version; // = null;
/**
* indent-result is by default no, which means an XSL processor must not
* change the whitespace on output.
* @serial
*/
bool m_indentResult; // = false;
/**
* The encoding attribute specifies the preferred encoding to use
* for outputting the result tree.
*/
DOMString m_encoding; // = null;
/**
* The media-type attribute is applicable for the xml output method.
* The default value for the media-type attribute is text/xml.
*/
DOMString m_mediatype; // = null;
/**
* If the doctype-system-id attribute is specified, the xml output
method should
* output a document type declaration immediately before the first
element.
* The name following <!DOCTYPE should be the name of the first
element.
*/
DOMString m_doctypeSystem; // = null;
/**
* If doctype-public-id attribute is also specified, then the xml
output
* method should output PUBLIC followed by the public identifier and
then
* the system identifier; otherwise, it should output SYSTEM followed
by
* the system identifier. The internal subset should be empty. The
* doctype-public-id attribute should be ignored unless the
doctype-system-id
* attribute is specified.
*/
DOMString m_doctypePublic; // = null;
/**
* Tells whether or not to output an XML declaration.
*/
bool m_xmlDecl; // = false;
/**
* Tells what the xmldecl should specify for the standalone value.
*/
DOMString m_standalone; // = null;
private:
/**
* List of qnames that specifies elements that should be formatted
* as CDATA.
*/
QNameVectorType m_cdataSectionElems; // = null;
/**
* A stack of who's importing who is needed in order to support
* "It is an error if a stylesheet directly or indirectly imports
* itself. Apart from this, the case where a stylesheet with a
* particular URI is imported in multiple places is not treated
* specially."
*/
//transient
ImportStackType m_importStack;
/**
* The default template to use for text nodes if we don't find
* anything else. This is initialized in initDefaultRule().
* @serial
*/
ElemTemplate* m_defaultTextRule;
/**
* The default template to use if we don't find anything
* else. This is initialized in initDefaultRule().
* @serial
*/
ElemTemplate* m_defaultRule;
/**
* The default template to use for the root if we don't find
* anything else. This is initialized in initDefaultRule().
* We kind of need this because the defaultRule isn't good
* enough because it doesn't supply a document context.
* For now, I default the root document element to "HTML".
* Don't know if this is really a good idea or not.
* I suspect it is not.
* @serial
*/
ElemTemplate* m_defaultRootRule;
public:
ImportStackType& getImportStack()
{
return m_importStack;
}
void setIndentResult(bool bIndent)
{
m_indentResult = bIndent;
}
void setOutputMethod(int meth)
{
m_outputmethod = meth;
}
int getTraceListeners();
void addTraceListener(TraceListener *tl);
// throws TooManyListenersException
// Remove a trace listener.
void removeTraceListener(TraceListener* tl);
// Fire a trace event.
void fireTraceEvent(const TracerEvent& te) const;
// Fire a selection event.
void fireSelectedEvent(const SelectionEvent& se) const;
const QNameVectorType& getCdataSectionElems() { return
m_cdataSectionElems; }
// Read the stylesheet root from a serialization stream.
// @@ Not implemented yet
// void readObject(ObjectInputStream stream);
};
#endif // XALAN_STYLESHEETROOT_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/TraceListener.hpp
Index: TraceListener.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_TraceListener_HEADER_GUARD)
#define XALAN_TraceListener_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
class TracerEvent;
class SelectionEvent;
class GenerateEvent;
class TraceListener
{
public:
/**
* Method that is called when a trace event occurs.
* The method is blocking. It must return before processing continues.
*
* @param ev the trace event.
*/
virtual void trace(const TracerEvent& ev) = 0;
/**
* Method that is called just after the formatter listener is called.
*
* @param ev the generate event.
*/
virtual void selected(const SelectionEvent& ev) = 0;
/**
* Method that is called just after the formatter listener is called.
*
* @param ev the generate event.
*/
virtual void generated(const GenerateEvent& ev) = 0;
};
#endif //XALAN_TraceListener_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/TracerEvent.cpp
Index: TracerEvent.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "TracerEvent.hpp"
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NodeList.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
/**
* This is the parent class of events generated for tracing the
* progress of the XSL processor.
*/
/**
* Create an event originating at the given node of the style tree.
* @param processor The XSLT Processor.
* @param sourceTree The input source tree.
* @param sourceNode The current context node.
* @param mode The current mode.
* @param m_styleNode node in the style tree reference for the event.
* Should not be null. That is not enforced.
*/
TracerEvent::TracerEvent(
const XSLTEngineImpl* processor,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode,
const ElemTemplateElement& styleNode): m_pProcessor(processor),
m_sourceTree(sourceTree),
m_sourceNode(sourceNode), m_mode(mode), m_styleNode(styleNode)
{
}
/**
Returns a string representation of the node.
The string returned for elements will contain the element name
and any attributes enclosed in angle brackets.
The string returned for attributes will be of form, "name=value."
@param n any DOM node. Must not be null.
@return a string representation of the given node.
*/
DOMString TracerEvent::printNode(const DOM_Node& n)
{
// in Java was thigs: String r = n.hashCode() + " ";
DOMString r = LongToDOMString(reinterpret_cast<long>(&n)) + " ";
if (n.getNodeType() == DOM_Node::ELEMENT_NODE)
{
r += "<" + n.getNodeName();
DOM_Node c = n.getFirstChild();
while (c != 0)
{
if (c.getNodeType() == DOM_Node::ATTRIBUTE_NODE)
{
r += printNode(c) + " ";
}
c = c.getNextSibling();
}
r += ">";
}
else
{
if (n.getNodeType() == DOM_Node::ATTRIBUTE_NODE)
{
r += n.getNodeName() + "=" + n.getNodeValue();
}
else
{
r += n.getNodeName();
}
}
return r;
}
/**
Returns a string representation of the node list.
The string will contain the list of nodes inside square braces.
Elements will contain the element name
and any attributes enclosed in angle brackets.
Attributes will be of form, "name=value."
@param l any DOM node list. Must not be null.
@return a string representation of the given node list.
*/
DOMString TracerEvent::printNodeList(const DOM_NodeList& l)
{
// in Java was this: String r = l.hashCode() + "[";
DOMString r = LongToDOMString(reinterpret_cast<long>(&l)) + "[";
int len = l.getLength() - 1;
int i = 0;
while (i < len)
{
DOM_Node n = l.item(i);
if (n != 0)
{
r += printNode(n) + ", ";
}
++i;
}
if (i == len)
{
DOM_Node n = l.item(len);
if (n != 0)
{
r += printNode(n);
}
}
return r + "]";
}
1.1 xml-xalan/c/src/XSLT/TracerEvent.hpp
Index: TracerEvent.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_TracerEvent_HEADER_GUARD)
#define XALAN_TracerEvent_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
class DOMString;
class DOM_Node;
class DOM_NodeList;
class QName;
class XSLTEngineImpl;
class ElemTemplateElement;
/**
* This is the parent class of events generated for tracing the
* progress of the XSL processor.
*/
class TracerEvent
{
public:
TracerEvent(const XSLTEngineImpl* processor, const DOM_Node&
sourceTree, const DOM_Node& sourceNode,
const QName& mode, const ElemTemplateElement& styleNode);
/**
Returns a string representation of the node.
The string returned for elements will contain the element name
and any attributes enclosed in angle brackets.
The string returned for attributes will be of form, "name=value."
@param n any DOM node. Must not be null.
@return a string representation of the given node.
*/
static DOMString printNode(const DOM_Node& n);
/**
Returns a string representation of the node list.
The string will contain the list of nodes inside square braces.
Elements will contain the element name
and any attributes enclosed in angle brackets.
Attributes will be of form, "name=value."
@param l any DOM node list. Must not be null.
@return a string representation of the given node list.
*/
static DOMString printNodeList(const DOM_NodeList& l);
/**
* The node in the style tree where the event occurs.
*/
const ElemTemplateElement& m_styleNode;
/**
* The XSLT processor instance.
*/
const XSLTEngineImpl* m_pProcessor;
/**
* The input source tree.
*/
const DOM_Node& m_sourceTree;
/**
* The current context node.
*/
const DOM_Node& m_sourceNode;
/**
* The current mode.
*/
const QName& m_mode;
private:
// not implemented
TracerEvent& operator=(const TracerEvent &);
};
#endif //XALAN_TracerEvent_HEADER_GUARD
1.1 xml-xalan/c/src/XSLT/XSLProcessorException.cpp
Index: XSLProcessorException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Base class header file.
#include "XSLProcessorException.hpp"
XSLProcessorException::XSLProcessorException(
const DOMString& message,
const DOM_Node& styleNode) :
XSLException(message),
m_styleNode(styleNode)
{
}
XSLProcessorException::~XSLProcessorException()
{
}
1.1 xml-xalan/c/src/XSLT/XSLProcessorException.hpp
Index: XSLProcessorException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XPATHPARSEREXCEPTION_HEADER_GUARD_1357924680)
#define XPATHPARSEREXCEPTION_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <Xslt/XSLTDefinitions.hpp>
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
#include <PlatformSupport/XSLException.hpp>
class XALAN_XSLT_EXPORT XSLProcessorException : public XSLException
{
public:
explicit
XSLProcessorException(
const DOMString& message = DOMString(),
const DOM_Node& styleNode = DOM_Node());
virtual
~XSLProcessorException();
private:
const DOM_Node m_styleNode;
};
#endif // XPATHPARSEREXCEPTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/XSLTDefinitions.hpp
Index: XSLTDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XSLTDEFINITIONS_HEADER_GUARD_1357924680)
#define XSLTDEFINITIONS_HEADER_GUARD_1357924680
#include <include/PlatformDefinitions.hpp>
#if defined(XALAN_XSLT_BUILD_DLL)
# define XALAN_XSLT_EXPORT XALAN_PLATFORM_EXPORT
# define XALAN_XSLT_EXPORT_FUNCTION(T) XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
# define XALAN_XSLT_EXPORT XALAN_PLATFORM_IMPORT
# define XALAN_XSLT_EXPORT_FUNCTION(T) XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // XSLTDEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
Index: XSLTEngineImpl.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: XSLTEngineImpl.cpp,v 1.1 1999/12/18 19:48:05 robweir Exp $
*
* $State: Exp $
*
* @author Scott Boag ([EMAIL PROTECTED])
@@ Need to check this text based on newer implementation:
*
* It is the responsibility of the XSLTEngineImpl class to traverse the
* source DOM tree according to the instructions in the style DOM tree,
* and output nodes into the result DOM tree.
*
* Basic flow of control:
* Starting from process(Document sourceTree, Document out, String mode),
* 1) init the Stylesheet instances (which hold the state for each imported
* XSL stylesheet) in the parseXSLRoot method, then
* 2) locate the rootRule (all rules are found via Stylesheet.findTemplate),
* then pass the root node of the source tree to
* 3) buildResultFromTemplate, which processes each of the template's
* child elements by calling
* 4) processTemplateElement, which either processes the element
* by handling it as an XSL directive (if it is in the xsl: namespace),
* or by cloning the source node to the result tree.
* If it is an XSL instruction,
* 5) processXSLTemplateInstruction is called, which calls various
* subfunctions according to the tag name.
* The XSL directives that effect the source traversal are
xsl:apply-templates
* and xsl:for-each, which are handled in the
* 6) handleApplyTemplatesInstruction, which selects the start node and
* calls the
* 7) transformSelectedChildren method, which performs a query or just
* traverses the child list, then for each node in the selected list
calls
* 8) transformChild, which then calls
* 9) Stylesheet.findTemplate (if it is not an xsl:for-each instruction)
* to locate the corresponding template, and then calls
* 10) buildResultFromTemplate, recursing back in to step 3 and starting the
* traversal cycle all over again.
*
* Glossory (abbreviations used in variable and method
* names in square brackets):
* <DL>
* <DT>XSL Instruction [instruction]</DT>
* <DD>Any tag with an XSL namespace prefix.</DD>
* <DT>XSL Template Instruction [instruction]</DT>
* <DD>Any tag with an XSL namespace prefix
* that occurs inside an xsl:template element.</DD>
* <DT>Template Child [templateChild]</DT>
* <DD>Any node that is a child of an xsl:template element.</DD>
* <DT>Source Tree</DT>
* <DD>The tree input to the XSL process.</DD>
* <DT>Result Tree</DT>
* <DD>The tree that is output by the XSL process.</DD>
* <DT>Stylesheet Tree</DT>
* <DD>The stylesheet tree produced from the XSL file.</DD>
* <DT>Pattern List [patternList]</DT>
* <DD>A parsed query or match pattern.</DD>
* </DL>
*
*/
// Class header file.
#include "XSLTEngineImpl.hpp"
#include <dom/DOM_DOMException.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_NodeList.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <dom/DOM_ProcessingInstruction.hpp>
#include <sax/DocumentHandler.hpp>
#include <sax/SaxException.hpp>
#include <util/StdOut.hpp>
#include <util/PlatformUtils.hpp>
#include <internal/URLInputSource.hpp>
#include "Arg.hpp"
#include "ContextMarker.hpp"
#include "ElemWithParam.hpp"
#include "ElementMarker.hpp"
#include "FunctionCurrent.hpp"
#include "FunctionFormatNumber.hpp"
#include "FunctionKey.hpp"
#include "FunctionUnparsedEntityURI.hpp"
#include "FunctionSystemProperty.hpp"
#include "FunctionGenerateID.hpp"
#include "NodeSortKey.hpp"
#include "NodeSorter.hpp"
#include "ProblemListener.hpp"
#include "ProblemListenerDefault.hpp"
#include "Stylesheet.hpp"
#include "StylesheetHandler.hpp"
#include "StylesheetRoot.hpp"
#include "XSLTProcessorException.hpp"
#include "GenerateEvent.hpp"
// @@ LATER #include "FunctionDocument.hpp"
// ?? #include <XercesPlatformSupport/XercesDOMPrintWriter.hpp>
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/DOMStringPrintWriter.hpp>
#include <PlatformSupport/PrintWriter.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include <XMLSupport/Formatter.hpp>
#include <XMLSupport/FormatterToDOM.hpp>
#include <XMLSupport/FormatterToText.hpp>
#include <XMLSupport/FormatterTreeWalker.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include <XMLSupport/FormatterTreeWalker.hpp>
#include <XPath/ElementPrefixResolverProxy.hpp>
#include <XPath/ResultTreeFrag.hpp>
#include <XPath/XObject.hpp>
#include <XPath/XPathFactory.hpp>
#include <XPath/XPathSupport.hpp>
#include <XPath/XString.hpp>
#include <XPath/XResultTreeFrag.hpp>
#include <DOMSupport/UnimplementedNode.hpp>
#include <DOMSupport/UnimplementedElement.hpp>
#include <DOMSupport/UnimplementedDocumentFragment.hpp>
const double XSLTEngineImpl::s_XSLTVerSupported(1.0);
const DOMString
XSLTEngineImpl::s_DefaultXSLNameSpaceURL("http://www.w3.org/1999/XSL/Transform/1.0");
const DOMString
XSLTEngineImpl::s_XSLNameSpaceURLPre("http://www.w3.org/1999/XSL/Transform");
const DOMString
XSLTEngineImpl::s_XSLT4JNameSpaceURL("http://xml.apache.org/xslt");
/**
* Control if the xsl:variable is resolved early or
* late. Resolving the xsl:variable
* early is a drag because it means that the fragment
* must be created into a DocumentFragment, and then
* cloned each time to the result tree. If we can resolve
* late, that means we can evaluate directly into the
* result tree. Right now this must be kept on 'early'
* because you would need to set the call stack back to
* the point of xsl:invoke... which I can't quite work out
* at the moment. I don't think this is worth fixing
* until NodeList variables are implemented.
*/
const bool
XSLTEngineImpl::m_resolveContentsEarly = true;
const XSLTEngineImpl::AttributeKeysMapType
XSLTEngineImpl::s_attributeKeys =
XSLTEngineImpl::InitializeAttributeKeysTable();
const XSLTEngineImpl::ElementKeysMapType
XSLTEngineImpl::s_elementKeys =
XSLTEngineImpl::InitializeElementKeysTable();
const XSLTEngineImpl::ElementKeysMapType
XSLTEngineImpl::s_XSLT4JElementKeys =
XSLTEngineImpl::InitializeXSLT4JElementKeys();
const XSLTEngineImpl::StaticInitializer
XSLTEngineImpl::s_staticInitializer;
//==========================================================
// SECTION: Constructors
//==========================================================
XSLTEngineImpl::XSLTEngineImpl(
XMLParserLiaison
&parserLiaison,
XPathSupport&
xpathSupport,
XPathEnvSupport&
xpathEnvSupport,
XObjectFactory*
xobjectFactory,
XPathFactory
*xpathFactory) :
/* was:
XSLTEngineImpl::XSLTEngineImpl(XMLParserLiaison& parserLiaison,
XPathSupport& xpathSupport)
*/
XSLTProcessor(),
DocumentHandler(),
m_stylesheetRoot(0),
m_stylesheets(),
m_sourceDocs(),
m_rootDoc(),
m_XSLNameSpaceURL(s_DefaultXSLNameSpaceURL),
m_XSLDirectiveLookup(),
m_quietConflictWarnings(false),
m_traceTemplateChildren(false),
m_traceTemplates(false),
m_traceSelects(false),
m_diagnosticsPrintWriter(0),
m_durationsTable(),
m_pendingElementName(),
m_pendingAttributes(),
m_resultNameSpaces(),
m_emptyNamespace(),
m_uniqueNSValue(0),
m_useATVsInSelects(false),
m_cssKeys(),
m_translateCSS(false),
m_stripWhiteSpace(false),
m_outputCarriageReturns(false),
m_outputLinefeeds(false),
m_topLevelParams(),
m_parserLiaison(parserLiaison),
m_xpathSupport(xpathSupport),
m_xpathEnvSupport(xpathEnvSupport),
m_xpathFactory(xpathFactory),
m_xobjectFactory(xobjectFactory),
m_formatter(0),
m_flistener(0),
m_resultTreeFactory(),
m_resultNameSpacePrefix(),
m_resultNameSpaceURL(),
m_contextNodeList(),
m_keyDeclarations(),
m_keys(),
m_needToBuildKeysTable(false),
m_currentNode(),
m_namedTemplates(),
m_topLevelVariables(),
m_problemListener(new ProblemListenerDefault()),
m_needToCheckForInfiniteLoops(false),
m_stackGuard(*this),
m_variableStacks(*this)
{
// @@ what's this
// FormatterToXML.initEncodings();
// java: m_parserLiaison.setEnvSupport(this);
/*
// @@ JMD: Do we need this ??
if(m_parserLiaison instanceof Formatter)
{
m_formatter = (Formatter)m_parserLiaison;
}
*/
initXPath(m_xpathFactory);
}
/**
* Init anything to do with XPath.
*/
void XSLTEngineImpl::initXPath(XPathFactory* xpathFactory)
{
if(0 != xpathFactory)
m_xpathFactory = xpathFactory;
// @@ Not in parser liaison or friends
// m_parserLiaison.setProcessorOwner(this);
m_xpathProcessor = new XPathProcessorImpl(m_xpathEnvSupport,
m_xpathSupport);
m_xpath = m_xpathFactory->create();
// @@ LATER m_xpath->installFunction("document", FunctionDocument());
}
/**
* Reset the state. This needs to be called after a process() call
* is invoked, if the processor is to be used again.
*/
void XSLTEngineImpl::reset()
{
m_rootDoc = 0;
m_XSLNameSpaceURL = s_DefaultXSLNameSpaceURL;
m_durationsTable.clear();
m_stylesheetLocatorStack.clear();
m_pendingElementName = "";
m_pendingAttributes.clear();
m_cdataStack.clear();
m_resultTreeFactory = 0;
m_contextNodeList.clear();
m_currentNode = 0;
m_needToCheckForInfiniteLoops = false;
m_variableStacks.reset();
m_stackGuard.clear();
m_xpathSupport.reset();
m_parserLiaison.reset();
m_xpathEnvSupport.reset();
m_xpathFactory->reset();
m_xobjectFactory->reset();
delete m_stylesheetRoot;
m_stylesheetRoot = 0;
}
XSLTEngineImpl::~XSLTEngineImpl()
{
delete m_problemListener;
delete m_xpathProcessor;
reset();
m_diagnosticsPrintWriter = 0;
m_xpathFactory = 0;
m_xobjectFactory = 0;
m_xpath = 0;
m_formatter = 0;
m_flistener = 0;
}
//==========================================================
// SECTION: Main API Functions
//==========================================================
AttributeListImpl&
XSLTEngineImpl::getPendingAttributes()
{
return m_pendingAttributes;
}
DOMString
XSLTEngineImpl::getPendingElementName() const
{
return m_pendingElementName;
}
void
XSLTEngineImpl::setPendingAttributes(const AttributeList&
pendingAttributes)
{
m_pendingAttributes = pendingAttributes;
}
void
XSLTEngineImpl::setPendingElementName(const DOMString& elementName)
{
m_pendingElementName = elementName;
}
void
XSLTEngineImpl::process(XSLTInputSource *inputSource,
XSLTInputSource *stylesheetSource,
XSLTResultTarget* outputTarget)
{
try
{
DOMString xslIdentifier(((0 == stylesheetSource) ||
(0 == stylesheetSource->getSystemId()))
? DOMString("Input XSL") : stylesheetSource->getSystemId());
bool totalTimeID = true;
pushTime(&totalTimeID);
DOM_Node sourceTree;
if(0 != inputSource)
sourceTree = getSourceTreeFromInput(inputSource);
if(0 != stylesheetSource)
{
m_stylesheetRoot = processStylesheet(stylesheetSource);
}
else if(0 != sourceTree)
{
DOMString stylesheetURI = 0;
DOM_NodeList children = sourceTree.getChildNodes();
int nNodes = children.getLength();
Stack <DOMString> hrefs;
for(int i = 0; i < nNodes; i++)
{
DOM_Node child = children.item(i);
if(DOM_Node::PROCESSING_INSTRUCTION_NODE ==
child.getNodeType())
{
/*DOM_ProcessingInstruction*/const DOM_Node&
pi = child;
if(pi.getNodeName().equals("xml-stylesheet")
||
pi.getNodeName().equals("xml:stylesheet"))
{
bool isOK = true;
StringTokenizer
tokenizer(pi.getNodeValue(), " \t=", true);
while(tokenizer.hasMoreTokens())
{
if(tokenizer.nextToken().equals("type"))
{
DOMString
typeVal = tokenizer.nextToken();
typeVal =
substring(typeVal, 1, typeVal.length()-1);
if(!typeVal.equals("text/xsl"))
{
isOK =
false;
}
}
}
if(isOK)
{
StringTokenizer
tokenizer(pi.getNodeValue(), " \t=", true);
while(tokenizer.hasMoreTokens())
{
if(tokenizer.nextToken().equals("href"))
{
stylesheetURI = tokenizer.nextToken();
stylesheetURI = substring(stylesheetURI, 1, stylesheetURI.length()-1);
hrefs.push(stylesheetURI);
}
}
// break;
}
}
}
} // end for(int i = 0; i < nNodes; i++)
bool isRoot = true;
Stylesheet* prevStylesheet = 0;
while(!hrefs.empty())
{
const XMLCh *pxch = (0 != inputSource) ?
inputSource->getSystemId() : 0;
DOMString sysid(pxch);
DOMString ref = hrefs.pop();
Stylesheet* stylesheet =
getStylesheetFromPIURL(ref, sourceTree,
sysid, isRoot);
if(false == isRoot)
{
prevStylesheet->getImports().push_back(stylesheet);
}
prevStylesheet = stylesheet;
isRoot = false;
}
}
else
{
error("Stylesheet input was not specified!");
}
if(0 == m_stylesheetRoot)
{
error("Failed to process stylesheet!");
}
if(0 != sourceTree)
{
m_stylesheetRoot->process(sourceTree, outputTarget);
if(0 != m_diagnosticsPrintWriter)
{
displayDuration("Total time", &totalTimeID);
}
}
}
/*
catch(MalformedURLException mue)
{
error(mue.getMessage(), mue);
// throw se;
}
catch(FileNotFoundException fnfe)
{
error(fnfe.getMessage(), fnfe);
// throw se;
}
catch(IOException ioe)
{
error(ioe.getMessage(), ioe);
// throw se;
}
*/
catch(SAXException& se)
{
message("SAX Exception");
throw se;
}
catch (...)
{
assert(0);
}
}
StylesheetRoot* XSLTEngineImpl::processStylesheet(const DOMString
&xsldocURLString)
{
try
{
std::auto_ptr<URL> url(getURLFromString(xsldocURLString));
XSLTInputSource input(url->getURL(), 0);
return processStylesheet(&input);
}
catch(SAXException& se)
{
message("processStylesheet not successful!");
throw se;
}
return 0;
}
StylesheetRoot* XSLTEngineImpl::processStylesheet(XSLTInputSource*
stylesheetSource)
{
if(0 != m_stylesheetRoot)
reset();
DOMString xslIdentifier(((0 == stylesheetSource) ||
(0 ==
stylesheetSource->getSystemId()))
?
DOMString("Input XSL") : stylesheetSource->getSystemId());
// In case we have a fragment identifier, go ahead and
// try to parse the XML here.
try
{
m_stylesheetRoot = new StylesheetRoot(this,
stylesheetSource->getSystemId());
addTraceListenersToStylesheet();
StylesheetHandler stylesheetProcessor(*this,
*m_stylesheetRoot);
if(0 != stylesheetSource->getNode())
{
FormatterListener& flistener =
dynamic_cast<FormatterListener&>(stylesheetProcessor);
FormatterTreeWalker tw(flistener);
tw.traverse(stylesheetSource->getNode());
}
else
{
diag("========= Parsing "+xslIdentifier+" ==========");
pushTime(&xslIdentifier);
m_parserLiaison.parseXMLStream(*stylesheetSource,
stylesheetProcessor);
if(0 != m_diagnosticsPrintWriter)
displayDuration("Parse of "+xslIdentifier,
&xslIdentifier);
}
}
catch(const XSLException& e)
{
message("Error parsing " + xslIdentifier);
throw;
}
catch(const SAXException& e)
{
message("Error parsing " + xslIdentifier);
throw;
}
catch(const XMLException& e)
{
message("Error parsing " + xslIdentifier);
throw;
}
return m_stylesheetRoot;
}
//==========================================================
// SECTION: XML Parsing Functions
//==========================================================
const DOM_Node XSLTEngineImpl::getSourceTreeFromInput(XSLTInputSource
*inputSource)
{
DOM_Node sourceTree;
const DOMString ds("Input XML");
DOMString xmlIdentifier = ((0 == inputSource) ||
(0 == inputSource->getSystemId())) ?
ds : inputSource->getSystemId();
if(0 != inputSource->getNode())
{
sourceTree = inputSource->getNode();
}
else
{
// In case we have a fragment identifier, go ahead and
// try to parse the XML here.
try
{
diag("========= Parsing "+xmlIdentifier+" ==========");
pushTime(&xmlIdentifier);
sourceTree =
m_parserLiaison.parseXMLStream(*inputSource,
xmlIdentifier);
if(0 != m_diagnosticsPrintWriter)
displayDuration("Parse of "+xmlIdentifier,
&xmlIdentifier);
}
// catch(Exception e)
// @@ Fix later
catch(...)
{
/*
java:
// Unwrap exception
if((e instanceof SAXException) && (null !=
((SAXException)e).getException()))
{
//
((SAXException)e).getException().printStackTrace();
e = ((SAXException)e).getException();
}
sourceTree = null; // shutup compiler
error("Could not parse "+xmlIdentifier+" document!", e);
*/
error("Could not parse "+xmlIdentifier+" document!");
}
}
return sourceTree;
}
DOM_Document XSLTEngineImpl::parseXML(const URL& url,
DocumentHandler* docHandler,
const DOM_Document& docToRegister)
{
// java: url.toExternalForm();
const DOMString& urlString = url.getURL();
DOM_Document doc;
const SourceDocumentsMapType::iterator it =
m_sourceDocs.find(urlString);
if(it != m_sourceDocs.end())
{
doc = (*it).second;
return doc;
}
// java: url.toString()
XSLTInputSource inputSource(url.getURL());
if(0 != docHandler)
m_parserLiaison.parseXMLStream(inputSource, *docHandler);
else
m_parserLiaison.parseXMLStream(inputSource);
if(0 == docHandler)
{
// java: doc = m_parserLiaison.getDocument();
assert(0); // @@ JMD: We don't handle this case right now
}
else
{
doc = docToRegister;
}
return doc;
}
Stylesheet* XSLTEngineImpl::getStylesheetFromPIURL(DOMString& xslURLString,
const DOM_Node&
fragBase,
DOMString&
xmlBaseIdent,
bool isRoot)
{
Stylesheet* stylesheet = 0;
// ?? String[] stringHolder = { null};
DOMString stringHolder;
xslURLString = trim(xslURLString);
int fragIndex = indexOf(xslURLString, '#');
DOM_Document stylesheetDoc;
if(fragIndex == 0)
{
diag("Locating stylesheet from fragment identifier...");
DOMString fragID = substring(xslURLString, 1);
DOM_Element nsNode;
if (fragBase.getNodeType() == DOM_Node::DOCUMENT_NODE)
{
const DOM_Document& doc = static_cast<const
DOM_Document&>(fragBase);
nsNode = doc.getDocumentElement();
}
else if (fragBase.getNodeType() == DOM_Node::ELEMENT_NODE)
nsNode = (static_cast<const DOM_Element&>(fragBase));
else
{
DOM_Node node = fragBase.getParentNode();
if (node.getNodeType() == DOM_Node::ELEMENT_NODE)
nsNode = (static_cast<const
DOM_Element&>(node));
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?
DOMString ds;
ds = "id("; ds += fragID; ds += ")";
ElementPrefixResolverProxy theProxy(nsNode,
m_xpathSupport);
XObject* xobj = evalXPathStr(ds, fragBase, theProxy);
// java: NodeList nl = xobj->nodeset();
const NodeRefListBase* nl = &(xobj->nodeset());
if(nl->getLength() == 0)
{
ds = "//[EMAIL PROTECTED]'"; ds += fragID; ds += "']";
xobj = evalXPathStr(ds, fragBase, theProxy);
nl = &(xobj->nodeset());
if(nl->getLength() == 0)
{
ds = "//[EMAIL PROTECTED]'"; ds += fragID; ds
+= "']";
xobj = evalXPathStr(ds, fragBase, theProxy);
nl = &(xobj->nodeset());
if(nl->getLength() == 0)
{
// Well, hell, maybe it's an XPath...
xobj = evalXPathStr(fragID, fragBase,
theProxy);
nl = &(xobj->nodeset());
}
}
}
if(nl->getLength() == 0)
{
error("Could not find fragment: "+fragID);
}
DOM_Node frag = nl->item(0);
if(DOM_Node::ELEMENT_NODE == frag.getNodeType())
{
pushTime(&frag);
if(isRoot)
{
m_stylesheetRoot = new StylesheetRoot(this,
stringHolder);
stylesheet = m_stylesheetRoot;
}
else
{
stylesheet = new Stylesheet(*m_stylesheetRoot,
this, stringHolder);
}
addTraceListenersToStylesheet();
StylesheetHandler stylesheetProcessor(*this,
*stylesheet);
FormatterListener& flistener =
dynamic_cast<FormatterListener&>(stylesheetProcessor);
FormatterTreeWalker tw(flistener);
tw.traverse(frag);
displayDuration("Setup of "+xslURLString, &frag);
}
else
{
stylesheetDoc = 0;
error("Node pointed to by fragment identifier was not
an element: "+fragID);
}
}
else
{
// hmmm.. for now I'll rely on the XML parser to handle
// fragment URLs.
diag("========= Parsing and preparing "+xslURLString+"
==========");
pushTime(&xslURLString);
if(isRoot)
{
m_stylesheetRoot = new StylesheetRoot(this,
xslURLString);
stylesheet = m_stylesheetRoot;
}
else
{
stylesheet = new Stylesheet(*m_stylesheetRoot, this,
xslURLString);
}
addTraceListenersToStylesheet();
StylesheetHandler stylesheetProcessor(*this, *stylesheet);
URL* xslURL = getURLFromString(xslURLString, xmlBaseIdent);
XSLTInputSource inputSource(xslURL->getURL());
// java:
m_parserLiaison.setDocumentHandler(stylesheetProcessor);
// m_parserLiaison.parse(inputSource);
m_parserLiaison.parseXMLStream(inputSource,
stylesheetProcessor);
displayDuration("Parsing and init of "+xslURLString,
&xslURLString);
}
return stylesheet;
}
//==========================================================
// SECTION: Stylesheet Tables
//==========================================================
double XSLTEngineImpl::getXSLTVerSupported()
{
return s_XSLTVerSupported;
}
//==========================================================
// SECTION: XSL directive handling functions
//==========================================================
#if 0
void
XSLTEngineImpl::initXSLTKeys()
{
m_elementKeys.clear();
m_elementKeys[Constants::ELEMNAME_APPLY_TEMPLATES_STRING] =
Constants::ELEMNAME_APPLY_TEMPLATES;
m_elementKeys[Constants::ELEMNAME_WITHPARAM_STRING] =
Constants::ELEMNAME_WITHPARAM;
m_elementKeys[Constants::ELEMNAME_CONSTRUCT_STRING] =
Constants::ELEMNAME_CONSTRUCT;
m_elementKeys[Constants::ELEMNAME_CONTENTS_STRING] =
Constants::ELEMNAME_CONTENTS;
m_elementKeys[Constants::ELEMNAME_COPY_STRING] =
Constants::ELEMNAME_COPY;
m_elementKeys[Constants::ELEMNAME_COPY_OF_STRING] =
Constants::ELEMNAME_COPY_OF;
m_elementKeys[Constants::ELEMNAME_ATTRIBUTESET_STRING] =
Constants::ELEMNAME_DEFINEATTRIBUTESET;
m_elementKeys[Constants::ELEMNAME_USE_STRING] = Constants::ELEMNAME_USE;
m_elementKeys[Constants::ELEMNAME_VARIABLE_STRING] =
Constants::ELEMNAME_VARIABLE;
m_elementKeys[Constants::ELEMNAME_PARAMVARIABLE_STRING] =
Constants::ELEMNAME_PARAMVARIABLE;
m_elementKeys[Constants::ELEMNAME_DISPLAYIF_STRING] =
Constants::ELEMNAME_DISPLAYIF;
m_elementKeys[Constants::ELEMNAME_EMPTY_STRING] =
Constants::ELEMNAME_EMPTY;
m_elementKeys[Constants::ELEMNAME_EVAL_STRING] =
Constants::ELEMNAME_EVAL;
m_elementKeys[Constants::ELEMNAME_CALLTEMPLATE_STRING] =
Constants::ELEMNAME_CALLTEMPLATE;
m_elementKeys[Constants::ELEMNAME_TEMPLATE_STRING] =
Constants::ELEMNAME_TEMPLATE;
m_elementKeys[Constants::ELEMNAME_STYLESHEET_STRING] =
Constants::ELEMNAME_STYLESHEET;
m_elementKeys[Constants::ELEMNAME_TRANSFORM_STRING] =
Constants::ELEMNAME_STYLESHEET;
m_elementKeys[Constants::ELEMNAME_IMPORT_STRING] =
Constants::ELEMNAME_IMPORT;
m_elementKeys[Constants::ELEMNAME_INCLUDE_STRING] =
Constants::ELEMNAME_INCLUDE;
m_elementKeys[Constants::ELEMNAME_FOREACH_STRING] =
Constants::ELEMNAME_FOREACH;
m_elementKeys[Constants::ELEMNAME_VALUEOF_STRING] =
Constants::ELEMNAME_VALUEOF;
m_elementKeys[Constants::ELEMNAME_KEY_STRING] = Constants::ELEMNAME_KEY;
m_elementKeys[Constants::ELEMNAME_STRIPSPACE_STRING] =
Constants::ELEMNAME_STRIPSPACE;
m_elementKeys[Constants::ELEMNAME_PRESERVESPACE_STRING] =
Constants::ELEMNAME_PRESERVESPACE;
m_elementKeys[Constants::ELEMNAME_NUMBER_STRING] =
Constants::ELEMNAME_NUMBER;
m_elementKeys[Constants::ELEMNAME_IF_STRING] = Constants::ELEMNAME_IF;
m_elementKeys[Constants::ELEMNAME_CHOOSE_STRING] =
Constants::ELEMNAME_CHOOSE;
m_elementKeys[Constants::ELEMNAME_WHEN_STRING] =
Constants::ELEMNAME_WHEN;
m_elementKeys[Constants::ELEMNAME_OTHERWISE_STRING] =
Constants::ELEMNAME_OTHERWISE;
m_elementKeys[Constants::ELEMNAME_TEXT_STRING] =
Constants::ELEMNAME_TEXT;
m_elementKeys[Constants::ELEMNAME_ELEMENT_STRING] =
Constants::ELEMNAME_ELEMENT;
m_elementKeys[Constants::ELEMNAME_ATTRIBUTE_STRING] =
Constants::ELEMNAME_ATTRIBUTE;
m_elementKeys[Constants::ELEMNAME_SORT_STRING] =
Constants::ELEMNAME_SORT;
m_elementKeys[Constants::ELEMNAME_PI_STRING] = Constants::ELEMNAME_PI;
m_elementKeys[Constants::ELEMNAME_COMMENT_STRING] =
Constants::ELEMNAME_COMMENT;
m_elementKeys[Constants::ELEMNAME_COUNTER_STRING] =
Constants::ELEMNAME_COUNTER;
m_elementKeys[Constants::ELEMNAME_COUNTERS_STRING] =
Constants::ELEMNAME_COUNTERS;
m_elementKeys[Constants::ELEMNAME_COUNTERINCREMENT_STRING] =
Constants::ELEMNAME_COUNTERINCREMENT;
m_elementKeys[Constants::ELEMNAME_COUNTERRESET_STRING] =
Constants::ELEMNAME_COUNTERRESET;
m_elementKeys[Constants::ELEMNAME_COUNTERSCOPE_STRING] =
Constants::ELEMNAME_COUNTERSCOPE;
m_elementKeys[Constants::ELEMNAME_APPLY_IMPORTS_STRING] =
Constants::ELEMNAME_APPLY_IMPORTS;
m_elementKeys[Constants::ELEMNAME_EXTENSION_STRING] =
Constants::ELEMNAME_EXTENSION;
m_elementKeys[Constants::ELEMNAME_MESSAGE_STRING] =
Constants::ELEMNAME_MESSAGE;
m_elementKeys[Constants::ELEMNAME_LOCALE_STRING] =
Constants::ELEMNAME_LOCALE;
m_elementKeys[Constants::ELEMNAME_FALLBACK_STRING] =
Constants::ELEMNAME_FALLBACK;
m_elementKeys[Constants::ELEMNAME_OUTPUT_STRING] =
Constants::ELEMNAME_OUTPUT;
m_XSLT4JElementKeys[Constants::ELEMNAME_CSSSTYLECONVERSION_STRING] =
Constants::ELEMNAME_CSSSTYLECONVERSION;
m_XSLT4JElementKeys[Constants::ELEMNAME_COMPONENT_STRING] =
Constants::ELEMNAME_COMPONENT;
m_XSLT4JElementKeys[Constants::ELEMNAME_SCRIPT_STRING] =
Constants::ELEMNAME_SCRIPT;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_METHOD] =
Constants::TATTRNAME_OUTPUT_METHOD;
m_attributeKeys[Constants::ATTRNAME_AMOUNT] =
Constants::TATTRNAME_AMOUNT;
m_attributeKeys[Constants::ATTRNAME_ANCESTOR] =
Constants::TATTRNAME_ANCESTOR;
m_attributeKeys[Constants::ATTRNAME_ARCHIVE] =
Constants::TATTRNAME_ARCHIVE;
m_attributeKeys[Constants::ATTRNAME_ATTRIBUTE] =
Constants::TATTRNAME_ATTRIBUTE;
m_attributeKeys[Constants::ATTRNAME_ATTRIBUTE_SET] =
Constants::TATTRNAME_ATTRIBUTE_SET;
m_attributeKeys[Constants::ATTRNAME_CASEORDER] =
Constants::TATTRNAME_CASEORDER;
m_attributeKeys[Constants::ATTRNAME_CLASS] = Constants::TATTRNAME_CLASS;
m_attributeKeys[Constants::ATTRNAME_CLASSID] =
Constants::TATTRNAME_CLASSID;
m_attributeKeys[Constants::ATTRNAME_CODEBASE] =
Constants::TATTRNAME_CODEBASE;
m_attributeKeys[Constants::ATTRNAME_CODETYPE] =
Constants::TATTRNAME_CODETYPE;
m_attributeKeys[Constants::ATTRNAME_CONDITION] =
Constants::TATTRNAME_CONDITION;
m_attributeKeys[Constants::ATTRNAME_COPYTYPE] =
Constants::TATTRNAME_COPYTYPE;
m_attributeKeys[Constants::ATTRNAME_COUNT] = Constants::TATTRNAME_COUNT;
m_attributeKeys[Constants::ATTRNAME_DATATYPE] =
Constants::TATTRNAME_DATATYPE;
m_attributeKeys[Constants::ATTRNAME_DEFAULT] =
Constants::TATTRNAME_DEFAULT;
m_attributeKeys[Constants::ATTRNAME_DEFAULTSPACE] =
Constants::TATTRNAME_DEFAULTSPACE;
m_attributeKeys[Constants::ATTRNAME_DEPTH] = Constants::TATTRNAME_DEPTH;
m_attributeKeys[Constants::ATTRNAME_DIGITGROUPSEP] =
Constants::TATTRNAME_DIGITGROUPSEP;
m_attributeKeys[Constants::ATTRNAME_DISABLE_OUTPUT_ESCAPING] =
Constants::TATTRNAME_DISABLE_OUTPUT_ESCAPING;
m_attributeKeys[Constants::ATTRNAME_ELEMENT] =
Constants::TATTRNAME_ELEMENT;
m_attributeKeys[Constants::ATTRNAME_ELEMENTS] =
Constants::TATTRNAME_ELEMENTS;
m_attributeKeys[Constants::ATTRNAME_EXPR] = Constants::TATTRNAME_EXPR;
m_attributeKeys[Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES] =
Constants::TATTRNAME_EXTENSIONELEMENTPREFIXES;
m_attributeKeys[Constants::ATTRNAME_FORMAT] =
Constants::TATTRNAME_FORMAT;
m_attributeKeys[Constants::ATTRNAME_FROM] = Constants::TATTRNAME_FROM;
m_attributeKeys[Constants::ATTRNAME_GROUPINGSEPARATOR] =
Constants::TATTRNAME_GROUPINGSEPARATOR;
m_attributeKeys[Constants::ATTRNAME_GROUPINGSIZE] =
Constants::TATTRNAME_GROUPINGSIZE;
m_attributeKeys[Constants::ATTRNAME_HREF] = Constants::TATTRNAME_HREF;
m_attributeKeys[Constants::ATTRNAME_ID] = Constants::TATTRNAME_ID;
m_attributeKeys[Constants::ATTRNAME_IMPORTANCE] =
Constants::TATTRNAME_IMPORTANCE;
m_attributeKeys[Constants::ATTRNAME_INDENTRESULT] =
Constants::TATTRNAME_INDENTRESULT;
m_attributeKeys[Constants::ATTRNAME_LANG] = Constants::TATTRNAME_LANG;
m_attributeKeys[Constants::ATTRNAME_LETTERVALUE] =
Constants::TATTRNAME_LETTERVALUE;
m_attributeKeys[Constants::ATTRNAME_LEVEL] = Constants::TATTRNAME_LEVEL;
m_attributeKeys[Constants::ATTRNAME_MATCH] = Constants::TATTRNAME_MATCH;
m_attributeKeys[Constants::ATTRNAME_METHOD] =
Constants::TATTRNAME_METHOD;
m_attributeKeys[Constants::ATTRNAME_MODE] = Constants::TATTRNAME_MODE;
m_attributeKeys[Constants::ATTRNAME_NAME] = Constants::TATTRNAME_NAME;
m_attributeKeys[Constants::ATTRNAME_NAMESPACE] =
Constants::TATTRNAME_NAMESPACE;
m_attributeKeys[Constants::ATTRNAME_NDIGITSPERGROUP] =
Constants::TATTRNAME_NDIGITSPERGROUP;
m_attributeKeys[Constants::ATTRNAME_NS] = Constants::TATTRNAME_NS;
m_attributeKeys[Constants::ATTRNAME_ONLY] = Constants::TATTRNAME_ONLY;
m_attributeKeys[Constants::ATTRNAME_ORDER] = Constants::TATTRNAME_ORDER;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS] =
Constants::TATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_DOCTYPE_PUBLIC] =
Constants::TATTRNAME_OUTPUT_DOCTYPE_PUBLIC;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_DOCTYPE_SYSTEM] =
Constants::TATTRNAME_OUTPUT_DOCTYPE_SYSTEM;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_ENCODING] =
Constants::TATTRNAME_OUTPUT_ENCODING;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_INDENT] =
Constants::TATTRNAME_OUTPUT_INDENT;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_MEDIATYPE] =
Constants::TATTRNAME_OUTPUT_MEDIATYPE;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_STANDALONE] =
Constants::TATTRNAME_OUTPUT_STANDALONE;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_VERSION] =
Constants::TATTRNAME_OUTPUT_VERSION;
m_attributeKeys[Constants::ATTRNAME_OUTPUT_XMLDECL] =
Constants::TATTRNAME_OUTPUT_XMLDECL;
m_attributeKeys[Constants::ATTRNAME_PRIORITY] =
Constants::TATTRNAME_PRIORITY;
m_attributeKeys[Constants::ATTRNAME_REFID] = Constants::TATTRNAME_REFID;
m_attributeKeys[Constants::ATTRNAME_RESULTNS] =
Constants::TATTRNAME_RESULTNS;
m_attributeKeys[Constants::ATTRNAME_SELECT] =
Constants::TATTRNAME_SELECT;
m_attributeKeys[Constants::ATTRNAME_SEQUENCESRC] =
Constants::TATTRNAME_SEQUENCESRC;
m_attributeKeys[Constants::ATTRNAME_STYLE] = Constants::TATTRNAME_STYLE;
m_attributeKeys[Constants::ATTRNAME_TEST] = Constants::TATTRNAME_TEST;
m_attributeKeys[Constants::ATTRNAME_TOSTRING] =
Constants::TATTRNAME_TOSTRING;
m_attributeKeys[Constants::ATTRNAME_TYPE] = Constants::TATTRNAME_TYPE;
m_attributeKeys[Constants::ATTRNAME_USE] = Constants::TATTRNAME_USE;
m_attributeKeys[Constants::ATTRNAME_USEATTRIBUTESETS] =
Constants::TATTRNAME_USEATTRIBUTESETS;
m_attributeKeys[Constants::ATTRNAME_VALUE] = Constants::TATTRNAME_VALUE;
m_attributeKeys[Constants::ATTRNAME_XMLNSDEF] =
Constants::TATTRNAME_XMLNSDEF;
m_attributeKeys[Constants::ATTRNAME_XMLNS] = Constants::TATTRNAME_XMLNS;
m_attributeKeys[Constants::ATTRNAME_XMLSPACE] =
Constants::TATTRNAME_XMLSPACE;
}
#endif
int
XSLTEngineImpl::getXSLToken(const DOM_Node& node) const
{
int tok = -2;
if(DOM_Node::ELEMENT_NODE != node.getNodeType()) return tok;
const DOMString ns =
m_xpathSupport.getNamespaceOfNode(node);
// was: toLowerCase
if(equals(ns, m_XSLNameSpaceURL))
{
const DOMString localName =
m_xpathSupport.getLocalNameOfNode(node);
// $$$ ToDo: Why can't this iterator be a
// const_iterator? VC++ pukes if it is.
const ElementKeysMapType::const_iterator j =
s_elementKeys.find(localName);
if(j != s_elementKeys.end())
{
tok = (*j).second;
}
else
tok = -2;
}
else if(equals(ns, s_XSLT4JNameSpaceURL))
{
const DOMString localName =
m_xpathSupport.getLocalNameOfNode(node);
const ElementKeysMapType::const_iterator j =
s_XSLT4JElementKeys.find(localName);
if(j != s_XSLT4JElementKeys.end())
{
tok = (*j).second;
}
else
tok = -2;
}
else
tok = -2;
return tok;
}
bool
XSLTEngineImpl::isXSLTagOfType(const DOM_Node& node,
int
tagType) const
{
return getXSLToken(node) == tagType ? true : false;
}
void XSLTEngineImpl::outputToResultTree(const Stylesheet& stylesheetTree,
XObject* value)
{
// java:
// Make the return object into an XObject because it
// will be easier below. One of the reasons to do this
// is to keep all the conversion functionality in the
// XObject classes.
// JMD: Has to be an XObject
int type = value->getType();
DOMString s;
switch(type)
{
case XObject::eTypeBoolean:
case XObject::eTypeNumber:
case XObject::eTypeString:
s = value->str();
characters(toCharArray(s), 0, length(s));
break;
case XObject::eTypeNodeSet:
{
const NodeRefListBase* nl = &(value->nodeset());
int nChildren = nl->getLength();
for(int i = 0; i < nChildren; i++)
{
DOM_Node pos = nl->item(i);
const DOM_Node& top = pos;
while(0 != pos)
{
flushPending();
cloneToResultTree(stylesheetTree, pos, false,
false, false, true);
DOM_Node nextNode = pos.getFirstChild();
while(0 == nextNode)
{
if(DOM_Node::ELEMENT_NODE ==
pos.getNodeType())
{
endElement(c_wstr(pos.getNodeName()));
}
if(top == pos)
break;
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
pos = pos.getParentNode();
if(top == pos)
{
if(DOM_Node::ELEMENT_NODE == pos.getNodeType())
{
endElement(c_wstr(pos.getNodeName()));
}
nextNode = 0;
break;
}
}
}
pos = nextNode;
}
}
}
break;
case XObject::eTypeResultTreeFrag:
outputResultTreeFragment(value);
break;
case XObject::eTypeNull:
case XObject::eTypeUnknown:
case XObject::eUnknown:
default:
assert(0);
}
}
/**
* Handle an extension function.
*/
XObject*
XSLTEngineImpl::extFunction(
XPathExecutionContext& executionContext,
const DOMString& theNamespace,
const DOMString& extensionName,
const std::vector<XObject*>& argVec) const
{
return m_xpathEnvSupport.extFunction( executionContext,
theNamespace, extensionName, argVec);
}
void
XSLTEngineImpl::handleFunctionsInstruction(DOM_Element extensionElem)
{
error("Calling external functions is not supported in the C++ version
of Xalan!!!");
}
//==========================================================
// SECTION: Diagnostic functions
//==========================================================
/**
* Add a trace listener for the purposes of debugging and diagnosis.
* @param tl Trace listener to be added.
*/
void XSLTEngineImpl::addTraceListener(TraceListener* tl)
// throws TooManyListenersException
{
m_traceListeners.push_back(tl);
if(0 != m_stylesheetRoot)
m_stylesheetRoot->addTraceListener(tl);
}
/**
* Add a trace listener for the purposes of debugging and diagnosis.
* @param tl Trace listener to be added.
*/
void XSLTEngineImpl::addTraceListenersToStylesheet()
{
if(0 == m_stylesheetRoot) return;
try
{
int nListeners = m_traceListeners.size();
for(int i = 0; i < nListeners; i++)
{
TraceListener* tl = m_traceListeners.at(i);
m_stylesheetRoot->addTraceListener(tl);
}
}
catch(...)
// catch(TooManyListenersException tmle)
{
throw SAXException("addTraceListenersToStylesheet -
TooManyListenersException");
}
}
/**
* Remove a trace listener.
* @param tl Trace listener to be removed.
*/
void XSLTEngineImpl::removeTraceListener(TraceListener* tl)
{
int nListeners = m_traceListeners.size();
for(int i = 0; i < nListeners; i++)
{
TraceListener* tli = m_traceListeners.at(i);
if (tli == tl)
m_traceListeners.erase(m_traceListeners.begin()+i);
}
if(0 != m_stylesheetRoot)
m_stylesheetRoot->removeTraceListener(tl);
}
/**
* Fire a generate event.
*/
void XSLTEngineImpl::fireGenerateEvent(const GenerateEvent& te)
{
int nListeners = m_traceListeners.size();
for(int i = 0; i < nListeners; i++)
{
TraceListener* tl = m_traceListeners.at(i);
tl->generated(te);
}
}
/**
* Warn the user of an problem.
* This is public for access by extensions.
* @exception XSLTProcessorException thrown if the active ProblemListener and
XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void XSLTEngineImpl::message(const DOMString& msg)
{
DOM_Node node;
message(node, node, msg);
}
void XSLTEngineImpl::message( const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg)
{
if (m_problemListener != 0)
{
const bool shouldThrow =
m_problemListener->problem(ProblemListener::eXSLPROCESSOR,
ProblemListener::eMESSAGE,
styleNode, sourceNode,
c_wstr(msg), 0, 0, 0);
if(shouldThrow == true)
{
throw XSLTProcessorException(msg);
}
}
}
void XSLTEngineImpl::problem(const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
ProblemListener::eClassification
classification) const
{
if (m_problemListener == 0) return;
Locator* locator = m_stylesheetLocatorStack.size() == 0 ? 0 :
m_stylesheetLocatorStack.back();
const XMLCh* id = (0 == locator) ?
0 : (0 ==
locator->getPublicId()) ?
locator->getPublicId() :
locator->getSystemId();
const bool shouldThrow =
m_problemListener->problem(ProblemListener::eXSLPROCESSOR,
classification,
styleNode,
sourceNode, msg,
id,
(0 ==
locator) ? 0: locator->getLineNumber(),
(0 ==
locator) ? 0: locator->getColumnNumber());
if(shouldThrow == true)
{
throw XSLTProcessorException(msg);
}
}
void
XSLTEngineImpl::warn(const DOMString& msg) const
{
warn(DOM_Node(), DOM_Node(), msg);
}
void
XSLTEngineImpl::warn(
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg) const
{
problem(styleNode, sourceNode, msg, ProblemListener::eWARNING);
}
void
XSLTEngineImpl::error(const DOMString& msg) const
{
error(DOM_Node(), DOM_Node(), msg);
}
void
XSLTEngineImpl::error(
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg) const
{
problem(styleNode, sourceNode, msg, ProblemListener::eERROR);
}
void
XSLTEngineImpl::pushTime(const void* key) const
{
if(0 != key)
{
m_durationsTable.insert(std::make_pair<const void* const,
clock_t>(key, clock()));
}
}
clock_t
XSLTEngineImpl::popDuration(const void* key) const
{
clock_t clockTicksDuration = 0;
if(0 != key)
{
const DurationsTableMapType::iterator i =
m_durationsTable.find(key);
assert(i != m_durationsTable.end());
if (i != m_durationsTable.end())
{
clockTicksDuration = clock() - (*i).second;
m_durationsTable.erase(i);
}
}
return clockTicksDuration;
}
void
XSLTEngineImpl::displayDuration(const DOMString& info,
const void*
key) const
{
if(0 != key)
{
const clock_t theDuration = popDuration(key);
double millis = 1000.0*theDuration/CLOCKS_PER_SEC;
if(0 != m_diagnosticsPrintWriter)
{
DOMString msg(info);
msg += " took ";
msg += DoubleToDOMString(millis);
msg += " millis";
m_diagnosticsPrintWriter->println(msg);
}
}
}
void
XSLTEngineImpl::setDiagnosticsOutput(PrintWriter* pw)
{
m_diagnosticsPrintWriter = pw;
m_problemListener->setPrintWriter(pw);
}
void
XSLTEngineImpl::diag(const DOMString& s) const
{
if (0 != m_diagnosticsPrintWriter)
{
m_diagnosticsPrintWriter->println(s);
}
}
/**
* If this is set to true, simple traces of
* template calls are made.
*/
void
XSLTEngineImpl::setTraceTemplates(bool b)
{
m_traceTemplates = b;
}
/**
* If this is set to true, simple traces of
* template calls are made.
*/
void
XSLTEngineImpl::setTraceSelect(bool b)
{
m_traceSelects = b;
}
bool XSLTEngineImpl::isTraceSelect() const
{
return m_traceSelects;
}
/**
* If this is set to true, debug diagnostics about
* template children as they are being constructed
* will be written to the m_diagnosticsPrintWriter
* stream. diagnoseTemplateChildren is false by
* default.
*/
void XSLTEngineImpl::setTraceTemplateChildren(bool b)
{
m_traceTemplateChildren = b;
}
void
XSLTEngineImpl::traceSelect(
DOM_Element theTemplate,
const NodeRefListBase& nl) const
{
DOMString msg = theTemplate.getNodeName() + DOMString(": ");
DOM_Attr attr =
theTemplate.getAttributeNode(Constants::ATTRNAME_SELECT);
if(0 != attr)
{
msg += attr.getValue();
msg += ", ";
msg += LongToDOMString(nl.getLength());
msg += " selected";
}
else
{
msg += "*|text(), (default select), ";
msg += LongToDOMString(nl.getLength());
msg += " selected";
}
attr = theTemplate.getAttributeNode(Constants::ATTRNAME_MODE);
if(0 != attr)
{
msg += DOMString(", mode = ") + attr.getValue();
}
//System.out.println(msg);
}
/**
* Print a trace of a template that is being called, either by
* a match, name, or as part of for-each.
*/
void
XSLTEngineImpl::traceTemplate(DOM_Element theTemplate) const
{
DOMString msg;
DOM_Attr attr =
theTemplate.getAttributeNode(Constants::ATTRNAME_MATCH);
if(0 != attr)
{
msg = DOMString("Calling template for: ") + attr.getValue();
}
else
{
attr = theTemplate.getAttributeNode(Constants::ATTRNAME_NAME);
if(0 != attr)
{
msg = DOMString("Calling named template, name = ") +
attr.getValue();
}
else
{
const int xslToken = getXSLToken(theTemplate);
if(Constants::ELEMNAME_FOREACH == xslToken)
{
attr =
theTemplate.getAttributeNode(Constants::ATTRNAME_SELECT);
if(0 != attr)
{
msg = DOMString("Processing for-each,
select = ") + attr.getValue();
}
else
{
error("for-each must have either a
match or name attribute");
msg = "";
}
}
else
{
error("templates must have either a match or
name attribute");
msg = "";
}
}
}
attr = theTemplate.getAttributeNode(Constants::ATTRNAME_MODE);
if(0 != attr)
{
msg += DOMString(", mode = ") + attr.getValue();
}
//System.out.println(msg);
}
void
XSLTEngineImpl::diagnoseTemplateChildren(
const DOM_Node& templateChild,
const DOM_Node& sourceNode) const
{
if(m_traceTemplateChildren)
{
const DOMString templateChildTagName =
templateChild.getNodeName();
const DOMString xmlElemName = sourceNode.getNodeName();
diag(DOMString("source node: ")
+ xmlElemName
+ DOMString(", template-node: ")
+ templateChildTagName);
}
}
void
XSLTEngineImpl::setDocumentLocator(
Locator* const /* locator */)
{
// Do nothing for now
}
void
XSLTEngineImpl::startDocument()
{
assert(m_flistener != 0);
m_flistener->startDocument();
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_STARTDOCUMENT);
fireGenerateEvent(ge);
}
}
void
XSLTEngineImpl::endDocument()
{
assert(m_flistener != 0);
flushPending();
m_flistener->endDocument();
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_ENDDOCUMENT);
fireGenerateEvent(ge);
}
m_variableStacks.popCurrentContext();
}
void XSLTEngineImpl::addResultNamespaceDecl(const DOMString& prefix,
const DOMString& namespaceVal)
{
NamespaceVectorType nsVector;
NameSpace ns(prefix, namespaceVal);
assert(m_resultNameSpaces.size() > 0);
NamespaceVectorType nsOnStack = m_resultNameSpaces.back();
// If the last vector contains only an empty namespace, replace it with
a
// new vector containing only this namespace
if(isEmpty(nsOnStack.front().getURI()))
{
nsVector.push_back(ns);
m_resultNameSpaces.pop_back();
m_resultNameSpaces.push_back(nsVector);
}
// Otherwise, add the namespace at the end of the last vector
else
{
nsOnStack.push_back(ns);
}
}
void
XSLTEngineImpl::addResultAttribute(
AttributeListImpl& attList,
const DOMString& aname,
const DOMString& value)
{
assert(length(value) > 0);
const bool isPrefix = startsWith(aname, "xmlns:");
if (equals(aname, "xmlns") || isPrefix == true)
{
const DOMString p = isPrefix == true ? substring(aname,
6) : DOMString();
addResultNamespaceDecl(p, value);
}
attList.removeAttribute(c_wstr(aname));
attList.addAttribute(c_wstr(aname), c_wstr(DOMString("CDATA")),
c_wstr(value));
}
void
XSLTEngineImpl::flushPending()
{
if(0 != length(m_pendingElementName))
{
assert(m_flistener != 0);
m_cdataStack.push(isCDataResultElem(m_pendingElementName)? true
: false);
m_flistener->startElement(c_wstr(m_pendingElementName),
m_pendingAttributes);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_STARTELEMENT,
m_pendingElementName,
&m_pendingAttributes);
fireGenerateEvent(ge);
}
m_pendingAttributes.clear();
m_pendingElementName = "";
}
}
void
XSLTEngineImpl::startElement(const XMLCh* const name)
{
assert(m_flistener != 0);
assert(name != 0);
flushPending();
// Push a new container on the stack, then push an empty
// result namespace on to that container.
NamespaceVectorType nsVector;
nsVector.push_back(m_emptyNamespace);
m_resultNameSpaces.push_back(nsVector);
m_pendingElementName = name;
}
void
XSLTEngineImpl::startElement(
const XMLCh* const name,
AttributeList& atts)
{
assert(m_flistener != 0);
assert(name != 0);
flushPending();
const int nAtts = atts.getLength();
m_pendingAttributes.clear();
for(int i = 0; i < nAtts; i++)
{
m_pendingAttributes.addAttribute(atts.getName(i),
atts.getType(i),
atts.getValue(i));
}
// Push a new container on the stack, then push an empty
// result namespace on to that container.
NamespaceVectorType nsVector;
nsVector.push_back(m_emptyNamespace);
m_resultNameSpaces.push_back(nsVector);
m_pendingElementName = name;
}
void
XSLTEngineImpl::endElement(const XMLCh* const name)
{
assert(m_flistener != 0);
assert(name != 0);
flushPending();
m_flistener->endElement(c_wstr(name));
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent.EVENTTYPE_ENDELEMENT,
name, 0);
fireGenerateEvent(ge);
}
m_resultNameSpaces.pop_back();
Stylesheet::QNameVectorType cdataElems =
m_stylesheetRoot->getCdataSectionElems();
if(0 != cdataElems.size())
m_cdataStack.pop();
}
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(m_flistener != 0);
assert(ch != 0);
flushPending();
Stylesheet::QNameVectorType cdataElems =
m_stylesheetRoot->getCdataSectionElems();
// java:
// if((null != m_stylesheetRoot.m_cdataSectionElems) &&
// !m_cdataStack.isEmpty() && (m_cdataStack.peek() ==
TRUE))
if(0 != cdataElems.size() && 0 != m_cdataStack.size())
{
// java: if(m_flistener instanceof FormatterListener)
// @@ JMD: Need to add type member to DocumentHandler, etc ...
// future: if (m_flistener.getType == eFormatterListener)
if (true) // @@ JMD: For now
{
FormatterListener* pfl =
static_cast<FormatterListener*>(m_flistener);
pfl->cdata(ch+start, length);
}
else
{
// Bad but I think it's better than dropping it.
m_flistener->characters(ch, length);
}
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_CDATA,
ch, start, length);
fireGenerateEvent(ge);
}
}
else
{
m_flistener->characters(ch+start, length);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_CHARACTERS, ch,
start, length);
fireGenerateEvent(ge);
}
}
}
/**
* Bottleneck the charactersRaw event.
*/
void
XSLTEngineImpl::charactersRaw (
const XMLCh* const ch,
const unsigned int start,
const unsigned int length)
//throws SAXException
{
flushPending();
// java: if(m_flistener instanceof FormatterListener)
FormatterListener* pFL = dynamic_cast<FormatterListener*>(m_flistener);
if(0 != pFL)
{
pFL->charactersRaw(ch, length);
}
else
{
m_flistener->characters(ch, length);
}
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_CHARACTERS,
ch, 0, length);
fireGenerateEvent(ge);
}
}
void
XSLTEngineImpl::resetDocument()
{
assert(m_flistener != 0);
flushPending();
m_flistener->resetDocument();
}
void
XSLTEngineImpl::ignorableWhitespace(
const XMLCh* const ch,
const unsigned int length)
{
assert(m_flistener != 0);
assert(ch != 0);
flushPending();
m_flistener->ignorableWhitespace(ch, length);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_IGNORABLEWHITESPACE,
ch, 0, length);
fireGenerateEvent(ge);
}
}
void
XSLTEngineImpl::processingInstruction(
const XMLCh* const target,
const XMLCh* const data)
{
assert(m_flistener != 0);
assert(target != 0);
assert(data != 0);
flushPending();
m_flistener->processingInstruction(target, data);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_PI,
target, data);
fireGenerateEvent(ge);
}
}
void
XSLTEngineImpl::comment(const XMLCh* const data)
{
assert(m_flistener != 0);
assert(data != 0);
flushPending();
// future: assert (m_flistener.getType == eFormatterListener)
FormatterListener* pfl =
static_cast<FormatterListener*>(m_flistener);
pfl->comment(data);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_COMMENT,
data);
fireGenerateEvent(ge);
}
}
void
XSLTEngineImpl::entityReference(const XMLCh* const name)
{
assert(m_flistener != 0);
assert(name != 0);
flushPending();
// future: assert (m_flistener.getType == eFormatterListener)
FormatterListener* pfl =
static_cast<FormatterListener*>(m_flistener);
pfl->entityReference(name);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_ENTITYREF,
name);
fireGenerateEvent(ge);
}
}
void XSLTEngineImpl::cdata(
const XMLCh* const ch,
const unsigned int start,
const unsigned int length)
{
assert(m_flistener != 0);
assert(ch != 0);
flushPending();
Stylesheet::QNameVectorType cdataElems =
m_stylesheetRoot->getCdataSectionElems();
if(0 != cdataElems.size() && 0 != m_cdataStack.size())
{
// future: assert (m_flistener.getType == eFormatterListener)
FormatterListener* pfl =
static_cast<FormatterListener*>(m_flistener);
pfl->cdata(ch, length);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this, GenerateEvent::EVENTTYPE_CDATA,
ch, start,
length);
fireGenerateEvent(ge);
}
}
else
{
m_flistener->characters(ch, length);
if(m_traceListeners.size() > 0)
{
GenerateEvent ge(this,
GenerateEvent::EVENTTYPE_CHARACTERS, ch,
start, length);
fireGenerateEvent(ge);
}
}
}
void
XSLTEngineImpl::
cloneToResultTree(
const Stylesheet& stylesheetTree,
const DOM_Node& node,
bool isLiteral,
bool /*
shouldCloneWithChildren */,
bool overrideStrip,
bool
shouldCloneAttributes)
{
bool stripWhiteSpace = false;
switch(node.getNodeType())
{
case DOM_Node::TEXT_NODE:
{
// 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 DOM_Text& tx = static_cast<const
DOM_Text&>(node);
DOMString data;
// System.out.println("stripWhiteSpace =
"+stripWhiteSpace+", "+tx.getData());
if(stripWhiteSpace == true)
{
if(!m_xpathSupport.isIgnorableWhitespace(tx))
{
data = getNormalizedText(tx);
if((0 != length(data)) && (0 ==
length(trim(data))))
{
data = "";
}
}
}
else
{
const DOM_Node parent = node.getParentNode();
if(parent==0 || DOM_Node::DOCUMENT_NODE !=
parent.getNodeType())
{
data = getNormalizedText(tx);
}
}
if(0 != length(data))
{
// TODO: Hack around the issue of comments next
to literals.
// This would be, when a comment is present,
the whitespace
// after the comment must be added to the
literal. The
// parser should do this, but XML4J doesn't
seem to.
// <foo>some lit text
// <!-- comment -->
// </foo>
// Loop through next siblings while they are
comments, then,
// if the node after that is a ignorable text
node, append
// it to the text node just added.
if(m_xpathSupport.isIgnorableWhitespace(tx))
{
ignorableWhitespace(toCharArray(data),
length(data));
}
else
{
characters(toCharArray(data), 0,
length(data));
}
}
}
break;
case DOM_Node::ELEMENT_NODE:
{
if(shouldCloneAttributes == true)
{
copyAttributesToAttList(node,
m_stylesheetRoot,
static_cast<const DOM_Element&>(node),
m_pendingAttributes);
copyNamespaceAttributes(node,
false,
m_pendingAttributes);
}
startElement(c_wstr(node.getNodeName()));
}
break;
case DOM_Node::CDATA_SECTION_NODE:
{
const DOM_CDATASection& theCDATA =
static_cast<const DOM_CDATASection&>(node);
const DOMString data = theCDATA.getData();
cdata(toCharArray(data), 0, length(data));
}
break;
case DOM_Node::ATTRIBUTE_NODE:
{
const DOM_Attr& attr =
static_cast<const DOM_Attr&>(node);
addResultAttribute(m_pendingAttributes,
attr.getName(),
attr.getValue());
}
break;
case DOM_Node::COMMENT_NODE:
{
const DOM_Comment& theComment =
static_cast<const DOM_Comment&>(node);
const DOMString theData = theComment.getData();
comment(toCharArray(theData));
}
break;
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
{
error(DOM_Node(), node, "No clone of a document
fragment!");
}
break;
case DOM_Node::ENTITY_REFERENCE_NODE:
{
#if 0
EntityReference er = (EntityReference)node;
entityReference(toCharArray(er.getNodeName()));
#else
const DOMString theName = node.getNodeName();
entityReference(toCharArray(theName));
#endif
}
break;
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
{
const DOM_ProcessingInstruction& pi =
static_cast<const
DOM_ProcessingInstruction&>(node);
const DOMString theTarget = pi.getTarget();
const DOMString theData = pi.getData();
processingInstruction(toCharArray(theTarget),
toCharArray(theData));
}
break;
default:
{
// $$$ ToDo: Fix this when DOMString::operator+() is
const.
DOMString msg("Can not create item in result
tree: ");
msg +=node.getNodeName();
error(msg);
// error(DOMString("Can not create item in result tree: ")
+
// node.getNodeName());
}
}
}
// @@ java: DocumentFragment
ResultTreeFragBase*
XSLTEngineImpl::createResultTreeFrag(
const Stylesheet* stylesheetTree,
ElemTemplateElement& templateChild,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode)
{
DocumentHandler* const savedFormatterListener = m_flistener;
std::auto_ptr<ResultTreeFragBase> pfrag(createDocFrag());
DOMString savedPendingName = m_pendingElementName;
m_pendingElementName = ""; // DOMString()
AttributeListImpl savedPendingAttributes = m_pendingAttributes;
m_pendingAttributes.clear();
m_flistener = new FormatterToDOM(m_resultTreeFactory,
DOM_UnimplementedDocumentFragment(pfrag.get()));
templateChild.executeChildren(*this, sourceTree, sourceNode, mode);
// flushPending();
delete m_flistener;
m_flistener = savedFormatterListener;
m_pendingElementName = savedPendingName;
m_pendingAttributes = savedPendingAttributes;
return pfrag.release();
}
void XSLTEngineImpl::writeChildren(
FormatterListener* flistener,
Stylesheet& stylesheetTree,
ElemTemplateElement& templateParent,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode, QName mode)
{
flushPending();
DocumentHandler* savedFormatterListener = m_flistener;
DOMString savedPendingName = m_pendingElementName;
m_pendingElementName = 0;
AttributeListImpl savedPendingAttributes = m_pendingAttributes;
m_pendingAttributes.clear();
m_flistener = flistener;
templateParent.executeChildren(*this, sourceTree, sourceNode, mode);
flushPending();
m_flistener = savedFormatterListener;
m_pendingElementName = savedPendingName;
m_pendingAttributes = savedPendingAttributes;
}
void
XSLTEngineImpl::outputResultTreeFragment(XObject* obj)
{
ResultTreeFragBase& docFrag = obj->rtree();
const NodeRefListBase& nl = docFrag.getChildNodesAsNodeRefList();
const int nChildren = nl.getLength();
for(int i = 0; i < nChildren; i++)
{
DOM_Node pos = nl.item(i);
const DOM_Node& top = pos;
while(0 != pos)
{
flushPending();
cloneToResultTree(*m_stylesheetRoot, pos, false, false,
false, true );
DOM_Node nextNode = pos.getFirstChild();
while(0 == nextNode)
{
if(DOM_Node::ELEMENT_NODE == pos.getNodeType())
{
endElement(c_wstr(pos.getNodeName()));
}
if(top == pos)
break;
nextNode = pos.getNextSibling();
if(0 == nextNode)
{
pos = pos.getParentNode();
if(top == pos || 0 == pos)
{
if (0 != pos)
{
if(DOM_Node::ELEMENT_NODE == pos.getNodeType())
{
endElement(c_wstr(pos.getNodeName()));
}
}
nextNode = 0;
break;
}
}
}
pos = nextNode;
}
}
}
/**
* Tell if a given element name should output it's text as cdata.
*/
bool XSLTEngineImpl::isCDataResultElem(DOMString& elementName)
{
bool is = false;
Stylesheet::QNameVectorType cdataElems =
m_stylesheetRoot->getCdataSectionElems();
if(0 != cdataElems.size())
{
DOMString elemNS;
DOMString elemLocalName;
const int indexOfNSSep = indexOf(elementName, ':');
if(indexOfNSSep > 0)
{
DOMString prefix = substring(elementName, 0,
indexOfNSSep);
if(equals(prefix, "xml"))
{
elemNS = Constants::S_XMLNAMESPACEURI;
}
else
{
elemNS = getResultNamespaceForPrefix(prefix);
}
if(0 == elemNS.length())
{
error(DOMString("Prefix must resolve to a
namespace: ") + prefix);
// throw new RuntimeException(+prefix);
}
}
elemLocalName = (indexOfNSSep < 0) ? elementName :
substring(elementName, indexOfNSSep+1);
const int n = cdataElems.size();
for(int i = 0; i < n; i++)
{
QName qname = cdataElems.at(i);
is = qname.equals(QName(elemNS, elemLocalName));
if(is)
break;
}
}
return is;
}
/**
* Tell if a qualified name equals the current result tree name.
*/
bool XSLTEngineImpl::qnameEqualsResultElemName(QName& qname, DOMString&
elementName)
{
DOMString elemNS;
DOMString elemLocalName;
const int indexOfNSSep = indexOf(elementName, ':');
if(indexOfNSSep > 0)
{
DOMString prefix = substring(elementName, 0, indexOfNSSep);
if(equals(prefix, "xml"))
{
elemNS = Constants::S_XMLNAMESPACEURI;
}
else
{
elemNS = getResultNamespaceForPrefix(prefix);
}
if(0 == elemNS.length())
{
error(DOMString("Prefix must resolve to a namespace: ")
+ prefix);
// throw new RuntimeException(+prefix);
}
}
elemLocalName = (indexOfNSSep < 0) ? elementName :
substring(elementName, indexOfNSSep+1);
return qname.equals(QName(elemNS, elemLocalName));
}
DOMString
XSLTEngineImpl::getResultNamespaceForPrefix(const DOMString& prefix) const
{
// Search vector from first element back
return QName::getNamespaceForPrefix(m_resultNameSpaces, prefix, false);
}
DOMString
XSLTEngineImpl::getResultPrefixForNamespace(const DOMString& theNamespace)
const
{
// Search vector from first element back
return QName::getPrefixForNamespace(m_resultNameSpaces, theNamespace,
false);
}
DOMString
XSLTEngineImpl::getPrefixForNamespace(
const DOMString& theNamespace,
const DOM_Element& namespaceContext) const
{
int type;
DOM_Node parent = namespaceContext;
DOMString prefix;
while ((0 != parent) && (0 == length(prefix))
&& (((type = parent.getNodeType()) == DOM_Node::ELEMENT_NODE)
|| (type == DOM_Node::ENTITY_REFERENCE_NODE)))
{
if (type == DOM_Node::ELEMENT_NODE)
{
DOM_NamedNodeMap nnm = parent.getAttributes();
for (int i = 0; i < nnm.getLength(); i ++)
{
const DOM_Node attr = nnm.item(i);
const DOMString aname =
attr.getNodeName();
const bool isPrefix =
startsWith(aname, "xmlns:");
if (equals(aname, "xmlns") || isPrefix)
{
const int index =
indexOf(aname, ':');
const DOMString
namespaceOfPrefix = attr.getNodeValue();
if((0 != length(namespaceOfPrefix)) &&
equals(namespaceOfPrefix,
theNamespace))
{
prefix = isPrefix ?
substring(aname, index + 1) : DOMString();
}
}
}
}
parent = m_xpathSupport.getParentOfNode(parent);
}
return prefix;
}
void
XSLTEngineImpl::copyNamespaceAttributes(
const DOM_Node& src,
bool srcIsStylesheetTree,
AttributeListImpl& /* destination */)
{
int type;
DOM_Node parent = src;
while (parent != 0
&& ((type = parent.getNodeType()) == DOM_Node::ELEMENT_NODE
|| (type == DOM_Node::ENTITY_REFERENCE_NODE)))
{
if (type == DOM_Node::ELEMENT_NODE)
{
// $$$ ToDo: This can become const when getLength()
// is made const.
DOM_NamedNodeMap nnm = parent.getAttributes();
const int nAttrs =
nnm.getLength();
for (int i = 0; i < nAttrs; i++)
{
const DOM_Node attr = nnm.item(i);
const DOMString aname =
attr.getNodeName();
const bool isPrefix =
startsWith(aname, "xmlns:");
if (equals(aname, "xmlns") || isPrefix)
{
const DOMString prefix =
isPrefix ? substring(aname, 6) : DOMString();
const DOMString desturi =
getResultNamespaceForPrefix(prefix);
DOMString srcURI
= attr.getNodeValue();
const bool isXSLNS
=
(srcIsStylesheetTree &&
equalsIgnoreCase(srcURI, m_XSLNameSpaceURL)
|| (0 !=
m_stylesheetRoot->lookupExtensionNSHandler(srcURI))
|| (srcIsStylesheetTree &&
equalsIgnoreCase(srcURI, s_XSLT4JNameSpaceURL)));
if(startsWith(srcURI, "quote:"))
{
srcURI = substring(srcURI, 6);
}
if(!equalsIgnoreCase(srcURI, desturi)
&& !isXSLNS)
{
addResultAttribute(m_pendingAttributes, aname, srcURI);
}
}
}
}
parent = parent.getParentNode();
}
}
XObject* XSLTEngineImpl::evalXPathStr(const DOMString& str,
const DOM_Node& context,
const PrefixResolver& resolver)
{
m_xpathProcessor->initXPath(*m_xpath, str, resolver);
return m_xpath->execute(context, resolver, m_contextNodeList);
}
/**
* Evaluate an xpath string and return the result.
*/
XPath* XSLTEngineImpl::createXPath(
const DOMString& str,
const PrefixResolver& resolver)
{
assert(m_xpathFactory);
XPath* xpath = m_xpathFactory->create();
m_xpathProcessor->initXPath(*xpath, str, resolver);
xpath->shrink();
return xpath;
}
/**
* Evaluate an xpath string and return the result.
*/
double XSLTEngineImpl::evalMatchPatternStr(const DOMString& str,
const DOM_Node& context,
const PrefixResolver& resolver)
{
// This needs to use a factory method of some sort.
m_xpathProcessor->initMatchPattern(*m_xpath, str, resolver);
return m_xpath->getMatchScore(context);
}
/**
* Evaluate an xpath string and return the result.
*/
XPath* XSLTEngineImpl::createMatchPattern(const DOMString &str, const
PrefixResolver& resolver)
{
XPath* xpath = m_xpathFactory->create();
m_xpathProcessor->initMatchPattern(*xpath, str, resolver);
xpath->shrink();
return xpath;
}
XPath* XSLTEngineImpl::getExpression(
AttributeList& attrs,
const DOMString& key,
const PrefixResolver& resolver)
{
const XMLCh* val = attrs.getValue(c_wstr(key));
return (0 != val) ? createXPath(DOMString(val), resolver) : 0;
}
DOMString
XSLTEngineImpl::getAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& /* contextNode */ )
{
// @@ JMD: context not used
return getAttrVal( el, key);
}
DOMString
XSLTEngineImpl::getAttrVal(
const DOM_Element& el,
const DOMString& key)
{
const DOM_Attr a = el.getAttributeNode(key);
return 0 == a ? DOMString() : a.getValue();
}
DOMString
XSLTEngineImpl::evaluateAttrVal(
const DOM_Node& contextNode,
const DOM_Element& namespaceContext,
const DOMString& stringedValue)
{
DOMString expressedValue; // return value
StringTokenizer tokenizer(stringedValue, "{}\"\'", true);
const int nTokens = tokenizer.countTokens();
if(nTokens < 2)
{
expressedValue = stringedValue; // then do the simple thing
}
else
{
DOMString buffer;
DOMString t; // base token
DOMString lookahead; // next token
DOMString error; // if not empty, break from loop
ElementPrefixResolverProxy theProxy(namespaceContext,
m_xpathSupport);
while(tokenizer.hasMoreTokens())
{
if(length(lookahead) != 0)
{
t = lookahead;
lookahead = "";
}
else t = tokenizer.nextToken();
if(length(t) == 1)
{
switch(charAt(t, 0))
{
case('\"'):
case('\''):
{
// just keep on going, since
we're not in an attribute template
append(buffer, t);
break;
}
case('{'):
{
// Attr template start
lookahead =
tokenizer.nextToken();
if(equals(lookahead, "{"))
{
// Double curlys mean
escape to show curly
append(buffer,
lookahead);
lookahead = "";
break; // from switch
}
/*
else if(equals(lookahead, "\"")
|| equals(lookahead, "\'"))
{
// Error. Expressions
can not begin with quotes.
error = "Expressions
can not begin with quotes.";
break; // from switch
}
*/
else
{
DOMString expression =
lookahead; // Probably should make into StringBuffer
while((0 !=
length(lookahead)) && (!equals(lookahead, "}")))
{
lookahead =
tokenizer.nextToken();
if(length(lookahead) == 1)
{
switch(charAt(lookahead, 0))
{
case '\'':
case '\"':
{
// String start
expression += lookahead;
DOMString quote = lookahead;
// Consume stuff 'till next quote
lookahead = tokenizer.nextToken();
while(!equals(lookahead, quote))
{
expression += lookahead;
lookahead = tokenizer.nextToken();
}
expression += lookahead;
break;
}
case '{':
{
// What's another curly doing here?
error = "Error: Can not have \"{\" within expression.";
break;
}
case '}':
{
// Proper close of attribute template.
// Evaluate the expression.
XObject* xobj = evalXPathStr(expression, contextNode, theProxy);
DOMString exprResult = xobj->str();
append(buffer, exprResult);
lookahead = ""; // breaks out of inner while loop
break;
}
default:
{
// part of the template stuff, just add it.
expression += lookahead;
}
} //
end inner switch
} // end if
lookahead length == 1
else
{
// part
of the template stuff, just add it.
expression += lookahead;
}
} // end
while(!lookahead.equals("}"))
if(length(error) != 0)
{
break; // from
inner while loop
}
}
break;
}
case('}'):
{
lookahead =
tokenizer.nextToken();
if(equals(lookahead, "}"))
{
// Double curlys mean
escape to show curly
append(buffer,
lookahead);
lookahead = ""; //
swallow
}
else
{
// Illegal, I think...
warn("Found \"}\" but
no attribute template open!");
append(buffer, "}");
// leave the lookahead
to be processed by the next round.
}
break;
}
default:
{
// Anything else just add to
string.
append(buffer, t);
}
} // end switch t
} // end if length == 1
else
{
// Anything else just add to string.
append(buffer, t);
}
if(0 != length(error))
{
// $$$ ToDo: Fix this when
DOMString::operator+() is const.
DOMString message("Attr Template, ");
warn(message + error);
break;
}
} // end while(tokenizer.hasMoreTokens())
expressedValue = buffer;
} // end else nTokens > 1
return expressedValue;
}
void
XSLTEngineImpl::copyAttributeToTarget(
const DOM_Attr& attr,
const DOM_Node& contextNode,
const Stylesheet* stylesheetTree,
AttributeListImpl& attrList,
const DOM_Element& namespaceContext)
{
const DOMString attrName = trim(attr.getName());
DOMString stringedValue = attr.getValue();
stringedValue = evaluateAttrVal(contextNode,
namespaceContext,
stringedValue);
// evaluateAttrVal might return a null value if the template expression
// did not turn up a result, in which case I'm going to not add the
// attribute.
// TODO: Find out about empty attribute template expression handling.
if(0 != length(stringedValue))
{
if((equals(attrName, "xmlns") || startsWith(attrName, "xmlns:"))
&& startsWith(stringedValue, "quote:"))
{
stringedValue = substring(stringedValue, 6);
}
addResultAttribute(attrList, attrName, stringedValue);
}
}
void
XSLTEngineImpl::copyAttributesToAttList(
const DOM_Node& contextNode,
const Stylesheet* stylesheetTree,
const DOM_Element& templateChild,
AttributeListImpl& attList)
{
assert(m_stylesheetRoot != 0);
assert(stylesheetTree != 0);
DOM_NamedNodeMap attributes = templateChild.getAttributes();
const int nAttributes = (0 != attributes) ? attributes.getLength() : 0;
DOMString attrSetUseVal;
for(int i = 0; i < nAttributes; i++)
{
const DOM_Node theNode = attributes.item(i);
const DOM_Attr& attr = static_cast<const
DOM_Attr&>(theNode);
// $$$ ToDo: Fix this when DOMString::operator+() is const.
DOMString theTemp(m_XSLNameSpaceURL);
theTemp += ":use";
if(equalsIgnoreCase(m_parserLiaison.getExpandedAttributeName(attr), theTemp))
//
if(equalsIgnoreCase(m_parserLiaison.getExpandedAttributeName(attr),
m_XSLNameSpaceURL + ":use"))
{
attrSetUseVal = attr.getValue();
}
else
{
copyAttributeToTarget(attr,
contextNode,
stylesheetTree,
attList,
templateChild);
}
}
}
void
XSLTEngineImpl::translateCSSAttrsToStyleAttr(AttributeListImpl&
attList)
{
if(m_translateCSS == true)
{
DOMString styleAttrValueString;
std::vector<const XMLCh*> toBeRemoved;
int nAttributes = attList.getLength();
for(int i = 0; i < nAttributes; i++)
{
const XMLCh* const attrName = attList.getName(i);
if(isCSSAttribute(attrName) == true)
{
toBeRemoved.push_back(attrName);
if(0 == length(styleAttrValueString))
{
// $$$ ToDo: Fix this when
DOMString::operator+() is const.
styleAttrValueString = attrName;
styleAttrValueString += ":";
styleAttrValueString +=
attList.getValue(i);
// styleAttrValueString =
attrName+":"+attList.getValue(i);
}
else
{
// $$$ ToDo: Fix this when
DOMString::operator+() is const.
styleAttrValueString += "; ";
styleAttrValueString += attrName;
styleAttrValueString += ":";
styleAttrValueString +=
attList.getValue(i);
// styleAttrValueString += ";
"+attrName+":"+attList.getValue(i);
}
}
}
const int nAttrsToRemove = toBeRemoved.size();
for(int j = 0; j < nAttrsToRemove; j++)
{
attList.removeAttribute(toBeRemoved[j]);
}
if(0 != length(styleAttrValueString))
{
addResultAttribute(attList, "style",
styleAttrValueString);
}
}
}
bool
XSLTEngineImpl::isCSSAttribute(const DOMString& name) const
{
if(m_cssKeys.size() == 0)
{
// Cast away const to initialize the table.
const_cast<XSLTEngineImpl*>(this)->initCSS2Table();
}
return (m_cssKeys.find(name) != m_cssKeys.end() ? true : false);
}
void
XSLTEngineImpl::initCSS2Table()
{
m_cssKeys.insert("azimuth");
m_cssKeys.insert("background");
m_cssKeys.insert("background-attachment");
m_cssKeys.insert("background-color");
m_cssKeys.insert("background-image");
m_cssKeys.insert("background-position");
m_cssKeys.insert("background-repeat");
m_cssKeys.insert("border");
m_cssKeys.insert("border-bottom");
m_cssKeys.insert("border-bottom-color");
m_cssKeys.insert("border-bottom-style");
m_cssKeys.insert("border-bottom-width");
m_cssKeys.insert("border-color");
m_cssKeys.insert("border-left");
m_cssKeys.insert("border-left-color");
m_cssKeys.insert("border-left-style");
m_cssKeys.insert("border-left-width");
m_cssKeys.insert("border-right");
m_cssKeys.insert("border-right-color");
m_cssKeys.insert("border-right-style");
m_cssKeys.insert("border-right-width");
m_cssKeys.insert("border-spacing");
m_cssKeys.insert("border-style");
m_cssKeys.insert("border-top");
m_cssKeys.insert("border-top-color");
m_cssKeys.insert("border-top-style");
m_cssKeys.insert("border-top-width");
m_cssKeys.insert("border-width");
m_cssKeys.insert("bottom");
m_cssKeys.insert("caption-side");
m_cssKeys.insert("clear");
m_cssKeys.insert("clip");
m_cssKeys.insert("color");
m_cssKeys.insert("column-span");
m_cssKeys.insert("content");
m_cssKeys.insert("cue");
m_cssKeys.insert("cue-after");
m_cssKeys.insert("cue-before");
m_cssKeys.insert("cursor");
m_cssKeys.insert("direction");
m_cssKeys.insert("display");
m_cssKeys.insert("elevation");
m_cssKeys.insert("float");
m_cssKeys.insert("font");
m_cssKeys.insert("font-family");
m_cssKeys.insert("font-size");
m_cssKeys.insert("font-size-adjust");
m_cssKeys.insert("font-style");
m_cssKeys.insert("font-variant");
m_cssKeys.insert("font-weight");
m_cssKeys.insert("height");
m_cssKeys.insert("left");
m_cssKeys.insert("letter-spacing");
m_cssKeys.insert("line-height");
m_cssKeys.insert("list-style");
m_cssKeys.insert("list-style-image");
m_cssKeys.insert("list-style-position");
m_cssKeys.insert("list-style-type");
m_cssKeys.insert("margin");
m_cssKeys.insert("margin-bottom");
m_cssKeys.insert("margin-left");
m_cssKeys.insert("margin-right");
m_cssKeys.insert("margin-top");
m_cssKeys.insert("marks");
m_cssKeys.insert("max-height");
m_cssKeys.insert("max-width");
m_cssKeys.insert("min-height");
m_cssKeys.insert("min-width");
m_cssKeys.insert("orphans");
m_cssKeys.insert("overflow");
m_cssKeys.insert("padding");
m_cssKeys.insert("padding-bottom");
m_cssKeys.insert("padding-left");
m_cssKeys.insert("padding-right");
m_cssKeys.insert("padding-top");
m_cssKeys.insert("page-break-after");
m_cssKeys.insert("page-break-before");
m_cssKeys.insert("pause");
m_cssKeys.insert("pause-after");
m_cssKeys.insert("pause-before");
m_cssKeys.insert("pitch");
m_cssKeys.insert("pitch-range");
m_cssKeys.insert("play-during");
m_cssKeys.insert("position");
m_cssKeys.insert("quotes");
m_cssKeys.insert("richness");
m_cssKeys.insert("right");
m_cssKeys.insert("row-span");
m_cssKeys.insert("size");
m_cssKeys.insert("speak");
m_cssKeys.insert("speak-date");
m_cssKeys.insert("speak-header");
m_cssKeys.insert("speak-numeral");
m_cssKeys.insert("speak-punctuation");
m_cssKeys.insert("speak-time");
m_cssKeys.insert("speech-rate");
m_cssKeys.insert("stress");
m_cssKeys.insert("table-layout");
m_cssKeys.insert("text-align");
m_cssKeys.insert("text-decoration");
m_cssKeys.insert("text-indent");
m_cssKeys.insert("text-shadow");
m_cssKeys.insert("text-transform");
m_cssKeys.insert("top");
m_cssKeys.insert("unicode-bidi");
m_cssKeys.insert("vertical-align");
m_cssKeys.insert("visibility");
m_cssKeys.insert("voice-family");
m_cssKeys.insert("volume");
m_cssKeys.insert("white-space");
m_cssKeys.insert("widows");
m_cssKeys.insert("width");
m_cssKeys.insert("word-spacing");
m_cssKeys.insert("z-index");
}
const NodeRefListBase*
XSLTEngineImpl::getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const
{
// Should this call the root or the current stylesheet?
const NodeRefListBase* nl = 0;
if (m_stylesheetRoot != 0)
{
nl = m_stylesheetRoot->getNodeSetByKey(doc, name, ref,
resolver);
}
if(0 == nl)
{
error(DOMString("There is no xsl:key declaration for '") + name
+ DOMString("'!"));
}
return nl;
}
DOM_Element
XSLTEngineImpl::getElementByID(
const DOMString& id,
const DOM_Document& doc) const
{
return m_xpathSupport.getElementByID(id, doc);
}
bool
XSLTEngineImpl::shouldStripSourceNode(const DOM_Node& textNode) const
{
bool strip = false; // return value
int type = textNode.getNodeType();
if((DOM_Node::TEXT_NODE == type) || (DOM_Node::CDATA_SECTION_NODE ==
type))
{
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(textNode);
if(!m_xpathSupport.isIgnorableWhitespace(theTextNode))
{
DOMString data = theTextNode.getData();
if(0 == length(data))
{
return true;
}
else if(!isWhiteSpace(data))
{
return false;
}
}
DOM_Node parent =
m_xpathSupport.getParentOfNode(textNode);
while(0 != parent)
{
if(parent.getNodeType() == DOM_Node::ELEMENT_NODE)
{
const DOM_Element& parentElem =
static_cast<const DOM_Element&>(parent);
const DOM_Attr attr =
parentElem.getAttributeNode("xml:space");
if(0 != attr)
{
const DOMString xmlSpaceVal =
attr.getValue();
if(equals(xmlSpaceVal, "preserve"))
{
strip = false;
}
else if(equals(xmlSpaceVal, "default"))
{
strip = true;
}
else
{
error("xml:space in the source
XML has an illegal value: "+xmlSpaceVal);
}
break;
}
double highPreserveScore =
XPath::s_MatchScoreNone;
double highStripScore = XPath::s_MatchScoreNone;
{
int nTests =
m_stylesheetRoot->m_whitespacePreservingElements.size();
for(int i = 0; i < nTests; i++)
{
XPath* matchPat =
m_stylesheetRoot->m_whitespacePreservingElements.at(i);
double score =
matchPat->getMatchScore(parent);
if(score > highPreserveScore)
highPreserveScore = score;
}
}
{
int nTests =
m_stylesheetRoot->m_whitespaceStrippingElements.size();
for(int i = 0; i < nTests; i++)
{
XPath* matchPat =
m_stylesheetRoot->m_whitespaceStrippingElements.at(i);
double score =
matchPat->getMatchScore(parent);
if(score > highStripScore)
highStripScore = score;
}
}
if((highPreserveScore >
XPath::s_MatchScoreNone) ||
(highStripScore > XPath::s_MatchScoreNone))
{
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;
}
DOMString
XSLTEngineImpl::fixWhiteSpace(
const DOMString& string,
bool trimHead,
bool trimTail,
bool
doublePunctuationSpaces)
{
const XMLCh* const theStringData = c_wstr(string);
std::vector<XMLCh> buf(theStringData,
theStringData +
length(string));
const int len = buf.size();
bool edit = false;
int s;
for(s = 0; s < len; s++)
{
if(isSpace(buf[s]) == true)
{
break;
}
}
/* replace S to ' '. and ' '+ -> single ' '. */
int d = s;
bool pres = false;
for ( ; s < len; s ++)
{
const XMLCh c = buf[s];
if (isSpace(c) == true)
{
if (!pres)
{
if (' ' != c)
{
edit = true;
}
buf[d++] = ' ';
if(doublePunctuationSpaces == true && (s != 0))
{
const XMLCh prevChar = buf[s-1];
if(!((prevChar == '.') || (prevChar ==
'!') || (prevChar == '?')))
{
pres = true;
}
}
else
{
pres = true;
}
}
else
{
edit = true;
pres = true;
}
}
else
{
buf[d++] = c;
pres = false;
}
}
if (trimTail == true && 1 <= d && ' ' == buf[d-1])
{
edit = true;
d --;
}
std::vector<XMLCh>::const_iterator start = buf.begin();
if (trimHead == true && 0 < d && ' ' == buf[0])
{
edit = true;
start++;
}
if (edit == false)
{
// If we haven't changed the string, just return a copy of the
// input string.
return string;
}
else
{
// OK, we have to calculate the length of the string,
// taking into account that we may have moved up the
// start because we're trimming the from of the string.
const int theLength = d - (start - buf.begin());
return DOMString(start, theLength);
}
}
DOMString
XSLTEngineImpl::getNormalizedText(const DOM_Text& tx) const
{
DOMString theResult;
if(m_outputCarriageReturns == false && m_outputLinefeeds == false)
{
return tx.getData();
}
const DOMString src = tx.getData();
const int nSrcChars = src.length();
std::vector<XMLCh> sb;
XMLCh prevChar = 0x00;
for(int i = 0; i < nSrcChars; i++)
{
const XMLCh c = charAt(src, i);
if(0x0A == c)
{
if(0x0D != prevChar)
{
if(m_outputCarriageReturns == true)
sb.push_back(0x0D);
if(m_outputLinefeeds == true)
sb.push_back(0x0A);
}
}
else if(0x0D == c)
{
if(m_outputCarriageReturns == true)
sb.push_back(0x0D);
if(m_outputLinefeeds == true)
sb.push_back(0x0A);
}
else
{
sb.push_back(c);
}
prevChar = c;
}
sb.push_back(0); // Null terminate
theResult = DOMString(sb.begin());
return theResult;
}
/**
* Convenience function to create an XString.
* @param s A valid string.
* @return An XString object.
*/
XObject* XSLTEngineImpl::createXString(const DOMString& s)
{
return m_xobjectFactory->createString(s);
}
/**
* Convenience function to create an XObject.
* @param o Any java object.
* @return An XObject object.
*/
// @@ JMD: how do we do this ?
XObject* XSLTEngineImpl::createXObject(void* o)
{
assert(0);
// return new XObject(o, m_parserLiaison);
return 0;
}
/**
* Convenience function to create an XNumber.
* @param d Any double number.
* @return An XNumber object.
*/
XObject* XSLTEngineImpl::createXNumber(double d)
{
return m_xobjectFactory->createNumber(d);
}
/**
* Convenience function to create an XBoolean.
* @param b bool value.
* @return An XBoolean object.
*/
XObject* XSLTEngineImpl::createXBoolean(bool b)
{
return m_xobjectFactory->createBoolean(b);
}
/**
* Convenience function to create an XNodeSet.
* @param nl A NodeList object.
* @return An XNodeSet object.
*/
XObject* XSLTEngineImpl::createXNodeSet(const NodeRefListBase& nl)
{
return m_xobjectFactory->createNodeSet(nl);
}
/**
* Convenience function to create an XRTreeFrag.
* @return An XRTreeFrag object.
*/
XObject* XSLTEngineImpl::createXResultTreeFrag(const ResultTreeFragBase& r)
{
return m_xobjectFactory->createResultTreeFrag(r);
}
/**
* Convenience function to create an XNodeSet from a node.
* @param n A DOM node.
* @return An XNodeSet object.
*/
XObject* XSLTEngineImpl::createXNodeSet(const DOM_Node& n)
{
return m_xobjectFactory->createNodeSet(n);
}
/**
* Convenience function to create an XNull.
* @return An XNull object.
*/
XObject* XSLTEngineImpl::createXNull()
{
return m_xobjectFactory->createNull();
}
/**
* Given a name, locate a variable in the current context, and return
* the Object.
*/
XObject* XSLTEngineImpl::getVariable(const QName& qname) const
{
XObject* obj = m_variableStacks.getXObjectVariable(qname);
// @@ JMD: in java the object may not already be an xobject, if so a
new one is created
// from it, this is not implemented in the C++ version, i.e., the
variable stack contains
// ONLY XObjects
return obj;
}
/**
* Create a document fragment. This function may return null.
*/
ResultTreeFragBase* XSLTEngineImpl::createDocFrag() const
{
if(0 == m_resultTreeFactory)
{
m_resultTreeFactory = m_parserLiaison.createDocument();
}
ResultTreeFrag* pfrag = new
ResultTreeFrag(m_resultTreeFactory, m_xpathSupport);
return pfrag;
}
XObject*
XSLTEngineImpl::getXObjectVariable(const DOMString& name) const
{
assert(m_stylesheetRoot != 0);
XObject* theResult = m_variableStacks.getXObjectVariable(name);
if(0 == theResult)
{
theResult = m_stylesheetRoot->getTopLevelVariable(name);
}
return theResult;
}
XString*
XSLTEngineImpl::getTopLevelVariable(const DOMString& theName) const
{
TopLevelVariablesMapType::const_iterator i =
m_topLevelVariables.find(theName);
if (i == m_topLevelVariables.end())
{
return 0;
}
else
{
assert((*i).second != 0);
return (*i).second;
}
}
ResultTreeFragBase*
XSLTEngineImpl::createResultTreeFrag() const
{
if(0 == m_resultTreeFactory)
{
m_resultTreeFactory = m_parserLiaison.createDocument();
}
ResultTreeFrag* pfrag = new
ResultTreeFrag(m_resultTreeFactory, m_xpathSupport);
return pfrag;
}
/**
* Given a document, get the default stylesheet URI from the
* xsl:stylesheet PI.
*/
DOMString
XSLTEngineImpl::getStyleSheetURIfromDoc(const DOM_Node& sourceTree)
// was: getStyleSheetURIfromDoc(DOM_Document sourceTree)
{
DOMString stylesheetURI;
// $$$ ToDo: Make this const when getLength() is const.
DOM_NodeList children = sourceTree.getChildNodes();
const int nNodes = children.getLength();
for(int i = 0; i < nNodes; i++)
{
const DOM_Node child = children.item(i);
if(DOM_Node::PROCESSING_INSTRUCTION_NODE == child.getNodeType())
{
/*DOM_ProcessingInstruction*/ const DOM_Node& pi =
child;
if(equals(pi.getNodeName(), "xml-stylesheet") ||
equals(pi.getNodeName(), "xml:stylesheet"))
{
bool isOK = true;
StringTokenizer
tokenizer(pi.getNodeValue(), " \t=");
while(tokenizer.hasMoreTokens() == true)
{
if(equals(tokenizer.nextToken(),
"type") == true)
{
DOMString typeVal =
tokenizer.nextToken();
typeVal = substring(typeVal, 1,
typeVal.length() - 1);
if(equals(typeVal, "text/xsl")
== false)
{
isOK = false;
}
}
}
if(isOK == true)
{
StringTokenizer
tokenizer(pi.getNodeValue(), " \t=");
while(tokenizer.hasMoreTokens() == true)
{
if(tokenizer.nextToken().equals("href"))
{
stylesheetURI =
tokenizer.nextToken();
stylesheetURI =
substring(stylesheetURI, 1, stylesheetURI.length() - 1);
}
}
break;
}
}
}
}
return stylesheetURI;
}
//bool
void
XSLTEngineImpl::setStylesheetParam(
const DOMString& theName,
const DOMString& expression)
{
// java: QName qname = new QName(key, null, m_parserLiaison);
QName qname(theName, DOM_Element(), m_xpathSupport);
Arg arg(qname, expression, true);
m_topLevelParams.push_back(arg);
}
void
XSLTEngineImpl::setStylesheetParam(
const DOMString& theName,
const XObject* theValue)
{
// java: QName qname = new QName(key, null, m_parserLiaison);
QName qname(theName, DOM_Element(), m_xpathSupport);
Arg arg(qname, theValue);
m_topLevelParams.push_back(arg);
}
void
XSLTEngineImpl::resolveTopLevelParams()
{
m_stylesheetRoot->pushTopLevelVariables(m_topLevelParams);
}
void
XSLTEngineImpl::resetCurrentState(
const DOM_Node& /* sourceTree */,
const DOM_Node& xmlNode)
{
if(0 != xmlNode)
{
//===============================================
// This will be used with callbacks from script,
// in places like getAttributeCallback.
m_currentNode = xmlNode;
}
}
void
XSLTEngineImpl::registerExtensionHandlerByName(
const DOMString& /* classid */,
const DOMString& /* codetype */)
{
#if 1
error("XSL4C does not support extensions at this time!");
#else
try
{
Class classObj = Class.forName(classid);
try
{
Object[] args = new Object[1];
Class[] argTypes = new Class[1];
args[0] = codetype;
argTypes[0] = codetype.getClass();
Method m = classObj.getMethod ("register", argTypes);
DispatcherFactory factory = (DispatcherFactory)m.invoke (0,
args);
if(0 != factory)
{
registerExtensionHandler(codetype, factory);
}
}
catch(NoSuchMethodException& nsme)
{
warn("Failed to get registration method for extension handler:
"+classid);
}
catch(InvocationTargetException& invocationTarget)
{
warn("Invocation Target Error when trying to register extension
handler: "+codetype);
}
catch(IllegalAccessException& illegalAccess)
{
warn("Illegal Access Error when trying to register extension
handler: "+codetype);
}
}
catch(ClassNotFoundException& classNotFound)
{
warn("Class Not Found Error when trying to register extension
handler: "+codetype);
}
#endif
}
void
XSLTEngineImpl::registerExtensionHandler(
const DOMString& /* mimeType */,
DispatcherFactory* /* factory */)
{
#if 1
error("XSL4C does not support extensions at this time!");
#else
if(0 != m_diagnosticsPrintWriter)
{
diag(DOMString("Registering dispatcher factory for: ") +
mimeType);
}
m_dispatcherFactories.put(mimeType, factory);
#endif
}
DOM_Element
XSLTEngineImpl::findElementByAttribute(
const DOM_Element& elem,
const DOMString& targetElementName,
const DOMString& targetAttributeName,
const DOMString& targetAttributeValue)
{
DOM_Element theFoundElement;
const DOMString tagName = elem.getTagName();
if((0 == length(targetElementName)) ||
tagName.equals(targetElementName))
{
// $$$ Todo: Make this const when getLength is const.
DOM_NamedNodeMap attributes = elem.getAttributes();
try
{
const int nAttributes = (0 != attributes) ?
attributes.getLength() : 0;
for(int i = 0; i < nAttributes; i++)
{
DOM_Node theNode =
attributes.item(i);
const DOM_Attr& attr =
static_cast<DOM_Attr&>(theNode);
const DOMString attrName =
attr.getName();
if(attrName.equals(targetAttributeName))
{
DOMString attrVal =
attr.getValue();
if(attrVal.equals(targetAttributeValue))
{
theFoundElement = elem;
break;
}
}
}
}
catch(const DOM_DOMException&)
{
}
}
if(0 == theFoundElement)
{
// $$$ Todo: Make this const when getLength is const.
DOM_NodeList children = elem.getChildNodes();
const int nNodes = children.getLength();
for(int i = 0; i < nNodes; i++)
{
const DOM_Node childNode = children.item(i);
if (childNode.getNodeType() == DOM_Node::ELEMENT_NODE)
{
const DOM_Element& child =
static_cast<const
DOM_Element&>(childNode);
const DOMString childName =
child.getTagName();
if(0 != length(childName))
{
theFoundElement =
findElementByAttribute(
child,
targetElementName,
targetAttributeName,
targetAttributeValue);
if(0 != theFoundElement)
{
break;
}
}
}
}
}
return theFoundElement;
}
URL* XSLTEngineImpl::getURLFromString (const DOMString& urlString)
// throws MalformedURLException
/*
* Create an URL as a file: protocol by constructing fully qualified name
* from 'urlstring'
* NOTE: caller owns memory
*/
{
URL* url = new URL();
try
{
url->setURL(c_wstr(urlString));
}
// 'urlString' not a valid url, try to construct a file url
catch (const MalformedURLException&)
{
DOMString fullpath("file:///");
try
{
XMLCh* lastPart =
XMLPlatformUtils::getBasePath(c_wstr(urlString));
fullpath += lastPart;
fullpath += urlString;
url->setURL(c_wstr(fullpath));
}
catch (MalformedURLException& e2)
{
diag("Error! Cannot create url for: " + fullpath);
throw e2;
}
}
return url;
}
URL* XSLTEngineImpl::getURLFromString(const DOMString& urlString,
const DOMString& base)
{
if (isEmpty(base))
return getURLFromString(urlString);
// We'll only do the really simple case for now:
// base is a complete file URL and urlString is a forward relative
path, i.e.
// in the same directory as the urlString or a subdirectory
DOMString context;
// just to be robust, we'll accept a forward or back slash
int i1 = lastIndexOf(base,'/');
int i2 = lastIndexOf(base,'\\');
int i = i1>i2 ? i1: i2;
if (i != -1)
context = substring(base,0,i+1);
context += urlString;
return getURLFromString(context);
}
void
XSLTEngineImpl::setFormatter(Formatter* formatter)
{
flushPending();
m_formatter = formatter;
if(0 != formatter)
{
m_flistener = formatter->getFormatterListener();
}
else
{
m_flistener = 0;
}
}
/**
* Given an element, return an attribute value in
* the form of a string, processing attributes as
* need be.
* @param el The element from where to get the attribute.
* @param key The name of the attribute.
* @param contextNode The context to evaluate the
* attribute value template.
* @return Attribute value.
*/
DOMString
XSLTEngineImpl::getProcessedAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& contextNode)
{
DOMString val;
const DOM_Attr attr = el.getAttributeNode(key);
if(0 != attr)
{
const DOMString stringedValue = attr.getValue();
if(stringedValue.length() != 0)
{
val = evaluateAttrVal(contextNode, el, stringedValue);
}
}
return val;
}
DOMString
XSLTEngineImpl::getNodeData(const DOM_Node& node)
{
DOMString data;
switch(node.getNodeType())
{
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
case DOM_Node::DOCUMENT_NODE:
case DOM_Node::ELEMENT_NODE:
{
DOM_NodeList children = node.getChildNodes();
int nNodes = children.getLength();
for(int i = 0; i < nNodes; i++)
{
DOMString nodeData =
getNodeData(children.item(i));
if(length(nodeData) > 0)
{
data += nodeData;
}
}
}
break;
case DOM_Node::TEXT_NODE:
case DOM_Node::CDATA_SECTION_NODE:
{
// Apply the same whitespace rules that you apply to
// fixing the whitespace when m_stripWhiteSpace == true.
// Don't know if this is OK.
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(node);
if(shouldStripSourceNode(node))
{
if(!m_xpathSupport.isIgnorableWhitespace(theTextNode))
{
// data =
fixWhiteSpace(((Text)node).getData(), false, false, true);
data = getNormalizedText(theTextNode);
}
}
else
{
data = theTextNode.getData();
}
}
break;
case DOM_Node::ATTRIBUTE_NODE:
data = node.getNodeValue();
break;
default:
// ignore
break;
}
return data;
}
//@@ JMD: NOTE: java implementation of these classes does not pass reference
//to processor
//////////////////////////////////////////////////////////////////////////////
// CLASS XSLTEngineImpl::StackGuard
//////////////////////////////////////////////////////////////////////////////
XSLTEngineImpl::StackGuard::StackGuard(
XSLTEngineImpl& processor,
const DOM_Element& xslTemplate,
const DOM_Node& sourceXML) :
m_processor(&processor),
m_xslRule(xslTemplate),
m_sourceXML(sourceXML),
m_stack()
{
}
XSLTEngineImpl::StackGuard::~StackGuard()
{
m_processor = 0;
}
void
XSLTEngineImpl::StackGuard::print(PrintWriter& pw) const
{
// for the moment, these diagnostics are really bad...
const int theType = m_sourceXML.getNodeType();
if(theType == DOM_Node::TEXT_NODE)
{
const DOM_Text& tx =
static_cast<const DOM_Text&>(m_sourceXML);
pw.println(tx.getData());
}
else if(theType == DOM_Node::ELEMENT_NODE)
{
const DOM_Element& elem =
static_cast<const DOM_Element&>(m_sourceXML);
pw.println(elem.getNodeName());
}
}
void
XSLTEngineImpl::StackGuard::checkForInfiniteLoop(const StackGuard& guard)
const
{
const int nRules = m_stack.size();
int loopCount = 0;
for(int i = (nRules - 1); i >= 0; i--)
{
if(m_stack[i] == (guard))
{
loopCount++;
}
if(loopCount >= 4)
{
DOMStringPrintWriter pw;
pw.println(DOMString("Infinite loop diagnosed! Stack
trace:"));
for(int k = 0; k < nRules; k++)
{
pw.println(DOMString("Source Elem #") +
LongToDOMString(k) +
DOMString(" "));
const StackGuard& guardOnStack =
m_stack[i];
guardOnStack.print(pw);
}
pw.println(DOMString("Source Elem #") +
LongToDOMString(k) +
DOMString(" "));
guard.print(pw);
pw.println(DOMString("End of infinite loop
diagnosis."));
m_processor->diag(pw.getString());
throw XSLTEngineImpl::XSLInfiniteLoopException();
}
}
}
void
XSLTEngineImpl::StackGuard::push(
const DOM_Element& xslTemplate,
const DOM_Node& sourceXML)
{
const StackGuard guard(*m_processor, xslTemplate, sourceXML);
checkForInfiniteLoop(guard);
m_stack.push_back(guard);
}
void
XSLTEngineImpl::StackGuard::pop()
{
m_stack.pop_back();
}
//////////////////////////////////////////////////////////////////////////////
// CLASS XSLTEngineImpl::VariableStack
//////////////////////////////////////////////////////////////////////////////
XSLTEngineImpl::VariableStack::VariableStack(XSLTEngineImpl& theProcessor) :
m_caller(),
m_stack(),
m_processor(theProcessor)
{
pushContextMarker(DOM_Node(), DOM_Node());
}
XSLTEngineImpl::VariableStack::~VariableStack()
{
reset();
}
void
XSLTEngineImpl::VariableStack::reset()
{
// Delete all entries left on the stack
std::for_each(m_stack.begin(),
m_stack.end(),
DeleteFunctor<StackEntry>());
m_stack.clear();
pushContextMarker(DOM_Node(), DOM_Node());
}
void
XSLTEngineImpl::VariableStack::pushElementMarker(const DOM_Node& elem)
{
m_stack.push_back(new ElementMarker(elem));
}
void
XSLTEngineImpl::VariableStack::popElementMarker(const DOM_Node& elem)
{
if(elementMarkerAlreadyPushed(elem) == true)
{
int nElems = m_stack.size();
bool fFound = false;
// Sub 1 extra for the context marker.
for(int i = (nElems - 1); i >= 0 && fFound == false; i--)
{
const StackEntry* const theEntry = m_stack[i];
assert(theEntry != 0);
if(theEntry->getType() == StackEntry::eElementMarker)
{
m_stack.pop_back();
fFound = true;
}
else
{
m_stack.pop_back();
}
delete theEntry;
}
}
}
bool
XSLTEngineImpl::VariableStack::elementMarkerAlreadyPushed(const DOM_Node&
elem) const
{
const int nElems = m_stack.size();
// Sub 1 extra for the context marker.
for(int i = (nElems - 1); i >= 0; i--)
{
const StackEntry* const theEntry = m_stack[i];
assert(theEntry != 0);
if(theEntry->getType() == StackEntry::eElementMarker)
{
const ElementMarker* const theElementMarkerEntry =
static_cast<const
ElementMarker*>(theEntry);
if(&theElementMarkerEntry->getElement() == &elem)
{
return true;
}
}
}
return false;
}
void
XSLTEngineImpl::VariableStack::pushContextMarker(
const DOM_Node& caller,
const DOM_Node& sourceNode)
{
m_stack.push_back(new ContextMarker(caller, sourceNode));
}
void
XSLTEngineImpl::VariableStack::popCurrentContext()
{
const int nElems = m_stack.size();
bool fFound = false;
// Sub 1 extra for the context marker.
for(int i = (nElems - 1); i >= 0 && fFound == false; i--)
{
const StackEntry* const theEntry = m_stack[i];
assert(theEntry != 0);
int type = theEntry->getType();
assert(type <4 && type >= 0);
fFound = (type == StackEntry::eContextMarker);
m_stack.pop_back();
delete theEntry;
}
}
void
XSLTEngineImpl::VariableStack::pushParams(
const Stylesheet*
stylesheetTree,
const ElemTemplateElement&
xslCallTemplateElement,
const DOM_Node&
sourceTree,
const DOM_Node&
sourceNode,
const QName& mode,
const DOM_Node& targetTemplate)
{
StackEntry* const theStackEntry = m_stack.back();
if (theStackEntry->getType() != StackEntry::eContextMarker)
{
// @@ $$$ ToDo: Fix this!!!
// throw InvalidStackContext();
return;
}
VariableStackStackType tempStack;
ContextMarker* const cm =
dynamic_cast<ContextMarker*>(theStackEntry);
try
{
try
{
m_stack.pop_back();
NodeImpl* child =
(const_cast<ElemTemplateElement&>(xslCallTemplateElement)).getFirstChild();
while(0 != child)
{
if(Constants::ELEMNAME_WITHPARAM ==
(dynamic_cast<ElemTemplateElement*>(child))->getXSLToken())
{
ElemWithParam* xslParamElement =
dynamic_cast<ElemWithParam*>(child);
Arg* theArg = 0;
XPath* pxpath =
xslParamElement->getSelectPattern();
if(0 != pxpath)
{
XObject* const theXObject =
pxpath->execute(sourceNode,
*xslParamElement,
m_processor.getContextNodeList());
theArg = new
Arg(*xslParamElement->getQName(), theXObject);
}
else
{
ResultTreeFragBase* const
theDocFragment =
m_processor.createResultTreeFrag(stylesheetTree,
*xslParamElement,
sourceTree,
sourceNode,
mode);
assert(theDocFragment != 0);
// Cast to result tree fragment
ResultTreeFrag* const
theResultTreeFrag =
static_cast<ResultTreeFrag* const>(theDocFragment);
XObject* var =
m_processor.createXResultTreeFrag(*theResultTreeFrag);
theArg = new
Arg(*xslParamElement->getQName(), var);
}
assert(theArg != 0);
tempStack.push_back(theArg);
}
child = child->getNextSibling();
} // while
}
catch(...)
{
m_stack.push_back(cm);
throw;
}
m_stack.push_back(cm);
try
{
pushElementMarker(targetTemplate);
const int nParams = tempStack.size();
for(int i = 0; i < nParams; i++)
{
m_stack.push_back(tempStack.back());
tempStack.pop_back();
}
}
catch(...)
{
popElementMarker(targetTemplate);
throw;
}
}
catch(...)
{
// Delete all temp entries not yet transferred.
// Any transferred ones will have been deleted
// by popElementMarker();
std::for_each(tempStack.begin(),
tempStack.end(),
DeleteFunctor<StackEntry>());
throw;
}
}
bool XSLTEngineImpl::VariableStack::hasParamVariable(QName& qname)
{
bool hasit = false;
const int nElems = m_stack.size();
// Sub 1 extra for the context marker.
for(int i = (nElems - 1); i >= 0; i--)
{
const StackEntry* const theEntry = m_stack[i];
assert(theEntry != 0);
if(theEntry->getType() == StackEntry::eArgument)
{
const Arg* const theArg = dynamic_cast<const
Arg*>(theEntry);
if((theArg->getName()).equals(qname))
{
hasit = true;
break;
}
}
else if(theEntry->getType() == StackEntry::eContextMarker)
{
break;
}
}
return hasit;
}
void
XSLTEngineImpl::VariableStack::pushVariable(
const QName& name,
XObject* val,
const DOM_Node& e)
{
if(elementMarkerAlreadyPushed(e) == false)
{
pushElementMarker(e);
}
m_stack.push_back(new Arg(name, val));
}
XObject*
XSLTEngineImpl::VariableStack::findXObject(
const QName& name,
bool fSearchGlobalSpace)
const
{
XObject* theXObject = 0;
const Arg* const theArg = findArg(name, fSearchGlobalSpace);
if (theArg != 0)
{
if (theArg->getArgType() == Arg::eXObject)
{
theXObject =
const_cast<XObject*>(theArg->getXObjectPtr());
}
}
return theXObject;
}
const Arg*
XSLTEngineImpl::VariableStack::findArg(
const QName& qname,
bool fSearchGlobalSpace)
const
{
const Arg* theResult = 0;
const int nElems = m_stack.size();
// Sub 1 extra for the context marker.
for(int i = (nElems - 1); i >= 0; i--)
{
const StackEntry* const theEntry =
m_stack[i];
assert(theEntry != 0);
if(theEntry->getType() == StackEntry::eArgument)
{
const Arg* const theArg =
dynamic_cast<const Arg*>(theEntry);
if((theArg->getName()).equals(qname))
{
theResult = theArg;
break;
}
}
else if(theEntry->getType() == StackEntry::eContextMarker)
{
break;
}
}
if(0 == theResult && true == fSearchGlobalSpace)
{
// Look in the global space
for(int i = 2; i < (nElems - 1); i++)
{
const StackEntry* const theEntry = m_stack[i];
assert(theEntry != 0);
if(theEntry->getType() == StackEntry::eArgument)
{
const Arg* const theArg =
dynamic_cast<const Arg*>(theEntry);
if((theArg->getName()).equals(qname))
{
theResult = theArg;
break;
}
}
else if(theEntry->getType() ==
StackEntry::eContextMarker)
{
break;
}
}
}
return theResult;
}
void
XSLTEngineImpl::InstallFunctions()
{
XPath::installFunction("current", FunctionCurrent());
XPath::installFunction("format-number", FunctionFormatNumber());
XPath::installFunction("key", FunctionKey());
XPath::installFunction("unparsed-entity-uri",
FunctionUnparsedEntityURI());
XPath::installFunction("system-property", FunctionSystemProperty());
XPath::installFunction("generate-id", FunctionGenerateID());
}
XSLTEngineImpl::AttributeKeysMapType
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_XMLDECL] =
Constants::TATTRNAME_OUTPUT_XMLDECL;
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;
return theAttributeKeys;
}
XSLTEngineImpl::AttributeKeysMapType
XSLTEngineImpl::InitializeElementKeysTable()
{
AttributeKeysMapType 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;
return theElementKeys;
}
XSLTEngineImpl::ElementKeysMapType
XSLTEngineImpl::InitializeXSLT4JElementKeys()
{
ElementKeysMapType theElementKeys;
theElementKeys[Constants::ELEMNAME_CSSSTYLECONVERSION_STRING] =
Constants::ELEMNAME_CSSSTYLECONVERSION;
theElementKeys[Constants::ELEMNAME_COMPONENT_STRING] =
Constants::ELEMNAME_COMPONENT;
theElementKeys[Constants::ELEMNAME_SCRIPT_STRING] =
Constants::ELEMNAME_SCRIPT;
return theElementKeys;
}
XSLTEngineImpl::StaticInitializer::StaticInitializer()
{
XSLTEngineImpl::InstallFunctions();
}
XSLTEngineImpl::StaticInitializer::~StaticInitializer()
{
}
//////////////////////////////////////////////////////////////////////////////
1.1 xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp
Index: XSLTEngineImpl.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XALAN_XSLTENGINEIMPL_HEADER_GUARD)
#define XALAN_XSLTENGINEIMPL_HEADER_GUARD
/**
*
* $Id: XSLTEngineImpl.hpp,v 1.1 1999/12/18 19:48:05 robweir Exp $
*
* $State: Exp $
*
* @author Scott Boag ([EMAIL PROTECTED])
*
* It is the responsibility of the XSLTEngineImpl class to traverse the
* source DOM tree according to the instructions in the style DOM tree,
* and output nodes into the result DOM tree.
*
* Basic flow of control:
* Starting from process(Document sourceTree, Document out, String mode),
* 1) init the Stylesheet instances (which hold the state for each imported
* XSL stylesheet) in the parseXSLRoot method, then
* 2) locate the rootRule (all rules are found via Stylesheet.findTemplate),
* then pass the root node of the source tree to
* 3) buildResultFromTemplate, which processes each of the template's
* child elements by calling
* 4) processTemplateElement, which either processes the element
* by handling it as an XSL directive (if it is in the xsl: namespace),
* or by cloning the source node to the result tree.
* If it is an XSL instruction,
* 5) processXSLTemplateInstruction is called, which calls various
* subfunctions according to the tag name.
* The XSL directives that effect the source traversal are
xsl:apply-templates
* and xsl:for-each, which are handled in the
* 6) handleApplyTemplatesInstruction, which selects the start node and
* calls the
* 7) transformSelectedChildren method, which performs a query or just
* traverses the child list, then for each node in the selected list
calls
* 8) transformChild, which then calls
* 9) Stylesheet.findTemplate (if it is not an xsl:for-each instruction)
* to locate the corresponding template, and then calls
* 10) buildResultFromTemplate, recursing back in to step 3 and starting the
* traversal cycle all over again.
*
* Glossary (abbreviations used in variable and method names in square
* brackets):
*
* XSL Instruction [instruction]
* Any tag with an XSL namespace prefix.
* XSL Template Instruction [instruction]
* Any tag with an XSL namespace prefix
* that occurs inside an xsl:template element.
* Template Child [templateChild]
* Any node that is a child of an xsl:template element.
* Source Tree
* The tree input to the XSL process.
* Result Tree
* The tree that is output by the XSL process.
* Stylesheet Tree
* The stylesheet tree produced from the XSL file.
* Pattern List [patternList]
* A parsed query or match pattern.
*
*
*/
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
// Standard library headers
#include <cassert>
#include <ctime>
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
#include <hash_map>
#endif
#include <list>
#include <map>
#include <memory>
#include <set>
#include <stack>
#include <vector>
#include <stdexcept>
// Xerces DOM header file
#include <dom/DOM_Node.hpp>
#include <dom/DOM_NodeList.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Text.hpp>
#include <dom/DOMString.hpp>
#include <util/URL.hpp>
#include <sax/DocumentHandler.hpp>
// XSL header files.
#include <Include/DOMHelper.hpp>
#include <PlatformSupport/AttributeListImpl.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XMLSupport/FormatterListener.hpp>
#include <XMLSupport/XMLParserLiaison.hpp>
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/XPathSupport.hpp>
#include <XPath/XPathEnvSupport.hpp>
#include <XPath/XPathProcessorImpl.hpp>
#include <XPath/QName.hpp>
#include <XPath/XObjectFactory.hpp>
#include <sax/Locator.hpp>
#include "Constants.hpp"
#include "ContextState.hpp"
#include "ElemTemplateElement.hpp"
#include "KeyDeclaration.hpp"
#include "ProblemListener.hpp"
#include "Stylesheet.hpp"
//#include "StylesheetRoot.hpp"
//#include "ElemVariable.hpp"
#include "XSLTInputSource.hpp"
/*
#include "XSLTResultTarget.hpp"
*/
class XSLTResultTarget;
#include "TraceListener.hpp"
// Base class
#include "XSLTProcessor.hpp"
//@@ JMD: maybe yes, maybe no
#include "Java2STL.hpp"
// Forward definitions
//class XMLReader;
class Arg;
class DispatcherFactory;
class Formatter;
class InputSource;
class PrintWriter;
class ProblemListener;
class ResultTreeFragBase;
class StackEntry;
class Stylesheet;
class StylesheetRoot;
class XMLParserLiaison;
class XObject;
class XString;
//class ElemTemplateElement;
class ElemVariable;
class XPathFactory;
class XPathProcessor;
class GenerateEvent;
/**
* It's the responsibility of the XSLTEngineImpl class, collaborating with the
* XML parser liaison, the DOM, and the XPath engine, to transform a source
* tree of nodes into a result tree according to instructions and templates
* specified by a stylesheet tree. The methods process(...) are the primary
* public entry points. The best way to call the processor classes is to use
* the
* process( XSLTInputSource inputSource, XSLTInputSource stylesheetSource,
* XSLTResultTarget outputTarget)
* method, but you may use any of process methods that are provided for
* convenience.
*
* Example:
*
* foo.xml:
* <?xml version="1.0"?>
* <doc>Hello</doc>
*
* foo.xsl:
* <?xml version="1.0"?>
* <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
* <xsl:template match="doc">
* <out><xsl:value-of select="."/></out>
* </xsl:template>
* </xsl:stylesheet>
*
* transform.cpp:
*
* void main()
* {
* XSLTEngineImpl* processor = new XSLTEngineImpl();
// @@ FIX THIS
* PrintWriter pw = new PrintWriter( new FileWriter("foo.out") );
* processor.process("foo.xml", "foo.xsl", pw);
* }
*
* foo.out:
* <out>Hello</out>
*
* Look at the Process class for an advanced example of usage by the main()
* function.
*
* If you reuse the processor instance, you should call reset() between calls.
*
*
* @author Scott Boag
* @author David N. Bertoni ([email protected])
*/
#ifdef _MSC_VER
#pragma warning(disable:4100)
#endif
class XALAN_XSLT_EXPORT XSLTEngineImpl : public XSLTProcessor,
private DocumentHandler
{
//==========================================================
// SECTION: Constructors
//==========================================================
public:
//////////////////////////////////////////////////////////////////////////////
/**
* Construct an XSL processor that uses the XML4J fast DOM liaison
* by default.
*/
// @@ JMD: how to model classForName ??
// XSLTEngineImpl(DOMString parserLiaisonClassName =
DOMString("org.apache.xml.xpath4j.xml.xml4j2dom.XML4JLiaison4dom"));
/**
* Construct an XSL processor that can call back to a XML processor, so
it
* can handle included files, and the like. You must create a new
instance
* of the XSLTEngineImpl class each time you run a transformation.
Fixing
* this is high on my priority list.
* @param XMLParserLiaison A liaison to an object that can help with
stuff
* specific to a parser implementation.
* @see org.apache.xml.xslt4j.XMLParserLiaison
* @see org.apache.xml.xslt4j.xml4j.ProcessXSL
*/
XSLTEngineImpl(
XMLParserLiaison&
parserLiaison,
XPathSupport&
xpathSupport,
XPathEnvSupport&
xpathEnvSupport,
XObjectFactory*
xobjectFactory,
XPathFactory*
xpathFactory);
//////////////////////////////////////////////////////////////////////////////
virtual ~XSLTEngineImpl();
protected:
/**
* Init anything to do with XPath.
*/
void initXPath(XPathFactory* xpathFactory);
/**
* Reset the state. This needs to be called after a process() call
* is invoked, if the processor is to be used again.
*/
virtual void reset();
// Guard against being serialized by mistake
private:
//@@ Serialization not supported, we don't need this in C++
// void writeObject(ObjectOutputStream stream);
//==========================================================
// SECTION: Main API Functions
//==========================================================
// private void ____MAIN_API____(){}
public:
/**
* Transform the source tree to the output in the given
* result tree target.
* @param inputSource The input source.
* @param stylesheetSource The stylesheet source. May be null if
source has a xml-stylesheet PI.
* @param outputTarget The output source tree.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual void process( XSLTInputSource *inputSource,
XSLTInputSource *stylesheetSource,
XSLTResultTarget* outputTarget);
/**
* Given a URI to an XSL stylesheet,
* Compile the stylesheet into an internal representation.
* This calls reset() before processing if the stylesheet root has been
set
* to non-null.
* @param stylesheetSource The stylesheet source. May be null if
source has a xml-stylesheet PI.
* @return The compiled stylesheet object.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual StylesheetRoot* processStylesheet(XSLTInputSource*
stylesheetSource);
/**
* Given a URI to an XSL stylesheet,
* Compile the stylesheet into an internal representation.
* This calls reset() before processing if the stylesheet root has been
set
* to non-null.
* @param xsldocURLString The URL to the input XML document.
* @return The compiled stylesheet object.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual StylesheetRoot* processStylesheet(const DOMString
&xsldocURLString);
//==========================================================
// SECTION: XML Parsing Functions
//==========================================================
// private void ____XML_PARSING_FUNCTIONS____(){}
/**
* Given an input source, get the source tree.
*/
virtual const DOM_Node getSourceTreeFromInput(XSLTInputSource
*inputSource);
/**
* Read in the XML file, either producing a Document or calling SAX
events,
* and register the document in a table. If the document has already
been
* read in, it will not be reparsed.
* @param url The location of the XML.
* @param docHandler The SAX event handler.
* @param docToRegister If using a SAX event handler, the object to
register in the source docs table.
* @return lcom.ms.xml.om.Document object, which represents the parsed
XML.
* @exception SAXException thrown if the active ProblemListener and
XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
DOM_Document parseXML(const URL& url,
//@@ TODO: Fix this
#if 1
DocumentHandler* docHandler,
#else
FormatterListener* docHandler,
#endif
const DOM_Document& docToRegister);
/**
* Reset the state of the XSL processor by reading in a new
* XSL stylesheet.
* @param xslURLString a valid URI to an XSL stylesheet.
* @param outDiagnostics The print stream to write diagnostics (may be
null).
*/
Stylesheet* getStylesheetFromPIURL(DOMString& xslURLString,
const DOM_Node&
fragBase,
DOMString&
xmlBaseIdent,
bool isRoot);
//==========================================================
// SECTION: Stylesheet Tables
//==========================================================
private:
/**
* The root of a linked set of stylesheets.
*/
StylesheetRoot* m_stylesheetRoot;
public:
StylesheetRoot*
getStylesheetRoot() const
{
return m_stylesheetRoot;
}
void
setStylesheetRoot(StylesheetRoot* theStylesheet)
{
m_stylesheetRoot = theStylesheet;
}
/**
* Table of stylesheet documents.
* Document objects are keyed by URL string.
*/
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef hash_map<DOMString,
Stylesheet*,
DOMStringHashFunction,
DOMStringEqualsFunction>
StylesheetMapType;
#else
typedef std::map<DOMString,
Stylesheet*>
StylesheetMapType;
#endif
StylesheetMapType m_stylesheets;
public:
/**
* Get table of stylesheet documents.
* Document objects are keyed by URL string.
*/
StylesheetMapType&
getStylesheetsTable()
{
return m_stylesheets;
}
// @@ JMD: needed by Stylesheet
// private:
//==========================================================
// SECTION: Source Tree Tables
//==========================================================
/**
* Table of input documents.
* Document objects are keyed by URL string.
*/
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef hash_map<DOMString,
DOM_Document,
DOMStringHashFunction,
DOMStringEqualsFunction>
SourceDocumentsMapType;
#else
typedef std::map<DOMString, DOM_Document, DOMStringEqualsFunction>
SourceDocumentsMapType;
#endif
SourceDocumentsMapType m_sourceDocs;
/**
* The root document.
*/
DOM_Document m_rootDoc;
public:
/**
* Given a DOM Document, tell what URI was used to parse it.
*/
DOMString findURIFromDoc(const DOM_Document& doc)
{
return m_xpathEnvSupport.findURIFromDoc(doc);
}
/**
* Get table of source tree documents.
* Document objects are keyed by URL string.
*/
SourceDocumentsMapType getSourceDocsTable()
{
return m_xpathEnvSupport.getSourceDocsTable();
}
/**
* Set a source document. Every time a source document is requested
* through either xsl:uri or in a process call,
* the processor will first consult table of supplied
* documents before trying to load and parse the corresponding
* document from the Net.
*/
void setSourceDocument(const DOMString& uri,
DOM_Document& doc)
{
m_sourceDocs.insert(std::make_pair<const DOMString,
DOM_Document>(uri, doc));
}
protected:
//==========================================================
// SECTION: Major flow-of-control functions
//==========================================================
//==========================================================
// SECTION: XSL directive handling functions
//==========================================================
private:
/**
* The full XSLT Namespace URL. To be replaced by the one actually
* found.
*/
DOMString m_XSLNameSpaceURL;
//"http://www.w3.org/1999/XSL/Transform/1.0"
/**
* The minimum version of XSLT supported.
*/
static const double s_XSLTVerSupported; // 1.0
/**
* Out version of XSLT
*/
static const DOMString s_DefaultXSLNameSpaceURL;
/**
* The namespace that we must match as a minumum for XSLT.
*/
static const DOMString s_XSLNameSpaceURLPre; //
"http://www.w3.org/1999/XSL/Transform"
/**
* Special Xalan namespace for built-in extensions.
*/
static const DOMString s_XSLT4JNameSpaceURL; //
"http://xml.apache.org/xslt"
public:
static const DOMString&
getXSLNameSpaceURLPre()
{
return s_XSLNameSpaceURLPre;
}
const DOMString&
getXSLNameSpaceURL() const
{
return m_XSLNameSpaceURL;
}
static const DOMString&
getXSLT4JNameSpaceURL()
{
return s_XSLT4JNameSpaceURL;
}
void
setXSLNameSpaceURL(const DOMString& theXSLNameSpaceURL)
{
m_XSLNameSpaceURL = theXSLNameSpaceURL;
}
static double getXSLTVerSupported();
static const DOMString&
getXalanXSLNameSpaceURL();
private:
/**
* Hash table that can look up XSLT4J extensions element IDs via name.
*/
typedef std::map<DOMString, int> ElementKeysMapType;
static const ElementKeysMapType s_XSLT4JElementKeys;
/**
* Init the XSLT hashtable.
*/
// static void
// initXSLTKeys();
public:
/**
* Hash table that can look up xslt element IDs via attribute.
*/
typedef std::map<DOMString, int> AttributeKeysMapType;
private:
static const AttributeKeysMapType s_attributeKeys;
/**
* Hash table that can look up xslt element IDs via name.
*/
static const AttributeKeysMapType s_elementKeys;
public:
static const AttributeKeysMapType&
getAttributeKeys()
{
return s_attributeKeys;
}
static const ElementKeysMapType&
getElementKeys()
{
return s_elementKeys;
}
private:
/**
* Node to xsl directive table, used so we don't have to keep
* looking up the directives each time. This isn't of huge
* benifit, but is used because of the cost of getExpandedElementName.
*/
// Create a hash table that can look up xsl element IDs via name.
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef hash_map<DOM_Node, int, DOM_NodeHashFunction>
XSLDirectiveMapType;
#else
typedef std::map<DOM_Node, int>
XSLDirectiveMapType;
#endif
mutable XSLDirectiveMapType m_XSLDirectiveLookup;
public:
/**
* Given an XSL tag name, return an integer token
* that corresponds to ELEMNAME_XXX constants defined
* in Constants.java.
* Note: I tried to optimize this by caching the node to
* id lookups in a hash table, but it helped not a bit.
* I'm not sure that it's spending too much time here anyway.
* @param node a probable xsl:xxx element.
* @return Constants.ELEMNAME_XXX token, or -1 if in xsl
* or Xalan namespace, -2 if not in known namespace.
*/
int
getXSLToken(
const DOM_Node& node) const;
/**
* Find the type of an element using this method. This is slower
* than it ought to be... I'll find a way to optimize down the
* line if need be.
* @param node a probable xsl:xxx element.
* @param tagType Constants.ELEMNAME_XXX token.
* @return true if node is of tagType.
*/
//final
bool
isXSLTagOfType(
const DOM_Node& node,
int tagType) const;
/**
* Output an object to the result tree by doing the right conversions.
* This is public for access by extensions.
*
* @param stylesheetTree the target stylesheet tree.
* @param obj the XObject to output.
*/
void outputToResultTree (const Stylesheet& stylesheetTree, XObject*
xobj);
private:
/**
* If the template element is in the xsl:namespace, process the
* element.
* @return true if the given XSL template child is an XSL directive.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
bool
processXSLTemplateInstruction(
const Stylesheet* stylesheetTree,
DOM_Element xslInstruction,
DOM_Document sourceTree,
const DOM_Node& sourceNode,
const DOMString& mode);
/**
* In response to 'xsl:import', call transformChild, or, if that
* fails, transformChildren.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
/*
@@ JMD: OBSOLETE ??
void
handleApplyImportInstruction(
Stylesheet* stylesheetTree,
DOM_Element templateChild,
DOM_Document sourceTree,
const DOM_Node& sourceNode,
const DOMString& mode,
int xslToken);
*/
public:
/**
* Execute the function-available() function.
* @param context The current source tree context node.
* @param opPos The current position in the m_opMap array.
* @param args The function args.
* @returns whether the given function is available or not.
*/
bool functionAvailable(DOMString& theNamespace,
DOMString&
extensionName)
{
return m_xpathEnvSupport.functionAvailable(theNamespace,
extensionName);
return false;
}
/**
* Handle an extension function.
*/
virtual XObject*
extFunction(
XPathExecutionContext&
executionContext,
const DOMString&
theNamespace,
const DOMString&
extensionName,
const std::vector<XObject*>& argVec) const;
// This is public for class Stylesheet...
/**
* In response to xsl:function, set up a function that can
* be called from the expression language.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
handleFunctionsInstruction(
DOM_Element extensionElem);
private:
//==========================================================
// SECTION: Diagnostic functions
//==========================================================
private:
/**
* If this is set to true, do not warn about pattern
* match conflicts.
*/
bool m_quietConflictWarnings;
/*
* If this is true, then the diag function will
* be called.
*/
bool m_traceTemplateChildren;
/*
* If this is true, then the simple tracing of templates
* will be performed.
*/
bool m_traceTemplates;
/*
* If this is true, then diagnostics of each select
* will be performed.
*/
bool m_traceSelects;
/*
* A stream to print diagnostics to.
*/
PrintWriter* m_diagnosticsPrintWriter;
/* For diagnostics */
typedef std::map<const void*, clock_t> DurationsTableMapType;
mutable DurationsTableMapType m_durationsTable;
/**
* List of listeners who are interested in tracing what's
* being generated.
*/
typedef std::vector<TraceListener*> TraceListenerVectorType;
/*transient*/ TraceListenerVectorType m_traceListeners;
// Common processing for errors and warnings
void problem(const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
ProblemListener::eClassification
classification) const;
public:
// @@ JMD: make this private w/accessor LATER
/**
* The top of this stack should contain the currently processed
* stylesheet SAX locator object.
*/
typedef Stack <Locator *> LocatorStack;
LocatorStack m_stylesheetLocatorStack;
/**
* Add a trace listener for the purposes of debugging and diagnosis.
* @param tl Trace listener to be added.
*/
virtual void addTraceListener(TraceListener* tl);
/**
* Add a trace listener for the purposes of debugging and diagnosis.
* @param tl Trace listener to be added.
*/
void addTraceListenersToStylesheet();
/**
* Remove a trace listener.
* @param tl Trace listener to be removed.
*/
virtual void removeTraceListener(TraceListener* tl);
/**
* Fire a generate event.
*/
void fireGenerateEvent(const GenerateEvent& te);
/**
* Warn the user of an problem.
* This is public for access by extensions.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void message(const DOMString& msg);
/**
* Warn the user of an problem.
* This is public for access by extensions.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void message( const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg);
/**
* Tell the user of an error, and probably throw an
* exception.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
bool
getQuietConflictWarnings() const
{
return m_quietConflictWarnings;
}
/**
* Warn the user of an problem.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual void
warn(const DOMString& msg) const;
/**
* Warn the user of an problem.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual void
warn(
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg) const;
/**
* Tell the user of an error, and probably throw an
* exception.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
error(const DOMString& msg) const;
/**
* Tell the user of an error, and probably throw an
* exception.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
//@@ HOLD until we figure out exceptions
// void error(DOMString& msg, Exception e);
/**
* Tell the user of an error, and probably throw an
* exception.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
error(
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg) const;
/**
* Mark the time, so that displayDuration can later
* display the elapsed clock ticks.
*/
void
pushTime(const void* key) const;
/**
* Returns the duration since pushTime was called,
* in in clock ticks.
*/
clock_t
popDuration(const void* key) const;
/**
* Display the duration since pushTime was called.
*/
void
displayDuration(
const DOMString& info,
const void* key) const;
/*
* Rather than exposing the member and testing it as in java
*/
bool doDiagnosticsOutput()
{ return 0 != m_diagnosticsPrintWriter; }
/**
* If this is set, diagnostics will be
* written to the m_diagnosticsPrintWriter stream. If
* the value is null, then diagnostics will be turned
* off.
*/
virtual void
setDiagnosticsOutput(PrintWriter* pw);
/**
* Bottleneck output of diagnostics.
*/
void
diag(
const DOMString& s) const;
/**
* If this is set to true, simple traces of
* template calls are made.
*/
virtual void
setTraceTemplates(bool b);
/**
* If this is set to true, simple traces of
* template calls are made.
*/
bool isTraceSelect() const;
virtual void
setTraceSelect(bool b);
/**
* If this is set to true, debug diagnostics about
* template children as they are being constructed
* will be written to the m_diagnosticsPrintWriter
* stream. diagnoseTemplateChildren is false by
* default.
*/
virtual void
setTraceTemplateChildren(bool b);
/**
* If the quietConflictWarnings property is set to
* true, warnings about pattern conflicts won't be
* printed to the diagnostics stream.
* True by default.
* @param b true if conflict warnings should be suppressed.
*/
virtual void
setQuietConflictWarnings(bool b)
{
m_quietConflictWarnings = b;
}
/**
* Print a trace of a selection being made.
*/
void traceSelect( DOM_Element theTemplate,
const NodeRefListBase&
nl) const;
//@@ WAS: int nodeCount)
const;
private:
/**
* Print a trace of a template that is being called, either by
* a match, name, or as part of for-each.
*/
void
traceTemplate(
DOM_Element theTemplate) const;
/**
* Print some diagnostics about the current
* template child.
*/
void
diagnoseTemplateChildren(
const DOM_Node& templateChild,
const DOM_Node& sourceNode) const;
public:
//==========================================================
// SECTION: Functions that create nodes in the result tree
//==========================================================
//@@ This all should be copied from FormatterListener.hpp...
/**
* To fullfill the FormatterListener interface... no action
* for the moment.
*/
virtual void setDocumentLocator( Locator* const locator);
/**
* Bottleneck the startDocument event.
*/
virtual void
startDocument();
/**
* Bottleneck the endDocument event.
*/
virtual void
endDocument();
protected:
/**
* The pending element. We have to delay the call to
* m_flistener.startElement(name, atts) because of the
* xsl:attribute and xsl:copy calls. In other words,
* the attributes have to be fully collected before you
* can call startElement.
*/
DOMString m_pendingElementName;
/**
* The pending attributes. We have to delay the call to
* m_flistener.startElement(name, atts) because of the
* xsl:attribute and xsl:copy calls. In other words,
* the attributes have to be fully collected before you
* can call startElement.
*/
AttributeListImpl m_pendingAttributes;
/**
* NOTE: This replaces the ResultNameSpace class in java, since it is
the
* same as the NameSpace class
*/
/**
* A stack to keep track of the result tree namespaces.
*/
typedef std::vector<NameSpace> NamespaceVectorType;
typedef std::vector<NamespaceVectorType>
NamespacesStackType;
NamespacesStackType m_resultNameSpaces;
/**
* This is pushed on the m_resultNameSpaces stack until a
* xmlns attribute is found. It's special because it has
* and empty prefix and uri field.
*/
NameSpace m_emptyNamespace;
// Factory for creating xpaths.
XPathFactory *m_xpathFactory;
// Factory for creating xobjects
XObjectFactory* m_xobjectFactory;
// The query/pattern-matcher object.
XPathProcessor* m_xpathProcessor;
/**
* Stack of Booleans to keep track of if we should be outputting
* cdata instead of escaped text.
* ## Optimization: use array stack instead of object stack.
*/
Stack <bool> m_cdataStack;
private:
/**
* This is for use by multiple output documents, to determine
* the base directory for the output document. It needs to
* be set by the caller.
*/
DOMString m_outputFileName;
public:
// @@ JMD added: Fri Oct 1 10:23:05 EDT 1999
/**
* Flush the pending element.
*/
void flushPending();
/**
* Bottleneck addition of result tree attributes, so I can keep
* track of namespaces.
*/
void addResultNamespaceDecl(const DOMString& prefix,
const DOMString& namespaceVal);
/**
* Bottleneck addition of result tree attributes, so I can keep
* track of namespaces.
*/
void
addResultAttribute(
AttributeListImpl& attList,
const DOMString& aname,
const DOMString& value);
/**
* Bottleneck the startElement event.
*/
virtual void
startElement(
const XMLCh* const name);
/**
* Bottleneck the startElement event.
*/
virtual void
startElement(
const XMLCh* const name,
AttributeList& atts);
/**
* Bottleneck the endElement event.
*/
virtual void
endElement (
const XMLCh* const name);
/**
* Bottleneck the characters event.
*/
virtual void
characters(
const XMLCh* const ch,
const unsigned int start,
const unsigned int length);
// @@ JMD: there is a basic mismatch between the characters method in
the
// Xerces SAX DocumentHandler and the java version -- this merely
bridges
// the gap ??
virtual void characters (
const XMLCh* const chars,
const unsigned int length);
/**
* Bottleneck the characters event.
*/
virtual void
charactersRaw(
const XMLCh* const ch,
const unsigned int start,
const unsigned int length);
/**
* Bottleneck the ignorableWhitespace event.
*/
virtual void
ignorableWhitespace(
const XMLCh* const ch,
const unsigned int length);
/**
* Bottleneck the processingInstruction event.
*/
virtual void
processingInstruction(
const XMLCh* const target,
const XMLCh* const data);
/**
* Bottleneck the comment event.
*/
virtual void
comment(
const XMLCh* const data);
/**
* Bottleneck the entity reference event.
*/
virtual void
entityReference(
const XMLCh* const name);
/**
* Bottleneck the cdata event.
*/
virtual void
cdata(
const XMLCh* const ch,
const unsigned int start,
const unsigned int length);
// pure virtual in DocumentHandler
virtual void resetDocument();
//@@ ?? private:
/**
* Clone an element with or without children.
* TODO: Fix or figure out node clone failure!
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
cloneToResultTree(
const Stylesheet& stylesheetTree,
const DOM_Node& node,
bool isLiteral,
bool
shouldCloneWithChildren,
bool overrideStrip,
bool
shouldCloneAttributes);
/**
* Given a result tree fragment, walk the tree and
* output it to the result stream.
*/
void
outputResultTreeFragment(XObject* theTree);
private:
/**
* Write the children of a stylesheet element to the given listener.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
* @param stylesheetTree The stylesheet object that holds the fragment.
* @param templateParent The template element that holds the fragment.
* @param sourceTree The source tree document context.
* @param sourceNode The current source context node.
* @param mode The mode under which the template is operating.
* @return An object that represents the result tree fragment.
*/
void writeChildren(
FormatterListener* flistener,
Stylesheet& stylesheetTree,
ElemTemplateElement& templateParent,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode, QName mode);
//==========================================================
// SECTION: Function to do with attribute handling
//==========================================================
/**
* This is used whenever a unique namespace is needed.
*/
mutable int m_uniqueNSValue; // 0
public:
int getUniqueNSValue() const
{
return m_uniqueNSValue++;
}
/**
* Tell if a given element name should output it's text
* as cdata.
*/
bool isCDataResultElem(DOMString& elementName);
/**
* Tell if a qualified name equals the current result tree name.
*/
bool qnameEqualsResultElemName(QName& qname, DOMString& elementName);
/**
* Given a prefix, return the namespace,
*/
DOMString
getResultNamespaceForPrefix(
const DOMString& prefix) const;
/**
* This should probably be in the XMLParserLiaison interface.
*/
DOMString
getResultPrefixForNamespace(
const DOMString& theNamespace) const;
/**
* Evaluate an xpath string and return the result.
*/
double evalMatchPatternStr(
const
DOMString& str,
const DOM_Node&
context,
const
PrefixResolver& resolver);
/**
* Evaluate an xpath string and return the result.
*/
XPath *createMatchPattern(const DOMString& str, const PrefixResolver&
resolver);
private:
/**
* XPath object to use for short evaluations, so we don't have to
* create one every time.
*/
XPath* m_xpath;
/**
* This should probably be in the XMLParserLiaison interface.
*/
DOMString
getPrefixForNamespace(
const DOMString& theNamespace,
const DOM_Element& namespaceContext) const;
public:
/**
* Copy xmlns: attributes in if not already in scope.
*/
void
copyNamespaceAttributes(
const DOM_Node& src,
bool
srcIsStylesheetTree,
AttributeListImpl& destination);
/**
* Evaluate an xpath string and return the result.
*/
XObject* evalXPathStr(const DOMString& str,
const DOM_Node& context, const
PrefixResolver& resolver);
private:
bool m_useATVsInSelects;
public:
/**
* Get an Expression object from a select node. Does not cache!
*/
XPath* getExpression(
AttributeList& attrs,
const DOMString& key,
const PrefixResolver& resolver);
/**
* Given an element, return an attribute value in
* the form of a string.
* @param el The element from where to get the attribute.
* @param key The name of the attribute.
* @param contextNode The context to evaluate the
* attribute value template.
* @return Attribute value.
*/
DOMString
getAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& contextNode);
/**
* Given an element, return an attribute value in
* the form of a string.
*/
static DOMString
getAttrVal(
const DOM_Element& el,
const DOMString& key);
public:
/**
* Given an element, return an attribute value in
* the form of a string, processing attributes as
* need be.
* @param el The element from where to get the attribute.
* @param key The name of the attribute.
* @param contextNode The context to evaluate the
* attribute value template.
* @return Attribute value.
*/
DOMString
getProcessedAttrVal(
const DOM_Element& el,
const DOMString& key,
const DOM_Node& contextNode);
/**
* Get the textual contents of the node. If the node
* is an element, apply whitespace stripping rules,
* though I'm not sure if this is right (I'll fix
* or declare victory when I review the entire
* whitespace handling).
*/
DOMString
getNodeData(const DOM_Node& node);
/**
* An ugly little parser that evaluates attribute values for
* attribute templates (Stuff in curly {} braces that hold
* expressions). Speed is pretty darned important with this
* function.
* @param contextNode the current node in the source tree
* @param stylesheetTree used as factory object for creating
* the pattern-by-example structures when parsing expressions.
* @param attr used as a key for first attribute template
* parse structure cache.
* @param stringedValue the attribute value to be processed.
* @return Processed stringedValue with attribute templates
* resolved.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
DOMString
evaluateAttrVal(
const DOM_Node& contextNode,
const DOM_Element& namespaceContext,
const DOMString& stringedValue);
/**
* Copy an attribute to the created output element, executing
* attribute templates as need be, and processing the xsl:use
* attribute.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
copyAttributeToTarget(
const DOM_Attr& attr,
const DOM_Node& contextNode,
const Stylesheet* stylesheetTree,
AttributeListImpl& attrList,
const DOM_Element& namespaceContext);
protected:
/**
* Copy the attributes from the XSL element to the created
* output element, executing attribute templates and
* processing the xsl:use attribute as need be.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
void
copyAttributesToAttList(
const DOM_Node& contextNode,
const Stylesheet* stylesheetTree,
const DOM_Element& templateChild,
AttributeListImpl& attList);
/**
* Keyed on CSS2 property names, and holding dummy
* values for quickly looking up if a result tree element
* attribute is a CSS attribute or not.
* @deprecated
*/
typedef std::set<DOMString> TranslateCSSSetType;
TranslateCSSSetType m_cssKeys;
/*
* If this is true, translate CSS attributes on the output to a "style"
* attribute.
*/
bool m_translateCSS;
public:
/**
* Translate CSS attributes on the output to a "style" attribute, for
* old submission support. You probably shouldn't rely on this, though
* I personally like it a lot.
* @param b If true, translate CSS attributes on the output to a
* "style" attribute.
* @deprecated
*/
bool
getTranslateCSS()
{
return m_translateCSS;
}
void
setTranslateCSS(bool b)
{
m_translateCSS = b;
}
private:
/**
* Translate CSS attributes and put them in a style tag.
* @deprecated
*/
void
translateCSSAttrsToStyleAttr(
AttributeListImpl& attList);
protected:
/**
* Returns whether or not an attribute key
* is a CSS2 attribute.
* @deprecated
*/
bool
isCSSAttribute(
const DOMString& name) const;
/**
* Stuff a hash table with CSS2 keys & dummy values
* in order to quickly look up if a template child
* attribute is a CSS attribute or not.
* Note: This has something in it to screw up the
* Dev Studio code format command, so that the
* last curly bracket goes all the way to the
* left.
* @deprecated
*/
void
initCSS2Table();
//==========================================================
// SECTION: Functions for finding elements by Key and ID
//==========================================================
public:
/**
* Given a valid element key, return the corresponding node list.
*/
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const;
/**
* Evaluate an xpath string and return the result.
*/
virtual XPath*
createXPath(
const DOMString& str,
const PrefixResolver& resolver);
/**
* Given a valid element id, return the corresponding element.
*/
DOM_Element
getElementByID(
const DOMString& id,
const DOM_Document& doc) const;
/**
* Given a name, locate a variable in the current context, and return
* the Object.
*/
virtual XObject* getVariable(const QName& qname) const;
private:
/**
* Given a name, locate a variable in the current context, and return
* the XObject.
* @exception XSLProcessorException thrown if the active
ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
XObject*
getXObjectVariable(const DOMString& name) const;
/**
* Get an XLocator provider keyed by node. This get's
* the association based on the root of the tree that the
* node is parented by.
*/
XLocator* getXLocatorFromNode(const DOM_Node& node)
{
return m_xpathEnvSupport.getXLocatorFromNode(node);
}
/**
* Associate an XLocator provider to a node. This makes
* the association based on the root of the tree that the
* node is parented by.
*/
void associateXLocatorToNode(const DOM_Node& node, XLocator* xlocator)
{
m_xpathEnvSupport.associateXLocatorToNode(node, xlocator);
}
private:
//==========================================================
// SECTION: Functions for controlling whitespace
//==========================================================
/**
* If this is true, the processor will do the best it can to strip
* unwanted white space. This is set in the stylesheet via the default-space
* attribute on xsl:stylesheet.
*/
bool m_stripWhiteSpace; // default default-space="preserve"
public:
/**
* This changes the default of the default-space attribute.
* @param b Sets the default of the default-space attribute
* to "strip" if true, or "preserve" if false.
*/
bool
getStripWhiteSpace() const
{
return m_stripWhiteSpace;
}
void
setStripWhiteSpace(bool fStrip)
{
m_stripWhiteSpace = fStrip;
}
private:
// typedef std::set<DOMString> WhitespaceLookupTableType;
/**
* A lookup table of all space preserving elements.
*/
// WhitespaceLookupTableType m_whitespacePreservingElements;
/**
* A lookup table of all space stripping elements.
*/
// WhitespaceLookupTableType m_whitespaceStrippingElements;
public:
/*
void
addWhitespacePreservingElement(const DOMString& theElement)
{
m_whitespacePreservingElements.insert(theElement);
}
void
addWhitespaceStrippingElement(const DOMString& theElement)
{
m_whitespaceStrippingElements.insert(theElement);
}
*/
/**
* indent-result is by default no, which means an XSL processor must not
* change the whitespace on output.
*/
//bool m_indentResult;
/**
* If true, output carriage returns.
*/
bool m_outputCarriageReturns;
/**
* If true, output linefeeds.
*/
bool m_outputLinefeeds;
/**
* Tells, through the combination of the default-space attribute
* on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the
* xml:space attribute, whether or not extra whitespace should be stripped
* from the node. Literal elements from template elements should
* <em>not</em> be tested with this function.
* @param textNode A text node from the source tree.
* @return true if the text node should be stripped of extra whitespace.
*/
virtual bool
shouldStripSourceNode(const DOM_Node& textNode) const;
/**
* (Code stolen and modified from XML4J)
* Conditionally trim all leading and trailing whitespace in the specified
String.
* All strings of white space are
* replaced by a single space character (#x20), except spaces after
punctuation which
* receive double spaces if doublePunctuationSpaces is true.
* This function may be useful to a formatter, but to get first class
* results, the formatter should probably do it's own white space handling
* based on the semantics of the formatting object.
* @param string String to be trimmed.
* @param trimHead Trim leading whitespace?
* @param trimTail Trim trailing whitespace?
* @param doublePunctuationSpaces Use double spaces for punctuation?
* @return The trimmed string.
*/
DOMString fixWhiteSpace(
const DOMString& string,
bool trimHead,
bool trimTail,
bool
doublePunctuationSpaces);
/**
* Control if carriage returns are put in the result tree.
* Default is to output carriage returns.
* @param b If true, output carriage returns.
*/
void setOutputCarriageReturns(bool b)
{
m_outputCarriageReturns = b;
}
/**
* Control if linefeeds are put in the result tree.
* Default is to output linefeeds.
* @param b If true, output linefeeds.
*/
void setOutputLinefeeds(bool b)
{
m_outputLinefeeds = b;
}
/**
* Normalize the linefeeds and/or carriage returns to
* be consistently 0x0D 0x0A. This should almost
* certainly be done somewhere else... like in the
* XML parser.
*/
DOMString getNormalizedText(const DOM_Text& tx) const;
/**
* Set the stylesheet root. If this is set, then the process calls that
* take only the input .xml will use this instead of looking for a
* stylesheet PI.
*/
void setStylesheet(StylesheetRoot *stylesheetRoot) { m_stylesheetRoot =
stylesheetRoot; }
/**
* Set the stylesheet root. If this is set, then the process calls that
* take only the input .xml will use this instead of looking for a
* stylesheet PI.
*/
StylesheetRoot *getStylesheet() { return m_stylesheetRoot; }
/**
* Get the filename of the output document, if it was set. This is for
use
* by multiple output documents, to determine the base directory for the
* output document. It needs to be set by the caller.
*/
DOMString &getOutputFileName() { return m_outputFileName; }
/**
* Set the filename of the output document. This is for use by multiple
* output documents, to determine the base directory for the output
* document. It needs to be set by the caller.
*/
void setOutputFileName(const DOMString& filename) { m_outputFileName =
filename; }
//==========================================================
// SECTION: Support functions in fairly random order
//==========================================================
private:
/**
* Control if the xsl:variable is resolved early or
* late. Resolving the xsl:variable
* early is a drag because it means that the fragment
* must be created into a DocumentFragment, and then
* cloned each time to the result tree. If we can resolve
* late, that means we can evaluate directly into the
* result tree. Right now this must be kept on 'early'
* because you would need to set the call stack back to
* the point of xsl:invoke... which I can't quite work out
* at the moment. I don't think this is worth fixing
* until NodeList variables are implemented.
*/
static const bool m_resolveContentsEarly;
public:
/**
* Get the XML Parser Liaison that this processor uses.
*/
virtual XMLParserLiaison& getXMLProcessorLiaison()
{ return m_parserLiaison; }
// @@ JMD: was: private: but public in base virtual class ?? So I made them
// all public; these should probably all take const arguments in the fullness
// of time
/**
* Convenience function to create an XString.
* @param s A valid string.
* @return An XString object.
*/
virtual XObject* createXString(const DOMString& s);
/**
* Convenience function to create an XObject.
* @param o Any java object.
* @return An XObject object.
*/
// @@ JMD: how do we do this ?
virtual XObject* createXObject(void* o);
/**
* Convenience function to create an XNumber.
* @param d Any double number.
* @return An XNumber object.
*/
virtual XObject* createXNumber(double d);
/**
* Convenience function to create an XBoolean.
* @param b bool value.
* @return An XBoolean object.
*/
virtual XObject* createXBoolean(bool b);
/**
* Convenience function to create an XNodeSet.
* @param nl A NodeList object.
* @return An XNodeSet object.
*/
virtual XObject* createXNodeSet(const NodeRefListBase& nl);
/**
* Convenience function to create an XNodeSet from a node.
* @param n A DOM node.
* @return An XNodeSet object.
*/
virtual XObject* createXNodeSet(const DOM_Node& n);
/**
* Convenience function to create an XRTreeFrag.
* @return An XRTreeFrag object.
*/
virtual XObject* createXResultTreeFrag(const ResultTreeFragBase& r);
/**
* Convenience function to create an XNull.
* @return An XNull object.
*/
virtual XObject* createXNull();
private:
/**
* Set the factory for making XPaths.
*/
void setXPathFactory(XPathFactory* factory) { m_xpathFactory = factory;
}
/**
* Get a DOM document, primarily for creating result
* tree fragments.
*/
DOM_Document getDOMFactory()
{
if(m_resultTreeFactory.isNull())
{
m_resultTreeFactory = m_parserLiaison.createDocument();
}
return m_resultTreeFactory;
}
/**
* Set the XPath processor object.
* @param processor A XPathProcessor interface.
*/
void setXPathProcessor(XPathProcessor* processor) { m_xpathProcessor =
processor; }
bool
getResolveContentsEarly() const
{
return m_resolveContentsEarly;
}
public:
/**
* Get the factory for making xpaths.
*/
XPathFactory* getXPathFactory() { return m_xpathFactory; }
/**
* Get the XPath processor object.
* @return The XPathProcessor interface being used.
*/
XPathProcessor* getXPathProcessor() { return m_xpathProcessor; }
/**
* Given a document, get the default stylesheet URI from the
* xsl:stylesheet PI. However, this will only get you the
* first URL, and there may be many.
* @deprecated
*/
DOMString getStyleSheetURIfromDoc(const DOM_Node& sourceTree);
private:
typedef std::vector<Arg> ParamVectorType;
ParamVectorType m_topLevelParams;
public:
/**
* Push a top-level stylesheet parameter. This value can
* be evaluated via xsl:param-variable.
* @param key The name of the param.
* @param expression An expression that will be evaluated.
*/
virtual void setStylesheetParam(
const DOMString& key,
const DOMString& expression);
/**
* Push a top-level stylesheet parameter. This value can
* be evaluated via xsl:param-variable.
* @param key The name of the param.
* @param value An XObject that will be used.
*/
virtual void setStylesheetParam(const DOMString& key, const XObject*
value);
/**
* Resolve the params that were pushed by the caller.
*/
void
resolveTopLevelParams();
/**
* Reset the vector or top level parameters
*/
void
clearTopLevelParams()
{
m_topLevelParams.clear();
}
private:
/**
* Returns the current input node that is being
* processed.
*/
DOM_Node
getSourceNode() const
{
return m_currentNode;
}
public:
/**
* Reset the current element state
*/
void
resetCurrentState(
const DOM_Node& sourceTree,
const DOM_Node& xmlNode);
public:
/**
* Given a classID and codetype, tr to register a code dispatcher.
*/
void
registerExtensionHandlerByName(
const DOMString& classid,
const DOMString& codetype);
/**
* Register the given DispatcherFactor for a given mime type.
*/
void
registerExtensionHandler(
const DOMString& mimeType,
DispatcherFactory* factory);
protected:
/**
* Given a tag name, an attribute name, and
* an attribute value, do a very crude recursive
* search and locate the first match.
*/
static DOM_Element
findElementByAttribute(
const DOM_Element& elem,
const DOMString& targetElementName,
const DOMString& targetAttributeName,
const DOMString& targetAttributeValue);
public:
/**
* Do everything possible to get a good URL from a string.
*/
/**
* Take a user string and try to parse XML, and also return
* the url.
*/
URL*
getURLFromString(const DOMString& urlString);
URL*
getURLFromString(const DOMString& urlString, const DOMString&
base);
private :
/**
* The liason to the XML parser, so the XSL processor
* can handle included files, and the like, and do the
* initial parse of the XSL document.
*/
XMLParserLiaison& m_parserLiaison;
XPathSupport& m_xpathSupport;
XPathEnvSupport& m_xpathEnvSupport;
public:
/**
* The formatter interface, which has the toMarkup
* method, and which will eventually hold other non-event
* methods. Not to be confused with the DocumentHandler
* interface.
*/
// @@ JMD: Temporarily public
Formatter* m_formatter;
XPathSupport& getXPathSupport()
{
return m_xpathSupport;
}
XPathEnvSupport& getXPathEnvSupport()
{
return m_xpathEnvSupport;
}
/**
* Set the formatter interface, which has the toMarkup
* method, and which will eventually hold other non-event
* methods. Not to be confused with the DocumentHandler
* interface.
*/
void
setFormatter(Formatter* formatter);
/**
* Get the current formatter listener.
*/
virtual FormatterListener* getFormatterListener()
{
return dynamic_cast<FormatterListener*>(m_flistener);
}
/**
* Set the current formatter listener.
*/
virtual void setFormatterListener(FormatterListener* flistener)
{
m_flistener = flistener;
}
private:
/**
* The listener for formatting events. This should be
* supplied by the Formatter object.
*/
// For now, we have to use the FormatterListener class,
// since we can't use RTTI to determine what we have.
#if 1
DocumentHandler* m_flistener;
#else
FormatterListener* m_flistener;
#endif
public:
/**
* The factory that will be used to create result tree fragments.
*/
mutable DOM_Document m_resultTreeFactory;
public:
/**
* The namespace that the result tree conforms to. A null value
* indicates that result-ns is not used and there is no checking.
* A empty string indicates that the result tree conforms to the
* default namespace.
*/
DOMString m_resultNameSpacePrefix;
/**
* The URL that belongs to the result namespace.
*/
DOMString m_resultNameSpaceURL;
private:
/**
* This holds the current context node list. This should arguably be
* passed by parameter.
*/
MutableNodeRefList m_contextNodeList;
public:
MutableNodeRefList getContextNodeList() { return m_contextNodeList; }
void setContextNodeList(const MutableNodeRefList& ref)
{
m_contextNodeList = ref;
}
DOM_Document& getRootDoc() { return m_rootDoc; }
void setRootDoc(const DOM_Document& doc) { m_rootDoc = doc; }
private:
/**
* Table of KeyDeclaration objects, which are set by the
* xsl:key element.
*/
typedef std::vector<KeyDeclaration>
KeyDeclarationVectorType;
KeyDeclarationVectorType m_keyDeclarations;
public:
void
addKeyDeclaration(const KeyDeclaration& theDeclaration)
{
m_keyDeclarations.push_back(theDeclaration);
setNeedToBuildKeysTable(true);
}
// $$$ ToDO: Are these next two really needed?
/**
* Set the table of KeyDeclaration objects, which are set by the
* xsl:key element.
* @param table Table of IDAttributeHolder objects.
*/
void
setKeyDeclarationsTable(const KeyDeclarationVectorType& table)
{
m_keyDeclarations = table;
}
/**
* Get the table of KeyDeclaration objects.
* @return Table of KeyDeclaration objects.
*/
const KeyDeclarationVectorType&
getKeyDeclarations() const
{
return m_keyDeclarations;
}
private:
/**
* Table of element keys. The table will be built on demand,
* when a key is requested, or set by the XMLParserLiaison or
* the caller. The table is:
* a) keyed by name,
* b) each with a value of a hashtable, keyed by the value returned by
* the use attribute,
* c) each with a value that is a nodelist.
* Thus, for a given key or keyref, look up hashtable by name,
* look up the nodelist by the given reference.
*/
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef hash_map<DOMString,
MutableNodeRefList,
DOMStringHashFunction,
DOMStringEqualsFunction>
NodeListMapType;
typedef hash_map<DOMString,
NodeListMapType,
DOMStringHashFunction,
DOMStringEqualsFunction>
KeysMapType;
#else
typedef std::map<DOMString,
MutableNodeRefList> NodeListMapType;
typedef std::map<DOMString,
NodeListMapType>
KeysMapType;
#endif
KeysMapType m_keys;
public:
/**
* Set the table of keys. This will be used by the
* key() and keyref() functions for lookup of a nodelist.
*/
void
setKeyTable(const KeysMapType& table)
{
m_keys = table;
}
/**
* Get the table of element IDs. This table is used by the
* id() functions for lookup of an element ID.
* @return Table of element IDs, keyed by ID string, with
* values that are Element nodes.
*/
const KeysMapType&
getKeysTable()
{
return m_keys;
}
private:
/**
* This is set to true if an xsl:id directive is found.
* Mainly for use by the XMLParserLiaison classes for
* optimized processing of ids.
*/
bool m_needToBuildKeysTable;
public:
/**
* Set needToBuildKeysTable to true if an xsl:key directive is found.
* Mainly for use by the XMLParserLiaison classes for
* optimized processing of keys.
*/
void
setNeedToBuildKeysTable(bool b)
{
m_needToBuildKeysTable = b;
}
/**
* Set the needToBuildKeysTable property, which, if true,
* will trigger the building of the keys table.
* Mainly for use by the XMLParserLiaison classes for
* optimized processing of keys.
*/
bool
getNeedToBuildKeysTable() const
{
return m_needToBuildKeysTable;
}
protected:
/*
* The current input element that is being processed.
*/
DOM_Node m_currentNode;
private:
/**
* Keyed on string macro names, and holding values
* that are macro elements in the XSL DOM tree.
* Initialized in initMacroLookupTable, and used in
* findNamedTemplate.
*/
#if defined(XALAN_HASH_CONTAINERS_AVAILABLE)
typedef hash_map<DOMString,
DOM_Node,
DOMStringHashFunction,
DOMStringEqualsFunction>
NamedTemplatesMapType;
#else
typedef std::map<DOMString,
DOM_Node> NamedTemplatesMapType;
#endif
NamedTemplatesMapType m_namedTemplates;
public:
void
addNamedTemplate(const DOMString& theName,
const DOM_Node& theNode)
{
m_namedTemplates[theName] = theNode;
}
DOM_Node
getNamedTemplate(const DOMString& theName) const
{
const NamedTemplatesMapType::const_iterator i =
m_namedTemplates.find(theName);
if(i != m_namedTemplates.end())
{
return (*i).second;
}
else
{
return DOM_Node();
}
}
private:
/**
* Table for defined constants, keyed on the names.
*/
typedef std::map<DOMString, XString*> TopLevelVariablesMapType;
TopLevelVariablesMapType m_topLevelVariables;
public:
XString*
getTopLevelVariable(const DOMString& theName) const;
private:
/**
* The XSL class can have a single listener that can be informed
* of errors and warnings, and can normally control if an exception
* is thrown or not (or the problem listeners can throw their
* own RuntimeExceptions).
*/
ProblemListener* m_problemListener;
public:
/**
* Set the problem listener property.
* The XSL class can have a single listener that can be informed
* of errors and warnings, and can normally control if an exception
* is thrown or not (or the problem listeners can throw their
* own RuntimeExceptions).
* @param l A ProblemListener interface.
*/
void setProblemListener(ProblemListener* l)
{
m_problemListener = l;
}
/**
* Get the problem listener property.
* The XSL class can have a single listener that can be informed
* of errors and warnings, and can normally control if an exception
* is thrown or not (or the problem listeners can throw their
* own RuntimeExceptions).
* @return A ProblemListener interface.
*/
ProblemListener* getProblemListener() const
{
return m_problemListener;
}
public:
/**
* An exception for that occurs when a given stylesheet
* goes into an infinite loop.
*/
class XSLInfiniteLoopException : public std::runtime_error
{
public:
XSLInfiniteLoopException() : std::runtime_error("XSL infinite
loop occurred!")
{ }
};
private:
/**
* The StackGuard class guard against infinite loops.
*/
class StackGuard
{
public:
StackGuard(
XSLTEngineImpl& processor,
const DOM_Element& xslTemplate =
DOM_Element(),
const DOM_Node& sourceXML = DOM_Node());
~StackGuard();
bool operator==(const StackGuard& theRHS) const
{
return m_xslRule == theRHS.m_xslRule &&
m_sourceXML == theRHS.m_sourceXML;
}
void print(PrintWriter& pw) const;
void push(
const DOM_Element& xslTemplate,
const DOM_Node& sourceXML);
void pop();
void clear() { m_stack.clear(); }
void checkForInfiniteLoop(const StackGuard& guard) const;
private:
XSLTEngineImpl* m_processor;
DOM_Element m_xslRule;
DOM_Node m_sourceXML;
typedef std::vector<StackGuard> StackGuardStackType;
StackGuardStackType m_stack;
};
// This is set to true when the "ancestor" attribute of
// the select element is encountered.
bool m_needToCheckForInfiniteLoops;
/**
* Object to guard agains infinite recursion when
* doing queries.
*/
StackGuard m_stackGuard;
public:
/**
* Defines a class to keep track of a stack for macro arguments.
*/
class VariableStack
{
public:
/**
* Constructor for a variable stack.
*/
VariableStack(XSLTEngineImpl& theProcessor);
~VariableStack();
virtual void
reset();
/**
* Push a context marker onto the stack to let us know when
* to stop searching for a var.
*/
void
pushElementMarker(const DOM_Node& elem);
/**
* Pop the current context from the current context stack.
*/
void
popElementMarker(const DOM_Node& elem);
/**
* Check to see if an element marker for the particular
* node has already been pushed.
*/
bool
elementMarkerAlreadyPushed(const DOM_Node& elem) const;
/**
* Push a context marker onto the stack to let us know when
* to stop searching for a var.
*/
void
pushContextMarker(
// was: const ElemTemplateElement& caller,
const DOM_Node& caller,
const DOM_Node& sourceNode);
/**
* Pop the current context from the current context stack.
*/
void
popCurrentContext();
/**
* Given a template, search for
* the arguments and push them on the stack. Also,
* push default arguments on the stack.
* You <em>must</em> call popContext() when you are
* done with the arguments.
*/
void
pushParams(
const Stylesheet*
stylesheetTree,
const ElemTemplateElement&
xslCallTemplateElement,
const DOM_Node&
sourceTree,
const DOM_Node&
sourceNode,
const QName& mode,
const DOM_Node& targetTemplate);
/**
* Same as getXObjectVariable, except don't look in the global
space.
*/
XObject* getXObjectParamVariable(const QName& qname) const
// java: getParamVariable(QName qname)
{
return findXObject(qname, false);
}
/**
* Tell if there is a param variable on the stack.
*/
bool hasParamVariable(QName& qname);
/**
* Same as getResultTreeFragVariable, except don't look
* in the global space.
*/
/*
@@ JMD: Obsolete??
ResultTreeFrag*
getResultTreeFragParamVariable(const QName& name) const
{
return findResultTreeFrag(name, false);
}
*/
/**
* Given a name, return a pointer to the corresponding
* XObject.
*/
XObject*
getXObjectVariable(const QName& name) const
// java: Object getVariable(QName name)
{
return findXObject(name, true);
}
/**
* Push an argument onto the stack. Don't forget
* to call startContext before pushing a series of
* arguments for a given macro call.
*/
void
pushVariable(
// was: const DOMString&
name,
const QName& name,
XObject*
val,
const DOM_Node& e);
/**
* Push an argument onto the stack. Don't forget
* to call startContext before pushing a series of
* arguments for a given macro call.
*/
/*
@@ JMD: assume we don't need this, see what happens
void
pushVariable(
const QName& name,
ResultTreeFrag* val,
const ElemTemplateElement& e);
*/
private:
XObject*
findXObject(
const QName& name,
bool
fSearchGlobalSpace) const;
const Arg*
findArg(
const QName& name,
bool
fSearchGlobalSpace) const;
// $$$ ToDo: Is this really used?
/**
* Holds caller, so that it may be searched for
* xsl:params, in order to resolve xsl:param-arg.
*/
DOM_Element
m_caller;
typedef std::vector<StackEntry*> VariableStackStackType;
VariableStackStackType m_stack;
XSLTEngineImpl& m_processor;
}; // end VariableStack
// Give VariableStack access to stuff.
friend class VariableStack;
private:
/**
* The stack of Variable stacks. A VariableStack will be
* pushed onto this stack for each template invocation.
*/
VariableStack m_variableStacks;
public:
VariableStack&
getVariableStacks()
{
return m_variableStacks;
}
/**
* Create a document fragment. This function may return null.
*/
ResultTreeFragBase*
createDocFrag() const;
public:
/**
* Given a stylesheet element, create a result tree fragment from its
* contents.
* @exception XSLProcessorException thrown if the active ProblemListener
and
* XMLParserLiaison decide the error condition is severe enough to halt
* processing.
* @param stylesheetTree The stylesheet object that holds the fragment.
* @param templateChild The template element that holds the fragment.
* @param sourceTree The source tree document context.
* @param sourceNode The current source context node.
* @param mode The mode under which the template is operating.
* @return An object that represents the result tree fragment.
*/
ResultTreeFragBase*
createResultTreeFrag(
const Stylesheet* stylesheetTree,
ElemTemplateElement& templateChild,
const DOM_Node& sourceTree,
const DOM_Node& sourceNode,
const QName& mode);
/**
* Create an empty result tree fragment. Caller owns the memory.
*/
ResultTreeFragBase* createResultTreeFrag() const;
/*
JMD:
These were inner classes in java:
class ContextState;
class ContextMarker extends ContextState;
class ElementMarker;
*/
public:
XMLParserLiaison& getParserLiaison() const;
AttributeListImpl& getPendingAttributes();
DOMString getPendingElementName() const;
void setPendingAttributes(const AttributeList& pendingAttributes) ;
void setPendingElementName(const DOMString& elementName) ;
private:
static void
InstallFunctions();
static AttributeKeysMapType
InitializeAttributeKeysTable();
static AttributeKeysMapType
InitializeElementKeysTable();
static ElementKeysMapType
InitializeXSLT4JElementKeys();
// Class to provide static initialization for XSLTEngineImpl...
class StaticInitializer
{
public:
StaticInitializer();
~StaticInitializer();
};
friend class StaticInitializer;
static const StaticInitializer s_staticInitializer;
}; // end XSLTEngineImpl class
#ifdef _MSC_VER
#pragma warning(default:4100)
#endif
#endif // XALAN_XSLTENGINEIMPL_HEADER_GUARD
// $ Log: $
1.1 xml-xalan/c/src/XSLT/XSLTInputSource.cpp
Index: XSLTInputSource.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
// Class header file.
#include "XSLTInputSource.hpp"
// @@ JMD: temporary
#include <cassert>
XSLTInputSource::XSLTInputSource(const XMLCh* const systemId) :
InputSource(systemId) { }
XSLTInputSource::XSLTInputSource(const XMLCh* const systemId, const XMLCh*
const publicId) :
InputSource(systemId, publicId) { }
XSLTInputSource::XSLTInputSource(const char* const systemId) :
InputSource(systemId) { }
XSLTInputSource::XSLTInputSource(const char* const systemId, const char*
const publicId) :
InputSource(systemId, publicId) { }
/**
* Create a new input source with a byte stream.
*
* <p>Application writers may use setSystemId to provide a base
* for resolving relative URIs, setPublicId to include a
* public identifier, and/or setEncoding to specify the object's
* character encoding.</p>
*
* @param byteStream The raw byte stream containing the document.
*/
XSLTInputSource::XSLTInputSource (InputStream* byteStream) : InputSource("")
{
// @@ JMD: These are not in the C++ InputSource class
assert(0); // @@ ??
// java: setByteStream(byteStream);
}
/**
* Create a new input source with a character stream.
*
* <p>Application writers may use setSystemId() to provide a base
* for resolving relative URIs, and setPublicId to include a
* public identifier.</p>
*/
XSLTInputSource::XSLTInputSource (Reader* characterStream) : InputSource("")
{
// @@ JMD: These are not in the C++ InputSource class
assert(0); // @@ ??
// java: setCharacterStream(characterStream);
}
/**
* Create a new input source with a DOM node.
*
* <p>Application writers may use setSystemId() to provide a base
* for resolving relative URIs, and setPublicId to include a
* public identifier.</p>
*
* <p>The character stream shall not include a byte order mark.</p>
*/
XSLTInputSource::XSLTInputSource (const DOM_Node& node) : InputSource("")
{
setNode(node);
}
/**
* Makes the byte stream for this input source.
*
* <p>The SAX parser will ignore this if there is also a character
* stream specified, but it will use a byte stream in preference
* to opening a URI connection itself.</p>
*
* @see #getByteStream
* @see InputStream
*/
BinInputStream*
XSLTInputSource::makeStream() const
{
URLInputSource inputSource(getSystemId());
return inputSource.makeStream();
}
/**
* Set the character stream for this input source.
*
* <p>If there is a character stream specified, the SAX parser
* will ignore any byte stream and will not attempt to open
* a URI connection to the system identifier.</p>
*
* @param characterStream The character stream containing the
* XML document or other entity.
* @see #getCharacterStream
* @see java.io.Reader
*/
void
XSLTInputSource::setNode (const DOM_Node& node)
{
m_node = node;
}
/**
* Get the character stream for this input source.
*
* @return The character stream, or null if none was supplied.
* @see #setCharacterStream
*/
const DOM_Node&
XSLTInputSource::getNode()
{
return m_node;
}
1.1 xml-xalan/c/src/XSLT/XSLTInputSource.hpp
Index: XSLTInputSource.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_XSLTINPUTSOURCE_HEADER_GUARD)
#define XALAN_XSLTINPUTSOURCE_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <internal/URLInputSource.hpp>
#include <dom/DOM_Node.hpp>
#include <sax/InputSource.hpp>
class BinInputStream;
class InputStream;
class Reader;
class XALAN_XSLT_EXPORT XSLTInputSource : public InputSource
{
/**
* Zero-argument default constructor.
*
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setCharacterStream
* @see #setEncoding
*/
public:
/**
* Zero-argument default constructor.
*
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setCharacterStream
* @see #setEncoding
*/
XSLTInputSource() : InputSource("") { } // @@ ??
/**
* Create a new input source with a system identifier.
*
* <p>Applications may use setPublicId to include a
* public identifier as well, or setEncoding to specify
* the character encoding, if known.</p>
*
* <p>If the system identifier is a URL, it must be full resolved.</p>
*
* @param systemId The system identifier (URI).
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setEncoding
* @see #setCharacterStream
*/
XSLTInputSource(const XMLCh* const systemId);
XSLTInputSource(const XMLCh* const systemId, const XMLCh* const
publicId);
/**
* Create a new input source with a system identifier.
*
* <p>Applications may use setPublicId to include a
* public identifier as well</p>
*
* <p>If the system identifier is a URL, it must be full resolved.</p>
*
* @param systemId The system identifier (URI).
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setCharacterStream
*/
XSLTInputSource(const char* const systemId);
/**
* Create a new input source with a system identifier and a public
identifier.
*
* <p>If the system identifier is a URL, it must be full resolved.</p>
*
* @param systemId The system identifier (URI).
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setCharacterStream
*/
XSLTInputSource(const char* const systemId, const char* const publicId);
/**
* Create a new input source with a byte stream.
*
* <p>Application writers may use setSystemId to provide a base
* for resolving relative URIs, setPublicId to include a
* public identifier, and/or setEncoding to specify the object's
* character encoding.</p>
*
* @param byteStream The raw byte stream containing the document.
*/
XSLTInputSource (InputStream* byteStream);
/**
* Create a new input source with a character stream.
*
* <p>Application writers may use setSystemId() to provide a base
* for resolving relative URIs, and setPublicId to include a
* public identifier.</p>
*/
XSLTInputSource (Reader* characterStream);
/**
* Create a new input source with a DOM node.
*
* <p>Application writers may use setSystemId() to provide a base
* for resolving relative URIs, and setPublicId to include a
* public identifier.</p>
*
* <p>The character stream shall not include a byte order mark.</p>
*/
XSLTInputSource (const DOM_Node& node);
/**
* Makes the byte stream for this input source.
*
* <p>The SAX parser will ignore this if there is also a character
* stream specified, but it will use a byte stream in preference
* to opening a URI connection itself.</p>
*
* @see #getByteStream
* @see InputStream
*/
virtual BinInputStream* makeStream() const;
/**
* Set the character stream for this input source.
*
* <p>If there is a character stream specified, the SAX parser
* will ignore any byte stream and will not attempt to open
* a URI connection to the system identifier.</p>
*
* @param characterStream The character stream containing the
* XML document or other entity.
* @see #getCharacterStream
* @see java.io.Reader
*/
void setNode (const DOM_Node& node);
/**
* Get the character stream for this input source.
*
* @return The character stream, or null if none was supplied.
* @see #setCharacterStream
*/
const DOM_Node& getNode ();
private:
DOM_Node m_node;
};
#endif // XALAN_XSLTINPUTSOURCE_HEADER_GUARD
// $ Log: $
1.1 xml-xalan/c/src/XSLT/XSLTProcessor.cpp
Index: XSLTProcessor.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XSLTProcessor.hpp"
XSLTProcessor::XSLTProcessor()
{
}
XSLTProcessor::~XSLTProcessor()
{
}
1.1 xml-xalan/c/src/XSLT/XSLTProcessor.hpp
Index: XSLTProcessor.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_XSLTPROCESSOR_HEADER_GUARD)
#define XALAN_XSLTPROCESSOR_HEADER_GUARD
// @@ JMD: Set values as pointers for now, until classes are defined, etc may
// want to revisit this
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
/*
#include "XSLTInputSource.hpp"
#include "XSLTResultTarget.hpp"
*/
class XSLTInputSource;
class XSLTResultTarget;
class PrintWriter;
class XNumber;
class XBoolean;
class XNodeSet;
class XNull;
class TraceListener;
class StylesheetRoot;
class XMLParserLiaison;
class XString;
class XObject;
class XNumber;
class XBoolean;
class XNodeSet;
class XNull;
class FormatterListener;
class TraceListener;
class NodeRefListBase;
//@@ JMD: This makes it all work, I don't know why?? Need to fix this
// These were all declared in the original class XSLProcessor.hpp, but
// shouldn't be needed for an abstract class I would think
class Arg;
class DispatcherFactory;
class DOM_Element;
class DOM_Node;
class Formatter;
class FormatterListener;
class InputSource;
class Locator;
class PrefixResolver;
class PrintWriter;
class ProblemListener;
class QName;
class ResultTreeFrag;
class StackEntry;
class Stylesheet;
class StylesheetRoot;
class XMLParserLiaison;
class XObject;
class XPathSupport;
class XString;
class ElemTemplateElement;
class ElemVariable;
class XPathFactory;
class XPathProcessor;
#include <dom/DOM_Node.hpp>
#include <dom/DOMString.hpp>
/**
* This is an interface for an XSLT Processor engine. It's the responsibility
* of the implementation of the XSLTProcessor interface, collaborating with a
* XMLParserLiaison, the DOM, and the XPath engine, to transform a source tree
* of nodes into a result tree according to instructions and templates
* specified by a stylesheet tree. The methods process(...) are
* the primary public entry points.
*
* Look at the Process class
* for an advanced example of usage by the main() function.
*
* If you reuse the processor instance, you should call reset() between calls.
*/
class XALAN_XSLT_EXPORT XSLTProcessor
{
public:
XSLTProcessor();
virtual ~XSLTProcessor();
/**
* Transform the source tree to the output in the given
* result tree target.
* @param inputSource The input source.
* @param stylesheetSource The stylesheet source. May be null if source
has a xml-stylesheet PI.
* @param outputTarget The output source tree.
* @exception XSLProcessorException thrown if the active ProblemListener
and
* XMLParserLiaison decide the error condition is severe enough to halt
* processing.
*/
virtual void process( XSLTInputSource* inputSource,
XSLTInputSource* stylesheetSource,
XSLTResultTarget* outputTarget) = 0;
// throws XSLProcessorException
/**
* Given a URI to an XSL stylesheet,
* Compile the stylesheet into an internal representation.
* This calls reset() before processing if the stylesheet root has been set
* to non-null.
* @param xmldocURLString The URL to the input XML document.
* @return The compiled stylesheet object.
* @exception XSLProcessorException thrown if the active ProblemListener
and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
virtual StylesheetRoot* processStylesheet(XSLTInputSource*
stylesheetSource) = 0;
// throws XSLProcessorException
/**
* Given a URI to an XSL stylesheet,
* Compile the stylesheet into an internal representation.
* This calls reset() before processing if the stylesheet root has been set
* to non-null.
* @param xmldocURLString The URL to the input XML document.
* @return The compiled stylesheet object.
* @exception XSLProcessorException thrown if the active ProblemListener
and
* XMLParserLiaison decide the error condition is severe enough to halt
* processing.
*/
virtual StylesheetRoot* processStylesheet(const DOMString& xsldocURLString)
= 0;
// throws XSLProcessorException
/**
* Reset the state. This needs to be called after a process() call
* is invoked, if the processor is to be used again.
*/
virtual void reset() = 0;
/**
* Given an input source, get the source tree.
*/
virtual const DOM_Node getSourceTreeFromInput(XSLTInputSource*
inputSource) = 0;
/**
* Get the XML Parser Liaison that this processor uses.
*/
virtual XMLParserLiaison& getXMLProcessorLiaison() = 0;
/**
* Convenience function to create an XString.
* @param s A valid string.
* @return An XString object.
*/
virtual XObject* createXString(const DOMString& s) = 0;
/**
* Convenience function to create an XObject.
* @param o Any java object.
* @return An XObject object.
*/
virtual XObject* createXObject(void* o) = 0;
/**
* Convenience function to create an XNumber.
* @param d Any double number.
* @return An XNumber object.
*/
virtual XObject* createXNumber(double d) = 0;
/**
* Convenience function to create an XBoolean.
* @param b bool value.
* @return An XBoolean object.
*/
virtual XObject* createXBoolean(bool b) = 0;
/**
* Convenience function to create an XNodeSet.
* @param nl A NodeList object.
* @return An XNodeSet object.
*/
virtual XObject* createXNodeSet(const NodeRefListBase& nl) = 0;
/**
* Convenience function to create an XNodeSet from a node.
* @param n A DOM node.
* @return An XNodeSet object.
*/
virtual XObject* createXNodeSet(const DOM_Node& n) = 0;
/**
* Convenience function to create an XNull.
* @return An XNull object.
*/
virtual XObject* createXNull() = 0;
/**
* Given a name, locate a variable in the current context, and return
* the object.
* @return An XObject if the variable was found, 0 if it was not.
*/
virtual XObject* getVariable(const QName& qname) const = 0;
/**
* Push a top-level stylesheet parameter. This value can
* be evaluated via xsl:param-variable.
* @param key The name of the param.
* @param value An XObject that will be used.
*/
virtual void setStylesheetParam(const DOMString& key, const XObject*
value) = 0;
/**
* Push a top-level stylesheet parameter. This value can
* be evaluated via xsl:param-variable.
* @param key The name of the param.
* @param expression An expression that will be evaluated.
*/
virtual void setStylesheetParam(const DOMString& key, const DOMString&
expression) = 0;
/**
* Given a valid element key, return the corresponding node list.
*/
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const
= 0;
/**
* Tells, through the combination of the default-space attribute
* on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the
* xml:space attribute, whether or not extra whitespace should be
stripped
* from the node. Literal elements from template elements should
* <em>not</em> be tested with this function.
* @param textNode A text node from the source tree.
* @return true if the text node should be stripped of extra whitespace.
*/
virtual bool
shouldStripSourceNode(const DOM_Node& textNode) const = 0;
/**
* Get the current formatter listener.
*/
virtual FormatterListener* getFormatterListener() = 0;
/**
* Set the current formatter listener.
*/
virtual void setFormatterListener(FormatterListener* flistener) = 0;
/**
* Add a trace listener for the purposes of debugging and diagnosis.
* @param tl Trace listener to be added.
*/
virtual void addTraceListener(TraceListener* tl) = 0;
// throws TooManyListenersException
/**
* If this is set to true, simple traces of
* template calls are made.
*/
virtual void setTraceTemplates(bool b) = 0;
/**
* If this is set to true, simple traces of
* template calls are made.
*/
virtual void setTraceSelect(bool b) = 0;
/**
* If this is set to true, debug diagnostics about
* template children as they are being constructed
* will be written to the m_diagnosticsPrintWriter
* stream. diagnoseTemplateChildren is false by
* default.
*/
virtual void setTraceTemplateChildren(bool b) = 0;
/**
* If the quietConflictWarnings property is set to
* true, warnings about pattern conflicts won't be
* printed to the diagnostics stream.
* True by default.
* @param b true if conflict warnings should be suppressed.
*/
virtual void setQuietConflictWarnings(bool b) = 0;
/**
* Remove a trace listener.
* @param tl Trace listener to be removed.
*/
virtual void removeTraceListener(TraceListener* tl) = 0;
// @@TODO: what to do about output stream ??
/**
* If this is set, diagnostics will be
* written to the m_diagnosticsPrintWriter stream. If
* the value is null, then diagnostics will be turned
* off.
*/
// virtual void setDiagnosticsOutput(java.io.OutputStream out) = 0;
/**
* If this is set, diagnostics will be
* written to the m_diagnosticsPrintWriter stream. If
* the value is null, then diagnostics will be turned
* off.
*/
virtual void setDiagnosticsOutput(PrintWriter* pw) = 0;
};
#endif // XALAN_XSLTPROCESSOR_HEADER_GUARD
/*
* $ Log: $
*/
1.1 xml-xalan/c/src/XSLT/XSLTProcessorEnvSupportDefault.cpp
Index: XSLTProcessorEnvSupportDefault.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XSLTProcessorEnvSupportDefault.hpp"
// $$$ ToDo: Xerces-specific code!
#include <util/StdOut.hpp>
#include "StylesheetRoot.hpp"
#include "XSLTProcessor.hpp"
XSLTProcessorEnvSupportDefault::XSLTProcessorEnvSupportDefault(XSLTProcessor*
theProcessor) :
XPathEnvSupportDefault(),
m_processor(theProcessor)
{
}
XSLTProcessorEnvSupportDefault::~XSLTProcessorEnvSupportDefault()
{
m_processor = 0;
}
const NodeRefListBase*
XSLTProcessorEnvSupportDefault::getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const
{
if (m_processor == 0)
{
return XPathEnvSupportDefault::getNodeSetByKey(doc,
name,
ref,
resolver);
}
else
{
return m_processor->getNodeSetByKey(doc,
name,
ref,
resolver);
}
}
XObject*
XSLTProcessorEnvSupportDefault::getVariable(
XPathExecutionContext& executionContext,
const QName& name) const
{
if (m_processor == 0)
{
return XPathEnvSupportDefault::getVariable(executionContext,
name);
}
else
{
return m_processor->getVariable(name);
}
}
bool
XSLTProcessorEnvSupportDefault::shouldStripSourceNode(const DOM_Node& node)
const
{
if (m_processor == 0)
{
return XPathEnvSupportDefault::shouldStripSourceNode(node);
}
else
{
return m_processor->shouldStripSourceNode(node);
}
}
bool
XSLTProcessorEnvSupportDefault::problem(
eSource /* where */,
eClassification classification,
const DOM_Node& /* styleNode */,
const DOM_Node& /* sourceNode */,
const DOMString& msg,
int lineNo,
int charOffset)
const
{
// $$$ ToDo: Xerces-specific code!
XMLStdErr theStdErr;
theStdErr << msg
<< ", at line number "
<< static_cast<long>(lineNo)
<< " at offset "
<< static_cast<long>(charOffset)
<< XMLStdErr::EndLine;
return classification == XPathEnvSupport::eWarning ? false : true;
}
bool
XSLTProcessorEnvSupportDefault::problem(
eSource /* where */,
eClassification classification,
const PrefixResolver& /* resolver */,
const DOM_Node& /* sourceNode */,
const DOMString& msg,
int lineNo,
int
charOffset) const
{
// $$$ ToDo: Xerces-specific code!
XMLStdErr theStdErr;
theStdErr << msg
<< ", at line number "
<< static_cast<long>(lineNo)
<< " at offset "
<< static_cast<long>(charOffset)
<< XMLStdErr::EndLine;
return classification == XPathEnvSupport::eWarning ? false : true;
}
1.1 xml-xalan/c/src/XSLT/XSLTProcessorEnvSupportDefault.hpp
Index: XSLTProcessorEnvSupportDefault.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XSLTPROCESSORENVSUPPORTDEFAULT_HEADER_GUARD_1357924680)
#define XSLTPROCESSORENVSUPPORTDEFAULT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
// Base class header file...
#include <XPath/XPathEnvSupportDefault.hpp>
class XSLTProcessor;
// Specializaton of XPathEnvSupportDefault, which implements calls that
// XPathEnvSupportDefault can't really do.
class XALAN_XSLT_EXPORT XSLTProcessorEnvSupportDefault : public
XPathEnvSupportDefault
{
public:
XSLTProcessorEnvSupportDefault(XSLTProcessor* theProcessor = 0);
virtual
~XSLTProcessorEnvSupportDefault();
// These interfaces are inherited from XPathEnvSupportDefault...
/**
* Given a valid element key, return the corresponding node list.
*/
virtual const NodeRefListBase*
getNodeSetByKey(
const DOM_Node& doc,
const DOMString& name,
const DOMString& ref,
const PrefixResolver& resolver) const;
/**
* Given a name, locate a variable in the current context, and return
* the Object.
*/
XObject*
getVariable(
XPathExecutionContext& executionContext,
const QName& name) const;
virtual bool
problem(
eSource where,
eClassification classification,
const DOM_Node& styleNode,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int charOffset)
const;
virtual bool
problem(
eSource where,
eClassification classification,
const PrefixResolver& resolver,
const DOM_Node& sourceNode,
const DOMString& msg,
int lineNo,
int
charOffset) const;
/**
* Tells, through the combination of the default-space attribute
* on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the
* xml:space attribute, whether or not extra whitespace should be
stripped
* from the node. Literal elements from template elements should
* <em>not</em> be tested with this function.
* @param textNode A text node from the source tree.
* @return true if the text node should be stripped of extra whitespace.
*/
virtual bool
shouldStripSourceNode(const DOM_Node& node) const;
void
setProcessor(XSLTProcessor* theProcessor)
{
m_processor = theProcessor;
}
private:
// These are not implemented...
XSLTProcessorEnvSupportDefault(const XSLTProcessorEnvSupportDefault&);
XSLTProcessorEnvSupportDefault&
operator=(const XSLTProcessorEnvSupportDefault&);
bool
operator==(const XSLTProcessorEnvSupportDefault&) const;
// Data members...
XSLTProcessor* m_processor;
};
#endif // XSLTPROCESSORENVSUPPORTDEFAULT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/XSLTProcessorException.cpp
Index: XSLTProcessorException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XSLTProcessorException.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
XSLTProcessorException::XSLTProcessorException(
const DOMString& theMessage,
const DOMString& theType) :
XSLException(theMessage, theType)
{
}
XSLTProcessorException::~XSLTProcessorException()
{
}
1.1 xml-xalan/c/src/XSLT/XSLTProcessorException.hpp
Index: XSLTProcessorException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XSLTPROCESSOREXCEPTION_HEADER_GUARD_1357924680)
#define XSLTPROCESSOREXCEPTION_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
// Base class header file...
#include <PlatformSupport/XSLException.hpp>
class XALAN_XSLT_EXPORT XSLTProcessorException : public XSLException
{
public:
XSLTProcessorException(
const DOMString& theMessage,
const DOMString& theType =
DOMString("XSLTProcessorException"));
virtual
~XSLTProcessorException();
};
#endif // XSLTPROCESSOREXCEPTION_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XSLT/XSLTResultTarget.cpp
Index: XSLTResultTarget.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
// Base include file. Must be first.
#include "XSLTResultTarget.hpp"
/**
* Zero-argument default constructor.
*/
XSLTResultTarget::XSLTResultTarget() :
m_fileName(),
m_byteStream(0),
m_encoding(),
m_characterStream(0),
m_node(),
m_formatterListener(0)
{ }
/**
* Create a new output target with a file name.
*
* @param fileName Must be a valid system file name.
*/
XSLTResultTarget::XSLTResultTarget (DOMString& fileName) :
m_fileName(fileName),
m_byteStream(0),
m_encoding(),
m_characterStream(0),
m_node(),
m_formatterListener(0)
{ }
XSLTResultTarget::XSLTResultTarget (OutputStream* byteStream) :
m_fileName(),
m_byteStream(byteStream),
m_encoding(),
m_characterStream(0),
m_node(),
m_formatterListener(0)
{ }
XSLTResultTarget::XSLTResultTarget (Writer* characterStream) :
m_fileName(),
m_byteStream(0),
m_encoding(),
m_characterStream(characterStream),
m_node(),
m_formatterListener(0)
{ }
XSLTResultTarget::XSLTResultTarget (DOM_Node& n) :
m_fileName(),
m_byteStream(0),
m_encoding(),
m_characterStream(0),
m_node(n),
m_formatterListener(0)
{ }
1.1 xml-xalan/c/src/XSLT/XSLTResultTarget.hpp
Index: XSLTResultTarget.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: $
#if !defined(XALAN_XSLTRESULTTARGET_HEADER_GUARD)
#define XALAN_XSLTRESULTTARGET_HEADER_GUARD
// Base include file. Must be first.
#include "XSLTDefinitions.hpp"
#include <dom/DOMString.hpp>
#include <dom/DOM_Node.hpp>
#include <sax/DocumentHandler.hpp>
#include <xmlsupport/FormatterListener.hpp>
class OutputStream;
class Writer;
class XALAN_XSLT_EXPORT XSLTResultTarget
{
public:
/**
* Zero-argument default constructor.
*/
XSLTResultTarget();
/**
* Create a new output target with a file name.
*
* @param fileName Must be a valid system file name.
*/
XSLTResultTarget (DOMString& fileName); // File?
/**
* Create a new output target with a byte stream.
*
* @param byteStream The raw byte stream that will contain the document.
*/
XSLTResultTarget (OutputStream* byteStream);
/**
* Create a new output target with a character stream.
*
* @param characterStream The character stream where the results will
be written.
*/
XSLTResultTarget (Writer* characterStream);
/**
* Create a new output target with a character stream.
*
* @param characterStream The character stream where the results will
be written.
*/
XSLTResultTarget (DOM_Node& n);
/**
* Set the file name where the results will be written.
*
* @param fileName The system identifier as a string.
*/
void setFileName (DOMString& fileName) // File?
{
m_fileName = fileName;
}
/**
* Get the file name where the results will be written to.
*
* @return The file name.
*/
DOMString& getFileName ()
{
return m_fileName;
}
/**
* Set the byte stream for this output target.
*
* @param byteStream A byte stream that will contain the result
document.
*/
void setByteStream (OutputStream* byteStream)
{
m_byteStream = byteStream;
}
/**
* Get the byte stream for this output target.
*
* @return The byte stream, or null if none was supplied.
*/
OutputStream* getByteStream ()
{
return m_byteStream;
}
/**
* Set the character encoding, if known.
*/
void setEncoding (DOMString& encoding)
{
m_encoding = encoding;
}
/**
* Get the character encoding that was used.
*
* @return The encoding, or null if none was supplied.
*/
DOMString& getEncoding ()
{
return m_encoding;
}
/**
* Set the character stream for this output target.
*
* @param characterStream The character stream that will contain
*
the result document.
*/
void setCharacterStream (Writer* characterStream)
{
m_characterStream = characterStream;
}
/**
* Get the character stream for this output target.
*
* @return The character stream, or null if none was supplied.
*/
Writer* getCharacterStream ()
{
return m_characterStream;
}
/**
* Set the node that will contain the result nodes.
*/
void setNode (const DOM_Node& node)
{
m_node = node;
}
/**
* Get the node that will contain the result nodes.
*/
DOM_Node& getNode ()
{
return m_node;
}
/**
* Set a SAX DocumentHandler to process the result tree events.
*/
void setDocumentHandler (DocumentHandler* handler)
{
m_formatterListener = handler;
}
/**
* Get the SAX DocumentHandler that will process the result tree events.
*/
DocumentHandler* getDocumentHandler ()
{
return m_formatterListener;
}
/**
* Set a FormatterListener to process the result tree events.
*/
void setFormatterListener (FormatterListener* handler)
{
m_formatterListener = static_cast<DocumentHandler*>(handler);
}
/**
* Get the FormatterListener that will process the result tree events.
*/
FormatterListener* getFormatterListener ()
{
return static_cast<FormatterListener*>(m_formatterListener);
}
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
private:
DOMString m_fileName;
OutputStream* m_byteStream;
DOMString m_encoding;
Writer* m_characterStream;
DOM_Node m_node;
DocumentHandler* m_formatterListener;
};
#endif // XALAN_XSLTRESULTTARGET_HEADER_GUARD
1.1 xml-xalan/c/src/XercesInit/XercesInit.cpp
Index: XercesInit.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XercesInit.hpp"
#include <util/PlatformUtils.hpp>
XercesInit::XercesInit()
{
}
XercesInit::~XercesInit()
{
}
#if defined(WIN32)
#include <windows.h>
BOOL APIENTRY DllMain(HANDLE /* hModule */,
DWORD ul_reason_for_call,
LPVOID /* lpReserved */)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
XMLPlatformUtils::Initialize();
}
return TRUE;
}
#else
#error Unsupported platform!!!
#endif
1.1 xml-xalan/c/src/XercesInit/XercesInit.hpp
Index: XercesInit.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XERCESINIT_HEADER_GUARD_1357924680)
#define XERCESINIT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include "XercesInitDefinitions.hpp"
// Class to initialize the Xerces Parser and its support library. Right now,
// this is just a dummy class to ensure that this system is linked in. Under
Win32,
// the DLLMain() function does the actual initialization. This ensures that
the
// Xerces library is already initialized by the time all static data is
initialized in
// our other libraries. In particular, this allows for static instances of
the
// Xerces DOMString class, which requires that the support library be
initialized
// before instances can be constructed.
class XALAN_XERCESINIT_EXPORT XercesInit
{
public:
XercesInit();
~XercesInit();
};
#endif // XERCESINIT_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XercesInit/XercesInitDefinitions.hpp
Index: XercesInitDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XercesINITDEFINITIONS_HEADER_GUARD_1357924680)
#define XercesINITDEFINITIONS_HEADER_GUARD_1357924680
#include <include/PlatformDefinitions.hpp>
#if defined(XALAN_XERCESINIT_BUILD_DLL)
#define XALAN_XERCESINIT_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_XERCESINIT_EXPORT_FUNCTION(T) XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_XERCESINIT_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_XERCESINIT_EXPORT_FUNCTION(T) XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // XercesINITDEFINITIONS_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.cpp
Index: XercesParserLiaison.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XercesParserLiaison.hpp"
#include <memory>
#include <parsers/DOMParser.hpp>
#include <parsers/SAXParser.hpp>
#include <internal/URLInputSource.hpp>
const char* const theParserName = "Xerces";
XercesParserLiaison::XercesParserLiaison(
DOMSupport& theSupport,
bool fUseValidatingParser) :
XMLParserLiaisonDefault(theSupport,
theParserName),
m_fUseValidatingParser(fUseValidatingParser)
{
}
XercesParserLiaison::~XercesParserLiaison()
{
}
bool
XercesParserLiaison::supportsSAX() const
{
return true;
}
namespace
{
inline DOMParser*
CreateDOMParser(bool fValidating)
{
return new DOMParser;
/*
if (fValidating == true)
{
return new ValidatingDOMParser;
}
else
{
return new NonValidatingDOMParser;
}
*/
}
inline SAXParser*
CreateSAXParser(bool fValidating)
{
return new SAXParser;
/*
if (fValidating == true)
{
return new ValidatingSAXParser;
}
else
{
return new NonValidatingSAXParser;
}
*/
}
};
DOM_Document
XercesParserLiaison::parseXMLStream(
InputSource& reader,
const DOMString& /* identifier */)
{
std::auto_ptr<DOMParser>
theParser(CreateDOMParser(m_fUseValidatingParser));
theParser->parse(reader);
return theParser->getDocument();
}
void
XercesParserLiaison::parseXMLStream(
InputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& /* identifier */)
{
std::auto_ptr<SAXParser>
theParser(CreateSAXParser(m_fUseValidatingParser));
theParser->setDocumentHandler(&handler);
theParser->parse(urlInputSource);
}
DOM_Document
XercesParserLiaison::parseXMLStream(
URLInputSource& urlInputSource,
const DOMString& /* identifier */)
{
std::auto_ptr<DOMParser>
theParser(CreateDOMParser(m_fUseValidatingParser));
theParser->parse(urlInputSource);
return theParser->getDocument();
}
void
XercesParserLiaison::parseXMLStream(
URLInputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& /* identifier */)
{
std::auto_ptr<SAXParser>
theParser(CreateSAXParser(m_fUseValidatingParser));
theParser->setDocumentHandler(&handler);
theParser->parse(urlInputSource);
}
DOM_Document
XercesParserLiaison::createDocument()
{
return DOM_Document::createDocument();
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.hpp
Index: XercesParserLiaison.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XercesPARSERLIAISON_HEADER_GUARD_1357924680)
#define XercesPARSERLIAISON_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
// Standard Library header files.
#include <string>
#include <memory>
// Xerces DOM header files
#include <dom/DOM_Attr.hpp>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOMString.hpp>
// Base class header file.
#include <XMLSupport/XMLParserLiaisonDefault.hpp>
class DOMSupport;
class InputSource;
class URLInputSource;
class XSLProcessor;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesParserLiaison : public
XMLParserLiaisonDefault
{
public:
XercesParserLiaison(
DOMSupport& theSupport,
bool fUseValidatingParser = false);
virtual
~XercesParserLiaison();
// These interfaces are inherited from XMLParserLiaison...
/**
* Returns true if the liaison supports the SAX DocumentHandler
* interface.
*/
virtual bool
supportsSAX() const;
/**
* Parse the text pointed at by the reader as XML, and return
* a DOM Document interface. May return null if not
* supported. It is recommended that you pass in some sort
* of recognizable name, such as the filename or URI, with
* which the reader can be recognized if the parse fails.
* @param reader A stream that should hold valid XML.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual DOM_Document
parseXMLStream(
InputSource& reader,
const DOMString& identifier = DOMString());
/**
* Parse the text pointed at by the reader as XML, and return
* a DOM Document interface. May return null if not
* supported. It is recommended that you pass in some sort
* of recognizable name, such as the filename or URI, with
* which the reader can be recognized if the parse fails.
* @param reader A URL input source that should hold valid XML.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual DOM_Document
parseXMLStream(
URLInputSource& reader,
const DOMString& identifier = DOMString());
/**
* Parse the text pointed at by the reader as XML.
*
* @param reader A URL input source that should hold valid XML.
* @param handler An instance of a DocumentHandler.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual void
parseXMLStream(
InputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& identifier = DOMString());
/**
* Parse the text pointed at by the reader as XML.
*
* @param reader A URL input source that should hold valid XML.
* @param handler An instance of a DocumentHandler.
* @param identifier Used for diagnostic purposes only,
* some sort of identification for error reporting, may be
* an empty string.
*/
virtual void
parseXMLStream(
URLInputSource& urlInputSource,
DocumentHandler& handler,
const DOMString& identifier = DOMString());
/**
* Create an empty DOM Document. Mainly used for creating an
* output document.
*/
virtual DOM_Document
createDocument();
private:
const bool m_fUseValidatingParser;
};
#endif // XercesPARSERLIAISON_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp
Index: XercesParserLiaisonDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XercesPARSERLIAISONDEFINITIONS_HEADER_GUARD_1357924680)
#define XercesPARSERLIAISONDEFINITIONS_HEADER_GUARD_1357924680
#include <include/PlatformDefinitions.hpp>
#if defined(XALAN_XERCESPARSERLIAISON_BUILD_DLL)
#define XALAN_XERCESPARSERLIAISON_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_XERCESPARSERLIAISON_EXPORT_FUNCTION(T)
XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_XERCESPARSERLIAISON_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_XERCESPARSERLIAISON_EXPORT_FUNCTION(T)
XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // XercesPARSERLIAISONDEFINITIONS_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesPlatformSupport/NullTextOutputStream.cpp
Index: NullTextOutputStream.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "NullTextOutputStream.hpp"
NullTextOutputStream::NullTextOutputStream() :
TextOutputStream()
{
}
NullTextOutputStream::~NullTextOutputStream()
{
}
void
NullTextOutputStream::flush()
{
}
void
NullTextOutputStream::write(const XMLCh* const /* theBuffer */)
{
}
void
NullTextOutputStream::write(const char* const /* theBuffer */)
{
}
1.1
xml-xalan/c/src/XercesPlatformSupport/NullTextOutputStream.hpp
Index: NullTextOutputStream.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(NULLTEXTOUTPUTSTREAM_HEADER_GUARD_1357924680)
#define NULLTEXTOUTPUTSTREAM_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XercesPlatformSupport/XercesPlatformSupportDefinitions.hpp>
// Base class header file.
#include <util/TextOutputStream.hpp>
class XALAN_XERCESPLATFORMSUPPORT_EXPORT NullTextOutputStream : public
TextOutputStream
{
public :
explicit
NullTextOutputStream();
virtual
~NullTextOutputStream();
// These are inherited from TextOutputStream...
virtual void
flush();
virtual void
write(const XMLCh* const theBuffer);
virtual void
write(const char* const theBuffer);
private:
// These are not implemented...
NullTextOutputStream(const NullTextOutputStream&);
NullTextOutputStream&
operator=(const NullTextOutputStream&);
bool
operator==(const NullTextOutputStream&) const;
};
#endif // NULLTEXTOUTPUTSTREAM_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesPlatformSupport/TextFileOutputStream.cpp
Index: TextFileOutputStream.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "TextFileOutputStream.hpp"
#include <sstream>
#if defined(_MSC_VER)
#include "windows.h"
#else
#define INVALID_HANDLE_VALUE 0
#endif
#include <util/Janitor.hpp>
#include <util/XMLString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
namespace
{
const bool gOnNT = true;
};
const TextFileOutputStream::BufferType::size_type
TextFileOutputStream::s_bufferSize = 8192;
TextFileOutputStream::TextFileOutputStream(const DOMString&
theFileName) :
TextOutputStream(),
m_fileName(theFileName),
#if defined(_MSC_VER)
m_handle(INVALID_HANDLE_VALUE),
#else
m_handle(0),
#endif
m_buffer()
{
m_buffer.reserve(s_bufferSize + 1);
#if defined(_MSC_VER)
if (gOnNT)
{
m_handle = ::CreateFileW(toCharArray(theFileName),
GENERIC_WRITE,
FILE_SHARE_WRITE,
0,
CREATE_ALWAYS,
FILE_FLAG_SEQUENTIAL_SCAN,
0);
}
else
{
char* const tmpName =
XMLString::transcode(toCharArray(theFileName));
ArrayJanitor<char> janTmp(tmpName);
m_handle = ::CreateFileA(tmpName,
GENERIC_WRITE,
FILE_SHARE_WRITE,
0,
CREATE_ALWAYS,
FILE_FLAG_SEQUENTIAL_SCAN,
0);
}
#else
char* const tmpName =
XMLString::transcode(toCharArray(theFileName));
ArrayJanitor<char> janTmp(tmpName);
m_handle = fopen(tmpName, "wt");
#endif
if (m_handle == INVALID_HANDLE_VALUE)
{
throw TextFileOutputStreamOpenException(theFileName,
errno);
}
}
TextFileOutputStream::~TextFileOutputStream()
{
if (m_handle != INVALID_HANDLE_VALUE)
{
#if defined(_MSC_VER)
CloseHandle(m_handle);
#else
fclose(m_handle);
#endif
}
}
void
TextFileOutputStream::flush()
{
flushBuffer();
#if defined(_MSC_VER)
FlushFileBuffers(m_handle);
#else
fflush(m_handle);
#endif
}
void
TextFileOutputStream::write(const XMLCh* const theBuffer)
{
const BufferType::size_type theLength =
static_cast<BufferType::size_type>(length(theBuffer));
if (theLength + m_buffer.size() > s_bufferSize)
{
flushBuffer();
}
if (theLength > s_bufferSize)
{
doWrite(theBuffer);
}
else
{
m_buffer.insert(m_buffer.end(),
theBuffer,
theBuffer + theLength);
}
}
void
TextFileOutputStream::write(const char* const theBuffer)
{
flushBuffer();
doWrite(theBuffer,
strlen(theBuffer));
}
void
TextFileOutputStream::write(
const char* theBuffer,
unsigned long theBufferLength)
{
flushBuffer();
doWrite(theBuffer,
theBufferLength);
}
void
TextFileOutputStream::flushBuffer()
{
if (m_buffer.size() > 0)
{
m_buffer.push_back(0);
doWrite(m_buffer.begin());
m_buffer.clear();
}
}
void
TextFileOutputStream::doWrite(const XMLCh* theBuffer)
{
char* const tmpVal = XMLString::transcode(theBuffer);
ArrayJanitor<char> janTmp(tmpVal);
doWrite(tmpVal,
strlen(tmpVal));
}
void
TextFileOutputStream::doWrite(
const char* theBuffer,
unsigned long theBufferLength)
{
#if defined(_MSC_VER)
DWORD theBytesWritten;
WriteFile(m_handle,
theBuffer,
theBufferLength,
&theBytesWritten,
0);
#else
const size_t theBytesWritten =
fwrite(theBuffer,
1,
theBufferLength,
m_handle);
#endif
if(theBytesWritten != theBufferLength)
{
throw TextFileOutputStreamWriteException(m_fileName,
errno);
}
}
TextFileOutputStreamException::TextFileOutputStreamException(
const DOMString& theMessage,
const DOMString& theType) :
XercesPlatformSupportException(theMessage,
theType)
{
}
TextFileOutputStreamException::~TextFileOutputStreamException()
{
}
namespace
{
const DOMString
theOpenExceptionType("TextFileOutputStreamOpenException");
const DOMString
theWriteExceptionType("TextFileOutputStreamWriteException");
DOMString
FormatMessageLocal(
const DOMString& theMessage,
const DOMString& theFileName,
int theErrorCode)
{
DOMString theResult(clone(theMessage));
theResult += theFileName;
std::stringstream theFormatter;
theFormatter << ". The error code was "
<< theErrorCode
<< ".";
theResult += theFormatter.str().c_str();
return theResult;
}
};
TextFileOutputStreamOpenException::TextFileOutputStreamOpenException(
const DOMString& theFileName,
int theErrorCode) :
TextFileOutputStreamException(FormatMessageLocal("Error opening file: ",
theFileName,
theErrorCode),
theOpenExceptionType)
{
}
TextFileOutputStreamOpenException::~TextFileOutputStreamOpenException()
{
}
TextFileOutputStreamWriteException::TextFileOutputStreamWriteException(
const DOMString& theFileName,
int theErrorCode) :
TextFileOutputStreamException(FormatMessageLocal("Error writing file: ",
theFileName,
theErrorCode),
theWriteExceptionType)
{
}
TextFileOutputStreamWriteException::~TextFileOutputStreamWriteException()
{
}
1.1
xml-xalan/c/src/XercesPlatformSupport/TextFileOutputStream.hpp
Index: TextFileOutputStream.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(TEXTFILEOUTPUTSTREAM_HEADER_GUARD_1357924680)
#define TEXTFILEOUTPUTSTREAM_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XercesPlatformSupport/XercesPlatformSupportDefinitions.hpp>
#if !defined(_MSC_VER)
#include <cstdio>
#endif
#include <vector>
// Base class header file.
#include <util/TextOutputStream.hpp>
#include <XercesPlatformSupport/XercesPlatformSupportException.hpp>
class XALAN_XERCESPLATFORMSUPPORT_EXPORT TextFileOutputStream : public
TextOutputStream
{
public :
TextFileOutputStream(const DOMString& theFileName);
virtual
~TextFileOutputStream();
// These are inherited from TextOutputStream...
virtual void
flush();
virtual void
write(const XMLCh* const theBuffer);
virtual void
write(const char* const theBuffer);
// This is new...
virtual void
write(
const char* theBuffer,
unsigned long theBufferLength);
private:
// These are not implemented...
TextFileOutputStream(const TextFileOutputStream&);
TextFileOutputStream&
operator=(const TextFileOutputStream&);
void
flushBuffer();
void
doWrite(const XMLCh* theBuffer);
void
doWrite(
const char* theBuffer,
unsigned long theBufferLength);
bool
operator==(const TextFileOutputStream&) const;
// Data members...
const DOMString m_fileName;
#if defined(_MSC_VER)
FileHandle m_handle;
#else
FILE* m_handle;
#endif
typedef std::vector<XMLCh> BufferType;
BufferType
m_buffer;
static const BufferType::size_type s_bufferSize;
};
class XALAN_XERCESPLATFORMSUPPORT_EXPORT TextFileOutputStreamException :
public XercesPlatformSupportException
{
public:
virtual
~TextFileOutputStreamException();
protected:
TextFileOutputStreamException(
const DOMString& theMessage,
const DOMString& theType);
};
class XALAN_XERCESPLATFORMSUPPORT_EXPORT TextFileOutputStreamOpenException :
public TextFileOutputStreamException
{
public:
TextFileOutputStreamOpenException(
const DOMString& theFileName,
int theErrorCode);
virtual
~TextFileOutputStreamOpenException();
};
class XALAN_XERCESPLATFORMSUPPORT_EXPORT TextFileOutputStreamWriteException :
public TextFileOutputStreamException
{
public:
TextFileOutputStreamWriteException(
const DOMString& theFileName,
int theErrorCode);
virtual
~TextFileOutputStreamWriteException();
};
#endif // TEXTFILEOUTPUTSTREAM_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesPlatformSupport/XercesDOMPrintWriter.cpp
Index: XercesDOMPrintWriter.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XercesDOMPrintWriter.hpp"
#include <cassert>
#include <util/TextOutputStream.hpp>
#include <dom/DOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
XercesDOMPrintWriter::XercesDOMPrintWriter(
TextOutputStream& theOutputStream,
bool fAutoFlush) :
PrintWriter(fAutoFlush),
m_OutputStream(theOutputStream)
{
}
XercesDOMPrintWriter::~XercesDOMPrintWriter()
{
}
bool
XercesDOMPrintWriter::checkError() const
{
return false;
}
void
XercesDOMPrintWriter::close()
{
}
void
XercesDOMPrintWriter::flush()
{
m_OutputStream.flush();
}
void
XercesDOMPrintWriter::write(
const char* s,
long theOffset,
long theLength)
{
write(DOMString(s), theOffset, theLength);
}
void
XercesDOMPrintWriter::write(
const XMLCh* s,
long theOffset,
long theLength)
{
assert(s != 0);
assert(theOffset >= 0);
assert(theLength >= 0 || theLength == -1);
if (theLength == -1)
{
for (long i = theOffset; s[i] != 0; i++)
{
m_OutputStream << s[i];
}
}
else
{
const long theStopIndex = theOffset + theLength;
for (long i = theOffset; i < theStopIndex; i++)
{
m_OutputStream << s[i];
}
}
}
void
XercesDOMPrintWriter::write(XMLCh c)
{
m_OutputStream << c;
}
void
XercesDOMPrintWriter::write(
const DOMString& s,
long theOffset,
long theLength)
{
assert(theOffset >= 0);
assert(theLength >= 0 || theLength == -1);
assert(theLength == -1 && length(s) > theOffset || length(s) >=
theOffset + theLength);
if (theOffset == 0 && theLength == -1)
{
m_OutputStream << s;
}
else
{
const long theStopIndex = (theLength == -1) ? length(s) :
theOffset + theLength;
for (long i = theOffset; i < theStopIndex; i++)
{
m_OutputStream << s.charAt(i);
}
}
}
void
XercesDOMPrintWriter::print(bool b)
{
if (b == true)
{
print(DOMString("true"));
}
else
{
print(DOMString("false"));
}
}
void
XercesDOMPrintWriter::print(char c)
{
write(c);
}
void
XercesDOMPrintWriter::print(
const char* s,
long theLength)
{
write(s,
0,
theLength);
}
void
XercesDOMPrintWriter::print(
const XMLCh* s,
long theLength)
{
assert(s != 0);
assert(theLength >= 0 || theLength == -1);
write(s,
0,
theLength);
}
void
XercesDOMPrintWriter::print(double d)
{
m_OutputStream << d;
}
void
XercesDOMPrintWriter::print(int i)
{
m_OutputStream << static_cast<long>(i);
}
void
XercesDOMPrintWriter::print(long l)
{
m_OutputStream << l;
}
void
XercesDOMPrintWriter::print(const DOMString& s)
{
m_OutputStream << s;
}
void
XercesDOMPrintWriter::println()
{
m_OutputStream << TextOutputStream::EndLine;
}
void
XercesDOMPrintWriter::println(bool b)
{
print(b);
println();
}
void
XercesDOMPrintWriter::println(char c)
{
print(c);
println();
}
void
XercesDOMPrintWriter::println(
const char* s,
long theLength)
{
print(s, theLength);
println();
}
void
XercesDOMPrintWriter::println(
const XMLCh* s,
long theLength)
{
print(s, theLength);
println();
}
void
XercesDOMPrintWriter::println(double d)
{
print(d);
println();
}
void
XercesDOMPrintWriter::println(int i)
{
print(i);
println();
}
void
XercesDOMPrintWriter::println(long l)
{
print(l);
println();
}
void
XercesDOMPrintWriter::println(const DOMString& s)
{
print(s);
println();
}
1.1
xml-xalan/c/src/XercesPlatformSupport/XercesDOMPrintWriter.hpp
Index: XercesDOMPrintWriter.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XercesDOMPRINTWRITER_HEADER_GUARD_1357924680)
#define XercesDOMPRINTWRITER_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XercesPlatformSupport/XercesPlatformSupportDefinitions.hpp>
#include <PlatformSupport/PrintWriter.hpp>
class TextOutputStream;
class XALAN_XERCESPLATFORMSUPPORT_EXPORT XercesDOMPrintWriter : public
PrintWriter
{
public:
// If fAutoFlush is true, the output will not
// be buffered.
XercesDOMPrintWriter(
TextOutputStream& theOutputStream,
bool fAutoFlush = false);
virtual
~XercesDOMPrintWriter();
// Flush the stream, then check the error status.
virtual bool
checkError() const;
virtual void
close();
virtual void
flush();
// Output functions...
// If the length is -1, then the array is assumed to be null-terminated.
virtual void
write(const char* s,
long theOffset = 0,
long theLength = -1);
// If the length is -1, then the entire string is printed.
virtual void
write(const XMLCh* s,
long theOffset = 0,
long theLength = -1);
virtual void
write(XMLCh c);
// If the length is -1, then the entire string is printed.
virtual void
write(const DOMString& s,
long theOffset = 0,
long theLength = -1);
virtual void
print(bool b);
virtual void
print(char c);
virtual void
print(const char* s,
long theLength = -1);
virtual void
print(const XMLCh* s,
long theLength = -1);
virtual void
print(double d);
virtual void
print(int i);
virtual void
print(long l);
virtual void
print(const DOMString& s);
virtual void
println();
virtual void
println(bool b);
virtual void
println(char c);
virtual void
println(const char* s,
long theLength = -1);
virtual void
println(const XMLCh* s,
long theLength = -1);
virtual void
println(double d);
virtual void
println(int i);
virtual void
println(long l);
virtual void
println(const DOMString& s);
protected:
TextOutputStream& m_OutputStream;
private:
// Not implemented
XercesDOMPrintWriter(const XercesDOMPrintWriter&);
XercesDOMPrintWriter&
operator=(const XercesDOMPrintWriter&);
bool
operator==(const XercesDOMPrintWriter&);
};
#endif // XercesDOMPRINTWRITER_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesPlatformSupport/XercesPlatformSupportDefinitions.hpp
Index: XercesPlatformSupportDefinitions.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XERCESPLATFORMSUPPORTDEFINITIONS_HEADER_GUARD_1357924680)
#define XERCESPLATFORMSUPPORTDEFINITIONS_HEADER_GUARD_1357924680
#include <include/PlatformDefinitions.hpp>
#if defined(XALAN_XERCESPLATFORMSUPPORT_BUILD_DLL)
#define XALAN_XERCESPLATFORMSUPPORT_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_XERCESPLATFORMSUPPORT_EXPORT_FUNCTION(T)
XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_XERCESPLATFORMSUPPORT_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_XERCESPLATFORMSUPPORT_EXPORT_FUNCTION(T)
XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // XERCESPLATFORMSUPPORTDEFINITIONS_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesPlatformSupport/XercesPlatformSupportException.cpp
Index: XercesPlatformSupportException.cpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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 "XercesPlatformSupportException.hpp"
XercesPlatformSupportException::XercesPlatformSupportException(
const DOMString& theMessage,
const DOMString& theType) :
XSLException(theMessage, theType)
{
}
XercesPlatformSupportException::~XercesPlatformSupportException()
{
}
1.1
xml-xalan/c/src/XercesPlatformSupport/XercesPlatformSupportException.hpp
Index: XercesPlatformSupportException.hpp
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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(XercesPLATFORMSUPPORTEXCEPTION_HEADER_GUARD_1357924680)
#define XercesPLATFORMSUPPORTEXCEPTION_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XercesPlatformSupport/XercesPlatformSupportDefinitions.hpp>
// Base class header file...
#include <PlatformSupport/XSLException.hpp>
class XALAN_XERCESPLATFORMSUPPORT_EXPORT XercesPlatformSupportException :
public XSLException
{
public:
XercesPlatformSupportException(
const DOMString& theMessage,
const DOMString& theType);
virtual
~XercesPlatformSupportException();
};
#endif // XercesPLATFORMSUPPORTEXCEPTION_HEADER_GUARD_1357924680