00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(DOMSERVICES_HEADER_GUARD_1357924680) 00058 #define DOMSERVICES_HEADER_GUARD_1357924680 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include <DOMSupport/DOMSupportDefinitions.hpp> 00064 00065 00066 00067 #include <XalanDOM/XalanDOMString.hpp> 00068 #include <XalanDOM/XalanAttr.hpp> 00069 #include <XalanDOM/XalanComment.hpp> 00070 #include <XalanDOM/XalanDocument.hpp> 00071 #include <XalanDOM/XalanElement.hpp> 00072 #include <XalanDOM/XalanProcessingInstruction.hpp> 00073 #include <XalanDOM/XalanText.hpp> 00074 00075 00076 00077 #include <PlatformSupport/DOMStringHelper.hpp> 00078 #include <PlatformSupport/FormatterListener.hpp> 00079 00080 00081 00082 class XalanDocument; 00083 class XalanDocumentFragment; 00084 00085 00086 00087 class XALAN_DOMSUPPORT_EXPORT DOMServices 00088 { 00089 public: 00090 00091 static const XalanDOMString& s_XMLString; 00092 static const XalanDOMString& s_XMLStringWithSeparator; 00093 static const XalanDOMString& s_XMLNamespaceURI; 00094 static const XalanDOMString& s_XMLNamespace; 00095 static const XalanDOMString& s_XMLNamespaceWithSeparator; 00096 static const XalanDOMString& s_XMLNamespaceSeparatorString; 00097 static const XalanDOMString& s_XMLNamespacePrefixURI; 00098 00099 static const unsigned int& s_XMLStringLength; 00100 static const unsigned int& s_XMLStringWithSeparatorLength; 00101 static const unsigned int& s_XMLNamespaceURILength; 00102 static const unsigned int& s_XMLNamespaceLength; 00103 static const unsigned int& s_XMLNamespaceWithSeparatorLength; 00104 static const unsigned int& s_XMLNamespaceSeparatorStringLength; 00105 static const unsigned int& s_XMLNamespacePrefixURILength; 00106 00107 00108 // A dummy string to return when we need an emtpy string... 00109 static const XalanDOMString s_emptyString; 00110 00111 00112 class XALAN_DOMSUPPORT_EXPORT WhitespaceSupport 00113 { 00114 public: 00115 00116 WhitespaceSupport(); 00117 00118 virtual 00119 ~WhitespaceSupport(); 00120 00128 virtual bool 00129 isIgnorableWhitespace(const XalanText& node) const = 0; 00130 }; 00131 00132 // A default implementation using the values from the XML spec. 00133 class XALAN_DOMSUPPORT_EXPORT WhitespaceSupportDefault : public WhitespaceSupport 00134 { 00135 public: 00136 00137 WhitespaceSupportDefault(); 00138 00139 virtual 00140 ~WhitespaceSupportDefault(); 00141 00149 virtual bool 00150 isIgnorableWhitespace(const XalanText& node) const; 00151 }; 00152 00157 static void 00158 initialize(); 00159 00164 static void 00165 terminate(); 00166 00173 static XalanDOMString 00174 getNodeData(const XalanNode& node); 00175 00182 static void 00183 getNodeData( 00184 const XalanNode& node, 00185 XalanDOMString& data); 00186 00193 static XalanDOMString 00194 getNodeData(const XalanAttr& attribute) 00195 { 00196 return attribute.getNodeValue(); 00197 } 00198 00205 static void 00206 getNodeData( 00207 const XalanAttr& attribute, 00208 XalanDOMString& data) 00209 { 00210 append(data, attribute.getNodeValue()); 00211 } 00212 00219 static XalanDOMString 00220 getNodeData(const XalanComment& comment) 00221 { 00222 return comment.getData(); 00223 } 00224 00231 static void 00232 getNodeData( 00233 const XalanComment& comment, 00234 XalanDOMString& data) 00235 { 00236 append(data, comment.getData()); 00237 } 00238 00245 static XalanDOMString 00246 getNodeData(const XalanDocument& document); 00247 00254 static void 00255 getNodeData( 00256 const XalanDocument& document, 00257 XalanDOMString& data); 00258 00265 static XalanDOMString 00266 getNodeData(const XalanDocumentFragment& documentFragment); 00267 00274 static void 00275 getNodeData( 00276 const XalanDocumentFragment& documentFragment, 00277 XalanDOMString& data); 00278 00285 static XalanDOMString 00286 getNodeData(const XalanElement& element); 00287 00294 static void 00295 getNodeData( 00296 const XalanElement& element, 00297 XalanDOMString& data); 00298 00305 static XalanDOMString 00306 getNodeData(const XalanProcessingInstruction& pi) 00307 { 00308 return pi.getData(); 00309 } 00310 00317 static void 00318 getNodeData( 00319 const XalanProcessingInstruction& pi, 00320 XalanDOMString& data) 00321 { 00322 append(data, pi.getData()); 00323 } 00324 00331 static XalanDOMString 00332 getNodeData(const XalanText& text) 00333 { 00334 return text.getData(); 00335 } 00336 00343 static void 00344 getNodeData( 00345 const XalanText& text, 00346 XalanDOMString& data) 00347 { 00348 append(data, text.getData()); 00349 } 00350 00351 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int); 00352 00360 static void 00361 getNodeData( 00362 const XalanNode& node, 00363 FormatterListener& formatterListener, 00364 MemberFunctionPtr function); 00365 00373 static void 00374 getNodeData( 00375 const XalanAttr& attribute, 00376 FormatterListener& formatterListener, 00377 MemberFunctionPtr function) 00378 { 00379 sendData(formatterListener, function, attribute.getNodeValue()); 00380 } 00381 00389 static void 00390 getNodeData( 00391 const XalanComment& comment, 00392 FormatterListener& formatterListener, 00393 MemberFunctionPtr function) 00394 { 00395 sendData(formatterListener, function, comment.getData()); 00396 } 00397 00405 static void 00406 getNodeData( 00407 const XalanDocument& document, 00408 FormatterListener& formatterListener, 00409 MemberFunctionPtr function); 00410 00418 static void 00419 getNodeData( 00420 const XalanDocumentFragment& documentFragment, 00421 FormatterListener& formatterListener, 00422 MemberFunctionPtr function); 00423 00431 static void 00432 getNodeData( 00433 const XalanElement& element, 00434 FormatterListener& formatterListener, 00435 MemberFunctionPtr function); 00436 00444 static void 00445 getNodeData( 00446 const XalanProcessingInstruction& pi, 00447 FormatterListener& formatterListener, 00448 MemberFunctionPtr function) 00449 { 00450 sendData(formatterListener, function, pi.getData()); 00451 } 00452 00460 static void 00461 getNodeData( 00462 const XalanText& text, 00463 FormatterListener& formatterListener, 00464 MemberFunctionPtr function) 00465 { 00466 sendData(formatterListener, function, text.getData()); 00467 } 00468 00477 static const XalanDOMString& 00478 getNameOfNode(const XalanNode& n); 00479 00488 static const XalanDOMString& 00489 getNameOfNode(const XalanAttr& attr) 00490 { 00491 const XalanDOMString& theName = attr.getNodeName(); 00492 00493 if (startsWith(theName, s_XMLNamespaceWithSeparator) == true) 00494 { 00495 // Special case for namespace nodes... 00496 return attr.getLocalName(); 00497 } 00498 else 00499 { 00500 return theName; 00501 } 00502 } 00503 00512 static const XalanDOMString& 00513 getNameOfNode(const XalanElement& element) 00514 { 00515 return element.getNodeName(); 00516 } 00517 00526 static const XalanDOMString& 00527 getLocalNameOfNode(const XalanNode& n) 00528 { 00529 const XalanDOMString& theLocalName = n.getLocalName(); 00530 00531 if (length(theLocalName) != 0) 00532 { 00533 return theLocalName; 00534 } 00535 else 00536 { 00537 return n.getNodeName(); 00538 } 00539 } 00540 00549 static const XalanDOMString& 00550 getNamespaceOfNode(const XalanNode& n); 00551 00559 static bool 00560 isNamespaceDeclaration(const XalanAttr& n) 00561 { 00562 const XalanDOMString& theName = n.getNodeName(); 00563 00564 return startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true || 00565 equals(theName, DOMServices::s_XMLNamespace) == true; 00566 } 00567 00575 static XalanNode* 00576 getParentOfNode(const XalanNode& node) 00577 { 00578 if(node.getNodeType() == XalanNode::ATTRIBUTE_NODE) 00579 { 00580 #if defined(XALAN_OLD_STYLE_CASTS) 00581 return ((const XalanAttr&)node).getOwnerElement(); 00582 #else 00583 return static_cast<const XalanAttr&>(node).getOwnerElement(); 00584 #endif 00585 } 00586 else 00587 { 00588 return node.getParentNode(); 00589 } 00590 } 00591 00599 static const XalanDOMString* 00600 getNamespaceForPrefix( 00601 const XalanDOMString& prefix, 00602 const XalanElement& namespaceContext); 00603 00611 static bool 00612 isNodeAfter( 00613 const XalanNode& node1, 00614 const XalanNode& node2); 00615 00624 static bool 00625 isNodeAfterSibling( 00626 const XalanNode& parent, 00627 const XalanNode& child1, 00628 const XalanNode& child2); 00629 00630 private: 00631 00642 static XalanNode* 00643 findOwnerElement(const XalanAttr& attr) 00644 { 00645 XalanNode* const theOwnerElement = attr.getOwnerElement(); 00646 00647 if (theOwnerElement != 0) 00648 { 00649 return theOwnerElement; 00650 } 00651 else 00652 { 00653 return findOwnerElement(attr, *attr.getOwnerDocument()->getDocumentElement()); 00654 } 00655 } 00656 00668 static XalanNode* 00669 findOwnerElement( 00670 const XalanNode& attr, 00671 XalanNode& element); 00672 00680 static void 00681 sendData( 00682 FormatterListener& formatterListener, 00683 MemberFunctionPtr function, 00684 const XalanDOMString& data) 00685 { 00686 (formatterListener.*function)(c_wstr(data), length(data)); 00687 } 00688 }; 00689 00690 00691 00692 #endif // DOMSERVICES_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|