xpath/trunk/XMLv2__XPathVWDocumentAdaptor.st
changeset 0 5057afe1ec87
equal deleted inserted replaced
-1:000000000000 0:5057afe1ec87
       
     1 "{ Package: 'stx:goodies/xmlsuite/xpath' }"
       
     2 
       
     3 "{ NameSpace: XMLv2 }"
       
     4 
       
     5 XPathDocumentAdaptor subclass:#XPathVWDocumentAdaptor
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'XML Suite-XPath-Adaptors'
       
    10 !
       
    11 
       
    12 
       
    13 !XPathVWDocumentAdaptor class methodsFor:'accessing'!
       
    14 
       
    15 documentClass
       
    16 
       
    17 
       
    18     ^XML::Document
       
    19 
       
    20     "Created: / 13-10-2006 / 21:05:53 / janfrog"
       
    21 ! !
       
    22 
       
    23 !XPathVWDocumentAdaptor methodsFor:'checking'!
       
    24 
       
    25 ensureIsValidNodeId: anObject
       
    26 
       
    27     "
       
    28         Ensures whether given object is valid node ID for myself
       
    29     "
       
    30 
       
    31     (anObject isKindOf: XML::Node)
       
    32         ifFalse:[XPathInvalidNodeIdError raiseErrorString:'Invalid Node ID']
       
    33 
       
    34     "Created: / 14-12-2006 / 23:44:34 / janfrog"
       
    35 ! !
       
    36 
       
    37 !XPathVWDocumentAdaptor methodsFor:'resource management'!
       
    38 
       
    39 primReleaseResources
       
    40 
       
    41     "Created: / 12-12-2006 / 10:46:37 / janfrog"
       
    42 ! !
       
    43 
       
    44 !XPathVWDocumentAdaptor methodsFor:'xpath axes'!
       
    45 
       
    46 primXpathAttributeOf: anObject
       
    47 
       
    48     ^(self xpathIsElement: anObject)
       
    49         ifTrue:[anObject attributes]
       
    50         ifFalse:[#()]
       
    51 
       
    52     "Created: / 14-12-2006 / 23:23:14 / janfrog"
       
    53 !
       
    54 
       
    55 primXpathChildOf: anObject
       
    56 
       
    57     ((self xpathIsElement:anObject) or:[self xpathIsDocument: anObject]) ifFalse:[^#()].
       
    58 
       
    59     ^anObject elements
       
    60 
       
    61     "Created: / 14-12-2006 / 23:23:21 / janfrog"
       
    62 !
       
    63 
       
    64 primXpathParentOf: anObject
       
    65 
       
    66     ^anObject parent
       
    67 
       
    68     "Created: / 14-12-2006 / 23:23:29 / janfrog"
       
    69 ! !
       
    70 
       
    71 !XPathVWDocumentAdaptor methodsFor:'xpath primitives'!
       
    72 
       
    73 primXpathIsDocumentFragment:arg 
       
    74     "Superclass says that I am responsible to implement this method"
       
    75 
       
    76     ^arg isDocumentFragment
       
    77 
       
    78     "Created: / 10-08-2007 / 09:16:21 / janfrog"
       
    79 !
       
    80 
       
    81 primXpathIsText:arg 
       
    82     "Superclass says that I am responsible to implement this method"
       
    83 
       
    84     self shouldImplement
       
    85 
       
    86     "Created: / 10-08-2007 / 09:16:21 / janfrog"
       
    87 !
       
    88 
       
    89 primXpathNameOf:arg 
       
    90     "Superclass says that I am responsible to implement this method"
       
    91 
       
    92     self shouldImplement
       
    93 
       
    94     "Created: / 10-08-2007 / 09:16:21 / janfrog"
       
    95 ! !
       
    96 
       
    97 !XPathVWDocumentAdaptor methodsFor:'xpath testing'!
       
    98 
       
    99 primXpathIsAttribute: anObject
       
   100 
       
   101     ^anObject isAttribute
       
   102 
       
   103     "Created: / 14-12-2006 / 23:24:18 / janfrog"
       
   104 !
       
   105 
       
   106 primXpathIsDocument: anObject
       
   107 
       
   108     ^anObject isDocument
       
   109 
       
   110     "Created: / 14-12-2006 / 23:24:27 / janfrog"
       
   111 !
       
   112 
       
   113 primXpathIsElement: anObject
       
   114 
       
   115     ^anObject isElement
       
   116 
       
   117     "Created: / 14-12-2006 / 23:24:32 / janfrog"
       
   118 ! !
       
   119 
       
   120 !XPathVWDocumentAdaptor methodsFor:'xpath values'!
       
   121 
       
   122 primXpathAttributeValueOf: anObject
       
   123 
       
   124     ^anObject value
       
   125 
       
   126     "Created: / 14-12-2006 / 23:24:47 / janfrog"
       
   127 !
       
   128 
       
   129 primXpathLocalNameOf: anObject
       
   130 
       
   131     ^anObject tag type
       
   132 
       
   133     "Created: / 14-12-2006 / 23:24:52 / janfrog"
       
   134 !
       
   135 
       
   136 primXpathNamespaceOf: anObject
       
   137 
       
   138     ^anObject tag namespace
       
   139 
       
   140     "Created: / 14-12-2006 / 23:25:02 / janfrog"
       
   141 ! !
       
   142 
       
   143 !XPathVWDocumentAdaptor methodsFor:'xpath values - private'!
       
   144 
       
   145 primXpathElementValueOf: anObject
       
   146 
       
   147     ^anObject tag type
       
   148 
       
   149     "Created: / 14-12-2006 / 23:25:11 / janfrog"
       
   150 !
       
   151 
       
   152 primXpathTextValueOf: anObject
       
   153 
       
   154     ^anObject text
       
   155 
       
   156     "Created: / 14-12-2006 / 23:25:16 / janfrog"
       
   157 ! !
       
   158 
       
   159 !XPathVWDocumentAdaptor class methodsFor:'documentation'!
       
   160 
       
   161 version
       
   162     ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xpath/XMLv2__XPathVWDocumentAdaptor.st,v 1.7 2007-08-10 07:34:30 vranyj1 Exp $'
       
   163 ! !