Hello again,
I have a problem with simple mapping in Altova MapForce,
Here are my files:
***Input XSD:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="csv_data_records">
<xs:complexType>
<xs:sequence>
<xs:element name="record" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="voltage"/>
<xs:element name="current"/>
</xs:sequence>
<xs:attribute name="num" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
***Output XSD:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="baza">
<xs:complexType>
<xs:sequence>
<xs:element name="pomiar" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="voltage">
<xs:complexType>
<xs:attribute name="unit" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:anySimpleType" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="current">
<xs:complexType>
<xs:attribute name="unit" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:anySimpleType" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
***Input XML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<csv_data_records xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\DOCUME~1\MasterAdmin\Pulpit\test_in.xsd">
<record num="1">
<voltage>mV</voltage>
<current>A</current>
</record>
<record num="2">
<voltage>1000</voltage>
<current>1000</current>
</record>
<record num="3">
<voltage>2000</voltage>
<current>2000</current>
</record>
<record num="4">
<voltage>3</voltage>
<current>3</current>
</record>
</csv_data_records>
When attribute "num" is set to 1 (one), under elements of voltage and current there is info about unit (volt and amper or V and A).
When attribute "num" is higher that 1, so when its 2,3, etc, then there is a value of voltage and current.
What I'm looking for in this egzample:
*when unit is "mV" I want value to be divided by 1000,
*when unit is "kV" I want value to be multiplyed by 1000,
Output XML should look like below:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<baza xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:/DOCUME~1/MasterAdmin/Pulpit/test_out.xsd">
<pomiar>
<voltage unit="V" value="1000"/>
</pomiar>
<pomiar>
<voltage unit="V" value="2000"/>
</pomiar>
<pomiar>
<voltage unit="V" value="3"/>
</pomiar>
</baza>
In the code above current is omitted, solution will be the same for voltage and current, so only 1 is needed.
I tried to do that for past few hours and no result. The main problem are data types. When it looks like all is ok, then I get lexical value error
Code:
lexical value error- " - xs:double(or decimal)
Below I include link to image of this little project in MapForce.
http://img179.imagevenue.com/img.php...u_122_92lo.jpg
And my little request: It would be best to see the solution in MapForce, because then I would understand how its connected, and how its works.
Best regards :)