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_XMLNamespacePrefix; 00094 static const XalanDOMString& s_XMLNamespaceURI; 00095 static const XalanDOMString& s_XMLNamespace; 00096 static const XalanDOMString& s_XMLNamespaceWithSeparator; 00097 static const XalanDOMString& s_XMLNamespaceSeparatorString; 00098 static const XalanDOMString& s_XMLNamespacePrefixURI; 00099 00100 static const XalanDOMString::size_type& s_XMLStringLength; 00101 static const XalanDOMString::size_type& s_XMLStringWithSeparatorLength; 00102 static const XalanDOMString::size_type& s_XMLNamespacePrefixLength; 00103 static const XalanDOMString::size_type& s_XMLNamespaceURILength; 00104 static const XalanDOMString::size_type& s_XMLNamespaceLength; 00105 static const XalanDOMString::size_type& s_XMLNamespaceWithSeparatorLength; 00106 static const XalanDOMString::size_type& s_XMLNamespaceSeparatorStringLength; 00107 static const XalanDOMString::size_type& s_XMLNamespacePrefixURILength; 00108 00109 00110 // A dummy string to return when we need an emtpy string... 00111 static const XalanDOMString s_emptyString; 00112 00113 00114 class XALAN_DOMSUPPORT_EXPORT WhitespaceSupport 00115 { 00116 public: 00117 00118 WhitespaceSupport(); 00119 00120 virtual 00121 ~WhitespaceSupport(); 00122 00130 virtual bool 00131 isIgnorableWhitespace(const XalanText& node) const = 0; 00132 }; 00133 00134 // A default implementation using the values from the XML spec. 00135 class XALAN_DOMSUPPORT_EXPORT WhitespaceSupportDefault : public WhitespaceSupport 00136 { 00137 public: 00138 00139 WhitespaceSupportDefault(); 00140 00141 virtual 00142 ~WhitespaceSupportDefault(); 00143 00151 virtual bool 00152 isIgnorableWhitespace(const XalanText& node) const; 00153 }; 00154 00159 static void 00160 initialize(); 00161 00166 static void 00167 terminate(); 00168 00175 static XalanDOMString 00176 getNodeData(const XalanNode& node); 00177 00184 static void 00185 getNodeData( 00186 const XalanNode& node, 00187 XalanDOMString& data); 00188 00195 static XalanDOMString 00196 getNodeData(const XalanAttr& attribute) 00197 { 00198 return attribute.getNodeValue(); 00199 } 00200 00207 static void 00208 getNodeData( 00209 const XalanAttr& attribute, 00210 XalanDOMString& data) 00211 { 00212 append(data, attribute.getNodeValue()); 00213 } 00214 00221 static XalanDOMString 00222 getNodeData(const XalanComment& comment) 00223 { 00224 return comment.getData(); 00225 } 00226 00233 static void 00234 getNodeData( 00235 const XalanComment& comment, 00236 XalanDOMString& data) 00237 { 00238 append(data, comment.getData()); 00239 } 00240 00247 static XalanDOMString 00248 getNodeData(const XalanDocument& document); 00249 00256 static void 00257 getNodeData( 00258 const XalanDocument& document, 00259 XalanDOMString& data); 00260 00267 static XalanDOMString 00268 getNodeData(const XalanDocumentFragment& documentFragment); 00269 00276 static void 00277 getNodeData( 00278 const XalanDocumentFragment& documentFragment, 00279 XalanDOMString& data); 00280 00287 static XalanDOMString 00288 getNodeData(const XalanElement& element); 00289 00296 static void 00297 getNodeData( 00298 const XalanElement& element, 00299 XalanDOMString& data); 00300 00307 static XalanDOMString 00308 getNodeData(const XalanProcessingInstruction& pi) 00309 { 00310 return pi.getData(); 00311 } 00312 00319 static void 00320 getNodeData( 00321 const XalanProcessingInstruction& pi, 00322 XalanDOMString& data) 00323 { 00324 append(data, pi.getData()); 00325 } 00326 00333 static XalanDOMString 00334 getNodeData(const XalanText& text) 00335 { 00336 return text.getData(); 00337 } 00338 00345 static void 00346 getNodeData( 00347 const XalanText& text, 00348 XalanDOMString& data) 00349 { 00350 append(data, text.getData()); 00351 } 00352 00353 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int); 00354 00362 static void 00363 getNodeData( 00364 const XalanNode& node, 00365 FormatterListener& formatterListener, 00366 MemberFunctionPtr function); 00367 00375 static void 00376 getNodeData( 00377 const XalanAttr& attribute, 00378 FormatterListener& formatterListener, 00379 MemberFunctionPtr function) 00380 { 00381 sendData(formatterListener, function, attribute.getNodeValue()); 00382 } 00383 00391 static void 00392 getNodeData( 00393 const XalanComment& comment, 00394 FormatterListener& formatterListener, 00395 MemberFunctionPtr function) 00396 { 00397 sendData(formatterListener, function, comment.getData()); 00398 } 00399 00407 static void 00408 getNodeData( 00409 const XalanDocument& document, 00410 FormatterListener& formatterListener, 00411 MemberFunctionPtr function); 00412 00420 static void 00421 getNodeData( 00422 const XalanDocumentFragment& documentFragment, 00423 FormatterListener& formatterListener, 00424 MemberFunctionPtr function); 00425 00433 static void 00434 getNodeData( 00435 const XalanElement& element, 00436 FormatterListener& formatterListener, 00437 MemberFunctionPtr function); 00438 00446 static void 00447 getNodeData( 00448 const XalanProcessingInstruction& pi, 00449 FormatterListener& formatterListener, 00450 MemberFunctionPtr function) 00451 { 00452 sendData(formatterListener, function, pi.getData()); 00453 } 00454 00462 static void 00463 getNodeData( 00464 const XalanText& text, 00465 FormatterListener& formatterListener, 00466 MemberFunctionPtr function) 00467 { 00468 sendData(formatterListener, function, text.getData()); 00469 } 00470 00479 static const XalanDOMString& 00480 getNameOfNode(const XalanNode& n); 00481 00490 static const XalanDOMString& 00491 getNameOfNode(const XalanAttr& attr) 00492 { 00493 const XalanDOMString& theName = attr.getNodeName(); 00494 00495 if (startsWith(theName, s_XMLNamespaceWithSeparator) == true) 00496 { 00497 // Special case for namespace nodes... 00498 return attr.getLocalName(); 00499 } 00500 else 00501 { 00502 return theName; 00503 } 00504 } 00505 00514 static const XalanDOMString& 00515 getNameOfNode(const XalanElement& element) 00516 { 00517 return element.getNodeName(); 00518 } 00519 00528 static const XalanDOMString& 00529 getLocalNameOfNode(const XalanNode& n) 00530 { 00531 const XalanDOMString& theLocalName = n.getLocalName(); 00532 00533 if (length(theLocalName) != 0) 00534 { 00535 return theLocalName; 00536 } 00537 else 00538 { 00539 return n.getNodeName(); 00540 } 00541 } 00542 00551 static const XalanDOMString& 00552 getNamespaceOfNode(const XalanNode& n); 00553 00561 static bool 00562 isNamespaceDeclaration(const XalanAttr& n) 00563 { 00564 const XalanDOMString& theName = n.getNodeName(); 00565 00566 return startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true || 00567 equals(theName, DOMServices::s_XMLNamespace) == true; 00568 } 00569 00577 static XalanNode* 00578 getParentOfNode(const XalanNode& node) 00579 { 00580 if(node.getNodeType() == XalanNode::ATTRIBUTE_NODE) 00581 { 00582 #if defined(XALAN_OLD_STYLE_CASTS) 00583 return ((const XalanAttr&)node).getOwnerElement(); 00584 #else 00585 return static_cast<const XalanAttr&>(node).getOwnerElement(); 00586 #endif 00587 } 00588 else 00589 { 00590 return node.getParentNode(); 00591 } 00592 } 00593 00601 static const XalanDOMString* 00602 getNamespaceForPrefix( 00603 const XalanDOMString& prefix, 00604 const XalanElement& namespaceContext); 00605 00613 static bool 00614 isNodeAfter( 00615 const XalanNode& node1, 00616 const XalanNode& node2); 00617 00626 static bool 00627 isNodeAfterSibling( 00628 const XalanNode& parent, 00629 const XalanNode& child1, 00630 const XalanNode& child2); 00631 00632 private: 00633 00644 static XalanNode* 00645 findOwnerElement(const XalanAttr& attr) 00646 { 00647 XalanNode* const theOwnerElement = attr.getOwnerElement(); 00648 00649 if (theOwnerElement != 0) 00650 { 00651 return theOwnerElement; 00652 } 00653 else 00654 { 00655 return findOwnerElement(attr, *attr.getOwnerDocument()->getDocumentElement()); 00656 } 00657 } 00658 00670 static XalanNode* 00671 findOwnerElement( 00672 const XalanNode& attr, 00673 XalanNode& element); 00674 00682 static void 00683 sendData( 00684 FormatterListener& formatterListener, 00685 MemberFunctionPtr function, 00686 const XalanDOMString& data) 00687 { 00688 assert(length(data) == FormatterListener::size_type(length(data))); 00689 00690 (formatterListener.*function)(c_wstr(data), FormatterListener::size_type(length(data))); 00691 } 00692 }; 00693 00694 00695 00696 #endif // DOMSERVICES_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.4 |
|