使用simple transformation查找xml file内某个节点的attribute是否存在指定value
Created by Jerry Wang on Jun 05, 2014
下列report實現(xiàn)通過simple transformation查找xml 文件內(nèi)下列路徑的節(jié)點ds其attribute uri的值是否等于指定值:
使用tcode STRANS創(chuàng)建simple transformation,copy如下source code:
<xsl:transform version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:sap="http://www.sap.com/sapxsl"xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml" > <xsl:param name="MY_NAMESPACE" sap:type="string" /> <xsl:strip-space elements="*"/> <xsl:template match="/"> <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><xsl:apply-templates select="ds:datastoreItem/ds:schemaRefs/ds:schemaRef"/></asx:values> </asx:abap> </xsl:template> <xsl:template match="ds:datastoreItem/ds:schemaRefs/ds:schemaRef"><xsl:if test="@ds:uri = $MY_NAMESPACE"><RESULT>X</RESULT></xsl:if> </xsl:template> </xsl:transform>運行結(jié)果:
關(guān)于xslt的語法
The match attribute is used to associate the template with an XML element. The match attribute can also be used to define a template for a whole branch of the XML document (i.e. match="/" defines the whole document).
2. The xsl:apply-templates element applies a template to the current element or to the current element’s child nodes.
If we add a select attribute to the xsl:apply-templates element it will process only the child element that matches the value of the attribute. We can use the select attribute to specify the order in which the child nodes are processed.
總結(jié)
以上是生活随笔為你收集整理的使用simple transformation查找xml file内某个节点的attribute是否存在指定value的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用代码判断某个note是否已经impl
- 下一篇: SAP ABAP ALV list ba