xquery/trunk/XQuery__XQueryConstructedNode.st
changeset 0 5057afe1ec87
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xquery/trunk/XQuery__XQueryConstructedNode.st	Tue Apr 08 19:47:42 2008 +0000
@@ -0,0 +1,351 @@
+"{ Package: 'stx:goodies/xmlsuite/xquery' }"
+
+"{ NameSpace: XQuery }"
+
+XQueryAbstractNode subclass:#XQueryConstructedNode
+	instanceVariableNames:'nodeName nodeValue nodeType nodeParent nodeChildren
+		nodeAttributes'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'XQuery-DataNodes'
+!
+
+
+!XQueryConstructedNode class methodsFor:'accessing - node type codes'!
+
+nodeTypeAttribute
+    ^#attribute.
+
+    "Created: / 22-10-2006 / 16:13:06 / ked"
+!
+
+nodeTypeDocument
+    ^#document.
+
+    "Created: / 22-10-2006 / 16:13:17 / ked"
+!
+
+nodeTypeElement
+    ^#element.
+
+    "Created: / 22-10-2006 / 16:13:28 / ked"
+!
+
+nodeTypeText
+    ^#text.
+
+    "Created: / 22-10-2006 / 16:13:39 / ked"
+! !
+
+!XQueryConstructedNode class methodsFor:'defaults'!
+
+defaultNodeAttributes
+    "default value for the 'nodeAttributes' instance variable (automatically generated)"
+
+    ^OrderedCollection new.
+
+    "Created: / 03-11-2006 / 19:30:33 / ked"
+!
+
+defaultNodeChildren
+    "default value for the 'nodeChildren' instance variable (automatically generated)"
+
+    ^OrderedCollection new.
+
+    "Created: / 03-11-2006 / 19:30:28 / ked"
+! !
+
+!XQueryConstructedNode methodsFor:'accessing'!
+
+documentAdaptor
+    "Superclass says that I am responsible to implement this method"
+
+    ^XPathDocumentAdaptorProxy instance
+
+    "Created: / 14-11-2007 / 15:07:48 / janfrog"
+    "Modified: / 17-11-2007 / 15:57:00 / janfrog"
+!
+
+documentURI
+    "Superclass says that I am responsible to implement this method"
+
+    ^'#xquery-constructed-document'
+
+    "Created: / 20-09-2007 / 14:51:37 / janfrog"
+!
+
+nodeAttributes
+    nodeAttributes isNil ifTrue:[
+        nodeAttributes := self class defaultNodeAttributes.
+    ].
+    ^ nodeAttributes
+
+    "Created: / 03-11-2006 / 19:30:33 / ked"
+!
+
+nodeAttributes:something
+    nodeAttributes := something.
+
+    "Created: / 03-11-2006 / 19:30:33 / ked"
+!
+
+nodeChildren
+    nodeChildren isNil ifTrue:[
+        nodeChildren := self class defaultNodeChildren.
+    ].
+    ^ nodeChildren
+
+    "Created: / 03-11-2006 / 19:30:28 / ked"
+!
+
+nodeChildren:something
+    nodeChildren := something.
+
+    "Created: / 03-11-2006 / 19:30:28 / ked"
+!
+
+nodeId
+    ^ self
+
+    "Created: / 14-11-2007 / 13:50:54 / janfrog"
+!
+
+nodeName
+    ^ nodeName
+
+    "Created: / 02-11-2006 / 11:49:42 / ked"
+!
+
+nodeName:aNodeName
+    nodeName := aNodeName.
+
+    "Created: / 02-11-2006 / 11:49:42 / ked"
+    "Modified: / 24-12-2006 / 16:11:06 / janfrog"
+!
+
+nodeParent
+    ^ nodeParent 
+        ifNil:[XQueryConstructedNode new
+                    nodeType: XQueryConstructedNode nodeTypeDocument ]
+
+    "Created: / 08-10-2006 / 20:17:44 / ked"
+    "Modified: / 20-03-2007 / 22:49:28 / janfrog"
+!
+
+nodeParent:something
+    nodeParent := something.
+
+    "Created: / 08-10-2006 / 20:17:44 / ked"
+!
+
+nodeType
+    ^ nodeType
+
+    "Created: / 08-10-2006 / 20:16:45 / ked"
+!
+
+nodeType:something
+    nodeType := something.
+
+    "Created: / 08-10-2006 / 20:16:45 / ked"
+!
+
+nodeValue
+    ^ nodeValue
+
+    "Created: / 08-10-2006 / 20:16:49 / ked"
+!
+
+nodeValue:something
+    nodeValue := something.
+
+    "Created: / 08-10-2006 / 20:16:49 / ked"
+! !
+
+!XQueryConstructedNode methodsFor:'accessing - xpath tests'!
+
+xpathIsAttribute
+
+    ^nodeType = XQueryConstructedNode nodeTypeAttribute.
+
+    "Created: / 03-11-2006 / 14:28:51 / ked"
+!
+
+xpathIsDocument
+
+    ^nodeType = XQueryConstructedNode nodeTypeDocument.
+
+    "Created: / 03-11-2006 / 14:28:52 / ked"
+!
+
+xpathIsElement
+
+    ^nodeType = XQueryConstructedNode nodeTypeElement.
+
+    "Created: / 03-11-2006 / 14:28:51 / ked"
+!
+
+xpathIsIgnorableText
+
+   ^false.
+
+    "Created: / 03-12-2006 / 12:39:35 / ked"
+!
+
+xpathIsText
+
+   ^nodeType = XQueryConstructedNode nodeTypeText.
+
+    "Created: / 03-11-2006 / 14:28:51 / ked"
+! !
+
+!XQueryConstructedNode methodsFor:'accessing - xpath values'!
+
+xpathLocalName
+
+    ^nodeName localName.
+
+    "Created: / 24-12-2006 / 17:52:34 / janfrog"
+!
+
+xpathName
+
+    ^nodeName qualifiedName.
+
+    "Created: / 03-11-2006 / 14:28:51 / ked"
+    "Modified: / 24-12-2006 / 17:24:11 / janfrog"
+!
+
+xpathNamespace
+
+    ^nodeName ns.
+
+    "Created: / 24-12-2006 / 17:52:44 / janfrog"
+!
+
+xpathValue 
+
+    ^nodeValue.
+
+    "Created: / 03-11-2006 / 14:28:51 / ked"
+! !
+
+!XQueryConstructedNode methodsFor:'adding & removing'!
+
+appendAttribute: constructedAttribute
+
+    self nodeAttributes add: constructedAttribute.
+    constructedAttribute nodeParent: self.
+
+    "Created: / 29-03-2007 / 13:28:46 / janfrog"
+!
+
+appendElement: constructedElement
+
+    self nodeChildren add: constructedElement.
+    constructedElement nodeParent: self.
+
+    "Created: / 29-03-2007 / 13:28:06 / janfrog"
+!
+
+appendText: constructedText
+
+    self nodeChildren add: constructedText.
+    constructedText nodeParent: self.
+
+    "Created: / 29-03-2007 / 13:29:07 / janfrog"
+! !
+
+!XQueryConstructedNode methodsFor:'copying'!
+
+copyNodeWithParent: aParent
+
+    | createdNode |
+
+    createdNode := self class new.
+
+    createdNode nodeName: self nodeName.
+    createdNode nodeValue: self nodeValue.
+    createdNode nodeType: self nodeType.
+
+    createdNode nodeParent: aParent.
+
+    createdNode nodeChildren: (self nodeChildren collect:[:node | node copyNodeWithParent: createdNode ]).
+
+    createdNode nodeAttributes: (self nodeAttributes collect:[:node | node copyNodeWithParent: createdNode ]).
+
+    ^createdNode.
+
+    "Created: / 03-11-2006 / 16:50:10 / ked"
+    "Modified: / 03-11-2006 / 19:31:56 / ked"
+!
+
+postCopy
+
+    nodeName := nodeName copy.
+    nodeValue := nodeValue copy.
+    nodeType := nodeType copy.
+    nodeParent := nodeParent copy.
+    nodeChildren := nodeChildren copy.
+    nodeAttributes := nodeAttributes copy.
+
+    "Created: / 05-12-2007 / 14:23:30 / janfrog"
+! !
+
+!XQueryConstructedNode methodsFor:'initialization & release'!
+
+releaseResources
+
+    "Nothing to do here"
+
+    "Created: / 12-12-2006 / 10:49:34 / janfrog"
+! !
+
+!XQueryConstructedNode methodsFor:'private'!
+
+transformNodeIds: nodeIds 
+    "raise an error: must be redefined in concrete subclass(es)"
+
+    ^nodeIds
+
+    "Created: / 18-11-2007 / 08:02:53 / janfrog"
+! !
+
+!XQueryConstructedNode methodsFor:'testing'!
+
+isAttributeNode
+    ^ self nodeType = self class nodeTypeAttribute
+
+    "Created: / 29-03-2007 / 13:54:44 / janfrog"
+!
+
+isDocumentNode
+
+    ^nodeType == #document
+
+    "Created: / 05-12-2007 / 15:57:43 / janfrog"
+!
+
+isElementNode
+    ^ self nodeType = self class nodeTypeElement
+
+    "Created: / 29-03-2007 / 13:54:54 / janfrog"
+!
+
+isTextNode
+    ^ self nodeType = self class nodeTypeText
+
+    "Created: / 29-03-2007 / 13:55:03 / janfrog"
+!
+
+isXQueryConstructedNode
+    ^ true
+
+    "Created: / 29-10-2006 / 15:30:47 / ked"
+! !
+
+!XQueryConstructedNode class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xquery/XQuery__XQueryConstructedNode.st,v 1.11 2007-12-05 21:07:37 vranyj1 Exp $'
+! !