[xml] Id attribute detection in arbitrary namespace


We discovered a problem with Id attribute detection, defined
as a global attribute in some external schema.

Here is an example:



         <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#";>
               <ds:Reference URI="#body"></ds:Reference>
   <soapenv:Body wsu:Id="body"></soapenv:Body>

Attribute "wsu:Id" is not detected as an Id attribute,
because libxml2 knows nothing about its type,
defined in wss-wssecurity-utility-1.0.xsd:

<!-- // Global attributes // -->
<xsd:attribute name="Id" type="xsd:ID">
    This global attribute supports annotating arbitrary
    elements with an ID.

As a result any library, such as xmlsec as an example,
cannot process such documents using "id()"
XPath expression.

Function xmlIsID can use DTD for Id detection,
but DTD does not allow to describe
the global attributes.

Is there known solution for this issue?

Currently just a difficult decision comes to mind:

1. Create in xmlDtd additional hash table
   for global attributes if any.
2. Modify xmlAddAttributeDecl to allow elem argument to be
   NULL (and use in such case new hash table).
3. Modify xmlGetDtdAttrDesc and xmlGetDtdQAttrDesc
   to allow elem argument to be NULL (and use in such case
   only new hash table) and implement search on both
   hash tables for normal and global attributes.
4. Modify '<!ATTLIST' parsing or simply use
   xmlAddAttributeDecl to manually create
   global attributes list.
5. Detect namespace declaration on xmlSAX2AttributeInternal
   and call global attribute list correction.

However, such modifications can lead to unpredictable consequences, especially in default and fixed attributes processing.
A good knowledge of the library are nessessary.

Therefore I would like to hope that there is
more simple solution.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]