Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: SVG DOM

From: "Adam Badura" <abadura@--.-->
To: NULL
Date: 10/1/2009 4:39:00 PM
>> It seems the intended way to reuse LINQ to XML classes is the annotation 
>> feature:
>> http://blogs.msdn.com/mikechampion/archive/2006/08/17/705278.aspx
>
>    This seems fine enough. And possibility to "inject methods" through 
> extensions seems very helpful as well (an example shown in 
> http://blogs.msdn.com/mikechampion/archive/2006/09/10/748408.aspx).
>    However after few small code experiments I came to a conclusion that it 
> might not be enough. I considered adding classes with SVG DOM-like 
> properties as annotations to the XElements. An example is the base IDL 
> SVGElement which contains attributes "id" and "xmlbase" (referring to "id" 
> element attribute and "xml:base" element attribute). I changed it to an 
> SvgElement class with Id and XmlBase properties. But then natural question 
> occurs: should those be get only or get/set? In the IDL's SVGElement they 
> are get/set (with some restrictions).  If I was to support the setting how 
> would I do that? I considered constructing my SvgElement with XElement (to 
> which it referrers) given during construction and not only reading 
> appropriate data but also storing the XElement to be able latter to set 
> the data in setters.

    There is yet another solution. Instead of adding annotation data I could 
use extension methods. To continue the example I could make GetId and SetId 
extension methods for XElement. This could be generalized to other functions 
and attributes defined in SVG DOM. (Functions and attributes for more 
specific SVG elements could just check at the beginning whether the "this" 
XElement is the required one.)
    However again there are some drawbacks. First attributes no longer can 
be mapped to properties as there are no "extension properties" (pity, as I 
like properties very much). I have to have Set* and Get* methods. But this 
is a minor issue. A more important one is that the values returned by 
functions will have to be computed each time anew since the extension 
methods do not have any "memory". I might want to make some kind of cache in 
the class defining the extension method this however seems quite complex (to 
update the cache upon value change) and will be hard to control (so that the 
cache does not grow to large storing xml trees already unused).
    So after all I think that DOM-like extending System.Xml.Linq classes is 
kind of hard if at all possible.

    Adam Badura 



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent