我是XSLT的新手,我正试图在其他方面转换XML。
源XML就是这样的:
<NoticeContent>
<Version> 1.0 </Version>
<Publisher>me</Publisher>
<Specification>1</Specification>
<Instance>1</Instance>
<NewState>10</NewState>
<Info>
<SDTInInfoExtra>
<Name> Client</Name>
<Value> 1 </Value>
</SDTInInfoExtra>
<SDTInInfoExtra>
<Name> LocalId </Name>
<Value>10 </Value>
</SDTInInfoExtra>
</Info>
</NoticeContent>
预期:
<?xml version="1.0" encoding="UTF-8"?>
<NoticeContent>
<Version></Version>
<Timestamp></Timestamp>
<Publisher></Publisher>
<Instance></Instance>
<NewState></NewState>
<Info>
<Characteristic name="Client" value="1" />
<Characteristic name="LocalId" value="10" />
</Info>
</NoticeContent>
我正在尝试使用以下XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Info">
<xsl:for-each select="SDTInInfoExtra">
<xsl:value-of select="Name" />
<xsl:value-of select="Value" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
问题是尝试转换标签,如:
<SDTInInfoExtra>
<Name> LocalId </Name>
<Value>10 </Value>
</SDTInInfoExtra>
成:
<Characteristic name="Client" value="1" />
非常感谢您的帮助!
答案 0 :(得分:0)
您已经开始
了$scope.items = storeFactory.getRecords().query(
function(response) {
$scope.items=response;
$scope.totalItems = $scope.items.length;
for (var i=0, len=$scope.totalItems; i<len; i++) {
$scope.items[i].toggleValue = ($scope.items[i].SHIP_FROM_STORE_IND=='Y')? true:false;
}
},
function(response) {
$scope.waitMessage = "Error: "+response.status + " " + response.statusText;
});
所以其余的很容易:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>