xslt - Altova's and Cooktop's different result -


i have lookup table table take result if buyeritemcode=substring(field[@id='0'], 11,3) subfamily=subfamily lookup table, otherwise '9':

<lookup>     <code>         <buyeritemcode>439</buyeritemcode>         <subfamily>016</subfamily>               </code> </lookup>    

xml file looks:

<document>     <line id="14">         <field id="0"><![cdata[mmm4443 419280600000]]></field>     </line>     <line id="15">         <field id="0"><![cdata[mmm4443 414390600000]]></field>     </line> </document> 

i need compare data lookup.xml , if data not compare insert constant 9. altova v11 program works, cooktop doesn't, mean comparing false. program looks:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:date="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="date exsl">     <xsl:output omit-xml-declaration="yes" indent="yes"/>     <xsl:key name="prodsubfamily" match="subfamily" use="../buyeritemcode"/>     <xsl:template match="/">         <interchange>             <group>                 <message>                     <xsl:if test="/document/line[(substring(field[@id='0'], 1,3)='mmm')]">                         <xsl:apply-templates mode="mmm" select="/document"/>                     </xsl:if>                 </message>             </group>         </interchange>     </xsl:template>     <xsl:template mode="mmm" match="/document">         <pricecatalogue-lines>             <xsl:for-each select="/document/line[contains(substring(field[@id='0'], 1,3),'mmm') , not(contains(substring(field[@id='0'],9,1),'0'))]">                 <xsl:variable name="inputprod" select="substring(field[@id='0'], 11,3)"/>                 <line>                     <line-item>                         <linenumber>                             <xsl:value-of select="position()"/>                         </linenumber>                         <buyeritemcode>                             <xsl:value-of select="substring(field[@id='0'], 11,3)"/>                         </buyeritemcode>                         <subfamily>                             <xsl:choose>                                 <xsl:when test="substring(field[@id='0'], 11,3) = document('lookup.xml')/*/*/buyeritemcode">                                     <xsl:for-each select="document('lookup.xml')">                                         <xsl:for-each select="key('prodsubfamily',$inputprod)">                                             <xsl:value-of select="."/>                                         </xsl:for-each>                                     </xsl:for-each>                                 </xsl:when>                                 <xsl:otherwise>                                     <xsl:value-of select="'9'"/>                                 </xsl:otherwise>                             </xsl:choose>                         </subfamily>                     </line-item>                 </line>             </xsl:for-each>         </pricecatalogue-lines>     </xsl:template> </xsl:stylesheet> 

correct result altova , want result cooktop:

<interchange>     <group>         <message>             <pricecatalogue-lines>                 <line>                     <line-item>                         <linenumber>1</linenumber>                         <buyeritemcode>928</buyeritemcode>                         <subfamily>9</subfamily>                     </line-item>                 </line>                 <line>                     <line-item>                         <linenumber>2</linenumber>                         <buyeritemcode>439</buyeritemcode>                         <subfamily>016</subfamily>                     </line-item>                 </line>             </pricecatalogue-lines>         </message>     </group> </interchange> 

bad result cooktop:

<interchange> <group> <message> <pricecatalogue-lines> <line> <line-item> <linenumber>1</linenumber> <buyeritemcode>928</buyeritemcode> <subfamily>9</subfamily> </line-item> </line> <line> <line-item> <linenumber>2</linenumber> <buyeritemcode>439</buyeritemcode> <subfamily>9</subfamily> </line-item> </line> </pricecatalogue-lines> </message> </group> </interchange> 

the problem in source xml document:

the cdata sections contain unnecessary [ character , first character of text node. means that:

substring(field[@id='0'], 1,3)='mmm' 

is false()

solution:

replace:

<field id="0"><![cdata[[mmm4443 419280600000]]></field> 

with:

<field id="0"><![cdata[mmm4443 419280600000]]></field> 

also replace:

<field id="0"><![cdata[[mmm4443 414390600000]]></field> 

with

<field id="0"><![cdata[mmm4443 414390600000]]></field> 

now, regardless of xslt processor used (i have 9 of them @ home , run on 8 of them: msxml3/4, .net xslcompiledtransform , xsltransform, altovaxml, saxon 6.5.4, saxon 9.1.05 , xqsharp), result of transformation guess wanted:

<interchange>   <group>     <message>       <pricecatalogue-lines>         <line>           <line-item>             <linenumber>1</linenumber>             <buyeritemcode>928</buyeritemcode>             <subfamily>9</subfamily>           </line-item>         </line>         <line>           <line-item>             <linenumber>2</linenumber>             <buyeritemcode>439</buyeritemcode>             <subfamily>016</subfamily>           </line-item>         </line>       </pricecatalogue-lines>     </message>   </group> </interchange> 

my guess cooktop's xslt processor needs configuration in order enabled execute document() function -- study available documentation how this.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -