<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using XML in scripting</title>
	<atom:link href="http://www.xsi-blog.com/archives/42/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xsi-blog.com/archives/42#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-xml-in-scripting</link>
	<description>People and thoughts behind XSI in production...</description>
	<lastBuildDate>Fri, 12 Mar 2010 18:58:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bernard Lebel</title>
		<link>http://www.xsi-blog.com/archives/42/comment-page-1#comment-143</link>
		<dc:creator>Bernard Lebel</dc:creator>
		<pubDate>Mon, 19 Sep 2005 19:47:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=42#comment-143</guid>
		<description>Hi Andy,

Thanks a lot for your answers.

About point #3, yeah, it&#039;&#039;s lot of fun. In fact it&#039;&#039;s rather easy because I write the XML to my taste and thus writing a XML &quot;interpreter&quot; for XSI is easy for most things. The only culpritt though is handling the case of trying to &quot;map&quot; the XML text to existing XSI objects.

Here are such a functions (Python):
(Note: I mentioned that I was using ElementTree, but that was because of a bug with BeautifulSoup, another Python XML parser. However that bug was corrected yesterday and thus I have reimplemented it in my code.)


def processSceneObject( oXSIObject, oXMLObject ):
	
	&quot;&quot;&quot;
	ARGUMENTS:
	- oXSIObject (object): an XSI 3D object
	- oXMLObject (BeautifulSoup object): an XML ElementTree object that is a  tag
		
		  ...
		
	&quot;&quot;&quot;
	
	# Parameters
	transferParameters( oXSIObject, oXMLObject )
	
	# ActivePrimitive
	processActivePrimitive( oXSIObject, oXMLObject )
	
	# LocalProperties
	processProperties( oXSIObject, oXMLObject, &#039;&#039;localproperties&#039;&#039; )
	
	# Kinematics
	processKinematics( oXSIObject, oXMLObject )


def processKinematics( oXSIObject, oXMLObject ):
	
	&quot;&quot;&quot;
	ARGUMENTS:
	- oXSIObject (object): the XSI object (must have a Kinematics object
	- oXMLObject (BeautifulSoup object): the XML scene object that has a  tag under
		
		  
		    
		      ...
		    
		  
		
	
	Note: We don&#039;&#039;t transfer global kinematics, it&#039;&#039;s useless.
	&quot;&quot;&quot;
	
	oXMLConstraints = oXMLObject.localproperties.constraints.fetch( &#039;&#039;constraint&#039;&#039; )
	oXMLLocalKine = oXMLObject.first( &#039;&#039;kinematicstate&#039;&#039;, attrs = { &#039;&#039;name&#039;&#039; : &#039;&#039;Local Transform&#039;&#039; } )
	
	oXSIConstraints = oXSIObject.Kinematics.Constraints
	oXSILocalKine = oXSIObject.Kinematics.Local
	
	# Constraints
	for oXMLConstraint in oXMLConstraints:
		
		oXSIConstraint = None
		
		if oXSIConstraints.count  :: No matching constraint could be established with %s.&#039;&#039; % ( oXMLConstaint[ &#039;&#039;fullname&#039;&#039; ] ), c.siError )
		else:
			transferParameters( oXSIConstraint, oXMLConstraint )
	
	
	# Local KinematicState
	transferParameters( oXSILocalKine, oXMLLocalKine )



def transferParameters( oXSIInput, oXMLInput ):
	
	&quot;&quot;&quot;
	ARGUMENTS:
	- oXSIInput (XSI object): the XSI object that has parameters
	- oXMLInput (BeautifulSoup object): the BeautifulSoup tag object under wich there is a  tag
		
		  
		    
		      ...
		    
		  
		
	&quot;&quot;&quot;
	
	oXSIParameters = oXSIInput.parameters
	oXMLParameters = oXMLInput.parameters.fetch( &#039;&#039;parameter&#039;&#039; )
	
	for oXMLParameter in oXMLParameters:
		
		if oXMLParameter.contents[0] != &#039;&#039;None&#039;&#039;:
			
			# Get the XSI parameter object
			oXSIParameter = oXSIParameters( oXMLParameter[ &#039;&#039;scriptname&#039;&#039; ] )
			
			# Check if parameter has a source
			if oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ] != &#039;&#039;nosource&#039;&#039;:
				# Has a source
				
				# Dispatch appropriate action to handle source
				if oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ] == &#039;&#039;FCurve&#039;&#039;: transferFcurve( oXSIParameter, oXMLParameter )
				elif oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ] == &#039;&#039;Constraint&#039;&#039;: pass
				elif oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ] == &#039;&#039;Expression&#039;&#039;: transferExpression( oXSIParameter, oXMLParameter )
				elif oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ] == &#039;&#039;CustomOperator&#039;&#039;: pass
				elif oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ] == &#039;&#039;Shader&#039;&#039;: pass
				elif oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ] == &#039;&#039;ImageClip&#039;&#039;: pass
				else: xsi.logmessage( &#039;&#039; :: Unsupported type of source &quot;%s&quot;, parameter &quot;%s&quot; skipped.&#039;&#039; % ( oXMLParameter[ &#039;&#039;sourceclassname&#039;&#039; ], oXSIParameter.scriptname ), c.siWarning )
			
			else:
				# No source
				oXSIParameter.value = oXMLParameter.contents[0]



I will definitely check the XSL transformation stuff. All this is very new to me.


Thanks again
Bernard</description>
		<content:encoded><![CDATA[<p>Hi Andy,</p>
<p>Thanks a lot for your answers.</p>
<p>About point #3, yeah, it&#8217;&#8217;s lot of fun. In fact it&#8217;&#8217;s rather easy because I write the XML to my taste and thus writing a XML &#8220;interpreter&#8221; for XSI is easy for most things. The only culpritt though is handling the case of trying to &#8220;map&#8221; the XML text to existing XSI objects.</p>
<p>Here are such a functions (Python):<br />
(Note: I mentioned that I was using ElementTree, but that was because of a bug with BeautifulSoup, another Python XML parser. However that bug was corrected yesterday and thus I have reimplemented it in my code.)</p>
<p>def processSceneObject( oXSIObject, oXMLObject ):</p>
<p>	&#8220;&#8221;"<br />
	ARGUMENTS:<br />
	- oXSIObject (object): an XSI 3D object<br />
	- oXMLObject (BeautifulSoup object): an XML ElementTree object that is a  tag</p>
<p>		  &#8230;</p>
<p>	&#8220;&#8221;"</p>
<p>	# Parameters<br />
	transferParameters( oXSIObject, oXMLObject )</p>
<p>	# ActivePrimitive<br />
	processActivePrimitive( oXSIObject, oXMLObject )</p>
<p>	# LocalProperties<br />
	processProperties( oXSIObject, oXMLObject, &#8221;localproperties&#8221; )</p>
<p>	# Kinematics<br />
	processKinematics( oXSIObject, oXMLObject )</p>
<p>def processKinematics( oXSIObject, oXMLObject ):</p>
<p>	&#8220;&#8221;"<br />
	ARGUMENTS:<br />
	- oXSIObject (object): the XSI object (must have a Kinematics object<br />
	- oXMLObject (BeautifulSoup object): the XML scene object that has a  tag under</p>
<p>		      &#8230;</p>
<p>	Note: We don&#8221;t transfer global kinematics, it&#8217;&#8217;s useless.<br />
	&#8220;&#8221;"</p>
<p>	oXMLConstraints = oXMLObject.localproperties.constraints.fetch( &#8221;constraint&#8221; )<br />
	oXMLLocalKine = oXMLObject.first( &#8221;kinematicstate&#8221;, attrs = { &#8221;name&#8221; : &#8221;Local Transform&#8221; } )</p>
<p>	oXSIConstraints = oXSIObject.Kinematics.Constraints<br />
	oXSILocalKine = oXSIObject.Kinematics.Local</p>
<p>	# Constraints<br />
	for oXMLConstraint in oXMLConstraints:</p>
<p>		oXSIConstraint = None</p>
<p>		if oXSIConstraints.count  :: No matching constraint could be established with %s.&#8221; % ( oXMLConstaint[ ''fullname'' ] ), c.siError )<br />
		else:<br />
			transferParameters( oXSIConstraint, oXMLConstraint )</p>
<p>	# Local KinematicState<br />
	transferParameters( oXSILocalKine, oXMLLocalKine )</p>
<p>def transferParameters( oXSIInput, oXMLInput ):</p>
<p>	&#8220;&#8221;"<br />
	ARGUMENTS:<br />
	- oXSIInput (XSI object): the XSI object that has parameters<br />
	- oXMLInput (BeautifulSoup object): the BeautifulSoup tag object under wich there is a  tag</p>
<p>		      &#8230;</p>
<p>	&#8220;&#8221;"</p>
<p>	oXSIParameters = oXSIInput.parameters<br />
	oXMLParameters = oXMLInput.parameters.fetch( &#8221;parameter&#8221; )</p>
<p>	for oXMLParameter in oXMLParameters:</p>
<p>		if oXMLParameter.contents[0] != &#8221;None&#8221;:</p>
<p>			# Get the XSI parameter object<br />
			oXSIParameter = oXSIParameters( oXMLParameter[ ''scriptname'' ] )</p>
<p>			# Check if parameter has a source<br />
			if oXMLParameter[ ''sourceclassname'' ] != &#8221;nosource&#8221;:<br />
				# Has a source</p>
<p>				# Dispatch appropriate action to handle source<br />
				if oXMLParameter[ ''sourceclassname'' ] == &#8221;FCurve&#8221;: transferFcurve( oXSIParameter, oXMLParameter )<br />
				elif oXMLParameter[ ''sourceclassname'' ] == &#8221;Constraint&#8221;: pass<br />
				elif oXMLParameter[ ''sourceclassname'' ] == &#8221;Expression&#8221;: transferExpression( oXSIParameter, oXMLParameter )<br />
				elif oXMLParameter[ ''sourceclassname'' ] == &#8221;CustomOperator&#8221;: pass<br />
				elif oXMLParameter[ ''sourceclassname'' ] == &#8221;Shader&#8221;: pass<br />
				elif oXMLParameter[ ''sourceclassname'' ] == &#8221;ImageClip&#8221;: pass<br />
				else: xsi.logmessage( &#8221; :: Unsupported type of source &#8220;%s&#8221;, parameter &#8220;%s&#8221; skipped.&#8221; % ( oXMLParameter[ ''sourceclassname'' ], oXSIParameter.scriptname ), c.siWarning )</p>
<p>			else:<br />
				# No source<br />
				oXSIParameter.value = oXMLParameter.contents[0]</p>
<p>I will definitely check the XSL transformation stuff. All this is very new to me.</p>
<p>Thanks again<br />
Bernard</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Nicholas</title>
		<link>http://www.xsi-blog.com/archives/42/comment-page-1#comment-139</link>
		<dc:creator>Andy Nicholas</dc:creator>
		<pubDate>Mon, 19 Sep 2005 09:59:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=42#comment-139</guid>
		<description>Hi Bernhard,

Thanks for the feedback, I&#039;&#039;m glad you found the article useful. To address your questions:

1) You said that I talked of two methods for exporting XML. I only intended one; that of outputting some form of XML that represented the basic data contained within the scene. I&#039;&#039;d favour a scene format that would represent the data in its purest form to preserve scalability. I&#039;&#039;d worry that if you try to add any structure or data that is specific to a particular application or usage, then it&#039;&#039;ll just get in the way later on when you need to use the same XML data in a different way to that originally intended.

The application specific part comes in the form of the XSL transform. Different XSL transforms can do completely different things with the same XML data. I&#039;&#039;d recommend letting the XSL document do the work for you, it&#039;&#039;s much more flexible and is much easier to alter later. Plus, you can store the XSL document as it&#039;&#039;s own asset, which neatly separates its functionality from any other pipeline scripts.

2) I use a script class to generate my XML, it handles things like indents nicely (to make it a little more easy to read) and also provides functionality for me to come back to insert nodes later on. The script class basically wraps the MSXML DOMDocument object. I&#039;&#039;ve pasted it in below in case you&#039;&#039;re interested:


Class XMLDocument

   Public Sub Create(rootNodeName)
      Set xmlDoc = CreateObject(&quot;Msxml2.DOMDocument.4.0&quot;)
      xmlDoc.LoadXML(&quot;&lt;?xml version=&quot;&amp;Chr(34)&amp;&quot;1.0&quot;&amp;Chr(34)&amp;&quot; encoding=&quot;&amp;Chr(34)&amp;&quot;utf-8&quot;&amp;Chr(34)&amp;&quot; ?&gt;&quot;&amp;vbCrLf&amp;&quot;&lt;&quot;&amp;rootNodeName&amp;&quot;/&gt;&quot;)
      xmlDoc.preserveWhiteSpace=True
      Set xmlRoot = xmlDoc.documentElement   
      indentLevel=1
   End Sub
   
   Public Function AddElement(parentNode, elementName, elementContent)
      If(typename(parentNode)&lt;&gt;&quot;IXMLDOMElement&quot;) Then Set parentNode=xmlRoot

      &#039;&#039;Formatting
      parentNode.appendChild xmlDoc.CreateTextNode(vbCrLf &amp; String(indentLevel,Chr(9)))
      
      Dim newNode
      Set newNode = xmlDoc.CreateElement(elementName)
      if(elementContent&lt;&gt;&quot;&quot;) Then newNode.Text = elementContent
      parentNode.appendChild newNode
   
      Set lastElementParent=parentNode
      Set AddElement=newNode      
   End Function

   Public Sub AddAttribute(node, attributeName, attributeValue)
      Dim att, namedNodeMap
      Set att = xmlDoc.CreateAttribute(attributeName)
      Set namedNodeMap = node.Attributes
      namedNodeMap.setNamedItem att
      node.setAttribute attributeName, attributeValue
   End Sub

   Public Sub StartInsertAt(parentNode, levelToindent)
      indentLevel=levelToindent
      Set lastElementParent=parentNode      
   End Sub
   
   Public Property Get IndentSpacing()
      IndentSpacing = indentLevel   
   End Property

   Public Function Indent()
      indentLevel=indentLevel+1
      Indent=indentLevel
   End Function

   Public Function Outdent()
      indentLevel=indentLevel-1
      If not (lastElementParent Is nothing) Then
         lastElementParent.appendChild xmlDoc.CreateTextNode(vbCrLf &amp; String(indentLevel,Chr(9)))   
         Set lastElementParent=lastElementParent.parentNode
      End If
      Outdent=indentLevel      
   End Function

   Public Function Save(filename)
      &#039;&#039;Add carriage return for closing node
      If(xmlRoot.lastChild.nodeTypeString&lt;&gt;&quot;text&quot;) Then
         xmlRoot.appendChild xmlDoc.CreateTextNode(vbCrLf)
      End If
      Save = xmlDoc.Save(filename)
   End Function

   Private xmlDoc
   Private xmlRoot
   Private indentLevel
   Private lastElementParent
   
End Class


I use it like this:


Function Export_Animation(xmlDoc, parentNode, exportData)
   Dim animNode
   Set animNode = xmlDoc.AddElement(parentNode,&quot;animation&quot;,&quot;&quot;)
   xmlDoc.AddAttribute animNode,&quot;version&quot;,exportData.version
   
   xmlDoc.Indent
   
   xmlDoc.AddElement animNode,&quot;name&quot;,exportData.animName
   xmlDoc.AddElement animNode,&quot;numframes&quot;,1+exportData.endFrame-exportData.startFrame
   xmlDoc.AddElement animNode,&quot;fps&quot;,exportData.fps
   
   exportData.success=Export_Skeleton(xmlDoc, animNode, exportData)
   
   xmlDoc.Outdent
   
   Export_Animation=exportData.success
End Function



Your example of a 50Mb file is quite large for XML, but I think that the flexibility that it offers, far outweighs the disadvantage of processing such a large file. XML usually compresses pretty well, so that can help, although that does add processing time. 

Another strategy would be to split the XML up into numerous smaller XML files, and simply link between them. For example, you could use a node like this: 

&lt;include filename=&quot;c:\scenedata\robotmodel.xml&quot; /&gt;. 

When your script loads the XML document, it can search for any &lt;include&gt; nodes and where desired, it can replace the &lt;include&gt; node with the tree fragment from the relevant file. This means that you can then run the XSL transform on smaller trees that only contain the appropriate information. Managing the extra files and all the different versions of them could be a headache though.

Incidentally, most popular databases are adding good support for XML now. For example, SQL can return query data as pure XML, formatted in a variety of different ways. So maybe another alternative would be to push all your data into a database and then generate your XML on the fly with queries.


3) I&#039;&#039;ve not tackled that problem. I&#039;&#039;ve been mainly using XML to export animation data. I&#039;&#039;ve read it back in to a Custom Display Host, but I&#039;&#039;ve not needed to apply it directly to a rig in the scene. What you&#039;&#039;re doing sounds like fun though ;-)

Regards

Andy</description>
		<content:encoded><![CDATA[<p>Hi Bernhard,</p>
<p>Thanks for the feedback, I&#8221;m glad you found the article useful. To address your questions:</p>
<p>1) You said that I talked of two methods for exporting XML. I only intended one; that of outputting some form of XML that represented the basic data contained within the scene. I&#8221;d favour a scene format that would represent the data in its purest form to preserve scalability. I&#8221;d worry that if you try to add any structure or data that is specific to a particular application or usage, then it&#8221;ll just get in the way later on when you need to use the same XML data in a different way to that originally intended.</p>
<p>The application specific part comes in the form of the XSL transform. Different XSL transforms can do completely different things with the same XML data. I&#8221;d recommend letting the XSL document do the work for you, it&#8217;&#8217;s much more flexible and is much easier to alter later. Plus, you can store the XSL document as it&#8217;&#8217;s own asset, which neatly separates its functionality from any other pipeline scripts.</p>
<p>2) I use a script class to generate my XML, it handles things like indents nicely (to make it a little more easy to read) and also provides functionality for me to come back to insert nodes later on. The script class basically wraps the MSXML DOMDocument object. I&#8221;ve pasted it in below in case you&#8221;re interested:</p>
<p>Class XMLDocument</p>
<p>   Public Sub Create(rootNodeName)<br />
      Set xmlDoc = CreateObject(&quot;Msxml2.DOMDocument.4.0&quot;)<br />
      xmlDoc.LoadXML(&quot;&lt;?xml version=&quot;&amp;Chr(34)&amp;&quot;1.0&quot;&amp;Chr(34)&amp;&quot; encoding=&quot;&amp;Chr(34)&amp;&quot;utf-8&quot;&amp;Chr(34)&amp;&quot; ?&gt;&quot;&amp;vbCrLf&amp;&quot;&lt;&quot;&amp;rootNodeName&amp;&quot;/&gt;&quot;)<br />
      xmlDoc.preserveWhiteSpace=True<br />
      Set xmlRoot = xmlDoc.documentElement<br />
      indentLevel=1<br />
   End Sub</p>
<p>   Public Function AddElement(parentNode, elementName, elementContent)<br />
      If(typename(parentNode)&lt;&gt;&quot;IXMLDOMElement&quot;) Then Set parentNode=xmlRoot</p>
<p>      &#8221;Formatting<br />
      parentNode.appendChild xmlDoc.CreateTextNode(vbCrLf &amp; String(indentLevel,Chr(9)))</p>
<p>      Dim newNode<br />
      Set newNode = xmlDoc.CreateElement(elementName)<br />
      if(elementContent&lt;&gt;&quot;&quot;) Then newNode.Text = elementContent<br />
      parentNode.appendChild newNode</p>
<p>      Set lastElementParent=parentNode<br />
      Set AddElement=newNode<br />
   End Function</p>
<p>   Public Sub AddAttribute(node, attributeName, attributeValue)<br />
      Dim att, namedNodeMap<br />
      Set att = xmlDoc.CreateAttribute(attributeName)<br />
      Set namedNodeMap = node.Attributes<br />
      namedNodeMap.setNamedItem att<br />
      node.setAttribute attributeName, attributeValue<br />
   End Sub</p>
<p>   Public Sub StartInsertAt(parentNode, levelToindent)<br />
      indentLevel=levelToindent<br />
      Set lastElementParent=parentNode<br />
   End Sub</p>
<p>   Public Property Get IndentSpacing()<br />
      IndentSpacing = indentLevel<br />
   End Property</p>
<p>   Public Function Indent()<br />
      indentLevel=indentLevel+1<br />
      Indent=indentLevel<br />
   End Function</p>
<p>   Public Function Outdent()<br />
      indentLevel=indentLevel-1<br />
      If not (lastElementParent Is nothing) Then<br />
         lastElementParent.appendChild xmlDoc.CreateTextNode(vbCrLf &amp; String(indentLevel,Chr(9)))<br />
         Set lastElementParent=lastElementParent.parentNode<br />
      End If<br />
      Outdent=indentLevel<br />
   End Function</p>
<p>   Public Function Save(filename)<br />
      &#8221;Add carriage return for closing node<br />
      If(xmlRoot.lastChild.nodeTypeString&lt;&gt;&quot;text&quot;) Then<br />
         xmlRoot.appendChild xmlDoc.CreateTextNode(vbCrLf)<br />
      End If<br />
      Save = xmlDoc.Save(filename)<br />
   End Function</p>
<p>   Private xmlDoc<br />
   Private xmlRoot<br />
   Private indentLevel<br />
   Private lastElementParent</p>
<p>End Class</p>
<p>I use it like this:</p>
<p>Function Export_Animation(xmlDoc, parentNode, exportData)<br />
   Dim animNode<br />
   Set animNode = xmlDoc.AddElement(parentNode,&quot;animation&quot;,&quot;&quot;)<br />
   xmlDoc.AddAttribute animNode,&quot;version&quot;,exportData.version</p>
<p>   xmlDoc.Indent</p>
<p>   xmlDoc.AddElement animNode,&quot;name&quot;,exportData.animName<br />
   xmlDoc.AddElement animNode,&quot;numframes&quot;,1+exportData.endFrame-exportData.startFrame<br />
   xmlDoc.AddElement animNode,&quot;fps&quot;,exportData.fps</p>
<p>   exportData.success=Export_Skeleton(xmlDoc, animNode, exportData)</p>
<p>   xmlDoc.Outdent</p>
<p>   Export_Animation=exportData.success<br />
End Function</p>
<p>Your example of a 50Mb file is quite large for XML, but I think that the flexibility that it offers, far outweighs the disadvantage of processing such a large file. XML usually compresses pretty well, so that can help, although that does add processing time. </p>
<p>Another strategy would be to split the XML up into numerous smaller XML files, and simply link between them. For example, you could use a node like this: </p>
<p>&lt;include filename=&quot;c:\scenedata\robotmodel.xml&quot; /&gt;. </p>
<p>When your script loads the XML document, it can search for any &lt;include&gt; nodes and where desired, it can replace the &lt;include&gt; node with the tree fragment from the relevant file. This means that you can then run the XSL transform on smaller trees that only contain the appropriate information. Managing the extra files and all the different versions of them could be a headache though.</p>
<p>Incidentally, most popular databases are adding good support for XML now. For example, SQL can return query data as pure XML, formatted in a variety of different ways. So maybe another alternative would be to push all your data into a database and then generate your XML on the fly with queries.</p>
<p>3) I&#8221;ve not tackled that problem. I&#8221;ve been mainly using XML to export animation data. I&#8221;ve read it back in to a Custom Display Host, but I&#8221;ve not needed to apply it directly to a rig in the scene. What you&#8221;re doing sounds like fun though ;-)</p>
<p>Regards</p>
<p>Andy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luc-Eric</title>
		<link>http://www.xsi-blog.com/archives/42/comment-page-1#comment-129</link>
		<dc:creator>Luc-Eric</dc:creator>
		<pubDate>Sat, 17 Sep 2005 21:05:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=42#comment-129</guid>
		<description>FYI, the Collada ( as you know, a 3D file format based on XML syntax) converter is written with the FTK, which provides high level objects for dealing with things.  The source is available here : http://collada.org/public_forum/viewtopic.php?t=153</description>
		<content:encoded><![CDATA[<p>FYI, the Collada ( as you know, a 3D file format based on XML syntax) converter is written with the FTK, which provides high level objects for dealing with things.  The source is available here : <a href="http://collada.org/public_forum/viewtopic.php?t=153" rel="nofollow">http://collada.org/public_forum/viewtopic.php?t=153</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard Lebel</title>
		<link>http://www.xsi-blog.com/archives/42/comment-page-1#comment-128</link>
		<dc:creator>Bernard Lebel</dc:creator>
		<pubDate>Sat, 17 Sep 2005 14:45:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.xsi-blog.com/?p=42#comment-128</guid>
		<description>Hi,

Very interesting article, especially considering that this is exactly what I&#039;&#039;m doing right now. I&#039;&#039;m doing this with Python, wich also happens to have an ElementTree package, that provides simple and nice XML parsing capabilities.

I have a few questions...

1- You have presented two ways of exporting XSI data to XML, one being like tree-based scene file, the other being writing programming objects with attributes that can be used to set or reconstruct XSI objects. What are the pros and cons of both approach?


2- You didn&#039;&#039;t talk much about the actual process of outputting the XML. I&#039;&#039;d be very interested in knowing how other do that, and why.

For the tools I&#039;&#039;m working on, the user can select any object in the scene (including objects &quot;above&quot; or &quot;next to&quot; the scene root in the Application scope, like a material library, or the list of action sources, etc), and it will export it as well as everything that is below. To accomplish this, I have wrote a myriad of functions that deal specifically with most of these objects in their own way, and there is this central dispatcher that can determine wich object is being tested and call the appropriate function to handle it. Obviously this resulted in a huge amount of code (around 1700 lines as of this writing), and an important part of this amount is dedicated to handling &quot;cases&quot; (for examples, the local kinematics shorts under an X3DObject).
Also it runs fast on a small amount of objects, but if you export a single action source that is the result of a plot of an entire character over 100 frames, then it takes 10 minutes and results in a 50 Mb file.

So I&#039;&#039;m interested in where is exporting XML relevant and not, and how do people takle the task of writing the XML.


3- Now about the import/interpretation/analysis. Once you have parsed the XML data, how do you translate its content to XSI? For instance, let say you wrote out a camera with all its parameters and animation to an XML file. Getting a parser to parse the file is easy, but then how would you deal with the XML camera and get it to XSI?

The approach I have been taking so far is, as I did with the export of XML, have functions for each specific XML object or so. So for example, I have a camera importer that looks for a camera object in the XML tree. If finds one, now let&#039;&#039;s check if this camera exists in the XSI scene. If not, create it, if so, go directly to transfer parameter. Oh, I see the XSI camera no longer has its direction constraint, but the XML one does. So add a constraint, and set it like in the XML camera..... and so on and so on. This will also lead to huge amounts of code and the need for many many functions.

Once again I&#039;&#039;m interested in how you people tackle the task of applying the XML information to XSI.



Thanks and great article!
Bernard</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Very interesting article, especially considering that this is exactly what I&#8221;m doing right now. I&#8221;m doing this with Python, wich also happens to have an ElementTree package, that provides simple and nice XML parsing capabilities.</p>
<p>I have a few questions&#8230;</p>
<p>1- You have presented two ways of exporting XSI data to XML, one being like tree-based scene file, the other being writing programming objects with attributes that can be used to set or reconstruct XSI objects. What are the pros and cons of both approach?</p>
<p>2- You didn&#8221;t talk much about the actual process of outputting the XML. I&#8221;d be very interested in knowing how other do that, and why.</p>
<p>For the tools I&#8221;m working on, the user can select any object in the scene (including objects &#8220;above&#8221; or &#8220;next to&#8221; the scene root in the Application scope, like a material library, or the list of action sources, etc), and it will export it as well as everything that is below. To accomplish this, I have wrote a myriad of functions that deal specifically with most of these objects in their own way, and there is this central dispatcher that can determine wich object is being tested and call the appropriate function to handle it. Obviously this resulted in a huge amount of code (around 1700 lines as of this writing), and an important part of this amount is dedicated to handling &#8220;cases&#8221; (for examples, the local kinematics shorts under an X3DObject).<br />
Also it runs fast on a small amount of objects, but if you export a single action source that is the result of a plot of an entire character over 100 frames, then it takes 10 minutes and results in a 50 Mb file.</p>
<p>So I&#8221;m interested in where is exporting XML relevant and not, and how do people takle the task of writing the XML.</p>
<p>3- Now about the import/interpretation/analysis. Once you have parsed the XML data, how do you translate its content to XSI? For instance, let say you wrote out a camera with all its parameters and animation to an XML file. Getting a parser to parse the file is easy, but then how would you deal with the XML camera and get it to XSI?</p>
<p>The approach I have been taking so far is, as I did with the export of XML, have functions for each specific XML object or so. So for example, I have a camera importer that looks for a camera object in the XML tree. If finds one, now let&#8217;&#8217;s check if this camera exists in the XSI scene. If not, create it, if so, go directly to transfer parameter. Oh, I see the XSI camera no longer has its direction constraint, but the XML one does. So add a constraint, and set it like in the XML camera&#8230;.. and so on and so on. This will also lead to huge amounts of code and the need for many many functions.</p>
<p>Once again I&#8221;m interested in how you people tackle the task of applying the XML information to XSI.</p>
<p>Thanks and great article!<br />
Bernard</p>
]]></content:encoded>
	</item>
</channel>
</rss>
