Re: [xslt] Transformation result DOM document does not honor xml:id

On Mon, Apr 06, 2009 at 04:03:09PM +0200, Michael Ludwig wrote:
> The result DOM document of a transformation does not honor the automatic
> ID-ness of an xml:id attribute. My feeling, which may of course be
> wrong, is that it should. But unlike Daniel, I wasn't among the editors
> of the xml:id specification.
> So should xml:id be honored in this case, or shouldn't it?

  Hum ... that's I think a bug in libxslt (or possibly libxml2 when
the attribute is added). I must admit xml:id was more though in the
context of a parser while here the document is generated by creating
the tree/DOM, still I think this should be fixed.

 I think I found the fix, due to an optimization in libxslt which
broke the ID tagging of the attribute when generated. See attached


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library
diff --git a/libxslt/attributes.c b/libxslt/attributes.c
index 168dae6..ce47df7 100644
--- a/libxslt/attributes.c
+++ b/libxslt/attributes.c
@@ -978,6 +978,13 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt,
 	if (inst->children->name == xmlStringTextNoenc)
 	    copyTxt->name = xmlStringTextNoenc;	
+        /*
+         * since we create the attribute without content IDness must be
+         * asserted as a second step
+         */
+        if ((copyTxt->content != NULL) &&
+            (xmlIsID(attr->doc, attr->parent, attr)))
+            xmlAddID(NULL, attr->doc, copyTxt->content, attr);
     } else {
 	* The sequence constructor might be complex, so instantiate it.

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