relaxng/trunk/RNG__DataType.st
changeset 0 5057afe1ec87
equal deleted inserted replaced
-1:000000000000 0:5057afe1ec87
       
     1 "{ Package: 'stx:goodies/xmlsuite/relaxng' }"
       
     2 
       
     3 "{ NameSpace: RNG }"
       
     4 
       
     5 Object subclass:#DataType
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'Relax NG-Data Type Library'
       
    10 !
       
    11 
       
    12 
       
    13 !DataType class methodsFor:'accessing'!
       
    14 
       
    15 typename
       
    16     ^self subclassResponsibility
       
    17 
       
    18     "Created: / 28-04-2005 / 14:00:01 / janfrog"
       
    19 ! !
       
    20 
       
    21 !DataType methodsFor:'accessing'!
       
    22 
       
    23 typename
       
    24     ^self class typename
       
    25 
       
    26     "Created: / 28-04-2005 / 14:03:47 / janfrog"
       
    27 ! !
       
    28 
       
    29 !DataType methodsFor:'initialization'!
       
    30 
       
    31 initializeFromDOMElement:anElement
       
    32 
       
    33     "Nothing by default"
       
    34 
       
    35     "Created: / 28-04-2005 / 13:47:32 / janfrog"
       
    36 ! !
       
    37 
       
    38 !DataType methodsFor:'instance creation'!
       
    39 
       
    40 createObjectFromString:arg 
       
    41     "raise an error: must be redefined in concrete subclass(es)"
       
    42     
       
    43     ^ self subclassResponsibility
       
    44 
       
    45     "Created: / 02-05-2005 / 10:38:06 / janfrog"
       
    46 !
       
    47 
       
    48 createStringFromObject:anObject 
       
    49     ^ self subclassResponsibility
       
    50 
       
    51     "Created: / 02-05-2005 / 10:38:21 / janfrog"
       
    52 !
       
    53 
       
    54 objectFromString:aString
       
    55 
       
    56     ^
       
    57     [
       
    58         "/ aString has expanded entites... somehow... must revise this
       
    59         self createObjectFromString: aString "/ (String fromXMLEscapedString:aString)
       
    60     ] on: Error do:[:ex|
       
    61         DataConversionError raiseErrorString:ex errorString.
       
    62         nil
       
    63     ]
       
    64 
       
    65     "Created: / 02-05-2005 / 10:40:09 / janfrog"
       
    66     "Modified: / 28-06-2005 / 13:52:46 / masca"
       
    67 !
       
    68 
       
    69 stringFromObject:anObject
       
    70 
       
    71     | res |
       
    72     [ 
       
    73         res := self createStringFromObject:anObject
       
    74     ] on:Error do:[:ex|
       
    75         ^DataConversionError raiseErrorString:'Cannot convert to string:',anObject printString
       
    76     ].
       
    77     ^res asXMLEscapedString
       
    78 
       
    79     "Created: / 02-05-2005 / 10:40:53 / janfrog"
       
    80     "Modified: / 16-05-2005 / 14:21:40 / masca"
       
    81 ! !
       
    82 
       
    83 !DataType methodsFor:'printing'!
       
    84 
       
    85 printOn:aStream
       
    86 
       
    87     aStream 
       
    88        nextPutAll:self class typename;
       
    89        nextPutAll:' (';
       
    90        nextPutAll:self class name;
       
    91         nextPut:$).
       
    92 
       
    93     "Created: / 29-04-2005 / 15:13:47 / janfrog"
       
    94 ! !
       
    95 
       
    96 !DataType methodsFor:'queries'!
       
    97 
       
    98 acceptsEmptyStringAsContent
       
    99 
       
   100     ^false
       
   101 
       
   102     "Created: / 14-06-2005 / 12:16:35 / masca"
       
   103 ! !
       
   104 
       
   105 !DataType methodsFor:'testing'!
       
   106 
       
   107 isKey
       
   108     "Answer whether this datatype represents an ID of the node within the
       
   109     document."
       
   110 
       
   111     ^false
       
   112 
       
   113     "Created: / 29-04-2005 / 12:18:30 / janfrog"
       
   114 !
       
   115 
       
   116 isKeyRef
       
   117     "Answer whether this datatype represents a reference to an ID of a node.
       
   118     The ID must exist in the document."
       
   119 
       
   120     ^false
       
   121 
       
   122     "Created: / 29-04-2005 / 12:19:03 / janfrog"
       
   123 !
       
   124 
       
   125 isText
       
   126     "Answer whether this datatype represents a general text.
       
   127      Such data type is used by <text/> pattern in Relax NG
       
   128     "
       
   129 
       
   130     ^false
       
   131 
       
   132     "Created: / 30-04-2005 / 17:39:55 / janfrog"
       
   133 ! !
       
   134 
       
   135 !DataType class methodsFor:'documentation'!
       
   136 
       
   137 version
       
   138     ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/relaxng/RNG__DataType.st,v 1.1.1.1 2005-11-01 22:07:13 vranyj1 Exp $'
       
   139 ! !