Changeset 2038

Show
Ignore:
Timestamp:
07/28/10 11:42:50 (6 weeks ago)
Author:
x.pechoultres@…
Message:

Dom3 :

+ Document::minimize? option to reduce generated xml files
+ escape attribute string with (see XML Spec / 2.3)

Location:
trunk/modules/Dom3/source
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/Dom3/source/print.cl

    r2016 r2038  
    2121// just prints spaces according to the indentation level 
    2222[indent(n:Node) : string 
    23 -> let res := "\n" 
    24    in (for i in (2 .. indentlevel(n) - 1) res :/+ "\t", res)] 
     23-> if (n.ownerDocument.minimize?) "" else 
     24        let res := "\n" 
     25        in (for i in (2 .. indentlevel(n) - 1) res :/+ "\t", res)] 
    2526 
    2627// @chapter 4 
     
    2829[print(a:Attr) : void 
    2930-> if (known?(value,a) & known?(name,a)) 
    30         printf(" ~A=\"~A\"",a.name,a.value)] 
     31        printf(" ~A=\"~A\"",a.name,strescape(a.value))] 
    3132// @chapter 4 
    3233// prints an attribute (attrName="attrValue") 
    3334[print(a:Attr,indent?:boolean) : void 
    34 -> if (known?(value,a) & known?(name,a)) 
    35         printf("~A~A=\"~A\"",(if indent? indent(a) else " "),a.name,a.value)] 
     35-> if (a.ownerDocument.minimize?) indent? := false, 
     36        if (known?(value,a) & known?(name,a)) 
     37        printf("~A~A=\"~A\"",(if indent? indent(a) else " "),a.name,strescape(a.value))] 
    3638 
    3739 
     
    126128                        else if(strncmp(src,\"#39;\",4) == 0) {*travel++ = '\\''; src += 4;} 
    127129                        else if(strncmp(src,\"amp;\",4) == 0) {*travel++ = '&'; src += 4;} 
     130                        else if(strncmp(src,\"apos;\",5) == 0) {*travel++ = '\\''; src += 5;} 
    128131                        else if(strncmp(src,\"quot;\",5) == 0) {*travel++ = '\"'; src += 5;} 
    129132                        else {*travel++ = '&'; *travel++ = *src++; } 
  • trunk/modules/Dom3/source/read.cl

    r2025 r2038  
    1111                let key := _graph[2 * i - 1], 
    1212                        _value := _graph[2 * i] in 
    13                 (if known?(key) setAttribute(n,key,_value)), 
     13                (if known?(key) setAttribute(n,key,strunescape(_value))), 
    1414                //[3] << domStartHandler, 
    1515        n)] 
  • trunk/modules/Dom3/source/xmlcore.cl

    r2025 r2038  
    9191                implementation:DOMImplementation = DOMImplementation(), 
    9292                documentElement:Element, 
     93                minimize?:boolean = false, 
    9394                mime:string = "application/xml", 
    9495                interfaceEncoding:string = "UTF-8", // encoding used when getting string