From: <bi...@us...> - 2012-07-09 11:38:43
|
Revision: 8020 http://oorexx.svn.sourceforge.net/oorexx/?rev=8020&view=rev Author: bigrixx Date: 2012-07-09 11:38:32 +0000 (Mon, 09 Jul 2012) Log Message: ----------- add isDefaultNamespace support Modified Paths: -------------- incubator/orxutils/xml/xmldom.cls Modified: incubator/orxutils/xml/xmldom.cls =================================================================== --- incubator/orxutils/xml/xmldom.cls 2012-07-09 00:29:47 UTC (rev 8019) +++ incubator/orxutils/xml/xmldom.cls 2012-07-09 11:38:32 UTC (rev 8020) @@ -122,6 +122,7 @@ ::method lookupPrefix abstract ::method lookupNamespaceURI abstract ::method textContent abstract +::method isDefaultNamespace -- an abstract attribute interface definition ::class "Attr" mixinclass Node public @@ -1847,6 +1848,18 @@ if ancestor \== .nil then return ancestor~lookupNamespaceURI(prefix) return .nil +-- test if the current node is using a given namespace as the default +::method isDefaultNamespace + use strict arg uri + -- see if we have an element ancestor. + -- if we have one, ask for this from the element + ancestor = self~getElementAncestor + if ancestor \== .nil then return ancestor~isDefaultNamespace(uri) + return .false + +-- this is the default behavior used for many nodes. Other nodes +-- will override this to provide different behaviors. + -- find the first ancestor of this node that is an -- element node ::method getElementAncestor @@ -1857,10 +1870,6 @@ end return .nil -::method isDefaultNamespace - use strict arg uri - raise syntax 93.963 -- not supported - ::method isEqualNode use strict arg other -- a node is always equal to itself @@ -2492,6 +2501,13 @@ -- always returns .nil return .nil +-- perform a default namespace test for a node +::method isDefaultNamespace + use strict arg uri + + -- always returns .false for this type + return .false + /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* Class: DocumentImpl */ @@ -2724,7 +2740,16 @@ if root \= .nil then return root~lookupNamespaceURI(prefix) return .nil +-- test if the current node is using a given namespace as the default +::method isDefaultNamespace + use strict arg uri + -- ask the root element for this (if we have one) + root = self~documentElement + if root \= .nil then return root~isDefaultNamespace(uri) + return .false + + /** * Introduced in DOM Level 2. <p> * Distribution engine for DOM Level 2 Events. @@ -3399,6 +3424,17 @@ return .nil +-- test if the current node is using a given namespace as the default +::method isDefaultNamespace + use strict arg uri + + -- if this node is owned and the owner is an attribute, then + -- pass along the lookup + ownerNode = self~ownerNode + if ownerNode \== .nil, ownerNode~nodeType == .Node~ELEMENT_NODE then + return ownerNode~isDefaultNamespace(uri) + return .false + ::attribute isId ::method cloneNode @@ -4118,7 +4154,7 @@ return previous -- resolve the prefix that a node is using for a given namespace URI -::method resolvePrefix +::method lookupPrefix use strict arg uri -- pass this along to the specialized lookup method @@ -4207,7 +4243,37 @@ -- unresolved return .nil +-- test if the current node is using a given namespace as the default +::method isDefaultNamespace + use strict arg uri + namespace = self~namespaceURI + prefix = self~prefix + + -- if there's no prefix in use, any namespace for this element + -- will be from a default, so just compare. This also handles + -- the situation where any of these are .nil + if prefix == .nil | prefix == "" then do + return namespace == uri + end + + -- if the node has attributes, then we need to look for an xmlns + -- attribute and compare that + if self~hasAttributes then do + attr = self~getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns") + if attr \== .nil then return uri == attr~nodeValue + end + + return .false + + -- if this node is owned and the owner is an attribute, then + -- pass along the lookup + ownerNode = self~ownerNode + if ownerNode \== .nil, ownerNode~nodeType == .Node~ELEMENT_NODE then + return ownerNode~isDefaultNamespace(uri) + return .false + + /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* Class: CharacterData -- base class for all nodes that carry character data */ @@ -4656,6 +4722,13 @@ -- always returns .nil return .nil +-- perform a default namespace test for a node +::method isDefaultNamespace + use strict arg uri + + -- always returns .false for this type + return .false + -- override for text content. For this type, it always -- returns .nil ::attribute textContent GET @@ -4718,6 +4791,13 @@ -- always returns .nil return .nil +-- perform a default namespace test for a node +::method isDefaultNamespace + use strict arg uri + + -- always returns .false for this type + return .false + /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* Class: EntityReference */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |