on 08-04-2016 11:57 AM
Dear Gurus,
I have a simple Scenario: multiple mapping: XML --> PI --> XML (step 1.) XML --> IDoc. (step 2.)
The file structure Looks like:
MT_SourceFile
record 1..unbounded
ReferNo 1..1
ContainerType 1..1
ContainerNo 1..1
Supplier 1..1
MaterialGroupNo 1..1
DeliveryDate 1..1
...
At the first step I want to sort it by using XSLT-Mapping v1.0 according to the ContainerNo and the MaterialGroupNo is not empty and is an integer.
The sort works well, but the check empty and integer not.
Could you help me?
thanks a lot in advance!
Regards
Sara
Hi Sara!
To check if value is integer in XSLT 1.0 you can use this:
<xsl:if test = "floor($var) = $var" >
...
</xsl:if>
To check if node exists:
test="YourNodeName"
To check if node is not empty:
test="YourNodeName=''"
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sara!
I've tried it myself.
Source XML:
<?xml version="1.0"?>
<ns0:MT_SourceFile xmlns:ns0="urn://my_test">
<record>
<ContainerType>A</ContainerType>
<ContainerNo>3</ContainerNo>
<MaterialGroupNo>12.01</MaterialGroupNo>
</record>
<record>
<ContainerType>A</ContainerType>
<ContainerNo>2</ContainerNo>
</record>
<record>
<ContainerType>B</ContainerType>
<ContainerNo>8</ContainerNo>
<MaterialGroupNo>01</MaterialGroupNo>
</record>
<record>
<ContainerType>A</ContainerType>
<ContainerNo>7</ContainerNo>
<MaterialGroupNo>4</MaterialGroupNo>
</record>
<record>
<ContainerType>B</ContainerType>
<ContainerNo>1</ContainerNo>
<MaterialGroupNo>A007</MaterialGroupNo>
</record>
<record>
<ContainerType>A</ContainerType>
<ContainerNo>4</ContainerNo>
<MaterialGroupNo>100</MaterialGroupNo>
</record>
</ns0:MT_SourceFile>
XSL transformation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<ns0:MT_DestFile xmlns:ns0="urn://my_test">
<xsl:for-each select="//record[MaterialGroupNo and MaterialGroupNo != '' and number(MaterialGroupNo) = number(MaterialGroupNo) and floor(number(MaterialGroupNo)) = number(MaterialGroupNo)]">
<xsl:sort select="ContainerNo"/>
<record>
<xsl:copy-of select="./*"/>
</record>
</xsl:for-each>
</ns0:MT_DestFile>
</xsl:template>
</xsl:stylesheet>
Result XML:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_DestFile xmlns:ns0="urn://my_test">
<record>
<ContainerType>A</ContainerType>
<ContainerNo>4</ContainerNo>
<MaterialGroupNo>100</MaterialGroupNo>
</record>
<record>
<ContainerType>A</ContainerType>
<ContainerNo>7</ContainerNo>
<MaterialGroupNo>4</MaterialGroupNo>
</record>
<record>
<ContainerType>B</ContainerType>
<ContainerNo>8</ContainerNo>
<MaterialGroupNo>01</MaterialGroupNo>
</record>
</ns0:MT_DestFile>
Regards, Evgeniy.
nobody can help me?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.