Class: WirisPlugin::XmlSerializer

Inherits:
Object
  • Object
show all
Includes:
Wiris
Defined in:
lib/com/wiris/util/xml/XmlSerializer.rb

Constant Summary collapse

MODE_READ =
0
MODE_WRITE =
1
MODE_REGISTER =
2
MODE_CACHE =
3

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeXmlSerializer

Returns a new instance of XmlSerializer.



25
26
27
28
29
30
31
32
33
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 25

def initialize()
    super()
    @tags = Hash.new()
    @elementStack = Array.new()
    @childrenStack = Array.new()
    @childStack = Array.new()
    self.cacheTagStackCount = 0
    self.ignoreTagStackCount = 0
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



21
22
23
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 21

def cache
  @cache
end

#cacheTagStackCountObject

Returns the value of attribute cacheTagStackCount.



22
23
24
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 22

def cacheTagStackCount
  @cacheTagStackCount
end

#childObject

Returns the value of attribute child.



14
15
16
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 14

def child
  @child
end

#childrenObject

Returns the value of attribute children.



13
14
15
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 13

def children
  @children
end

#childrenStackObject

Returns the value of attribute childrenStack.



16
17
18
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 16

def childrenStack
  @childrenStack
end

#childStackObject

Returns the value of attribute childStack.



17
18
19
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 17

def childStack
  @childStack
end

#currentTagObject

Returns the value of attribute currentTag.



20
21
22
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 20

def currentTag
  @currentTag
end

#elementObject

Returns the value of attribute element.



12
13
14
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 12

def element
  @element
end

#elementStackObject

Returns the value of attribute elementStack.



15
16
17
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 15

def elementStack
  @elementStack
end

#ignoreObject

Returns the value of attribute ignore.



23
24
25
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 23

def ignore
  @ignore
end

#ignoreTagStackCountObject

Returns the value of attribute ignoreTagStackCount.



24
25
26
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 24

def ignoreTagStackCount
  @ignoreTagStackCount
end

#modeObject

Returns the value of attribute mode.



11
12
13
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 11

def mode
  @mode
end

#rawxmlsObject

Returns the value of attribute rawxmls.



19
20
21
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 19

def rawxmls
  @rawxmls
end

#tagsObject

Returns the value of attribute tags.



18
19
20
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 18

def tags
  @tags
end

Class Method Details

.booleanToString(b) ⇒ Object



435
436
437
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 435

def self.booleanToString(b)
    return b ? "true" : "false"
end

.compareStrings(a, b) ⇒ Object



516
517
518
519
520
521
522
523
524
525
526
527
528
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 516

def self.compareStrings(a, b)
    an = a::length()
    bn = b::length()
    n = (an > bn) ? bn : an
    for i in 0..n - 1
        c = Std::charCodeAt(a,i) - Std::charCodeAt(b,i)
        if c != 0
            return c
        end
        i+=1
    end
    return a::length() - b::length()
end

.getXmlTextContent(element) ⇒ Object



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 296

def self.getXmlTextContent(element)
    if (element::nodeType == Xml::CData) || (element::nodeType == Xml::PCData)
        return WXmlUtils::getNodeValue(element)
    else 
        if (element::nodeType == Xml::Document) || (element::nodeType == Xml::Element)
            sb = StringBuf.new()
            children = element::iterator()
            while children::hasNext()
                sb::add(XmlSerializer.getXmlTextContent(children::next()))
            end
            return sb::toString()
        else 
            return ""
        end
    end
end

.parseBoolean(s) ⇒ Object



432
433
434
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 432

def self.parseBoolean(s)
    return (s::toLowerCase() == "true") || (s == "1")
end

Instance Method Details

#arrayToString(a) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 186

def arrayToString(a)
    if a == nil
        return nil
    end
    sb = StringBuf.new()
    for i in 0..a::length - 1
        if i != 0
            sb::add(",")
        end
        sb::add(a[i].to_s + "")
        i+=1
    end
    return sb::toString()
end

#attributeBoolean(name, value, def_) ⇒ Object



174
175
176
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 174

def attributeBoolean(name, value, def_)
    return XmlSerializer::parseBoolean(attributeString(name,XmlSerializer::booleanToString(value),XmlSerializer::booleanToString(def_)))
end

#attributeFloat(name, value, def_) ⇒ Object



232
233
234
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 232

def attributeFloat(name, value, def_)
    return Std::parseFloat(attributeString(name,"" + value.to_s,"" + def_.to_s))
end

#attributeInt(name, value, def_) ⇒ Object



177
178
179
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 177

def attributeInt(name, value, def_)
    return Std::parseInt(attributeString(name,"" + value.to_s,"" + def_.to_s))
end

#attributeIntArray(name, value, def_) ⇒ Object



180
181
182
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 180

def attributeIntArray(name, value, def_)
    return stringToArray(attributeString(name,arrayToString(value),arrayToString(def_)))
end

#attributeString(name, value, def_) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 147

def attributeString(name, value, def_)
    if self.mode == XmlSerializer::MODE_READ
        value = WXmlUtils::getAttribute(self.element,name)
        if value == nil
            value = def_
        end
    else 
        if self.mode == XmlSerializer::MODE_WRITE
            if ((value != nil) && !((value == def_))) && (self.ignoreTagStackCount == 0)
                WXmlUtils::setAttribute(self.element,name,value)
            end
        end
    end
    return value
end

#attributeStringArray(name, value, def_) ⇒ Object



183
184
185
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 183

def attributeStringArray(name, value, def_)
    return stringToArrayString(attributeString(name,stringArrayToString(value),stringArrayToString(def_)))
end

#base64Content(data) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 261

def base64Content(data)
    b64 = BaseCode.new(Bytes::ofString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"))
    if @mode == MODE_READ
        content = textContent(nil)
        data = b64::decodeBytes(Bytes::ofString(content))
    else 
        if @mode == MODE_WRITE
            textContent(b64::encodeBytes(data)::toString())
        end
    end
    return data
end

#beginCacheObject



453
454
455
456
457
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 453

def beginCache()
    if self.cache && (self.mode == XmlSerializer::MODE_WRITE)
        self.mode = XmlSerializer::MODE_CACHE
    end
end

#beginTag(tag) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 94

def beginTag(tag)
    if @mode == MODE_READ
        if ((self.currentChild() != nil) && (self.currentChild()::nodeType == Xml::Element)) && (tag == self.currentChild()::nodeName)
            self.pushState()
            self.setCurrentElement(self.currentChild())
        else 
            return false
        end
    else 
        if @mode == MODE_WRITE
            if self.isIgnoreTag(tag) || (self.ignoreTagStackCount > 0)
                self.ignoreTagStackCount+=1
            else 
                child = @element::createElement_(tag)
                @element::addChild(child)
                @element = child
            end
        else 
            if (@mode == MODE_REGISTER) && (self.currentTag == nil)
                self.currentTag = tag
            else 
                if @mode == MODE_CACHE
                    self.cacheTagStackCount+=1
                end
            end
        end
    end
    return true
end

#beginTagIf(tag, current, desired) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 70

def beginTagIf(tag, current, desired)
    if @mode == MODE_READ
        if beginTag(tag)
            return desired
        end
    else 
        if current == desired
            beginTag(tag)
        end
    end
    return current
end

#beginTagIfBool(tag, current, desired) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 82

def beginTagIfBool(tag, current, desired)
    if @mode == MODE_READ
        if beginTag(tag)
            return desired
        end
    else 
        if current == desired
            beginTag(tag)
        end
    end
    return current
end

#booleanContent(content) ⇒ Object



290
291
292
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 290

def booleanContent(content)
    return XmlSerializer::parseBoolean(textContent(XmlSerializer::booleanToString(content)))
end

#cacheAttribute(name, value, def_) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 162

def cacheAttribute(name, value, def_)
    if self.mode == XmlSerializer::MODE_WRITE
        if self.cache
            value = attributeString(name,value,def_)
            self.mode = XmlSerializer::MODE_CACHE
            self.cacheTagStackCount = 0
        end
    else 
        value = attributeString(name,value,def_)
    end
    return value
end

#childInt(name, value, def_) ⇒ Object



447
448
449
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 447

def childInt(name, value, def_)
    return Std::parseInt(childString(name,"" + value.to_s,"" + def_.to_s))
end

#childString(name, value, def_) ⇒ Object



438
439
440
441
442
443
444
445
446
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 438

def childString(name, value, def_)
    if !((@mode == MODE_WRITE) && (((value == nil) && (def_ == nil)) || ((value != nil) && (value == def_))))
        if self.beginTag(name)
            value = textContent(value)
            self.endTag()
        end
    end
    return value
end

#currentChildObject



416
417
418
419
420
421
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 416

def currentChild()
    if (self.child == nil) && @children::hasNext()
        self.child = @children::next()
    end
    return self.child
end

#endCacheObject



458
459
460
461
462
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 458

def endCache()
    if self.mode == XmlSerializer::MODE_CACHE
        self.mode = XmlSerializer::MODE_WRITE
    end
end

#endTagObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 123

def endTag()
    if self.mode == MODE_READ
        self.element = @element::parent_()
        self.popState()
        self.nextChild()
    else 
        if self.mode == MODE_WRITE
            if self.ignoreTagStackCount > 0
                self.ignoreTagStackCount-=1
            else 
                self.element = @element::parent_()
            end
        else 
            if self.mode == MODE_CACHE
                if self.cacheTagStackCount > 0
                    self.cacheTagStackCount-=1
                else 
                    self.mode = MODE_WRITE
                    self.element = @element::parent_()
                end
            end
        end
    end
end

#floatContent(d) ⇒ Object



293
294
295
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 293

def floatContent(d)
    return Std::parseFloat(textContent(d.to_s + ""))
end

#getMainTag(xml) ⇒ Object



463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 463

def getMainTag(xml)
    i = 0
    loop do
        i = xml::indexOf("<",i)
        i+=1
        c = Std::charCodeAt(xml,i)
    break if not (c != 33) && (c != 63)
    end
    _end = [">", " ", "/"]
    min = 0
    for j in 0.._end::length - 1
        n = xml::indexOf(_end[j])
        if (n != -1) && (n < min)
            n = min
        end
        j+=1
    end
    return Std::substr(xml,i,min)
end

#getModeObject



34
35
36
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 34

def getMode()
    return self.mode
end

#getTagName(elem) ⇒ Object



383
384
385
386
387
388
389
390
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 383

def getTagName(elem)
    mode = self.mode
    self.mode = XmlSerializer::MODE_REGISTER
    self.currentTag = nil
    elem::onSerialize(self)
    self.mode = mode
    return self.currentTag
end

#isIgnoreTag(s) ⇒ Object



505
506
507
508
509
510
511
512
513
514
515
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 505

def isIgnoreTag(s)
    if self.ignore != nil
        i = self.ignore::iterator()
        while i::hasNext()
            if (i::next() == s)
                return true
            end
        end
    end
    return false
end

#nextChildObject



408
409
410
411
412
413
414
415
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 408

def nextChild()
    if @children::hasNext()
        self.child = @children::next()
    else 
        self.child = nil
    end
    return self.child
end

#popStateObject



427
428
429
430
431
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 427

def popState()
    self.element = self.elementStack::pop()
    self.children = self.childrenStack::pop()
    self.child = self.childStack::pop()
end

#pushStateObject



422
423
424
425
426
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 422

def pushState()
    self.elementStack::push(self.element)
    self.childrenStack::push(self.children)
    self.childStack::push(self.child)
end

#rawXml(xml) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 273

def rawXml(xml)
    if self.mode == MODE_READ
        raise Exception,"Should not use rawXml() function on read operation!"
    else 
        if self.mode == MODE_WRITE
            raw = @element::createElement_("rawXml")
            raw::set("id","" + self.rawxmls::length().to_s)
            self.rawxmls::push(xml)
            self.element::addChild(raw)
        else 
            if self.mode == MODE_REGISTER
                self.currentTag = self.getMainTag(xml)
            end
        end
    end
    return xml
end

#read(xml) ⇒ Object



37
38
39
40
41
42
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 37

def read(xml)
    document = Xml::parse(xml)
    self.setCurrentElement(document)
    self.mode = XmlSerializer::MODE_READ
    return readNode()
end

#readNodeObject



391
392
393
394
395
396
397
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 391

def readNode()
    if !self.tags::exists(self.currentChild()::nodeName)
        raise Exception,("Tag " + self.currentChild()::nodeName.to_s) + " not registered."
    end
    model = self.tags::get(self.currentChild()::nodeName)
    return readNodeModel(model)
end

#readNodeModel(model) ⇒ Object



398
399
400
401
402
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 398

def readNodeModel(model)
    node = model::newInstance()
    node::onSerialize(self)
    return node
end

#readXml(xml) ⇒ Object



43
44
45
46
47
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 43

def readXml(xml)
    self.setCurrentElement(xml)
    self.mode = XmlSerializer::MODE_READ
    return readNode()
end

#register(elem) ⇒ Object



380
381
382
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 380

def register(elem)
    self.tags::set(self.getTagName(elem),elem)
end

#serializeArray(array, tagName) ⇒ Object



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 327

def serializeArray(array, tagName)
    if self.mode == XmlSerializer::MODE_READ
        array = Array.new()
        child = self.currentChild()
        while (child != nil) && ((tagName == nil) || (tagName == child::nodeName))
            elem = (self.readNode())
            array::push(elem)
            child = self.currentChild()
        end
    else 
        if ((self.mode == XmlSerializer::MODE_WRITE) && (array != nil)) && (array::length() > 0)
            items = array::iterator()
            while items::hasNext()
                (items::next())::onSerialize(self)
            end
        end
    end
    return array
end

#serializeArrayName(array, tagName) ⇒ Object



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 359

def serializeArrayName(array, tagName)
    if self.mode == MODE_READ
        if beginTag(tagName)
            array = serializeArray(array,nil)
            endTag()
        end
    else 
        if ((self.mode == MODE_WRITE) && (array != nil)) && (array::length() > 0)
            element = self.element
            self.element = element::createElement_(tagName)
            element::addChild(self.element)
            array = self.serializeArray(array,nil)
            self.element = element
        else 
            if self.mode == MODE_REGISTER
                self.beginTag(tagName)
            end
        end
    end
    return array
end

#serializeChild(s) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 312

def serializeChild(s)
    if self.mode == XmlSerializer::MODE_READ
        child = self.currentChild()
        if child != nil
            s = (self.readNode())
        else 
            s = nil
        end
    else 
        if (self.mode == XmlSerializer::MODE_WRITE) && (s != nil)
            (s)::onSerialize(self)
        end
    end
    return s
end

#serializeChildName(s, tagName) ⇒ Object



346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 346

def serializeChildName(s, tagName)
    if self.mode == MODE_READ
        child = self.currentChild()
        if (child != nil) && (child::nodeName == tagName)
            s = self.serializeChild(s)
        end
    else 
        if self.mode == MODE_WRITE
            s = self.serializeChild(s)
        end
    end
    return s
end

#serializeXml(tag, elem) ⇒ Object



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 482

def serializeXml(tag, elem)
    if self.mode == MODE_READ
        if (tag == nil) || ((self.currentChild() != nil) && (self.currentChild()::nodeName == tag))
            elem = self.currentChild()
            self.nextChild()
        end
    else 
        if self.mode == MODE_WRITE
            if (elem != nil) && (self.ignoreTagStackCount == 0)
                imported = WXmlUtils::importXml(elem,self.element)
                self.element::addChild(imported)
            end
        else 
            if self.mode == MODE_REGISTER
                self.beginTag(tag)
            end
        end
    end
    return elem
end

#setCached(cache) ⇒ Object



450
451
452
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 450

def setCached(cache)
    self.cache = cache
end

#setCurrentElement(element) ⇒ Object



403
404
405
406
407
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 403

def setCurrentElement(element)
    self.element = element
    self.children = self.element::elements()
    self.child = nil
end

#setIgnoreTags(ignore) ⇒ Object



502
503
504
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 502

def setIgnoreTags(ignore)
    self.ignore = ignore
end

#stringArrayToString(a) ⇒ Object



200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 200

def stringArrayToString(a)
    if a == nil
        return nil
    end
    sb = StringBuf.new()
    for i in 0..a::length - 1
        if i != 0
            sb::add(",")
        end
        sb::add(a[i])
        i+=1
    end
    return sb::toString()
end

#stringToArray(s) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 220

def stringToArray(s)
    if s == nil
        return nil
    end
    ss = s::split(",")
    a = []
    for i in 0..ss::length - 1
        a[i] = Std::parseInt(ss[i])
        i+=1
    end
    return a
end

#stringToArrayString(s) ⇒ Object



214
215
216
217
218
219
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 214

def stringToArrayString(s)
    if s == nil
        return nil
    end
    return s::split(",")
end

#textContent(content) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 235

def textContent(content)
    if self.mode == MODE_READ
        content = XmlSerializer::getXmlTextContent(self.element)
    else 
        if ((self.mode == MODE_WRITE) && (content != nil)) && (self.ignoreTagStackCount == 0)
            if (content::length() > 100) || (StringTools::startsWith(content,"<") && StringTools::endsWith(content,">"))
                k = content::indexOf("]]>")
                i = 0
                while k > -1
                    subcontent = Std::substr(content,i,(k - i) + 2)
                    textNode = @element::createCData_(subcontent)
                    self.element::addChild(textNode)
                    i = k + 2
                    k = content::indexOf("]]>",i)
                end
                str = Std::substr(content,i)
                textNode = @element::createCData_(str)
                self.element::addChild(textNode)
            else 
                textNode = WXmlUtils::createPCData(@element,content)
                self.element::addChild(textNode)
            end
        end
    end
    return content
end

#write(s) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/com/wiris/util/xml/XmlSerializer.rb', line 48

def write(s)
    self.mode = XmlSerializer::MODE_WRITE
    self.element = Xml::createDocument()
    self.rawxmls = Array.new()
    s::onSerialize(self)
    res = self.element::toString()
    if StringTools::startsWith(res,"<__document")
        res = Std::substr(res,res::indexOf(">") + 1)
    end
    if StringTools::endsWith(res,"</__document>")
        res = Std::substr(res,0,res::length() - "</__document>"::length())
    end
    for i in 0..self.rawxmls::length() - 1
        start = res::indexOf(("<rawXml id=\"" + i.to_s) + "\"")
        if start != -1
            _end = res::indexOf(">",start)
            res = (Std::substr(res,0,start).to_s + self.rawxmls::_(i).to_s) + Std::substr(res,_end + 1).to_s
        end
        i+=1
    end
    return res
end