[xml] =?ISO-8859-1?Q?namespaces=20in=20the=20dtd=20=28xmlHasNsProp=29?=



Hello Daniel,

I am trying to declare default attributes, containing namespaces, in a dtd.

This is the xml:

  xmlstr = '<?xml version="1.0" encoding="iso-8859-1"?>'+
           '<!DOCTYPE test ['+CRLF+
           '<!ELEMENT test (#PCDATA) >'+CRLF+
           '<!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org"; >'+CRLF+
           '<!ATTLIST test abc:attr CDATA #FIXED "def" >'+CRLF+
           ']>'+CRLF+
           '<test />';

This is the code:

  ...
  attr := xmlHasNSProp(xmlElement, pchar('attr'), pchar('http://abc.org'));

  // the fixed attribute is not found
  if attr=nil then begin

      // the following statement returns the correct result
      attrDecl := xmlGetDtdQAttrDesc(xmlElement.doc.intSubset,
xmlElement.name,
      pchar('attr'),pchar('abc'));
    if assigned(attrDecl) then begin
      temp:=attrDecl.name;
      temp:=attrDecl.defaultValue;
      temp:=attrDecl.prefix;
    end;
  end;

The api-documentation says:

/**
 * xmlHasNsProp:
 * @node:  the node
 * @name:  the attribute name
 * @nameSpace:  the URI of the namespace
 *
 * Search for an attribute associated to a node
 * This attribute has to be anchored in the namespace specified.
 * This does the entity substitution.
 * This function looks in DTD attribute declaration for #FIXED or
 * default declaration values unless DTD use has been turned off.
 *
 * Returns the attribute or the attribute declaration or NULL
 *     if neither was found.
 */

But xmlHasNsProp doesn't return default attributes from the dtd.

The problem is, that in the c code of xmlHasNsProp you try to find the
attrDecl
with xmlGetDtdAttrDesc, and this function doesn't find a default attribute
bound
to a namespace, if you pass the local name.

Any comments?

Uwe Fechner




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