[xml] Id attribute detection in arbitrary namespace



Hello.

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

Here is an example:

<soapenv:Envelope
   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";>
   <soapenv:Header>
      <wsse:Security>
         <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#";>
            <ds:SignedInfo>
               <ds:Reference URI="#body"></ds:Reference>
            </ds:SignedInfo>
            <ds:SignatureValue/>
            <ds:KeyInfo>
              <ds:KeyName/>
            </ds:KeyInfo>
         </ds:Signature>
      </wsse:Security>
   </soapenv:Header>
   <soapenv:Body wsu:Id="body"></soapenv:Body>
</soapenv:Envelope>

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">
  <xsd:annotation><xsd:documentation>
    This global attribute supports annotating arbitrary
    elements with an ID.
  </xsd:documentation></xsd:annotation>
</xsd:attribute>

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]