trunk/XMLv2__DOMConfiguration.st
changeset 0 5057afe1ec87
equal deleted inserted replaced
-1:000000000000 0:5057afe1ec87
       
     1 "{ Package: 'stx:goodies/xmlsuite' }"
       
     2 
       
     3 "{ NameSpace: XMLv2 }"
       
     4 
       
     5 Object subclass:#DOMConfiguration
       
     6 	instanceVariableNames:'parameters'
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'XML Suite-DOM3'
       
    10 !
       
    11 
       
    12 DOMConfiguration class instanceVariableNames:'defaultParameters'
       
    13 
       
    14 "
       
    15  No other class instance variables are inherited by this class.
       
    16 "
       
    17 !
       
    18 
       
    19 
       
    20 !DOMConfiguration class methodsFor:'instance creation'!
       
    21 
       
    22 new
       
    23     ^ self basicNew initialize.
       
    24 
       
    25     "Created: / 10-08-2005 / 22:12:01 / janfrog"
       
    26 ! !
       
    27 
       
    28 !DOMConfiguration class methodsFor:'accessing'!
       
    29 
       
    30 defaultParameters
       
    31 
       
    32     defaultParameters ifNil:[
       
    33         defaultParameters := Dictionary new
       
    34             at:'canonical-form' put:false;
       
    35             at:'cdata-sections' put:true;
       
    36             at:'check-character-normalization' put:false;
       
    37             at:'comments' put:true;
       
    38             at:'datatype-normalization' put:false;
       
    39             at:'element-content-whitespace' put:true;
       
    40             at:'entities' put:true;
       
    41             at:'error-handler' put:DOMErrorHandler default;
       
    42             at:'infoset' put:true;
       
    43             at:'namespaces' put:true;
       
    44             at:'namespace-declarations' put:true;
       
    45             at:'normalize-characters' put:false;
       
    46             at:'schema-location' put:'';
       
    47             at:'schema-type' put: '';
       
    48             at:'split-cdata-sections' put: true;
       
    49             at:'validate' put: false;
       
    50             at:'validate-if-schema' put: false;
       
    51             at:'well-formed' put: true;
       
    52 
       
    53             yourself.
       
    54     ].
       
    55     ^defaultParameters
       
    56 
       
    57     "Created: / 10-08-2005 / 22:11:00 / janfrog"
       
    58 !
       
    59 
       
    60 settableParameterNames
       
    61     "Answers collection of parameters that can be set"
       
    62     
       
    63     ^ #(
       
    64         'comments'
       
    65         'error-handler'
       
    66         'cdata-sections'
       
    67         'namespaces'
       
    68     )
       
    69 
       
    70     "Created: / 10-08-2005 / 22:14:02 / janfrog"
       
    71     "Modified: / 28-12-2005 / 16:59:23 / janfrog"
       
    72 ! !
       
    73 
       
    74 !DOMConfiguration methodsFor:'DOM3 interface'!
       
    75 
       
    76 canSetParameter:name value:value
       
    77 
       
    78     ^self class settableParameterNames includes:name asLowercase
       
    79 
       
    80     "Created: / 10-08-2005 / 22:13:53 / janfrog"
       
    81     "Modified: / 28-12-2005 / 17:08:10 / janfrog"
       
    82 !
       
    83 
       
    84 getParameter:name
       
    85 
       
    86     ^parameters 
       
    87         at:name asLowercase 
       
    88         ifAbsent:[DOMException 
       
    89                     raiseErrorString:'Parameter ',name ,' not found'
       
    90                     withCode:#NOT_FOUND_ERR]
       
    91 
       
    92     "Created: / 10-08-2005 / 22:15:41 / janfrog"
       
    93     "Modified: / 11-08-2005 / 22:32:16 / janfrog"
       
    94 !
       
    95 
       
    96 parameterNames
       
    97 
       
    98     ^parameters keys
       
    99 
       
   100     "Created: / 10-08-2005 / 22:12:49 / janfrog"
       
   101 !
       
   102 
       
   103 setParameter:name value:value
       
   104 
       
   105     (self parameterNames includes:name asLowercase) ifFalse:[
       
   106         ^DOMException
       
   107             raiseErrorString:'Parameter ',name,' not found'
       
   108             withCode:#NOT_FOUND_ERR
       
   109     ].
       
   110     (self canSetParameter:name asLowercase value:value) ifFalse:[
       
   111         ^DOMException
       
   112             raiseErrorString:'Parameter ',name,' cannot be set'
       
   113             withCode:#NOT_SUPPORTED_ERR
       
   114     ].
       
   115     parameters at:name asLowercase put:value
       
   116 
       
   117     "Created: / 10-08-2005 / 22:21:45 / janfrog"
       
   118     "Modified: / 11-08-2005 / 22:32:16 / janfrog"
       
   119 ! !
       
   120 
       
   121 !DOMConfiguration methodsFor:'initialization'!
       
   122 
       
   123 initialize
       
   124 
       
   125     parameters := self class defaultParameters copy
       
   126 
       
   127     "Created: / 10-08-2005 / 22:12:01 / janfrog"
       
   128 ! !
       
   129 
       
   130 !DOMConfiguration class methodsFor:'documentation'!
       
   131 
       
   132 version
       
   133     ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/XMLv2__DOMConfiguration.st,v 1.3 2005-12-28 16:15:33 vranyj1 Exp $'
       
   134 ! !