<?xml version="1.0" encoding="utf-8" ?>
<XMLScreen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <HMIWindow Type="Window" Name="Window_1">
    <Attribute Name="BackColor" Value="ffffffff" />
    <Attribute Name="ImageURI" Value="" />
    <Attribute Name="Enabled" Value="True" />
    <Attribute Name="Visible" Value="True" />
  </HMIWindow>
</XMLScreen>要用xsl转成文本输出:Window Window_1 = new Window();
Window_1.BackColor = "ffffffff";
Window_1.ImageURI = "";
Window_1.Enabled = True;
Window_1.Visible = True;XSL文件要如何写才会有这样的输出效果呀???
谢谢 !!!

解决方案 »

  1.   

    http://blog.csdn.net/lemong/archive/2008/07/15/2655098.aspx我这有几个例子
      

  2.   

    在线聊天
     zhu6789888 
     
    等级:
     发表于:2008-07-25 19:32:5514楼 得分:0 
    思归大大 
    孟子大大, 
    都去哪里了?? 
     
      

  3.   

    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
      
      <xsl:template match="/">
        <xsl:apply-templates   select="//XMLScreen/HMIWindow"/>
      </xsl:template>  <xsl:template match="//XMLScreen/HMIWindow" >    <xsl:apply-templates   select="@Type"/>   
        <xsl:apply-templates   select="@Name"/>
        =new <xsl:apply-templates   select="@Type"/>();
        
        <xsl:for-each   select="Attribute">
          <xsl:apply-templates   select="//XMLScreen/HMIWindow/@Name"/>.  <xsl:apply-templates   select="@Name"/>
          =
          "<xsl:apply-templates   select="@Value"/>";
        </xsl:for-each>  </xsl:template>  <xsl:template   match="@Name">
        <xsl:value-of   select="."/>
      </xsl:template>  <xsl:template   match="@Value">
        <xsl:value-of   select="."/>
      </xsl:template>  <xsl:template   match="@Type">
        <xsl:value-of   select="."/>
      </xsl:template>
      
    </xsl:stylesheet>
      

  4.   

    <?xml version="1.0" encoding="utf-8" ?>
    <?xml-stylesheet type="text/xsl" href="b.xsl"?>
    <XMLScreen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <HMIWindow Type="Window" Name="Window_1">
        <Attribute Name="BackColor" Value="ffffffff" />
        <Attribute Name="ImageURI" Value="" />
        <Attribute Name="Enabled" Value="True" />
        <Attribute Name="Visible" Value="True" />
      </HMIWindow>
    </XMLScreen>
      

  5.   

    正好接触过XSLT,希望可以帮到你
      

  6.   

    格式有点不对,基本正确,谢谢了还有问题,如果我加属性怎么插入呢 ?
    <HMIWindow Type="Window" Name="Window_1" CType= “” CName=“”> 
      

  7.   

    如果XML文档是这样,  
    <HMIWindow Type="Window" Name="Window_1">
        <Attribute Name="BackColor" Value=" ffffff" />
        <Attribute Name="ImageURI" Value="" />
        <Attribute Name="Enabled" Value="True" />
        <Attribute Name="Visible" Value="True" />
      </HMIWindow>
     <HMIWindow Type="Window" Name="Window_2">
        <Attribute Name="BackColor" Value="ffffff " />
        <Attribute Name="ImageURI" Value="" />
        <Attribute Name="Enabled" Value="True" />
        <Attribute Name="Visible" Value="True" />
     </HMIWindow>
    则按上面的方式,结果会变成这样
       Winow_1Window_2.BackColor = "ffffff";
       Winow_1Window_2.ImageURI = "";
       Winow_1Window_2.Enabled = "True";
       Winow_1Window_2.Visible = "True";
       我想要这样的结果:
       Winow_1.BackColor = "ffffff";
       Winow_1.ImageURI = "";
       Winow_1.Enabled = "True";
       Winow_1.Visible = "True";
       Window_2.BackColor = "ffffff";
       Window_2.ImageURI = "";
       Window_2.Enabled = "True";
       Window_2.Visible = "True";
      

  8.   

    上面重复的问题我自己解决了,还有这个问题
    还有问题,如果我加属性怎么插入呢 ? 
    <HMIWindow Type="Window" Name="Window_1" CType= “” CName=“”>