使用XSLT格式化从FileMaker导出的XML以重映射字段

时间:2015-08-07 15:53:28

标签: xml xslt export filemaker

我为公司管理Filemaker系统,我们需要将xml产品订单导出到我们的供应商之一,用于他们的EDI系统。我是这个xslt的完全黑客但不知何故我设法根据他们的ALMOST工作要求创建了以下xslt模板。我的问题是我需要将来自Filemaker系统“PO_Num”的数据放入采购订单的ID =区域而不是“TestPO”,并且不知道如何格式化

<purchaseOrder orderDate="2015-08-15" id= "TestPO" >

这是我们的完整xslt代码:

<?xml version='1.0' encoding='UTF-8' ?>
<xsl:stylesheet version='1.0'   
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:fm="http://www.filemaker.com/fmpdsoresult"
exclude-result-prefixes="fm">

<xsl:output version='1.0' encoding='UTF-8' indent='yes' method='xml' />

<xsl:template match="/">

<Order>
  <xsl:for-each select="fm:FMPDSORESULT/fm:ROW">

<purchaseOrder orderDate="2015-08-15" id= "TestPO" >
    <referenceNumber></referenceNumber>
    <customer_ID><xsl:value-of select="fm:Account_Number_Prog_Code"/></customer_ID> 
    <subteamName></subteamName>          
    <shipdate>2015-09-15</shipdate> 
    <shipdateqaulifier></shipdateqaulifier>      

    <vendor country="US">
            <name>Vendor Name</name>                    
            <address>1234 Main Street</address>                    
            <address2></address2>                                                                   
            <city>Anytown</city>                                        
            <state>NY</state>                                          
            <zip>00000</zip>                                           
            <phone>123-456-7890</phone>             
    </vendor>                             

    <billto country="US"> 
            <name>Our Company</name>                    
            <address>4321 South Street</address>                    
            <address2>#275</address2>                                                                   
            <city>Your Town</city>                                        
            <state>CA</state>                                          
            <zip>00000</zip>                                           
            <phone>800-432-1234</phone>             
            <fax>800-432-1235</fax>               
    </billto>


    <shipto country="US">
            <name><xsl:value-of select="fm:Store_Name"/></name>
            <address><xsl:value-of select="fm:Store_Address"/></address>
            <address2></address2>
            <city><xsl:value-of select="fm:Store_City"/></city>
            <state><xsl:value-of select="fm:Store_State"/></state>
            <zip><xsl:value-of select="fm:Store_Zip"/></zip>
            <phone><xsl:value-of select="fm:Store_Phone"/></phone>
            <fax><xsl:value-of select="fm:Store_Fax"/></fax>
      </shipto>

    <buyer country="US">
            <name>Our Company</name>                    
            <address>4321 South Street</address>                    
            <address2>#275</address2>                                                                   
            <city>Your Town</city>                                        
            <state>CA</state>                                          
            <zip>00000</zip>                                           
            <phone>800-432-1234</phone>          
    </buyer>                           

    <comment></comment>

    <customer><xsl:value-of select="fm:Account_Number_Prog_Code"/></customer> 
    <acknowledge_note ></acknowledge_note>

    <items>                            
        <item vendorPartNum="012345678912">
            <WFMSKU>12345</WFMSKU>             
            <posDept></posDept>             
            <productName>PRODUCt BUNDLE</productName> 
            <casePack>1</casePack>                            
            <packSize></packSize>                         
            <UOM></UOM>                                                                                                
            <USPrice>Bundle Price</USPrice>                             
            <quantity Unit="EA">1</quantity>                                         
            <eaches>1</eaches>                                                           
        </item>                                              
    </items>


</purchaseOrder>

  </xsl:for-each>
</Order>
</xsl:template>
</xsl:stylesheet>

它产生下面的结果对我们来说几乎是完美的,除了我不知道如何用Filemaker PO_Num字段中的实际数据链接替换模板中的“TestPO”文本。使用xsl:value-of select =“fm:PO_Num”在id =部分代码中不起作用:

<?xml version="1.0" encoding="UTF-8"?>
<Order>
    <purchaseOrder orderDate="2015-08-15" id="TestPO">
        <referenceNumber/>
        <customer_ID>GN1234567</customer_ID>
        <subteamName/>
        <shipdate>2015-09-15</shipdate>
        <shipdateqaulifier/>
        <vendor country="US">
            <name>Vendor Name</name>
            <address>1234 Main Street</address>
            <address2/>
            <city>Anytown</city>
            <state>NY</state>
            <zip>00000</zip>
            <phone>123-456-7890</phone>
        </vendor>
        <billto country="US">
            <name>Our Company</name>
            <address>4321 South Street</address>
            <address2>#275</address2>
            <city>Your Town</city>
            <state>CA</state>
            <zip>00000</zip>
            <phone>800-432-1234</phone>
            <fax>800-432-1235</fax>
        </billto>
        <shipto country="US">
            <name>Test Store</name>
            <address>1234 West Street</address>
            <address2/>
            <city>My Town</city>
            <state>CA</state>
            <zip>91105</zip>
            <phone>213-123-1235</phone>
            <fax>213-123-1234</fax>
        </shipto>
        <buyer country="US">
            <name>Our Company</name>
            <address>4321 South Street</address>
            <address2>#275</address2>
            <city>Your Town</city>
            <state>CA</state>
            <zip>00000</zip>
            <phone>800-432-1234</phone>
        </buyer>
        <comment/>
        <customer>GN1234567</customer>
        <acknowledge_note/>
        <items>
            <item vendorPartNum="012345678912">
                <WFMSKU>12345</WFMSKU>
                <posDept/>
                <productName>PRODUCt BUNDLE</productName>
                <casePack>1</casePack>
                <packSize/>
                <UOM/>
                <USPrice>Bundle Price</USPrice>
                <quantity Unit="EA">1</quantity>
                <eaches>1</eaches>
            </item>
        </items>
    </purchaseOrder>
</Order>

我确信这可能是一个简单的解决办法,但我似乎已经在我脑海中。任何解决方案或建议将不胜感激!

谢谢, 鲍勃

1 个答案:

答案 0 :(得分:0)

  

如何更换&#34; TestPO&#34;带有实际数据链接的模板中的文本   来自Filemaker PO_Num字段。

如果没有看到您的原始出口,很难回答您的问题。尝试:

<purchaseOrder orderDate="2015-08-15" id="{fm:PO_Num}">

当然,日期也不应该是硬编码的。