BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
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
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
Thnx Cynthia
:)

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1189 views
  • 0 likes
  • 2 in conversation