XalanC
  1. XalanC
  2. XALANC-609

Template with built-in template rules for namespaces gives and assert

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: CurrentCVS
    • Fix Version/s: CurrentCVS
    • Component/s: XalanC
    • Labels:
      None
    • Environment:
      all

      Description

      Stylesheet:
      <xsl:template match="/">
      <out>
      <xsl:apply-templates select="//namespace::*"/>
      </out>
      </xsl:template>

      and an input document:
      <?xml version="1.0"?>
      <doc xmlns="default.uri">
      <!-Comment 1->
      <item xmlns:one="http://one.org" xmlns:two="http://two.org">
      <inner>Some text <!-Comment 3->
      <sub-inner xmlns:one="http://example.org"/>
      </inner>
      </item>
      <item/>
      <item></item>
      </doc>

      Gives :
      Assertion failed: DOMServices::isNamespaceDeclaration(static_cast<const XalanAtt
      r&>(theNode)) == false, file \src\xalanc\Xslt\Stylesheet.cpp, line 1093

      1. patch.diff
        2 kB
        Dmitry Hayes

        Activity

        Dmitry Hayes created issue -
        Hide
        David Bertoni added a comment -

        It's amazing we haven't hit this bug before, since it's been in the processor for years.

        I think the best fix is to add a static instance of an empty list, then convert the assert to an actual if test:

        #if defined(XALAN_OLD_STYLE_CASTS)
        if (DOMServices::isNamespaceDeclaration((const XalanAttr&)theNode) == true)
        #else
        if ((DOMServices::isNamespaceDeclaration(static_cast<const XalanAttr&>(theNode)) == true)
        #endif

        { return &s_emptyTemplateList; }

        We'll also have to filter out the namespace nodes in ElemTemplateElement::findTemplateToTransformChild():

        case XalanNode::CDATA_SECTION_NODE:
        case XalanNode::TEXT_NODE:
        theTemplate = getStylesheet().getStylesheetRoot().getDefaultTextRule();
        break;

        case XalanNode::ATTRIBUTE_NODE:
        if (DOMServices::isNamespaceDeclaration(static_cast<const XalanAttr&>(*child)) == false)

        { theTemplate = getStylesheet().getStylesheetRoot().getDefaultTextRule(); }

        break;

        This is a potential performance issue, and points out why we shouldn't be using attributes to represent namespace nodes. It's just another one of the many issues with representing the source tree as an instance of the DOM.

        Show
        David Bertoni added a comment - It's amazing we haven't hit this bug before, since it's been in the processor for years. I think the best fix is to add a static instance of an empty list, then convert the assert to an actual if test: #if defined(XALAN_OLD_STYLE_CASTS) if (DOMServices::isNamespaceDeclaration((const XalanAttr&)theNode) == true) #else if ((DOMServices::isNamespaceDeclaration(static_cast<const XalanAttr&>(theNode)) == true) #endif { return &s_emptyTemplateList; } We'll also have to filter out the namespace nodes in ElemTemplateElement::findTemplateToTransformChild(): case XalanNode::CDATA_SECTION_NODE: case XalanNode::TEXT_NODE: theTemplate = getStylesheet().getStylesheetRoot().getDefaultTextRule(); break; case XalanNode::ATTRIBUTE_NODE: if (DOMServices::isNamespaceDeclaration(static_cast<const XalanAttr&>(*child)) == false) { theTemplate = getStylesheet().getStylesheetRoot().getDefaultTextRule(); } break; This is a potential performance issue, and points out why we shouldn't be using attributes to represent namespace nodes. It's just another one of the many issues with representing the source tree as an instance of the DOM.
        Dmitry Hayes made changes -
        Field Original Value New Value
        Assignee Dmitry Hayes [ dmitryh ]
        Hide
        Dmitry Hayes added a comment -

        Patch for the problem. Please review ! Thanks!

        Show
        Dmitry Hayes added a comment - Patch for the problem. Please review ! Thanks!
        Dmitry Hayes made changes -
        Attachment patch.diff [ 12323960 ]
        Hide
        Ashley Zinyk added a comment -

        Dmitry's patch looks good to me.

        Show
        Ashley Zinyk added a comment - Dmitry's patch looks good to me.
        Hide
        David Bertoni added a comment -

        Let's apply this patch.

        Show
        David Bertoni added a comment - Let's apply this patch.
        Dmitry Hayes made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12347307 ] Default workflow, editable Closed status [ 12572337 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12572337 ] jira [ 12592602 ]

          People

          • Assignee:
            Dmitry Hayes
            Reporter:
            Dmitry Hayes
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development