collada-dom: cannot add xmlns:math attribute to <COLLADA> ta

From the collada exmples I’ve seen that include formulas, all of them use xmlns:math and include a

xmlns:math=“MathML Namespace

attribute in the COLLADA tag. I’ve tried to do this in collada-dom with no success by:

daeSafeCast<domCOLLADA>(doc->getDomRoot())->setAttribute(“xmlns:math”,“MathML Namespace”);

The problem is that collada-dom limits the attributes that could be set and does not allow a xmlns:math attribute. As a quick hack, I ended up modifying and using a local copy of collada-dom with the xmlns:math attribute properly added in domCOLLADA.cpp… but it would be great to find a solution that does not involve local changes.

i also posted the bug report here:
https://sourceforge.net/tracker/?func=d … tid=805424

Hi,

unfortunatly the code generator doesn’t support the mathml namspace. So we changed the code, too. :?

domFormula* formula = …
if(formula)
{
formula->setId(id.c_str());
formula->setNSUri(“MathML Namespace”);

}
Now the MathML Elements can be attached - don’t forget to set the “mathml:” prefix for each MathML element :wink:
Patch for current DOM attached

==
Index: include/1.5/dom/domFormula.h

— include/1.5/dom/domFormula.h (revision 844)
+++ include/1.5/dom/domFormula.h (working copy)
@@ -21,6 +21,7 @@
xsID attrId;
xsToken attrName;
domSid attrSid;

  • xsToken attrNSUri;

protected: // Elements
domFormula_newparam_Array elemNewparam_array;
@@ -65,6 +66,17 @@
void setSid( domSid atSid ) { (daeStringRef)&attrSid = atSid;}

/**
    • Gets the sid attribute.
    • @return Returns a domSid of the sid attribute.
  • */
  • xsToken getNSUri() const { return attrNSUri; }
  • /**
    • Sets the sid attribute.
    • @param atSid The new value for the sid attribute.
  • */
  • void setNSUri( xsToken atNSUri ) { (daeStringRef)&attrNSUri = atNSUri;}
  • /**
    • Gets the newparam element array.
    • @return Returns a reference to the array of newparam elements.
      /
      @@ -98,7 +110,7 @@
      /
      *
    • Constructor
      */
  • domFormula(DAE& dae) : daeElement(dae), attrId(), attrName(), attrSid(), elemNewparam_array(), elemTarget(), elemTechnique_common(), elemTechnique_array() {}
  • domFormula(DAE& dae) : daeElement(dae), attrId(), attrName(), attrSid(), attrNSUri(), elemNewparam_array(), elemTarget(), elemTechnique_common(), elemTechnique_array() {}
    /**

    • Destructor
      */
      Index: src/1.5/dom/domFormula.cpp
      ===================================================================
      — src/1.5/dom/domFormula.cpp (revision 844)
      +++ src/1.5/dom/domFormula.cpp (working copy)
      @@ -91,6 +91,17 @@
      meta->appendAttribute(ma);
      }
  • // Add attribute: xmlns:mathml

  • {

  •   daeMetaAttribute *ma = new daeMetaAttribute;
    
  •   ma-&gt;setName( "xmlns:mathml" );
    
  •   ma-&gt;setType( dae.getAtomicTypes().get("xsToken"));
    
  •   ma-&gt;setOffset( daeOffsetOf( domFormula , attrNSUri ));
    
  •   ma-&gt;setContainer( meta );
    
  •   meta-&gt;appendAttribute(ma);
    
  • }

  • meta->setElementSize(sizeof(domFormula));
    meta->validate();
    ==

Regards

Steffen