XSLT:XML转换,需要SOQL查询作为输出



感谢您的解决方案。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns="urn:partner.soap.sforce.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <LimitInfoHeader>
            <limitInfo>
                <current>18029</current>
                <limit>5000000</limit>
                <type>API REQUESTS</type>
            </limitInfo>
        </LimitInfoHeader>
    </soapenv:Header>
    <soapenv:Body>
        <upsertResponse>
            <result>
                <created>false</created>
                <id xsi:nil="true"/>
                <success>false</success>
            </result>
            <result>
                <created>false</created>
                <id xsi:nil="true"/>
                <success>false</success>
            </result>
            <result>
                <created>false</created>
                <id xsi:nil="true"/>
                <success>false</success>
            </result>
        </upsertResponse>
    </soapenv:Body>
</soapenv:Envelope>

对于上述XML作为XSLT的输入,输出低于一个

<?xml version="1.0" encoding="utf-8"?><soql>select (select Id from contacts where AccountId in (SELECT  AccountId from Opportunity where id in ())), (select Id from opportunities where id in()) from account where id in (SELECT  AccountId from Opportunity where id in())</soql>

如果在给定输入XML中所有成功标签值都是错误的,则不应生成<soql>标签。我的意思是输出应该为空

最终我需要的是有效的SOQL,因此我可以查询销售人员,对于上述给定的XML输入,生成的输出不是有效的SOQL。此后,我无法查询销售人员。

因此,在需要完成XSLT的更改,需要您的帮助

谢谢

为什么不能简单地做:

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:ns="urn:partner.soap.sforce.com"
exclude-result-prefixes="ns">
<xsl:variable name="ids">
    <xsl:for-each select="//ns:result[ns:success='true']">
        <xsl:text>'</xsl:text>
        <xsl:value-of select="ns:id" />
        <xsl:text>'</xsl:text>
        <xsl:if test="position()!=last()">
            <xsl:text>,</xsl:text>
        </xsl:if>
    </xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<soql>
    <xsl:text>select (select Id from contacts where AccountId in (SELECT  AccountId from Opportunity where id in (</xsl:text>
    <xsl:value-of select="$ids"/>
    <xsl:text>))), (select Id from opportunities where id in(</xsl:text>
    <xsl:value-of select="$ids"/>
    <xsl:text>)) from account where id in (SELECT  AccountId from Opportunity where id in(</xsl:text>
    <xsl:value-of select="$ids"/>
    <xsl:text>))</xsl:text>
</soql>    
</xsl:template>
</xsl:stylesheet>  

相关内容

  • 没有找到相关文章

最新更新