原格式如下:
<span row="1" col="1"/>
<span row="1" col="2"/>
<span row="2" col="1"/>
.....................目标格式:
<row index="1">
<col index="1"/>
</row>
.........应该如何处理?
<span row="1" col="1"/>
<span row="1" col="2"/>
<span row="2" col="1"/>
.....................目标格式:
<row index="1">
<col index="1"/>
</row>
.........应该如何处理?
解决方案 »
- winform 中的 panel如何才能让其只出现竖直方向的滚动条?
- 定义的 student 索引用不了
- InvokeMember报错!!!谢谢!
- socket异步通讯问题
- [真心求问]小弟刚接触C#不久,最近遇到了一点问题,关于C#中使用Win32API的问题,请大侠赐教
- 在WEB上怎样实现及时提醒功能..备忘录怎么实现..谢谢大侠..
- 请朋友对用.NET开发winform软件的看法
- 数据集合并绑定dataGridView4列顺序会变化
- 100分球第三方控件网址,要求能下载,能使用,最好免费
- 奇怪! 这个结构为什么不能传递到函数中去呢?
- DataTable中筛选数据
- 急求助!有BindingSource.Item属性吗???
类似
http://blog.csdn.net/net_lover/archive/2002/05/16/6900.aspx
<row index="1">
<col index="1"/>
<col index="2"/>
</row>
<row index="2">
<col index="1">
<col index="2">
</row>
........
这样没有对应吗?
<body><script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("cdcatalog.xml")// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cdcatalog.xsl")// Transform
document.write(xml.transformNode(xsl))</script></body>
</html>
------------------------
cdcatalog.xml<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>------------------------
cdcatalog.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd"> ---- for-each读取xml节点
<tr>
<td><xsl:value-of select="title" /></td>
<td><xsl:value-of select="artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>
xsl:if (@row)
creamteelement(row)
xsl:if (@col)
createelement(col)
.............
伪代码,
下面有结构转换的例子
http://blog.csdn.net/honkerhero/archive/2007/03/14/1528837.aspx
<xsl:key name="row" match="@row" use="."/>
<xsl:for-each select="span/@row[generate-id()=generate-id(key('row',.))]">
<Row Index="{current()+1}">
<xsl:for-each select="../../span[@row = current()]">
<Cell Index="{@col}">
<xsl:value-of select="@text"/>
</Cell>
</xsl:for-each>
</Row>
</xsl:for-each>
<!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by opec (opec) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Table">
<table>
<xsl:if test="@ID!=''">
<xsl:attribute name="ID"><xsl:value-of select="@ID"/></xsl:attribute>
</xsl:if>
<xsl:if test="@CssClass!=''">
<xsl:attribute name="Class"><xsl:value-of select="@CssClass"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Style!=''">
<xsl:attribute name="Style"><xsl:value-of select="@Style"/></xsl:attribute>
</xsl:if>
<xsl:if test="@HAlign!=''">
<xsl:attribute name="Align"><xsl:value-of select="@HAlign"/></xsl:attribute>
</xsl:if>
<xsl:if test="@VAlign!=''">
<xsl:attribute name="VAlign"><xsl:value-of select="@VAlign"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Width!=''">
<xsl:attribute name="Width"><xsl:value-of select="@Width"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Height!=''">
<xsl:attribute name="Height"><xsl:value-of select="@Height"/></xsl:attribute>
</xsl:if>
<xsl:if test="@BgColor!=''">
<xsl:attribute name="BgColor"><xsl:value-of select="@BgColor"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Border!=''">
<xsl:attribute name="Border"><xsl:value-of select="@Border"/></xsl:attribute>
</xsl:if>
<xsl:if test="@BorderColor!=''">
<xsl:attribute name="BorderColor"><xsl:value-of select="@BorderColor"/></xsl:attribute>
</xsl:if>
<xsl:if test="@CellPadding!=''">
<xsl:attribute name="CellPadding"><xsl:value-of select="@CellPadding"/></xsl:attribute>
</xsl:if>
<xsl:if test="@CellSpacing!=''">
<xsl:attribute name="CellSpacing"><xsl:value-of select="@CellSpacing"/></xsl:attribute>
</xsl:if>
<xsl:if test="@OnClick!=''">
<xsl:attribute name="OnClick"><xsl:value-of select="@OnClick"/></xsl:attribute>
</xsl:if>
<xsl:if test="@OnDbClick!=''">
<xsl:attribute name="OnDbClick"><xsl:value-of select="@OnDbClick"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="DataRow">
<tr>
<xsl:if test="@CssClass!=''">
<xsl:attribute name="Class"><xsl:value-of select="@CssClass"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Style!=''">
<xsl:attribute name="Style"><xsl:value-of select="@Style"/></xsl:attribute>
</xsl:if>
<xsl:if test="@HAlign!=''">
<xsl:attribute name="Align"><xsl:value-of select="@HAlign"/></xsl:attribute>
</xsl:if>
<xsl:if test="@VAlign!=''">
<xsl:attribute name="VAlign"><xsl:value-of select="@VAlign"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Width!=''">
<xsl:attribute name="Width"><xsl:value-of select="@Width"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Height!=''">
<xsl:attribute name="Height"><xsl:value-of select="@Height"/></xsl:attribute>
</xsl:if>
<xsl:if test="@BgColor!=''">
<xsl:attribute name="BgColor"><xsl:value-of select="@BgColor"/></xsl:attribute>
</xsl:if>
<xsl:if test="@BorderColor!=''">
<xsl:attribute name="BorderColor"><xsl:value-of select="@BorderColor"/></xsl:attribute>
</xsl:if>
<xsl:if test="@OnClick!=''">
<xsl:attribute name="OnClick"><xsl:value-of select="@OnClick"/></xsl:attribute>
</xsl:if>
<xsl:if test="@OnDbClick!=''">
<xsl:attribute name="OnDbClick"><xsl:value-of select="@OnDbClick"/></xsl:attribute>
</xsl:if>
<xsl:for-each select="Column[@IsDisplay='True']">
<td>
<xsl:if test="@CssClass!=''">
<xsl:attribute name="Class"><xsl:value-of select="@CssClass"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Style!=''">
<xsl:attribute name="Style"><xsl:value-of select="@Style"/></xsl:attribute>
</xsl:if>
<xsl:if test="@ColSpan!=''">
<xsl:attribute name="ColSpan"><xsl:value-of select="@ColSpan"/></xsl:attribute>
</xsl:if>
<xsl:if test="@RowSpan!=''">
<xsl:attribute name="RowSpan"><xsl:value-of select="@RowSpan"/></xsl:attribute>
</xsl:if>
<xsl:if test="@HAlign!=''">
<xsl:attribute name="Align"><xsl:value-of select="@HAlign"/></xsl:attribute>
</xsl:if>
<xsl:if test="@VAlign!=''">
<xsl:attribute name="VAlign"><xsl:value-of select="@VAlign"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Width!=''">
<xsl:attribute name="Width"><xsl:value-of select="@Width"/></xsl:attribute>
</xsl:if>
<xsl:if test="@Height!=''">
<xsl:attribute name="Height"><xsl:value-of select="@Height"/></xsl:attribute>
</xsl:if>
<xsl:if test="@BgColor!=''">
<xsl:attribute name="BgColor"><xsl:value-of select="@BgColor"/></xsl:attribute>
</xsl:if>
<xsl:if test="@BorderColor!=''">
<xsl:attribute name="BorderColor"><xsl:value-of select="@BorderColor"/></xsl:attribute>
</xsl:if>
<xsl:if test="@OnClick!=''">
<xsl:attribute name="OnClick"><xsl:value-of select="@OnClick"/></xsl:attribute>
</xsl:if>
<xsl:if test="@OnDbClick!=''">
<xsl:attribute name="OnDbClick"><xsl:value-of select="@OnDbClick"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="Value">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="BR">
<br/>
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="Page">
<p style="page-break-after:always"></p>
</xsl:template>
</xsl:stylesheet>