buyeritemcode = substring (field [@ id = '0'], 11,3) 다음 lookf table에서 subfamily = 서브 패밀리가 있으면 결과를 가져 오는이 테이블의 lookup 테이블이 있습니다.Altova 및 cooktop의 다른 결과
<lookup>
<Code>
<BuyerItemCode>439</BuyerItemCode>
<Subfamily>016</Subfamily>
</Code>
</lookup>
XML 파일은 같습니다
<document>
<line id="14">
<field id="0"><![CDATA[MMM4443 419280600000]]></field>
</line>
<line id="15">
<field id="0"><![CDATA[MMM4443 414390600000]]></field>
</line>
</document>
내가 lookup.xml와이 데이터를 비교해야하고 데이터가 비교되지 않을 경우 내 프로그램이 작동 altova의 V11과 함께 일정 (9)를 삽입 렌지하지 않는으로, 나는 비교가 거짓이라는 뜻입니다. 내 프로그램은 같습니다
<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') and 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>
내가 Altova으로 얻을 내가 쿡탑이 결과를 얻을 것이다 할
올바른 결과 :
<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 결과 :
<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>
을
쿡탑의 출력은 무엇입니까? 비어있는 ''요소? –
LarsH
좋은 질문입니다. +1. 문제의 설명과 쉬운 해결책을 위해 내 대답을 참조하십시오. :) –
@LarsH : cooktop에 서브 패밀리 = 9 – Petras