cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kirk Woerner" <k...@stoneseeker.com>
Subject [C1][XInclude][PATCH] - XInclude DOM2 problem
Date Tue, 14 Nov 2000 15:58:29 GMT
This is a little ugly, but it works and I think it's valid.  The bug
appears when attempting to process xinclude elements that were generated
from a stylesheet.  The DOM nodes generated from within xsl are apparently
not DOM II so the checks for "getAttributeNS()" in scanForXInclude() do
not work when they should.

I do not have "diff" so I just have to explain where the fix goes.
scanForXInclude currently looks like the following.

boolean scanForXInclude(Element element, Element parent) {
  if ( element.hasAttributeNS(processor.XINCLUDE_NAMESPACE_URI,
                              processor.XINCLUDE_HREF_ATTRIBUTE) &&
       element.hasAttributeNS(processor.XINCLUDE_NAMESPACE_URI,
                              processor.XINCLUDE_PARSE_ATTRIBUTE)) {
    String href = element.getAttributeNS(processor.XINCLUDE_NAMESPACE_URI,

processor.XINCLUDE_HREF_ATTRIBUTE);
    String parse =
element.getAttributeNS(processor.XINCLUDE_NAMESPACE_URI,
                   processor.XINCLUDE_PARSE_ATTRIBUTE);
    xinclude_elements.addElement(new XIncludeElement(element,

parent,href,parse,current_xmlbase));
    return true;
  }
  return false;
}


I propose that we add two static variables to the class

	public static final String XINCLUDE_NAMESPACE_TAG = "xinclude:";
	public static final String XINCLUDE_TAG = "include";

and change scanForXInclude to be the following

boolean scanForXInclude(Element element, Element parent) {
  if ( element.hasAttributeNS(processor.XINCLUDE_NAMESPACE_URI,
                              processor.XINCLUDE_HREF_ATTRIBUTE) &&
       element.hasAttributeNS(processor.XINCLUDE_NAMESPACE_URI,
                              processor.XINCLUDE_PARSE_ATTRIBUTE)) {
    String href = element.getAttributeNS(processor.XINCLUDE_NAMESPACE_URI,

processor.XINCLUDE_HREF_ATTRIBUTE);
    String parse =
element.getAttributeNS(processor.XINCLUDE_NAMESPACE_URI,
                   processor.XINCLUDE_PARSE_ATTRIBUTE);
    xinclude_elements.addElement(new XIncludeElement(element,

parent,href,parse,current_xmlbase));
    return true;
  }

  // also allow that if the NodeName is "include" or "xinclude:include"
and there are
  // attributes "xinclude:href" and "xinclude:parse" then it's also an
XInclude Node
  if ( ( element.getNodeName().equals(processor.XINCLUDE_TAG) ||
         element.getNodeName().equals(processor.XINCLUDE_NAMESPACE_TAG +
                                      processor.XINCLUDE_TAG)) &&
       element.hasAttribute(processor.XINCLUDE_NAMESPACE_TAG +
                            processor.XINCLUDE_HREF_ATTRIBUTE) &&
       element.hasAttribute(processor.XINCLUDE_NAMESPACE_TAG +
                            processor.XINCLUDE_PARSE_ATTRIBUTE)) {
    String href = element.getAttribute(processor.XINCLUDE_NAMESPACE_TAG +
                                       processor.XINCLUDE_HREF_ATTRIBUTE);
    String parse = element.getAttribute(processor.XINCLUDE_NAMESPACE_TAG +

processor.XINCLUDE_PARSE_ATTRIBUTE);
    xinclude_elements.addElement(new XIncludeElement(element,

parent,href,parse,current_xmlbase));
    return true;
  }
  return false;
}


Mime
View raw message