williamr@4: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: // All rights reserved. williamr@4: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@4: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: // williamr@4: // Initial Contributors: williamr@4: // Nokia Corporation - initial contribution. williamr@4: // williamr@4: // Contributors: williamr@4: // williamr@4: // Description: williamr@4: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@4: @file williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: #ifndef XMLENGNAMESPACE_H williamr@4: #define XMLENGNAMESPACE_H williamr@4: williamr@4: #include williamr@4: williamr@4: /** williamr@4: This class represents an existing namespace declaration in the DOM tree or a williamr@4: namespace node returned in RXmlEngNodeSet as a result of some XPath expression. williamr@4: williamr@4: All elements and attributes may have a namespace instance associated with them. williamr@4: Once added to an element, a namespace declaration (instance of williamr@4: TXmlEngNamespace) may be referred to by all attributes and descendants of the williamr@4: element (unless the prefix that this namespace-to-prefix binding uses is williamr@4: overriden somewhere below in the document tree). williamr@4: williamr@4: General rules for namespace handling: williamr@4: williamr@4: - A NULL prefix in the namespace node means NO PREFIX. An empty string "" can williamr@4: be used to specify the absence of a prefix when setting it, however, NULL will williamr@4: be stored and returned. williamr@4: williamr@4: - A NULL value for a namespace URI is legal only with a NULL prefix and is only williamr@4: used in the undeclaration of a namespace (@c xmlns="" ). An empty string "" williamr@4: can be used too, however, it will be returned as NULL. williamr@4: williamr@4: - A NULL or empty string namespace URI with a non-NULL prefix is illegal williamr@4: acording to the XML specification. williamr@4: williamr@4: - The namespace of an element is a default namespace if it has a NULL prefix. williamr@4: williamr@4: - Elements with namespace undeclarations (@c xmlns="" ), have no namespace and williamr@4: are treated as local names. williamr@4: williamr@4: - Attributes do not have a default namespace. Even if a namespace is applied at williamr@4: element scope, the default namespace declaration is not applied to the williamr@4: element's attributes (according to the XML specification). williamr@4: williamr@4: - The namespace of a node (element or attribute) is undefined if no namespace williamr@4: declaration is associated with it. williamr@4: williamr@4: - A node with an undefined namespace is serialized as having no prefix. In williamr@4: general, the DOM API handles the complexity of namespace declaration handling, williamr@4: creating neccessary namespace declarations and undeclaring default namespaces. williamr@4: However, some node-creation methods (e.g. TXmlEngElement::AddNewElementL()) do williamr@4: not ensure that a node created with an undefined namespace (i.e. without a williamr@4: prefix) will be treated after serialization as having the default namespace. williamr@4: williamr@4: Note: williamr@4: Namespace nodes that are the result of XPath expressions have following restrictions: williamr@4: williamr@4: - They cannot be used as namespace definitions, because they are not part of williamr@4: the DOM tree, but rather copies of existing namespace definitions. williamr@4: williamr@4: - The namespace prefix is not available because it is not mandated by the DOM williamr@4: Level 3 XPath API. So, in returned copies of the DOM tree, namespace prefix williamr@4: strings are not preserved and Prefix() returns NULL. williamr@4: */ williamr@2: class TXmlEngNamespace: public TXmlEngNode williamr@2: { williamr@4: friend class TXmlEngElement; williamr@4: friend class TXmlEngNode; williamr@4: williamr@2: public: williamr@4: /** Default constructor */ williamr@2: inline TXmlEngNamespace(); williamr@2: williamr@2: /** williamr@4: Gets the namespace URI williamr@4: @return Namespace URI string or an empty string if the namespace is either williamr@4: NULL or undeclared (@c xmlns="" ) williamr@4: */ williamr@2: IMPORT_C TPtrC8 Uri() const; williamr@2: williamr@2: /** williamr@4: Gets the namespace prefix. williamr@4: @return The prefix bound in the namespace declaration or an empty string williamr@4: when there is a default namespace or if no binding exists williamr@4: */ williamr@2: IMPORT_C TPtrC8 Prefix() const; williamr@2: williamr@2: /** williamr@4: Check if the namespace is default. williamr@4: @return ETrue if the namespace is default (no prefix), EFalse if the williamr@4: namespace is not default (bound to prefix) or the namespace is NULL williamr@4: */ williamr@2: IMPORT_C TBool IsDefault() const; williamr@2: williamr@2: /** williamr@4: Check if the namespace is undefined. A node's namespace is undefined if no williamr@4: namespace declaration is associated with it. This is the same as williamr@4: TXmlEngNode::IsNull(). williamr@4: @return ETrue if the namespace is undefined, EFalse otherwise williamr@4: */ williamr@2: IMPORT_C TBool IsUndefined() const; williamr@2: williamr@2: protected: williamr@2: /** williamr@4: This method is inherited from TXmlEngNode. To prevent its use, no function body williamr@4: has been supplied. The method Uri() should be used instead. williamr@4: williamr@4: @see Uri(). williamr@4: */ williamr@2: inline TPtrC8 NamespaceUri(); williamr@2: williamr@2: protected: williamr@2: /** williamr@4: Constructor williamr@4: @param aPtr Namespace pointer williamr@4: */ williamr@2: inline TXmlEngNamespace(void* aPtr); williamr@2: }; williamr@2: williamr@4: #include williamr@2: williamr@4: #endif /* XMLENGNAMESPACE_H */ williamr@2: