我想对“ zero:PosNo”进行分组 如果删除组命令,它将返回结果,但显然返回以下结果:
INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION)
VALUES ('6111', '26-0008-R552-MOD-01-M', '1','PIP03D1160', 'PIPE sch.160 ASTM A790 UNS S31', 2.000, 'M', 2.000, 42.700, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A790 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.559, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');
INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES
('6111', '26-0008-R552-MOD-01-M', '1','PIP03D1160', 'PIPE sch.160 ASTM A790 UNS S31', 0.660, 'M', 0.660, 14.093, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A790 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.184, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');
xmlns:zero="rosenbergverft.com:3D/2011/Zero"
<xsl:output method="text" omit-xml-declaration="yes" standalone="no" media-type="text/plain"/>
<xsl:template match="/">
<xsl:for-each select="/zero:Zero/zero:MTOOwner/zero:DocumentNo/zero:BiProduct/zero:Part">
<xsl:for-each-group select="/" group-by="zero:POS_NO">
<xsl:sort select="zero:PosNo" />
INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES ('
<xsl:value-of select="../../../../pdms:PDMSProject/pdms:ProjectNumber/@text" />',
'<xsl:value-of select="zero:MtoOwnerNo" />',
'<xsl:value-of select="zero:PosNo" />',
'<xsl:value-of select="zero:StockNo" />',
'<xsl:value-of select="zero:Description" />',
<xsl:choose>
<xsl:when test="zero:Quantity/@unit = 'mm2'"><xsl:value-of select="format-number(zero:Quantity/@number div 1000000, '#0.000')"/><xsl:text>, 'M2'</xsl:text></xsl:when>
<xsl:when test="zero:Quantity/@unit = 'mm'"><xsl:value-of select="format-number(zero:Quantity/@number div 1000, '#0.000')"/><xsl:text>, 'M'</xsl:text></xsl:when>
<xsl:when test="zero:Quantity/@unit = 'pcs'"><xsl:value-of select="format-number(zero:Quantity/@number, '#0')"/><xsl:text>, 'EA'</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(zero:Quantity/@number, '#0.000')"/><xsl:text>, ''</xsl:text></xsl:otherwise>
</xsl:choose>,
<xsl:value-of select="format-number(zero:TotalLength/@number div 1000, '#0.000')" />,
<xsl:value-of select="zero:TotalWeight/@number" />,
'<xsl:value-of select="zero:DocumentNo" />', '<xsl:value-of select="zero:Grade" />',
<xsl:choose>
<xsl:when test="zero:Traceable/@boolean = 'false'"><xsl:text>'N'</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>'Y'</xsl:text></xsl:otherwise>
</xsl:choose>,
'<xsl:value-of select="zero:BiProduct" />',
<xsl:value-of select="format-number(zero:Surface/@number div 1000000, '#0.000')" />,
'<xsl:value-of select="zero:Calc" />', '<xsl:value-of select="zero:Discipline" />',
'<xsl:value-of select="zero:Designer" />', '<xsl:value-of select="zero:Name" />',
<xsl:value-of select="../../../zero:PlantSeq/@number" />, '<xsl:value-of select="../../../zero:ObjectSeq/@number" />',
'<xsl:value-of select="../../../zero:ObjectRev" />');
</xsl:for-each-group>
</xsl:for-each>
这是我要实现的目标: 我希望汇总位置1上的数字,以便它只返回位置1的一个插入,而不返回两个。 Posno 2、3等相同。
INSERT INTO RAPP_ADM.MTO_POS_IMP_TAB (PROJECT_NO, MTO_OWNER_NO, POS_NO, PART_NO, DESCRIPTION, QTY, UNIT, TOT_LEN, TOT_WEIGHT, DRAWING, GRADE, TRACE, BI_PRODUCT, SURFACE, CALC, DISCIPLINE, MADE_BY, POS_NO2, PLT_SEQ, OBJECT_SQ, OBJECT_REVISION) VALUES
('6111', '26-0008-R552-MOD-01-M', '1','PIP03D1160', 'PIPE sch.160 ASTM A790 UNS S31', 2.66, 'M', 2.66, 56.793, 'C097-RWP-L-XN-0057-01', 'sch.160 ASTM A790 UNS S31', 'N', '26-0008-R552-MOD-01-1', 0.559, 'N', 'L', 'sindre.thompson', '', 721, '1556750', '1');
我不知道自己在做什么错。我有明显的错误吗?
答案 0 :(得分:0)
我猜不是
<xsl:for-each select="/zero:Zero/zero:MTOOwner/zero:DocumentNo/zero:BiProduct/zero:Part">
<xsl:for-each-group select="/" group-by="zero:POS_NO">
<xsl:sort select="zero:PosNo" />
您想要的
<xsl:for-each-group select="/zero:Zero/zero:MTOOwner/zero:DocumentNo/zero:BiProduct/zero:Part" group-by="zero:POS_NO">
<xsl:sort select="current-grouping-key()" />
但这只是一个猜测,请向我们展示您的输入结构和所需的结果结构。
答案 1 :(得分:0)
<xsl:for-each-group select="/">
可能是错误的,因为“ /”选择单个节点,并且对单个节点进行分组永远没有用。
但是在没有看到输入XML的情况下,很难告诉您应该写些什么。