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

[xml] Re: Attributes without knowing name



> I'm working on an XML cryptographic signer, both in Java and in C++. The
> Java version (Using Xerces) is finished, but I have now hit a problem
> in the C++ version (Using libxml).

> When signing, the string that is signed must be identical to the one
> which is checked at some later time. The problem with this and XML
> is that attribute order isn't important, and libxml and Xerces orders
> them diffrently, so I need to sort them. The signer must be general,
> so it shouldn't need to know the names of the attributes in the
> given element. So, I need to get all the attributes from an element
> without knowing the names of these attributes. I was looking at the
> documentation, for something like: 
> 
> xmlGetPropCount(xmlNodePtr node);
> 
> and 
> 
> xmlGetProp(xmlNodePtr node, int index); 
> 
> ... but I couldn't find anything like this, or anything that could do
> the job. Is what I'm attempting possible, and if so, how?
> 
> *********************************************************
> Christian Rygg - EDB Fellesdata
> Avd. for sikkerhet - Bergen
> Telefon-55204658
> Mobil - 92433995
> *********************************************************

I have encountered a similar need to order attribute elements, but my
question centers around the DTD specification:

Regarding the linked list xmlAttributePtr in xmlElementPtr:  are the
nodes in this list guaranteed to be in the same order in which the same
attributes appear in the DTD?

Code which produces an attribute list as a function of element name,
and based on the DTD is as follows:

xmlAttributePtr dtdGetAttrList(xmlChar *elemName){
   xmlDtdPtr dtd;
   xmlChar *uri;
   xmlChar *SystemID="my.dtd";
   xmlElementPtr elem;
   xmlAttributePtr attribute = NULL;

   uri = xmlBuildURI(SystemID,NULL);
   dtd = xmlParseDTD(NULL,uri);
   elem = xmlGetDtdElementDesc(dtd,elemName);
   return attribute = elem->attributes;
}



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