Hi,
I am looking into using XSLT to convert an XML based declarative language into pure JavaScript code as its output. The declarative language will be used for describing user interfaces similar to Mozilla XUL. I am fairly new to XSLT, and I am not sure how to properly handle all the attributes that the tags can contain. For instance, below I have a "script" tag and a "button" tag, both with different attributes, many of which are optional. There will also be many additional tags with even more attributes. My question is, how do I design my XSLT script to properly handle all the possible attribute in a maintainable way?
<window>
<script type="javascript">
blah
blah
</script>
<button id="button1" height="100" vOffset="0" renderer="Test.control.Button" />
</window>
I was thinking initialy something like the following
<xsl:template match="button">
var <xsl:value-of select="@id" /> = new <xsl:value-of select="@renderer" />({
id: <xsl:value-of select="@id" />,
styles: {
<xsl:apply-templates select="@*" />
},
}).appendTo(panel);
</xsl:template>
<xsl:template match="button/@*">
<xsl:if test="name() = 'height' or name() = 'vOffset'">
		<xsl:value-of select="name()" />: <xsl:value-of select="." />,
</xsl:if>
</xsl:template>