DATA Step, Macro, Functions and more

Validating XML file

Reply
N/A
Posts: 0

Validating XML file

Hello!!!!

I am using an XML input file to capture the data. I have created an XML Map file by using SAS XML Mapper and this map file is refered by SAS XML Engine to fetch the data from input XML file with the proper hierarchy.

The real issue is, if the input XML file is not syntactically correct, the XML Engine throws exception. Just wanted to know if there is any way that SAS will first validate the structure of XML file (may be something like XML Schema validation) and if its a valid structure then only SAS will read the file else it will give a message (or return code) saying invalid XML input file.

Any help regarding this issue will be highly appreciated.

Regards
- Kapil
SAS Super FREQ
Posts: 8,743

Re: Validating XML file

Hi:
Refer to the FAQ here:
http://support.sas.com/documentation/cdl/en/engxml/61740/HTML/default/a002591914.htm

where it says on this topic:
"Does the XML Engine Validate an XML Document?

The XML engine does not validate an input XML document. The engine assumes that the data passed to it is in valid, well-formed XML markup. Because the engine does not use a DTD (Document Type Definition) or SCHEMA, there is nothing to validate against."


cynthia
N/A
Posts: 0

Re: Validating XML file

Oh Okies!!!!

However I have found the below link where an approach to read XML using SAS Data step is mentioned. But unfortunately it does not contain the SAS source code.

http://www2.sas.com/proceedings/sugi29/036-29.pdf

Any idea if there is an algorithm or source code readily available on SAS Support?

regards
Kapil
SAS Super FREQ
Posts: 8,743

Re: Validating XML file

Hi:
Look on page 12 of the paper. The author says he is willing to share the Data step code. Since his method essentially bypasses both XMLMapper and PROC TEMPLATE, you would either need to write your own DATA step code or get the code from this paper author.

Also, note that on page 11 of his paper, he says that:
"An alternative to the LIBNAME XML engine for XML import and PROC TEMPLATE for export is to flatten the hierarchical XML into a numerically indexed representation that presents nothing new to the SAS programmer, unlike native XML. This method is the basis for the import and export of XML that takes place 100% in the familiar DATA step."


This flattening of the hierarchy would -still- mean that SAS is NOT checking the XML file for whether it is valid, well-formed or conforming to the schema or DTD. So it would be possible in this method for you to work with a badly formed, and/or invalid XML file.

cynthia
N/A
Posts: 0

Re: Validating XML file

Thnx Cynthia
Smiley Happy
Ask a Question
Discussion stats
  • 4 replies
  • 156 views
  • 0 likes
  • 2 in conversation