<?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文件要如何写才会有这样的输出效果呀???
谢谢 !!!
<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文件要如何写才会有这样的输出效果呀???
谢谢 !!!
zhu6789888
等级:
发表于:2008-07-25 19:32:5514楼 得分:0
思归大大
孟子大大,
都去哪里了??
<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>
<?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>
<HMIWindow Type="Window" Name="Window_1" CType= “” CName=“”>
<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";
还有问题,如果我加属性怎么插入呢 ?
<HMIWindow Type="Window" Name="Window_1" CType= “” CName=“”>