undefined name-attribute in param-element

Hi!

I would need an example where the name of a param is undefined.

<source>
   <int_array name="values" count="9">
      1 0 1 2 0 2 3 0 3
   </int_array>
   <technique_common>
      <accessor source="#values" count="3" stride="3">
         <param name="A" type="int"/>
         <param type="int"/>
         <param name="B" type="int"/>
      </accessor>
   </technique_common>
</source>

int_array defines: 1 0 1 2 0 2 3 0 3
but valid values are (because the name of the second <param> is undefined): 1 1 2 2 3 3

I don´t know how a

might look like. What are valid

-values (if all offset-attributes of <input> are 0)?

From 0 to 8 or
from 0 to 5?

Well, i wanted to program a collada-parser in javascript. Open source and free. But i can´t do that without any help.

Example of a class:

function COLLADA_Input(node) {
   var offset;
   var semantic;
   var source;
   var set;
   
   if (node.nodeType != 1) // Element-Knoten
      throw new Error('CALLADA_INPUT');
   
   var functions = [];
   /**
    * Setzt semantic.
    * @param string value Node-Value
    * @throws Error
    */
   functions['semantic'] = function(value) {
      if (semantic != undefined)
         throw new Error('CALLADA_INPUT_SEMANTIC_NOT_UNIQUE');
      var semantics = [
         'BINORMAL',
         'COLOR',
         'CONTINUITY',
         'IMAGE',
         'INPUT',
         'IN_TANGENT',
         'INTERPOLATION',
         'INV_BIND_MATRIX',
         'JOINT',
         'LINEAR_STEPS',
         'MORPH_TARGET',
         'MORPH_WEIGHT',
         'NORMAL',
         'OUT_TANGENT',
         'POSITION',
         'TANGENT',
         'TEXBINORMAL',
         'TEXCOORD',
         'TEXTANGENT',
         'UV',
         'VERTEX',
         'WEIGHT'
      ];
      if (!ARRAY_inArray(semantics, value))
         throw new Error('CALLADA_INPUT_SEMANTIC_VALUE');
      semantic = value;
   };
   /**
    * Setzt source.
    * @param string value Node-Value
    * @throws Error
    */
   functions['source'] = function(value) {
      if (source != undefined)
         throw new Error('CALLADA_INPUT_SOURCE_NOT_UNIQUE');
      value = value.trim();
      if (value == '')
         throw new Error('CALLADA_INPUT_SOURCE_VALUE');
      source = value;
   };
   /**
    * Setzt offset.
    * @param string value Node-Value
    * @throws Error
    */
   functions['offset'] = function(value) {
      if (offset != undefined)
         throw new Error('CALLADA_INPUT_OFFSET_NOT_UNIQUE');
      if (!/^\d+$/.test(value))
         throw new Error('CALLADA_INPUT_OFFSET_VALUE');
      offset = Number(value);
   };
   /**
    * Setzt set.
    * @param string value Node-Value
    * @throws Error
    */
   functions['set'] = function(value) {
      if (set != undefined)
         throw new Error('CALLADA_INPUT_SET_NOT_UNIQUE');
      if (!/^\d+$/.test(value))
         throw new Error('CALLADA_INPUT_SET_VALUE');
      set = Number(value);
   };

   var attributes = node.attributes;
   var length = attributes.length;
   for (var j = 0; j < length; ++j) {
      var attribute = attributes[j];
      var key = attribute.nodeName;
      if (functions[key] == undefined)
         throw new Error('CALLADA_INPUT_INPUT_ATTRIBUTE_NAME');
         
      functions[key](attribute.nodeValue);
   }
   
   // must-Elemente:
   //if (offset == undefined)
   //   throw new Error('CALLADA_INPUT_INPUT_MISSING_OFFSET');
   if (semantic == undefined)
      throw new Error('CALLADA_INPUT_INPUT_MISSING_SEMANTIC');
   if (source == undefined)
      throw new Error('CALLADA_INPUT_INPUT_MISSING_SOURCE');
   
   /**
    * Gibt den offset zurück.
    * Bei dem Programm Blender gibt es einen Bug:
    *    In vertices gibt es auch ein input-Element. Dieses beinhaltet jedoch kein offset-Attribut.
    *    Habe den Bug an Blender gemeldet.
    * Aufgrund dieses Bugs habe ich hier einen Workaround programmiert:
    * Hier ist offset kein required Attribute. Die Methode kann also auch null zurückgaben.
    * @return null|int
    */
   this.getOffset = function() {
      return offset;
   };
   /**
    * @return string
    */
   this.getSemantic = function() {
      return semantic;
   };
   /**
    * @return string
    */
   this.getSource = function() {
      return source;
   };
   /**
    * @return null|int
    */
   this.getSet = function() {
      return set;
   };
}
/*
// test:
var xml = 
'<?xml version="1.0" encoding="utf-8"?>'+
'<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">'+
'  <library_geometries>'+
'    <geometry id="Plane-mesh" name="Plane">'+
'      <mesh>'+
'        <vertices id="Plane-mesh-vertices">'+
'          <input semantic="POSITION" source="#Plane-mesh-positions"/>'+
'        </vertices>'+
'        <polylist count="1">'+
'          <input semantic="VERTEX" source="#Plane-mesh-vertices" offset="0"/>'+
'          <input semantic="NORMAL" source="#Plane-mesh-normals" offset="1"/>'+
'          <vcount>4 </vcount>'+
'          

1 0 0 0 2 0 3 0</p>'+
'        </polylist>'+
'      </mesh>'+
'      <extra><technique profile="MAYA"><double_sided>1</double_sided></technique></extra>'+
'    </geometry>'+
'  </library_geometries>'+
'</COLLADA>';
var parser = new DOMParser();
var dom = parser.parseFromString(xml, 'text/xml');
var nodes = dom.getElementsByTagName('input');
var result = [];
var length = nodes.length;
for (var i = 0; i < length; ++i) {
   var node = nodes[i];
   result.push(new COLLADA_Input(node));
}
for (var i = 0; i < length; ++i) {
   var input = result[i];
   alert(input.getSemantic());
   alert(input.getSource());
   alert(input.getOffset());
   alert(input.getSet());
}*/

Comments are currently in german. This will change in future.

But i really would need some help to program a perfect parser.’+

Looking at the SPEC (1.4.1) page 73 and 125 I am not sure what information you are missing