<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" 
                xmlns:t="urn:GetUnitInfo-schema" 
                xmlns:ms="urn:schemas-microsoft-com:xslt" 
	              xmlns:flex="urn:schemas-flextronics-com:xslt"                
                version="1.0">
<xsl:output method="xml" version="1.0" encoding="utf-8"/>
  <ms:script language="VBScript" implements-prefix="flex">
    <![CDATA[
    dim m_PartItem
    dim m_Rev

    function SetItem(sItem, Value)
    if sItem = "PartItem" then
      m_PartItem = Value
     end if
     if sItem = "Rev" then
        m_Rev = Value
     end if
     SetItem = sItem
    end function
    
    function GetItem(sItem)
    GetItem = ""
    if sItem = "PartItem" then
      if not m_PartItem is nothing then
        GetItem = m_PartItem
      else
        GetItem = ""
      end if
    end if
    if sItem = "Rev" then
      if not m_Rev is nothing then
        GetItem = m_Rev
       else
        GetItem = ""
       end if
    end if
    end function
	]]>
  </ms:script>

  <xsl:template match="/t:GetUnitInfo">
<xsl:element name="SerialNumber">
  <xsl:variable name ="Part" select ="''"/>
  <xsl:variable name ="Rev" select ="''"/>
  <xsl:for-each select="@*">
  <xsl:if test ="not ('PartItem' = local-name() or 'Rev' = local-name())">
    <xsl:element name="S">
      <xsl:attribute name="Descr">
        <xsl:value-of select="local-name()" />
      </xsl:attribute>
      <xsl:value-of select="current()" />
    </xsl:element>
  </xsl:if>
    <xsl:if test ="'PartItem' = local-name()" >
         <xsl:element name="PartItem">
      <xsl:value-of select="current()" />
    </xsl:element>
    </xsl:if>
  <!-- 
  <xsl:if test ="'PartItem' = flex:SetItem(local-name(), current() )">
    
  </xsl:if>
  -->
  <xsl:if test ="'Rev' = local-name()">
    <xsl:element name="Rev">
      <xsl:value-of select="current()" />
    </xsl:element>
  </xsl:if>
    
    <!-- Some readon the 2 parameter call does not working...
  <xsl:if test ="'Rev' = flex:SetItem(local-name(), current() )">
    
  </xsl:if>
  -->
  </xsl:for-each>
<!-- For delete
  <xsl:element name="P">
    <xsl:attribute name ="Part">
      <xsl:value-of select="'Test'"/>
    </xsl:attribute>
    <xsl:attribute name ="Rev">
      <xsl:value-of select="'Rev'"/>
    </xsl:attribute>
  </xsl:element>
-->
</xsl:element>
</xsl:template>
</xsl:stylesheet>
