我有一个结果集结构,例如
<ResultSets>
<ResultSet rowCount="100">
<Row>
<InvoiceNr>12345</InvoiceNr>
<InvoiceItem>0</InvoiceItem>
<Year>2014</Year>
<Month>201401</Month>
<Week>201402</Week>
<ItemCategory/>
<BillingType/>
<BPCodeSoldTo>123456</BPCodeSoldTo>
<BPCodeShipTo/>
</Row>
<Row>
<InvoiceNr>123452</InvoiceNr>
<InvoiceItem>1</InvoiceItem>
<Year>2014</Year>
<Month>201401</Month>
<Week>201402</Week>
<ItemCategory/>
<BillingType/>
<BPCodeSoldTo>123452</BPCodeSoldTo>
<BPCodeShipTo/>
<BPCodeBillTo/>
</Row>
</ResultSet>
</ResultSets>
我需要将结构更改为
<io>
<row>
<col>12345</col>
<col>0</col>
<col>2014</col>
<col>201401</col>
<col>201402</col>
<col/>
<col/>
<col>123456</col>
<col/>
<col/>
</row>
<row>
<col>123452</col>
<col>1</col>
<col>2014</col>
<col>201401</col>
<col>201402</col>
<col/>
<col/>
<col>123452</col>
<col/>
<col/>
</row>
</io>
我现在已经完成了(这不是实际的代码,只是一个想法)并且它有效。但有没有办法不明确ID列标记名称,并有一个语句,只捕获所有子标记并放入值strucutre?
<row>
<xsl:foreach../RecordSets/RecordSet/Row>
<col>
<xsl:value of select = "InvoiceNr"/>
</col>
<col>
<xsl:value of select = "InvoiceItem"/>
</col>
<col>
<xsl:value of select = "Year"/>
</col>
<col>
<xsl:value of select = "InvoiceNr"/>
</col>
....
</xsl:foreach>
</row>
***另一个问题。在我的原始结构中。我可能有ResultSets / ResultSet或Just ResulSet(取决于它运行的查询类型)如何忽略它,只是说ResultSets / ResultSet / Row或ResultSet / Row可以工作?
答案 0 :(得分:0)
有没有一种方法可以不显式标识列标记名称并具有 声明只捕获所有子标记并投入值 strucutre?
以这种方式试试吗?
<xsl:template match="/">
<io>
<xsl:for-each select="ResultSets/ResultSet/Row">
<row>
<xsl:for-each select="*">
<col><xsl:value-of select="."/></col>
</xsl:for-each>
</row>
</xsl:for-each>
</io>
</xsl:template>
我可能有ResultSets / ResultSet或Just ResulSet(取决于类型 查询它被运行)我如何忽略它,只是说 ResultSets / ResultSet / Row或ResultSet / Row可以工作吗?
使用:
<xsl:for-each select="ResultSets/ResultSet/Row | ResultSet/Row">
哦......还有一件事。无论如何要排除某些标签 声明。例如,选择 除了tagname =
之外的所有内容<EXEMPT_ID>
??
是的,使用谓词:
<xsl:for-each select="*[not(self::EXEMPT_ID)]">