cancel
Showing results for 
Search instead for 
Did you mean: 

Can you associate an XML Schema with a DataWindow?

Former Member
0 Kudos

Greetings all,

We have a client that has asked for datathat has master/detail information in XML format. They are also asking for the XML to be associated with an XML Schema that they have provided to ensure that the data is validated using the Schema.

I am pretty sure I can make the XML look most like the way they want it, but not sure about how to make it exactly the way they want it.

<Invoice xsi:noNamespaceSchemaLocation="AlexFeed.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Vendor><VendorId>9</VendorId><TotalRides>4</TotalRides><TotalAmount>1038.54</TotalAmount><BillingCurrency>USD</BillingCurrency>


Ride><BookerEmployeeID>21416</BookerEmployeeID><BookerTieExtension>8054305</BookerTieExtension><BookerFirstName>PAUL</BookerFirstName><BookerLastName>GOYENECHE</BookerLastName><RiderFirstName>AINHOA</RiderFirstName><RiderLastName>MURRAY</RiderLastName><ReferenceId>1401745691</ReferenceId><CarId>999</CarId><RideTypeId>B</RideTypeId><AirportCode>IAD</AirportCode><RideDate>2014-08-04</RideDate><RideTime>15:35:00.0Z</RideTime><FromAddress>IAD</FromAddress><FromZone>IAD</FromZone><ToAddress>DC, WASHINGTON</ToAddress><ToZone>IAD  </ToZone><NoShow>false</NoShow><BaseAmount>108.58</BaseAmount><ServiceAmount>19.20</ServiceAmount><WaitAmount>71.78</WaitAmount><MeetAndGreetAmount>10.00</MeetAndGreetAmount><ParkingAmount>10.00</ParkingAmount><FuelSurchargeAmount>2.00</FuelSurchargeAmount><MiscAmount>36.07</MiscAmount><MiscAmountDesc>Tips,Package and Miscellaneous charge</MiscAmountDesc><NetAmount>257.63</NetAmount><TotalAmount>257.63</TotalAmount></Ride>

Thanks everyone in advance for any pointers!!

Best,

Paul

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Don't know if this is what you are looking for but if you Right-Click on the root element you can select 'Schema Options'.  This will allow you to specify the namespace to use.  You will also need to set the Meta Data Type to XMLSchema! in the Data Export tab of the DW.

Chris Craft

Former Member
0 Kudos

Thanks, Chris!!

Can you kindly help me with information do I put where?

I am pretty green with namespaces.

Also, where do I put AlexFeed.xsd?

Thanks!!

Paul

Former Member
0 Kudos

Hey Paul,

Looking at your sample this might be easier than I thought.  All you need to do is create your XML template (which you might have already done?).  The root element name should be 'Invoice' followed by 'Vendor', etc.  Your data looks like the detail row starts at 'Ride'.  After you have saved that then under the Data Export tab do the following:

1) Select your template under 'Use Template'

2) Select XMLSchema! under 'Meta Data Type'

3) Select MetaDataExternal! under 'Save Meta Data'

Now when you do a SaveAs save it as XML and give it the name AlexFeed.xml.  This will create 2 files - one with the XML and the other will be the XSD.  The XML file should look like your example above.

If this is not what you are looking for we can go further.

Chris Craft

Former Member
0 Kudos

Hi Chris,

I am guess I am a bit confused. I did as you said and I did end with an XML file that mostly looks like what they gave me.  What I am confused about is that you said doing SaveAs would create two files (AlexFeed.xml and AlexFeed.xsd).  But they already gave me the AlexFeed.xsd file.  I was thinking that somewhere in the data window near where I select XMLSchema! that I would be prompted to type in the name of the XML Schema as 'AlexFeed.xsd' so that it can provide an error response if the XML that I created does not match up with 'AlexFeed.xsd'.

So doing what you suggested DOES in fact create two files.  It overwrote the .XSD file provided by the client (I have a back up copy).

Their heirarchy is as follows:

<INVOICE>

     <VENDOR>

          <RIDE>

          <RIDE>

          <RIDE>

     </VENDOR>

</INVOICE><INVOICE_DATE>2014-09-13</INVOICE_DATE>

For some reason, I cannot add an XML tag that is at the end like theirs is.  I keep getting something more like this:

<INVOICE>

     <INVOICE_DATE>2014-09-13</INVOICE_DATE>

     <VENDOR>

          <RIDE>

          <RIDE>

          <RIDE>

     </VENDOR>

</INVOICE>

Thanks again for your help.

Best,

Paul

Former Member
0 Kudos

I think I hate XML.

I also noticed that XML samples provided by the client, per XMLSpy, are valid. But the Schema doesn't like zero or "" values in some of the tags.  So in their example if WaitTime is null they just leave the whole tag out and XMLSpy is good with that.  But I don't see a way in the XML data window to leave out tags if the value is null.

Ugh.

I think I am barking up the wrong tree with the Datawindow XML export.

Paul

Former Member
0 Kudos

Typically the consumer of the XML would be validating the data with an XSD.  The DW cannot create the XML by using an XSD to validate it first.  If you are trying to create the XML from an XSD then you might have to use MSXML (I don't believe PBDOM allows you to do this) and do all the work but I think that is overkill.  Seems to me the user of the XML just wants to make sure that you are createing the XML properly and when you created the template you did that by looking at the XSD.

Regarding the XML layout - the Invoice_Date element should not be outside of the Root element.  This violates the XML standards and any XML validator will error on that. We can get it to show at the bottom but not outside the root. Can you post the actual XSD from the consumer?  Maybe we are missing something.

Chris Craft

Answers (0)