Created by Jerry Wang on Jun 05, 2014

下列report实现通过simple transformation查找xml 文件内下列路径的节点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创建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>

运行结果:

关于xslt的语法

  1. 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.

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

  1. Tomcat中server.xml文件内各节点详解

    由于 Tomcat 基于 Java,实际上在各种 Linux 发行版里的配置方法都大同小异,只是我看见在 Arch Linux 环境里搭建 Tomcat 的文章比较少,所以在 Arch Linux 实 ...

  2. Android 异常 “Binary XML file line # : Error inflating class”

    自己的项目在Pad上一直运行正常,可是当运行在手机上时在一个Inflater.inflater()解析布局时出现了运行时异常" Binary XML file line # : Error ...

  3. ijkplayer eclipse 运行错误解决java.lanBinary XML file line #16: Error inflating class tv.danmaku.ijk.media

    移植android studio的ijkplayer sample到eclipse.运行时提示 程序停止运行,log如下: 折腾了一下午,终于解决了. 04-02 20:37:14.471: D/da ...

  4. android error inflating 自定义控件,解决Android 异常 “Binary XML file line # : Error inflating class”...

    自己的项目在5.0及以上的手机山一直运行正常,可是当运行在低版本手机上时在一个Inflater.inflater()解析布局时出现了运行时异常" Binary XML file line # ...

  5. 报错android.view.InflateException: Binary XML file line #11: Attempt to invoke virtual method 'boolean

    出现这种问题,打开Android monitor的调试信息发现是 android.view.InflateException: Binary XML file line #11: Attempt to ...

  6. operate XML file (Open,Insert)

    1. Some specific  name: XmlDocument XmlNodeList XmlNode XmlElement     The whole architecture and re ...

  7. SAP ABAP实用技巧介绍系列之 使用simple transformation的mapping功能

    Created by Jerry Wang, last modified on Jun 25, 2014 Simple transformation如下: 当node VALTO_DATE的value ...

  8. JAVA-基础(查找文件夹内文件)

    JAVA-基础(查找文件夹内文件) 1.目的? 查找指定文件夹内的文件.以查询.txt结尾的文件为例. 2.分析? 目录搜索,无法判断多少级目录,所以使用递归,遍历所有目录. 遍历目录时,获取的子文件 ...

  9. Android 运行时异常 Binary XML file line # : Error inflating class

    今天在做一个二维码扫描的项目的时候出现了一个错误: android.view.InflateException: Binary XML file line #12: Error inflating c ...

最新文章

  1. Matlab并行运算
  2. 自然语言处理NLP常用开源/免费工具
  3. P1001 第K极值【tyvj】
  4. Linux 设备驱动中的 I/O模型(二)—— 异步通知和异步I/O
  5. 【债券】可转换债券基本概念
  6. 安川机器人焊枪切换设定方法_【分享】焊接机器人的性能要求与系统构成
  7. zabbix企业应用之固定端口监控memcache
  8. C++ 常见错误(01) —— error LNK1104: 无法打开文件“avcodec.lib”
  9. 华成英模拟电子技术笔记(1)-绪
  10. python毕业设计作品基于django框架 电影院购票选座系统毕设成品(5)任务书
  11. protoc ——protubuf编译后的可执行文件命令usage
  12. 【C#】基于Opencv/Emgucv的身份证识别
  13. 万年历打印Java_java实验之打印万年历
  14. 2008年买书流水账
  15. 台湾ICPlus九旸 5接口FE以太网交换机 IP175G,IP175GH/GHI
  16. Android 手机重启相关内容
  17. 附录2-PS基本操作
  18. DNS 系列(三):如何免受 DNS 欺骗的侵害
  19. F28027-Flash介绍
  20. 友盟消息推送SDK集成

热门文章

  1. php的webservice的soapheader认证问题
  2. 对几种二叉树的简单理解
  3. 签名build apk: Could not resolve all files for configuration ':app:lintClassPath' 问题
  4. 《犯罪心理学》读书笔记(part11)--犯罪心理的性别差异(中)
  5. 精选22个Pandas函数!
  6. 把 SAP UI5 应用部署到 SAP Kyma
  7. SAP Commerce Cloud启动时遇到的9001端口被占用的问题
  8. SAP Spartacus 基于行项目的订单取消功能(order cancel)实现
  9. 您的主机不满足在启用Hyper-V 或DeviceCredential Guard的情况下运行VMware player的最低要求
  10. 如何检查并unregister本地注册的Chrome service worker