日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用simple transformation查找xml file内某个节点的attribute是否存在指定value

發(fā)布時間:2023/12/19 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用simple transformation查找xml file内某个节点的attribute是否存在指定value 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Created by Jerry Wang on Jun 05, 2014

下列report實現(xiàn)通過simple transformation查找xml 文件內(nèi)下列路徑的節(jié)點ds其attribute uri的值是否等于指定值:

REPORT zdoc_trans_find_namespace. DATA: lv_xml TYPE string,lv_xml2 TYPE string,lv_result1 TYPE abap_bool,lv_result2 TYPE abap_bool. START-OF-SELECTION.lv_xml = '<?xml version="1.0" encoding="UTF-8"?>' &&`<ds:datastoreItem xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml" ds:itemID="{0090FA0D-8DC2-1ED3-B783-90F3808D030B}">`&& `<ds:schemaRefs><ds:schemaRef ds:uri="http://schemas.sap.com/crm"/></ds:schemaRefs></ds:datastoreItem>`.lv_xml2 = zcl_jerry_tool=>get_file_content_by_path( '\\TSHomeServer\TSHome$\i042416\Desktop\1.xml' ).CALL TRANSFORMATION zcontains_customxmlPARAMETERS my_namespace = 'http://schemas.sap.com/crm'SOURCE XML lv_xmlRESULT result = lv_result1.CALL TRANSFORMATION zcontains_customxmlPARAMETERS my_namespace = 'http://schemas.sap.com/crm'SOURCE XML lv_xml2RESULT result = lv_result2.WRITE:/ 'Result1: ', lv_result1, ' Result2: ' , lv_result2.

使用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 xsl:template element contains rules to apply when a specified node is matched.
  • 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)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。