| Return to previous page
|
The observation boundary translates into a collection of rows with a constant set of columns. Using an XMLMap file, you determine the observation boundary with the TABLE-PATH element by specifying a location path.
In the following XML document, PUBLICATION appears to be a possible element to use as the observation boundary, resulting in these columns: TITLE, ACQUIRED, TOPIC. However, the TOPIC element occurs arbitrarily within a single PUBLICATION container, so the result would be a set of columns with TOPIC occurring more than once. Therefore, the TOPIC element is the better choice to use as the observation boundary in order to result in these columns: TITLE, ACQUIRED, TOPIC, MAJOR.
<?xml version="1.0" encoding="iso-8859-1" ?> <Library> <Publication> <Title>Developer's Almanac</Title> <Acquired>12-11-2000</Acquired> <Topic Major="Y">JAVA</Topic> </Publication> <Publication> <Title>Inside Visual C++</Title> <Acquired>06-19-1998</Acquired> <Topic>Major="Y">C</Topic> <Topic>Reference</Topic> </Publication> <Publication> <Title>Core Servlets</Title> <Acquired>05-30-2001</Acquired> <Topic Major="Y">JAVA</Topic> <Topic>Servlets</Topic> <Topic>Reference</Topic> </Publication> </Library>
Here is the XMLMap file to use in order to import the previous XML document:
<?xml version="1.0" ?>
<SXLEMAP version="1.1">
<TABLE name="Publication">
<TABLE-PATH syntax="xpath">
/Library/Publication/Topic [1]
</TABLE-PATH>
<COLUMN name="Title" retain="YES">
<PATH>
/Library/Publication/Title
</PATH>
<TYPE>character</TYPE>
<DATATYPE>STRING</DATATYPE>
<LENGTH>19</LENGTH>
</COLUMN>
<COLUMN name="Acquired" retain="YES">
<PATH>
/Library/Publication/Acquired
</PATH>
<TYPE>numeric</TYPE>
<DATATYPE>FLOAT</DATATYPE>
<LENGTH>10</LENGTH>
<FORMAT width="10">mmddyy</FORMAT> [2]
<INFORMAT width="10">mmddyy</INFORMAT>
</COLUMN>
<COLUMN name="Topic">
<PATH>
/Library/Publication/Topic</PATH>
<TYPE>character</TYPE>
<DATATYPE>STRING</DATATYPE>
<LENGTH>9</LENGTH>
</COLUMN>
<COLUMN name="Major">
<PATH>
/Library/Publication/Topic/@Major
</PATH>
<TYPE>character</TYPE>
<DATATYPE>STRING</DATATYPE>
<LENGTH>1</LENGTH>
<ENUM> [3]
<VALUE>Y</VALUE>
<VALUE>N</VALUE>
</ENUM>
<DEFAULT>N</DEFAULT> [4]
</COLUMN>
</TABLE>
</SXLEMAP>
The previous XMLMap file tells SXLE how to interpret the XML markup as explained below:
filename REP 'C:\My Documents\XML\Rep.xml'; filename MAP 'C:\My Documents\XML\Rep.map'; libname REP xml xmlmap=MAP; proc print data=REP.Publication noobs; run;
PROC PRINT Output for PUBLICATION Data Set
The SAS System 1
Title Acquired Topic Major
Developer's Almanac 12/11/2000 JAVA Y
Inside Visual C++ 06/19/1998 C Y
Inside Visual C++ 06/19/1998 Reference N
Core Servlets 05/30/2001 JAVA Y
Core Servlets 05/30/2001 Servlets N
Core Servlets 05/30/2001 Reference N