[xsd-users] xlink href use of idref class

Laurence Davies laurence.davies at unsw.edu.au
Wed Sep 2 03:34:18 EDT 2015


Hi Boris,

I'm revisiting the xlink.href idref feature of XSD, as per the below email from you in 2008. My question is with regards to the scope of the search that idref carries out when calling get(). In the below code you initialise the idref as follows

    color_t& color = ... // reference to an object containing href
    xml_schema::idref ref (href, 0, &color);

The `color` element is a "reference to an object containing href". Does this mean that color is a _type object which contains a tree of children, one of which containing a _tree object with ID==href? Or does it explicitly mean that color.ID==href?

The reason I ask is because I am streaming a document as it is being parsed into custom classes and discarding the generated _type objects. Thus for the href to point to something valid, I need to know where XSD is looking for said valid object.

Thank you and regards,
Laurence

> Boris Kolpackov boris at codesynthesis.com 
> Fri Aug 8 04:39:13 EDT 2008
> 
> I checked the GML schema and the gml:id attribute is of xsd:ID type. If
> all href attributes always refer one of those gml:id attributes then this
> is pretty simple to do:
> 
> std::string href = ... // contains "COLOR_70", without #
> color_t& color = ... // reference to an object containing href
> 
> xml_schema::idref ref (href, 0, &color);
> xml_schema::type* p = ref.get (); // p points to the object with ID COLOR_70
> 
> // Now you can use static_cast (if you are sure about the type of p) or
> // dynamic_cast (if you are not) to cast it to the Color_t type.
> 
> If you cannot assume that all href attributes point to one of the gml:id
> attributes (or other attributes as long as they are of the xsd:ID type)
> then things get a bit more complex. Let me know if this is the case and
> I will describe how this can be done.



Laurence Davies
____________________
Research Assistant in eGeodesy
CRC-SI, UNSW
Desk phone: (03) 8636 2373
Mobile: 0427 519 289



More information about the xsd-users mailing list