[ 
https://issues.apache.org/jira/browse/XAP-269?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Trevor Oldak closed XAP-269.
----------------------------


id and name both work. i'm assuming this is acceptable.

> macro uses "id" attribute but should use "name" based on the documentation
> --------------------------------------------------------------------------
>
>                 Key: XAP-269
>                 URL: https://issues.apache.org/jira/browse/XAP-269
>             Project: XAP
>          Issue Type: Bug
>          Components: Macros
>            Reporter: David Gennaco
>
> The example of using macros I saw uses "name" to identify a macro to be 
> executed, but I can only get it to work if I use "id"
> The example:
> <macro:macro xmlns:macro="http://openxal.org/core/macro"; 
> name="changeLabelTextMacro">
>     <xm:modifications xmlns:xm="http://openxal.com/core/xmodify";>
>       <xm:set-attribute select="id(''mylabel'')">
>         <xm:attribute name="text" value="Some new text"/>
>       </xm:set-attribute>
>     </xm:modifications>
> </macro:macro>
>  I changed MacroNamespaceHanler.js (receiveDispatch) to the following and it 
> seems to be working now:
> /**
>  * This method is called when an element with the Macro namespace is 
>  * encountered.
>  * 
>  * @param element the element that is namespaced, including all of its 
>  * children
>  * @param container The xap.xml.DocumentContainer to be used for processing.
>  * @throws UpdateException
>  */
> xap.macro.MacroNamespaceHandler.prototype.receiveDispatch = function( element 
> ) {
>       var session = this._session;
>        var name = element.getAttribute("name");
>        if ( name == null || 
>                name == "" ) {
>                session.handleException(
>                       new xap.xml.InvalidXmlException( 
>                               
> xap.xml.InvalidXmlException.MISSING_ATTRIBUTE_MSGID,
>                               new Array( "name", element.toXml( true ))));
>       }
>       if (xap.util.LogFactory.s_loggingEnabled)
>               xap.macro.MacroNamespaceHandler.s_log.debug( "Create macro 
> name: ["+ name + 
>                                                                       "] from 
> element: [" + element.toXml() + "]");
>        
>       //TODO we really need to clarify whether or not XAP is a generic 
> wrapping
>       //tag or something with more meaning
>       //TODO what if the original macro is malformed?
>       var macro = new xap.macro.Macro( "<xap>" + 
> element.childNodes[0].toXmlWithoutAutoAssignedIds() + "</xap>", session );
>        
>       //TODO if we are replacing and existing one should probably
>       //output that to info at least.
>       
>       var macroContainer = session.getMacroContainer();
>       if ( macroContainer.get( name ) != null ){
>               xap.macro.MacroNamespaceHandler.s_log.info( "Replacing an 
> existing macro registered" +
>                       " with name:" + name + ". Element:" + element.toXml() );
>       }
>       macroContainer.put( name, macro );
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to