epoc32/include/xml/dom/xmlengnamespace.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/xml/dom/xmlengnamespace.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,161 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:       Namespace node functions
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +#ifndef XMLENGINE_NAMESPACE_H_INCLUDED
    1.28 +#define XMLENGINE_NAMESPACE_H_INCLUDED
    1.29 +
    1.30 +#include "xmlengnode.h"
    1.31 +
    1.32 +/**
    1.33 + *   Represents existing namespace declaration in DOM tree <b>OR</b> namespace node returned
    1.34 + *   in RXmlEngNodeSet as a result of some XPath expression. 
    1.35 + *
    1.36 + *   All elements and attributes may have a namespace instance associated.
    1.37 + *   Once put in element, a namespace declaration (instance of TXmlEngNamespace) may be 
    1.38 + *   referred to by all attributes and descentants of the element (unless
    1.39 + *   prefix that this namespace-to-prefix binding uses is overriden somewhere below in the document tree)
    1.40 + *
    1.41 + *   <b>General rules of namespace handling:</b>
    1.42 + *
    1.43 + * - <b>NULL</b> prefix in namespace node means NO PREFIX. ""(empty string '\\0') can be used for specifying 
    1.44 + *   absense of prefix when setting it, however <b>NULL</b> will be stored and returned.
    1.45 + *
    1.46 + * - <b>NULL</b> value of namespace URI is legal only with <b>NULL</b> prefix and only met in 
    1.47 + *   undeclaration of namespace (<i>xmlns=""</i>). <b>""</b> (empty string) can be used too, however it 
    1.48 + *   will be returned as <b>NULL</b>.
    1.49 + *
    1.50 + * - <b>NULL</b> or <b>""</b> namespace <b>URI</b> with non-<b>NULL</b> prefix is illegal acording to the XML specification.
    1.51 + *
    1.52 + * - Namespace of a element is <b>default</b> if it is associated with some namespace declaration with <b>NULL</b> prefix.
    1.53 + *
    1.54 + * - Elements are never associated with namespace undeclarations (<b>xmlns=""</b>), instead, such elements have no
    1.55 + *   namespace declaration referred to. 
    1.56 + *
    1.57 + * - Attributes do not have <i>default</i> namespace. Even if it is effective at element scope,
    1.58 + *   default namespace declaration is not applied to element's attributes (according to the XML specification)
    1.59 + *
    1.60 + * - Namespace of a node (element or attribute) is <b>undefined</b> if no namespace declaration is
    1.61 + *   associated with it.
    1.62 + *
    1.63 + * - Node with <i>undefined</i> namespace is serialized as having no prefix. In general,
    1.64 + *   DOM API handles the complexity of namespace declaration handling and creates neccessary
    1.65 + *   namespace declarations and undeclares default namespace. However, some node-creation methods (e.g. TXmlEngElement::AddNewElementL()) 
    1.66 + *   do not ensure that created node with undefined namespace (thus, without a prefix) will 
    1.67 + *   actually treated after serialization as having some <i>default</i> namespace
    1.68 + *
    1.69 + *   @note
    1.70 + *   Namespace nodes that are result of XPath expression have following restrictions:
    1.71 + *       - they cannot be used as namespace definitions, because they are not part of
    1.72 + *         the DOM tree, but copies of existing namespace definitions.
    1.73 + *       - namespace prefix is not available because it is not mandated by DOM Level 3 XPath module API, 
    1.74 + *         so in returned copies of DOM tree, namespaces prefix strings are not preserved 
    1.75 + *         and Prefix() returns NULL.
    1.76 + * 
    1.77 + * @lib XmlEngineDOM.lib
    1.78 + * @since S60 v3.1
    1.79 + */
    1.80 +class TXmlEngNamespace: public TXmlEngNode
    1.81 +{
    1.82 +  public:
    1.83 +    /**
    1.84 +     * Default constructor
    1.85 +     *
    1.86 +     * @since S60 v3.1
    1.87 +     */
    1.88 +	inline TXmlEngNamespace();
    1.89 +
    1.90 +    /**
    1.91 +    /**
    1.92 +     * Get namespace URI
    1.93 +     *
    1.94 +     * @since S60 v3.1
    1.95 +     * @return Namespace URI string 
    1.96 +     * @note "" is never returned - it is replaced with NULL
    1.97 +     *
    1.98 +     * For TXmlEngNamespace(NULL) or namespace undeclaration (xmlns=""), which are
    1.99 +     * treatet as <i>undefined namespace</i> returns NULL,
   1.100 +     * otherwise result is not a NULL string and not a "" (empty string).
   1.101 +     */
   1.102 +    IMPORT_C TPtrC8 Uri() const;
   1.103 +
   1.104 +    /**
   1.105 +     * Get namespace prefix. 
   1.106 +     *
   1.107 +     * @since S60 v3.1
   1.108 +     * @return prefix that is bound in the namespace declaration
   1.109 +     * or NULL string for default namespace or if no binding exist
   1.110 +     */
   1.111 +    IMPORT_C TPtrC8 Prefix() const;
   1.112 +
   1.113 +    /**
   1.114 +     * Check if namespace is default.
   1.115 +     *
   1.116 +     * @since S60 v3.1
   1.117 +     * @return Whether it is a definition of default namespace
   1.118 +     *    TRUE  -- is a default namespace (no prefix)
   1.119 +     *    FALSE -- not a default namespace (bound to prefix) or empty TXmlEngNamespace(NULL) instance
   1.120 +     */
   1.121 +    IMPORT_C TBool IsDefault() const;
   1.122 +
   1.123 +	/**
   1.124 +     * Check if namespace is undefined
   1.125 +	 *
   1.126 +     * @since S60 v3.1
   1.127 +     * @return Whether the namespace is undefined
   1.128 +     *
   1.129 +     * A node's namespace is undefined if no namespace declaration associated with it.
   1.130 +     * @note Same as TXmlEngNode::IsNull()
   1.131 +     */
   1.132 +    IMPORT_C TBool IsUndefined() const; 
   1.133 +
   1.134 +protected:
   1.135 +    /**
   1.136 +     *   Workaround to avoid misuse of TXmlEngNode::NamespaceUri() method, which should not be
   1.137 +     *   applied to TXmlEngNamespace node. Since the name of the inherited method from TXmlEngNode
   1.138 +     *   is too similar to TXmlEngNamespace::Uri(), NamespaceUri() is disabled for direct
   1.139 +     *   use. 
   1.140 +     *   If NamespaceUri() is called on the TXmlEngNamespace object that is downcasted to TXmlEngNode, then
   1.141 +     *   NamespaceUri()'s result equals to result of Uri() method.
   1.142 +     *
   1.143 +     * @since S60 v3.1
   1.144 +     * @return NULL
   1.145 +     */
   1.146 +	inline TPtrC8 NamespaceUri();
   1.147 +
   1.148 +protected:
   1.149 +    /**
   1.150 +     * Constructor
   1.151 +     *
   1.152 +     * @since S60 v3.1
   1.153 +     * @param aPtr Namespace pointer
   1.154 +     */
   1.155 +	inline TXmlEngNamespace(void* aPtr);
   1.156 +
   1.157 +    friend class TXmlEngElement;
   1.158 +    friend class TXmlEngNode;
   1.159 +};
   1.160 +
   1.161 +#include "xmlengnamespace.inl"
   1.162 +
   1.163 +#endif /* XMLENGINE_NAMESPACE_H_INCLUDED */
   1.164 +