小编Abh*_*bhi的帖子

仅剥离空根元素

我有一个输入XML,看起来像这样,并希望使用XSL转换如下所示的所需输出.我一直在浏览博客但是找不到任何关于如何删除匹配根元素而不是子节点的空标签的相关性.

<?xml version="1.0" encoding="UTF-8"?>
<objects xmlns="urn:sobject.partner.soap.sforce.com">
  <Revenue__c/>
  <Revenue__c/>
  <Revenue__c/>
  <Revenue__c>
    <Sales_Org_ID__c>IV</Sales_Org_ID__c>
    <Branch_ID__c>1</Branch_ID__c>
    <Branch_Name__c>TEST</Branch_Name__c>
    <Therapy_Code__c>TEST</Therapy_Code__c>
    <Therapy_Name__c>TEST</Therapy_Name__c>
    <Therapy_Class_Code__c>TEST</Therapy_Class_Code__c>
    <Therapy_Class_Name__c>TEST</Therapy_Class_Name__c>
    <Payor_Type_Name__c>TEST</Payor_Type_Name__c>
    <Calendar_Year_Number__c>2011</Calendar_Year_Number__c>
    <Month_Revenue_Amount__c>100.01</Month_Revenue_Amount__c>
    <Payor_ID__c>TEST</Payor_ID__c>
    <Payor_Name__c/>
    <Payor_Type_Code__c>TEST</Payor_Type_Code__c>
    <MDM_Account_EID__c>66600001</MDM_Account_EID__c>
    <MDM_Physician_EID__c>99900001</MDM_Physician_EID__c>
    <Account__c>001a000001APU5OAAX</Account__c>
    <Contact__c>003a000001RL1EFAA1</Contact__c>
    <Revenue_ID__c>41</Revenue_ID__c>
    <Calendar_Year_Month__c>01</Calendar_Year_Month__c>
  </Revenue__c>
</objects>
Run Code Online (Sandbox Code Playgroud)

这正是我想要的:

<?xml version="1.0" encoding="UTF-8"?>
<objects xmlns="urn:sobject.partner.soap.sforce.com">
  <Revenue__c>
    <Sales_Org_ID__c>IV</Sales_Org_ID__c>
    <Branch_ID__c>1</Branch_ID__c>
    <Branch_Name__c>TEST</Branch_Name__c>
    <Therapy_Code__c>TEST</Therapy_Code__c>
    <Therapy_Name__c>TEST</Therapy_Name__c>
    <Therapy_Class_Code__c>TEST</Therapy_Class_Code__c>
    <Therapy_Class_Name__c>TEST</Therapy_Class_Name__c>
    <Payor_Type_Name__c>TEST</Payor_Type_Name__c>
    <Calendar_Year_Number__c>2011</Calendar_Year_Number__c>
    <Month_Revenue_Amount__c>100.01</Month_Revenue_Amount__c>
    <Payor_ID__c>TEST</Payor_ID__c>
    <Payor_Name__c/>
    <Payor_Type_Code__c>TEST</Payor_Type_Code__c>
    <MDM_Account_EID__c>66600001</MDM_Account_EID__c>
    <MDM_Physician_EID__c>99900001</MDM_Physician_EID__c>
    <Account__c>001a000001APU5OAAX</Account__c>
    <Contact__c>003a000001RL1EFAA1</Contact__c>
    <Revenue_ID__c>41</Revenue_ID__c>
    <Calendar_Year_Month__c>01</Calendar_Year_Month__c>
  </Revenue__c>
</objects>
Run Code Online (Sandbox Code Playgroud)

任何建议将不胜感激.

xml xslt strip

2
推荐指数
1
解决办法
216
查看次数

在javascript中将yyyy-MM-dd转换为MM/dd/yyyy

这可能是一个简单的解决方案,但我卡住了,基本上我需要将传入的yyyy-MM-dd转换为MM/dd/yyyy,如果传入日期为零,则输出也应为零.

传入日期可以是以下格式

2015-01-25 or nil
Run Code Online (Sandbox Code Playgroud)

输出日期应该是

01/25/2015 or nil
Run Code Online (Sandbox Code Playgroud)

我尝试从以下链接 转换日期yyyy/mm/dd到MM dd yyyy,但无法使其工作.

谢谢你的帮助.

忘记提及,在xml文件中,作为nil的传入日期具有以下格式

<Through_Date__c xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
Run Code Online (Sandbox Code Playgroud)

因此,如果我得到上面的格式,输出应该只是零

javascript

2
推荐指数
2
解决办法
3万
查看次数

标签 统计

javascript ×1

strip ×1

xml ×1

xslt ×1