Code Listing 4: Create an XMLType view to expose XML data as files.

CREATE OR REPLACE VIEW ATTRACTION_XML
   OF XMLType 
   WITH OBJECT ID (

      extractValue(sys_nc_rowinfo$,'/County/@Name')
   ) from columns (c.County_name) 
AS
SELECT XMLElement("County",
       XMLAttributes(c.county_name AS "Name",
                     'http://www.w3.org/2001/XMLSchema-instance'

                        AS "xmlns:xsi",
                     'http://gennick.com/tourist.xsd'
                        AS "xsi:noNamespaceSchemaLocation"),
          XMLAgg(
             XMLElement("Attraction", 
                        XMLAttributes(government_owned AS GOV),
                XMLForest(a.attraction_name AS "Name", 

                          a.Location AS "Location", 
                          a.attraction_url AS "URL")))) x
FROM county c INNER JOIN attraction a
     ON c.county_name = a.county_name
GROUP BY c.county_name;


E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy