IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

CSV to xml not outputting required attribute Options · View
SetMatch
Posted: Monday, June 11, 2018 6:05:43 PM
Rank: Member

Joined: 1/15/2016
Posts: 16
Location: Newport News, VA USA
Hi, this is my first time mapping to xml. My schema has a required attribute "Specifier" that must be present in the xml and can be |A|E|.
<xs:element name="LicenseRecords">
<xs:complexType>
<xs:sequence>
<xs:element ref="LicenseRecord" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="LicenseRecord">
<xs:complexType>
<xs:attribute name="LicenseType" use="required">
<xs:simpleType>
<xs:restriction base="riLicenseType">
<xs:maxLength value="3"/>
<xs:minLength value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="LicenseState" use="required">
<xs:simpleType>
<xs:restriction base="riStateCodes">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="LicenseStartDate" use="required">
<xs:simpleType>
<xs:restriction base="riDate"/>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="LicenseNumber" use="required">
<xs:simpleType>
<xs:restriction base="riAlphaNumeric">
<xs:minLength value="1"/>
<xs:maxLength value="12"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="LicenseEndDate" use="required">
<xs:simpleType>
<xs:restriction base="riDate"/>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="LicenseStatus" use="required">
<xs:simpleType>
<xs:restriction base="riTypeStatus">
<xs:length value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Specifier" use="required">
<xs:simpleType>
<xs:restriction base="riSpecifier">
<xs:minLength value="0"/>
<xs:maxLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>

<xs:simpleType name="riSpecifier">
<xs:restriction base="xs:string">
<xs:pattern value="A|E|"/>
</xs:restriction>

The sample csv has a blank value for the Specifier. My Mapforce output looks like this:

<LicenseRecords>
<LicenseRecord LicenseType="PA" LicenseState="RI" LicenseStartDate="2013-03-25" LicenseNumber="PA3456" LicenseEndDate="2382-12-31" LicenseStatus="A"/>
</LicenseRecords>

Any suggestion how to insure that the attribute Specifier="" will appear in the above Mapforce output?

Thanks
that
Posted: Monday, June 11, 2018 6:27:24 PM
Rank: Advanced Member

Joined: 6/16/2006
Posts: 486
Location: AT
Assuming you have a column in your CSV connected to that attribute:

Option A: Turn off "[x] Treat empty fields as absent" in the CSV component.

Option B: Add a substitute-missing component and with an empty string constant before the required attribute.
SetMatch
Posted: Monday, June 11, 2018 7:47:28 PM
Rank: Member

Joined: 1/15/2016
Posts: 16
Location: Newport News, VA USA
Thank You That!
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.