Hello,
I am quite new to XML/XSLT and I face a "little" problem regarding XSLT processing. I have to generate a B2MML file using an XSL Transformation.
I synthesized the example into files bellow.
The XML file is :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<ROOTE_NODE xmlns="http://xmlns.example.com/unique/default/namespace/1311054750884">
<ID1>val_id1</ID1>
<ID2>val_id2</ID2>
<DATAAREA>
<item>
<KEY1>1000</KEY1>
<QTY_KEY1>13.10</QTY_KEY1>
<KEY2>0010</KEY2>
<KEY3>00001</KEY3>
<PrototypeID>112233</PrototypeID>
<H-Code>S023</H-Code>
</item>
<item>
<KEY1>1000</KEY1>
<QTY_KEY1>13.10</QTY_KEY1>
<KEY2>0010</KEY2>
<KEY3>00002</KEY3>
<PrototypeID>112244</PrototypeID>
<H-Code>S022</H-Code>
</item>
<item>
<KEY1>1001</KEY1>
<QTY_KEY1>19.50</QTY_KEY1>
<KEY2>0010</KEY2>
<KEY3>00001</KEY3>
<PrototypeID>112233</PrototypeID>
<H-Code>M001</H-Code>
</item>
</DATAAREA>
</ROOTE_NODE>
The XSLT is :
Code:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:amg="Pelican@Plant1" xmlns:bml="http://www.wbf.org/xml/b2mml-v02" xmlns:oag="http://www.openapplications.org/oagis" xmlns:sit="http://www.siemens.com/ad/mes/b2mml-v02-SITExt-1.0" xmlns:xsi="http://www.siemens.com/ad/mes/b2mt-1.0 C:\DATA_EXCHANGE\B2MT\B2MT_Schemas\AMG_ProductionSchedule.xsd" version="2.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="ROOTE_NODE">
<SyncProductionSchedule>
<oag:ApplicationArea>
<oag:Sender>
<oag:LogicalId>
<xsl:value-of select="ID1"/>
</oag:LogicalId>
<oag:Component>
<xsl:value-of select="ID2"/>
</oag:Component>
</oag:Sender>
</oag:ApplicationArea>
<DataArea>
<xsl:apply-templates select="DATAAREA"/>
</DataArea>
</SyncProductionSchedule>
</xsl:template>
<xsl:template match="DATAAREA">
<xsl:for-each-group select="item" group-by="KEY1">
<bml:ProductionSchedule>
<bml:ProductionRequest>
<bml:ID_1>
<xsl:value-of select="KEY1"/>
</bml:ID_1>
<bml:Any>
<sit:ProductionRequestExtension>
<sit:Quantity>
<bml:QuantityString>
<xsl:value-of select="QTY_KEY1"/>
</bml:QuantityString>
<bml:DataType>
<xsl:text>float</xsl:text>
</bml:DataType>
</sit:Quantity>
</sit:ProductionRequestExtension>
<amg:ProductionRequestExtension>
<xsl:for-each-group select="current-group()" group-by="KEY2">
<amg:ID_2>
<xsl:value-of select="KEY2"/>
</amg:ID_2>
<amg:Order>
<xsl:for-each select="current-group()">
<amg:ID_3>
<xsl:value-of select="KEY3"/>
<amg:Prototypes>
<amg:PrototypeID>
<xsl:value-of select="PrototypeID"/>
</amg:PrototypeID>
<amg:H-Code>
<xsl:value-of select="H-Code"/>
</amg:H-Code>
</amg:Prototypes>
</amg:ID_3>
</xsl:for-each>
</amg:Order>
</xsl:for-each-group>
</amg:ProductionRequestExtension>
</bml:Any>
</bml:ProductionRequest>
</bml:ProductionSchedule>
</xsl:for-each-group>
</xsl:template>
</xsl:transform>
Everything works perfectly if the XML file does not contain the text in red. However, we use Tibco to automatically extract data, create the XML and to apply the transformation and the red part is inserted in the process (at XML creation). How to correct my XSLT file in order to successfully process the XML with red part included ?
Thank you very much
Doru