--RAW Domain Value XML services      
--**************************************************************************************************************    
-- Date: 2023-02-24
--Illegal Characters: & < > " '   Converted to Characters:  + { } ^ `
--Replacement Legal Characters:   &amp;   &lt;   &gt;   &quot;   &apos;
--
SET TERMOUT OFF;
set feedback off
set verify off
set linesize 5000
set define off
set pagesize 0
set trimspool on

spool ActivityGroupType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ActivityGroupType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Activity Group Type" schemaElement="ActivityGroupTypeCode" rowCount="'||(select count(*) from wqx.activity_group_type)||'" maxLastChangeDate="'||to_char(cast((select max(agtyp_last_change_date) from wqx.activity_group_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ActivityGroupType>' ||chr(10)||
	'    <Domain>Activity Group Type(ActivityGroupTypeCode)</Domain>' ||chr(10)||
	'      <UID>'||agtyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(agtyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(agtyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(agtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ActivityGroupType>'
from wqx.activity_group_type 
order by agtyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ActivityMedia.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ActivityMedia.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Activity Media" schemaElement="ActivityMediaName" rowCount="'||(select count(*) from wqx.activity_media)||'" maxLastChangeDate="'||to_char(cast((select max(acmed_last_change_date) from wqx.activity_media) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ActivityMedia>' ||chr(10)||
	'    <Domain>Activity Media(ActivityMediaName)</Domain>' ||chr(10)||
	'      <UID>'||acmed_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(acmed_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(acmed_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(acmed_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ActivityMedia>'
from wqx.activity_media 
order by acmed_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ActivityMediaSubdivision.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ActivityMediaSubdivision.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Activity Media Subdivision" schemaElement="ActivityMediaSubdivisionName" rowCount="'||(select count(*) from wqx.activity_media_subdivision)||'" maxLastChangeDate="'||to_char(cast((select max(amsub_last_change_date) from wqx.activity_media_subdivision) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ActivityMediaSubdivision>' ||chr(10)||
	'    <Domain>Activity Media Subdivision(ActivityMediaSubdivisionName)</Domain>' ||chr(10)||
	'      <UID>'||amsub_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(amsub_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(amsub_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(amsub_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ActivityMediaSubdivision>'
from wqx.activity_media_subdivision 
order by amsub_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ActivityType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ActivityType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Activity Type" schemaElement="ActivityTypeCode" rowCount="'||(select count(*) from wqx.activity_type)||'" maxLastChangeDate="'||to_char(cast((select max(actyp_last_change_date) from wqx.activity_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ActivityType>' ||chr(10)||
	'    <Domain>Activity Type(ActivityTypeCode)</Domain>' ||chr(10)||
	'      <UID>'||actyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(actyp_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(actyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <AnalyticalMethodRequiredYN>'||actyp_anl_mth_req_yn||'</AnalyticalMethodRequiredYN>' ||chr(10)||
	'      <MonitoringLocationRequiredYN>'||actyp_mon_loc_req_yn||'</MonitoringLocationRequiredYN>' ||chr(10)||
	'      <Abbreviation>'||actyp_abbrev||'</Abbreviation>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(actyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ActivityType>'
from wqx.activity_type 
order by actyp_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool AddressType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="AddressType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Address Type" schemaElement="AddressTypeName" rowCount="'||(select count(*) from wqx.address_type)||'" maxLastChangeDate="'||to_char(cast((select max(addtyp_last_change_date) from wqx.address_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <AddressType>' ||chr(10)||
	'    <Domain>Address Type(AddressTypeName)</Domain>' ||chr(10)||
	'      <UID>'||addtyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(addtyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(addtyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(addtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </AddressType>'
from wqx.address_type 
order by addtyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool AliasType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="AliasType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="AliasType" schemaElement="AliasTypeName" rowCount="'||(select count(*) from wqx.alias_type)||'" maxLastChangeDate="'||to_char(cast((select max(alstyp_last_change_date) from wqx.alias_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <AliasType>' ||chr(10)||
	'    <Domain>Alias Type(AliasTypeName)</Domain>' ||chr(10)||
	'      <UID>'||alstyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(alstyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
--	'      <Description>'||alstyp_desc||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(alstyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </AliasType>'
from wqx.alias_type 
order by alstyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool AnalyticalMethod.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="AnalyticalMethod.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Analytical Method" schemaElement="ResultAnalyticalMethod/MethodIdentifier" rowCount="'||(select count(*) from wqx.analytical_method where org_uid is null)||'" maxLastChangeDate="'||to_char(cast((select max(anlmth_last_change_date) from wqx.analytical_method where org_uid is null) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <AnalyticalMethod>' ||chr(10)||
	'    <Domain>Analytical Method(MethodIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||anlmth_uid||'</UID>' ||chr(10)||
	'      <Identifier>'|| replace(replace(replace(replace(replace(translate(anlmth_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Identifier>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(amctx_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(anlmth_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(anlmth_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <QualifierType>'|| replace(replace(replace(replace(replace(translate(anlmth_qual_type,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</QualifierType>' ||chr(10)||
	'      <URL>'|| replace(replace(replace(replace(replace(translate(anlmth_url,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</URL>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(anlmth_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </AnalyticalMethod>'
from wqx.analytical_method am, wqx.analytical_method_context amc 
where am.amctx_uid=amc.amctx_uid and am.org_uid is null
order by anlmth_id ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool AnalyticalMethodContext.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="AnalyticalMethodContext.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Analytical Method Context" schemaElement="ResultAnalyticalMethod/MethodIdentifierContext" rowCount="'||(select count(*) from wqx.analytical_method_context)||'" maxLastChangeDate="'||to_char(cast((select max(amctx_last_change_date) from wqx.analytical_method_context) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <AnalyticalMethodContext>' ||chr(10)||
	'    <Domain>Analytical Method Context(MethodIdentifierContext)</Domain>' ||chr(10)||
	'      <UID>'||amctx_uid||'</UID>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(amctx_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(amctx_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(amctx_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(amctx_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </AnalyticalMethodContext>'
from wqx.analytical_method_context 
where org_uid is null 
order by amctx_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Aquifer.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Aquifer.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Aquifer" schemaElement="LocalAquiferCode" rowCount="'||(select count(*) from wqx.Aquifer where org_uid is null)||'" maxLastChangeDate="'||to_char(cast((select max(aqfr_last_change_date) from wqx.Aquifer where org_uid is null) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Aquifer>' ||chr(10)||
	'    <Domain>Aquifer(LocalAquiferCode)</Domain>' ||chr(10)||
	'      <UID>'||aqfr_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(aqfr_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <CodeContext>'|| replace(replace(replace(replace(replace(translate(aqfrctx_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</CodeContext>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(aqfr_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(aqfr_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(aqfr_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Aquifer>'
from wqx.Aquifer aqfr, wqx.Aquifer_context aqfrc 
where aqfr.aqfrctx_uid=aqfrc.aqfrctx_uid and aqfr.org_uid is null
order by aqfr_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool AquiferContext.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="AquiferContext.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Aquifer Context" schemaElement="AquiferCodeContext" rowCount="'||(select count(*) from wqx.Aquifer_context)||'" maxLastChangeDate="'||to_char(cast((select max(aqfrctx_last_change_date) from wqx.Aquifer_context) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <AquiferContext>' ||chr(10)||
	'    <Domain>Aquifer Context(AquiferCodeContext)</Domain>' ||chr(10)||
	'      <UID>'||aqfrctx_uid||'</UID>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(aqfrctx_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(aqfrctx_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(aqfrctx_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(aqfrctx_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </AquiferContext>'
from wqx.Aquifer_context 
where org_uid is null 
order by aqfrctx_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool NationalAquifer.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="NationalAquifer.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="NationalAquifer" schemaElement="NationalAquiferCode" rowCount="'||(select count(*) from wqx.National_Aquifer )||'" maxLastChangeDate="'||to_char(cast((select max(nataqfr_last_change_date) from wqx.National_Aquifer ) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <NationalAquifer>' ||chr(10)||
	'    <Domain>National Aquifer(NationalAquiferCode)</Domain>' ||chr(10)||
	'      <UID>'||nataqfr_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(nataqfr_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(nataqfr_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(nataqfr_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(nataqfr_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </NationalAquifer>'
from wqx.National_Aquifer nataqfr
order by nataqfr_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool AquiferType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="AquiferType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Aquifer Type" schemaElement="AquiferTypeName" rowCount="'||(select count(*) from wqx.Aquifer_Type)||'" maxLastChangeDate="'||to_char(cast((select max(aqfrtyp_last_change_date) from wqx.Aquifer_Type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <AquiferType>' ||chr(10)||
	'    <Domain>Aquifer Type(AquiferTypeName)</Domain>' ||chr(10)||
	'      <UID>'||aqfrtyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(aqfrtyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(aqfrtyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(aqfrtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </AquiferType>'
from wqx.aquifer_type 
order by aqfrtyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off


--
spool Assemblage.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="AssemblageName.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Assemblage" schemaElement="AssemblageSampledName" rowCount="'||(select count(*) from wqx.assemblage)||'" maxLastChangeDate="'||to_char(cast((select max(asmblg_last_change_date) from wqx.assemblage) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Assemblage>' ||chr(10)||
	'    <Domain>Assemblage(AssemblageSampledName)</Domain>' ||chr(10)||
	'      <UID>'||asmblg_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(asmblg_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(asmblg_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(asmblg_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Assemblage>'
from wqx.assemblage 
order by asmblg_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool BiologicalIntent.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="BiologicalIntent.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Biological Intent" schemaElement="BiologicalIntentName" rowCount="'||(select count(*) from wqx.biological_intent)||'" maxLastChangeDate="'||to_char(cast((select max(bioint_last_change_date) from wqx.biological_intent) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <BiologicalIntent>' ||chr(10)||
	'    <Domain>Biological Intent(BiologicalIntentName)</Domain>' ||chr(10)||
	'      <UID>'||bioint_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(bioint_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(bioint_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(bioint_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </BiologicalIntent>'
from wqx.biological_intent 
order by bioint_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool CellForm.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="CellForm.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Cell Form" schemaElement="CellFormName" rowCount="'||(select count(*) from wqx.cell_form)||'" maxLastChangeDate="'||to_char(cast((select max(celfrm_last_change_date) from wqx.cell_form) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <CellForm>' ||chr(10)||
	'    <Domain>Cell Form(CellFormName)</Domain>' ||chr(10)||
	'      <UID>'||celfrm_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(celfrm_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(celfrm_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(celfrm_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </CellForm>'
from wqx.cell_form 
order by celfrm_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool CellShape.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="CellShape.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Cell Shape" schemaElement="CellShapeName" rowCount="'||(select count(*) from wqx.cell_shape)||'" maxLastChangeDate="'||to_char(cast((select max(celshp_last_change_date) from wqx.cell_shape) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <CellShape>' ||chr(10)||
	'    <Domain>Cell Shape(CellShapeName)</Domain>' ||chr(10)||
	'      <UID>'||celshp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(celshp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(celshp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(celshp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </CellShape>'
from wqx.cell_shape 
order by celshp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Characteristic.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Characteristic.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Characteristic" schemaElement="CharacteristicName" rowCount="'||(select count(*) from wqx.characteristic)||'" maxLastChangeDate="'||to_char(cast((select max(chr_last_change_date) from wqx.characteristic) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Characteristic>' ||chr(10)||
	'    <Domain>Characteristic(CharacteristicName)</Domain>' ||chr(10)||
	'      <UID>'||chr_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(chr_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <SRS_ID>'||chr_srs_id||'</SRS_ID>' ||chr(10)||
	'      <STORET_ID>'||chr_storet_id||'</STORET_ID>' ||chr(10)||
	'      <CAS_NUMBER>'||chr_cas_number||'</CAS_NUMBER>' ||chr(10)||
	'      <SampleFractionRequiredYN>'||chr_sample_fraction_req_yn||'</SampleFractionRequiredYN>' ||chr(10)||
	'      <PickListYN>'||chr_pick_list_yn||'</PickListYN>' ||chr(10)||
	'      <SpeciationRequiredYN>'||chr_method_speciation_req_yn||'</SpeciationRequiredYN>' ||chr(10)||
	'      <AnalyticalMethodRequiredYN>'||chr_analytical_method_req_yn||'</AnalyticalMethodRequiredYN>' ||chr(10)||
	'      <GroupName>'|| replace(replace(replace(replace(replace(translate(chrgrp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</GroupName>' ||chr(10)||
	'      <ComparableName>'|| replace(replace(replace(replace(replace(translate(chr_name_comparable,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</ComparableName>' ||chr(10)||
	'      <Status>'||dvsta_name||'</Status>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(chr_description,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(chr_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Characteristic>'
from wqx.characteristic c, wqx.characteristic_group cg, wqx.domain_value_status dvs
where c.chrgrp_uid=cg.chrgrp_uid and c.dvsta_uid=dvs.dvsta_uid
order by chr_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool CharacteristicAlias.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="CharacteristicAlias.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Characteristic Alias" schemaElement="CharacteristicAliasName" rowCount="'||(select count(*) from wqx.characteristic_alias)||'" maxLastChangeDate="'||to_char(cast((select max(chrals_last_change_date) from wqx.characteristic_alias) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <CharacteristicAlias>' ||chr(10)||
	'    <Domain>Characteristic Alias(CharacteristicAliasName)</Domain>' ||chr(10)||
	'      <UID>'||chrals_uid||'</UID>' ||chr(10)||
	'      <AliasType>'|| replace(replace(replace(replace(replace(translate(alstyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</AliasType>' ||chr(10)||
	'      <AliasName>'|| replace(replace(replace(replace(replace(translate(chrals_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</AliasName>' ||chr(10)||
	'      <CharacteristicName>'|| replace(replace(replace(replace(replace(translate(chr_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</CharacteristicName>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(chrals_description,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(chrals_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </CharacteristicAlias>'
from wqx.characteristic_alias ca, wqx.characteristic c, wqx.alias_type at
where ca.alstyp_uid=at.alstyp_uid and ca.chr_uid=c.chr_uid
order by alstyp_name, chrals_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool CharacteristicGroup.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="CharacteristicGroup.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Characteristic Group" schemaElement="CharacteristicGroupName" rowCount="'||(select count(*) from wqx.characteristic_group)||'" maxLastChangeDate="'||to_char(cast((select max(chrgrp_last_change_date) from wqx.characteristic_group) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <CharacteristicGroup>' ||chr(10)||
	'    <Domain>Characteristic Group(CharacteristicGroupName)</Domain>' ||chr(10)||
	'      <UID>'||chrgrp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(chrgrp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(chrgrp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(chrgrp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </CharacteristicGroup>'
from wqx.characteristic_group 
order by chrgrp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool CharacteristicPickList.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="CharacteristicPickList.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Characteristic Pick List" schemaElement="CharacteristicName" rowCount="'||(select count(*) from wqx.characteristic_pick_list_value)||'" maxLastChangeDate="'||to_char(cast((select max(cplval_last_change_date) from wqx.characteristic_pick_list_value) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <CharacteristicPickList>' ||chr(10)||
	'    <Domain>Characteristic PickList(CharacteristicName)</Domain>' ||chr(10)||
	'      <UID>'||cplval_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(chr_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(cplval_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(cplval_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
--	'      <Description>'||cplval_desc||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(cplval_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </CharacteristicPickList>'
from wqx.characteristic_pick_list_value cpl, wqx.characteristic c
where c.chr_uid=cpl.chr_uid
order by chr_name, cplval_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Citation.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Citation.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Citation" schemaElement="TaxonomicDetailsCitation/ResourceIdentifier" rowCount="'||(select count(*) from wqx.citation)||'" maxLastChangeDate="'||to_char(cast((select max(citatn_last_change_date) from wqx.citation) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Citation>' ||chr(10)||
	'    <Domain>Citation(ResourceIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||citatn_uid||'</UID>' ||chr(10)||
	'      <Identifier>'|| replace(replace(replace(replace(replace(translate(citatn_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Identifier>' ||chr(10)||
	'      <Creator>'|| replace(replace(replace(replace(replace(translate(citatn_creator,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Creator>' ||chr(10)||
	'      <Date>'||citatn_date||'</Date>' ||chr(10)||
	'      <Publisher>'|| replace(replace(replace(replace(replace(translate(citatn_publisher,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Publisher>' ||chr(10)||
	'      <Subject>'|| substr(replace(replace(replace(replace(replace(translate(citatn_subject,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;'),1,3600)||'</Subject>' ||chr(10)||
	'      <Title>'|| replace(replace(replace(replace(replace(translate(citatn_title,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Title>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(citatn_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Citation>'
from wqx.citation 
--where org_uid is null
order by citatn_id ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off


--
spool ContainerColor.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ContainerColor.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Container Color" schemaElement="SampleContainerColorName" rowCount="'||(select count(*) from wqx.container_color)||'" maxLastChangeDate="'||to_char(cast((select max(concol_last_change_date) from wqx.container_color) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ContainerColor>' ||chr(10)||
	'    <Domain>Container Color(SampleContainerColorName)</Domain>' ||chr(10)||
	'      <UID>'||concol_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(concol_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(concol_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(concol_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ContainerColor>'
from wqx.container_color 
order by concol_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ContainerType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ContainerType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Container Type" schemaElement="SampleContainerTypeName" rowCount="'||(select count(*) from wqx.container_type)||'" maxLastChangeDate="'||to_char(cast((select max(contyp_last_change_date) from wqx.container_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ContainerType>' ||chr(10)||
	'    <Domain>Container Type(SampleContainerTypeName)</Domain>' ||chr(10)||
	'      <UID>'||contyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(contyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(contyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(contyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ContainerType>'
from wqx.container_type 
order by contyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Country.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Country.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Country" schemaElement="CountryCode" rowCount="'||(select count(*) from wqx.country)||'" maxLastChangeDate="'||to_char(cast((select max(cntry_last_change_date) from wqx.country) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Country>' ||chr(10)||
	'    <Domain>Country(CountryCode)</Domain>' ||chr(10)||
	'      <UID>'||cntry_uid||'</UID>' ||chr(10)||
	'      <Code>'||cntry_cd||'</Code>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(cntry_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(cntry_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Country>'
from wqx.country 
order by cntry_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool County.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="County.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="County" schemaElement="CountyCode" rowCount="'||(select count(*) from wqx.county)||'" maxLastChangeDate="'||to_char(cast((select max(cnty_last_change_date) from wqx.county) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <County>' ||chr(10)||
	'    <Domain>County(CountyCode)</Domain>' ||chr(10)||
	'      <UID>'||cnty_uid||'</UID>' ||chr(10)||
	'      <State>'|| replace(replace(replace(replace(replace(translate(st_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</State>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(cnty_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <StateCode>'||lpad(st_cd, 2, '0')||'</StateCode>' ||chr(10)||
	'      <FIPSCountyCode>'||lpad(cnty_fips_cd, 3, '0')||'</FIPSCountyCode>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(cnty_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </County>'
from wqx.county c, wqx.state s 
where c.st_uid=s.st_uid
order by st_name, cnty_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool DetectionQuantationLimit.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="DetectionQuantationLimit.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Detection Quantation Limit" schemaElement="ResultDetectionQuantitationLimit/DetectionQuantitationLimitTypeName" rowCount="'||(select count(*) from wqx.detection_quant_limit_type)||'" maxLastChangeDate="'||to_char(cast((select max(dqltyp_last_change_date) from wqx.detection_quant_limit_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <DetectionQuantationLimit>' ||chr(10)||
	'    <Domain>Detection Quantation Limit(DetectionQuantitationLimitTypeName)</Domain>' ||chr(10)||
	'      <UID>'||dqltyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(dqltyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(dqltyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(dqltyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'      <HierarchySortOrder>'||dqltyp_hierarchy_sort_order||'</HierarchySortOrder>' ||chr(10)||
	'    </DetectionQuantationLimit>'
from wqx.detection_quant_limit_type 
order by dqltyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ElectronicAddressType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ElectronicAddressType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Electronic Address Type" schemaElement="ElectronicAddressTypeName" rowCount="'||(select count(*) from wqx.electronic_address_type)||'" maxLastChangeDate="'||to_char(cast((select max(eatyp_last_change_date) from wqx.electronic_address_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ElectronicAddressType>' ||chr(10)||
	'    <Domain>Electronic Address Type(ElectronicAddressTypeName)</Domain>' ||chr(10)||
	'      <UID>'||eatyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(eatyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(eatyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(eatyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ElectronicAddressType>'
from wqx.electronic_address_type 
order by eatyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool FrequencyClassDescriptor.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="FrequencyClassDescriptor.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Frequency Class Descriptor" schemaElement="FrequencyClassInformation/FrequencyClassDescriptorCode" rowCount="'||(select count(*) from wqx.frequency_class_descriptor)||'" maxLastChangeDate="'||to_char(cast((select max(fcdsc_last_change_date) from wqx.frequency_class_descriptor) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <FrequencyClassDescriptor>' ||chr(10)||
	'    <Domain>Frequency Class Descriptor(FrequencyClassDescriptorCode)</Domain>' ||chr(10)||
	'      <UID>'||fcdsc_uid||'</UID>' ||chr(10)||
	'      <Type>'|| replace(replace(replace(replace(replace(translate(fctyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Type>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(fcdsc_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(fcdsc_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(fcdsc_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </FrequencyClassDescriptor>'
from wqx.frequency_class_descriptor fcd, wqx.frequency_class_type fct 
where fcd.fctyp_uid=fct.fctyp_uid
order by fcdsc_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool FrequencyClassType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="FrequencyClassType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Frequency Class Type" schemaElement="FrequencyClassTypeName" rowCount="'||(select count(*) from wqx.frequency_class_type)||'" maxLastChangeDate="'||to_char(cast((select max(fctyp_last_change_date) from wqx.frequency_class_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <FrequencyClassType>' ||chr(10)||
	'    <Domain>Frequency Class Type(FrequencyClassTypeName)</Domain>' ||chr(10)||
	'      <UID>'||fctyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(fctyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <UnitRequiredYN>'||fctyp_unit_required_yn||'</UnitRequiredYN>' ||chr(10)||
	'      <BoundsRequiredYN>'||fctyp_bounds_required_yn||'</BoundsRequiredYN>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(fctyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </FrequencyClassType>'
from wqx.frequency_class_type 
order by fctyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool GearProcedureUnit.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="GearProcedureUnit.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Gear Procedure Unit" schemaElement="CollectionEffort/GearProcedureUnitCode" rowCount="'||(select count(*) from wqx.gear_procedure_unit)||'" maxLastChangeDate="'||to_char(cast((select max(gpunt_last_change_date) from wqx.gear_procedure_unit) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <GearProcedureUnit>' ||chr(10)||
	'    <Domain>Gear Procedure Unit(GearProcedureUnitCode)</Domain>' ||chr(10)||
	'      <UID>'||gpunt_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(gpunt_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(gpunt_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(gpunt_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </GearProcedureUnit>'
from wqx.gear_procedure_unit 
order by gpunt_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Habit.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Habit.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Habit" schemaElement="HabitName" rowCount="'||(select count(*) from wqx.habit)||'" maxLastChangeDate="'||to_char(cast((select max(habit_last_change_date) from wqx.habit) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Habit>' ||chr(10)||
	'    <Domain>Habit(HabitName)</Domain>' ||chr(10)||
	'      <UID>'||habit_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(habit_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(habit_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(habit_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Habit>'
from wqx.habit 
order by habit_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool HabitatSelectionMethod.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="HabitatSelectionMethod.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Habitat Selection Method" schemaElement="HabitatSelectionMethodName" rowCount="'||(select count(*) from wqx.habitat_selection_method)||'" maxLastChangeDate="'||to_char(cast((select max(hsm_last_change_date) from wqx.habitat_selection_method) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <HabitatSelectionMethod>' ||chr(10)||
	'    <Domain>Habitat Selection Method(HabitatSelectionMethodName)</Domain>' ||chr(10)||
	'      <UID>'||hsm_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(hsm_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(hsm_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(hsm_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </HabitatSelectionMethod>'
from wqx.habitat_selection_method 
order by hsm_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool HorizontalCollectionMethod.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="HorizontalCollectionMethod.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Horizontal Collection Method" schemaElement="HorizontalCollectionMethodName" rowCount="'||(select count(*) from wqx.horizontal_collection_method)||'" maxLastChangeDate="'||to_char(cast((select max(hcmth_last_change_date) from wqx.horizontal_collection_method) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <HorizontalCollectionMethod>' ||chr(10)||
	'    <Domain>Horizontal Collection Method(HorizontalCollectionMethodName)</Domain>' ||chr(10)||
	'      <UID>'||hcmth_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(hcmth_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(hcmth_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(hcmth_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </HorizontalCollectionMethod>'
from wqx.horizontal_collection_method 
order by hcmth_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool HorizontalReferenceDatum.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="HorizontalReferenceDatum.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Horizontal Reference Datum" schemaElement="HorizontalReferenceDatumName" rowCount="'||(select count(*) from wqx.horizontal_reference_datum)||'" maxLastChangeDate="'||to_char(cast((select max(hrdat_last_change_date) from wqx.horizontal_reference_datum) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <HorizontalReferenceDatum>' ||chr(10)||
	'    <Domain>Horizontal Reference Datum(HorizontalReferenceDatumName)</Domain>' ||chr(10)||
	'      <UID>'||hrdat_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(hrdat_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(hrdat_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(hrdat_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </HorizontalReferenceDatum>'
from wqx.horizontal_reference_datum 
order by hrdat_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool HydrologicCondition.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="HydrologicCondition.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Hydrologic Condition" schemaElement="HydrologicCondition" rowCount="'||(select count(*) from wqx.hydrologic_condition)||'" maxLastChangeDate="'||to_char(cast((select max(hydcnd_last_change_date) from wqx.hydrologic_condition) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <HydrologicCondition>' ||chr(10)||
	'    <Domain>Hydrologic Condition(HydrologicCondition)</Domain>' ||chr(10)||
	'      <UID>'||hydcnd_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(hydcnd_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(hydcnd_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(hydcnd_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </HydrologicCondition>'
from wqx.hydrologic_condition 
order by hydcnd_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool HydrologicEvent.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="HydrologicEvent.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Hydrologic Event" schemaElement="HydrologicEvent" rowCount="'||(select count(*) from wqx.hydrologic_event)||'" maxLastChangeDate="'||to_char(cast((select max(hydev_last_change_date) from wqx.hydrologic_event) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <HydrologicEvent>' ||chr(10)||
	'    <Domain>Hydrologic Event(HydrologicEvent)</Domain>' ||chr(10)||
	'      <UID>'||hydev_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(hydev_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(hydev_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(hydev_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </HydrologicEvent>'
from wqx.hydrologic_event 
order by hydev_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool IndexType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="IndexType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Index Type" schemaElement="IndexType/IndexTypeIdentifier" rowCount="'||(select count(*) from wqx.Index_type)||'" maxLastChangeDate="'||to_char(cast((select max(idxtyp_last_change_date) from wqx.Index_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <IndexType>' ||chr(10)||
	'    <Domain>Index Type(IndexTypeIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||idxtyp_uid||'</UID>' ||chr(10)||
	'      <Identifier>'|| replace(replace(replace(replace(replace(translate(idxtyp_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Identifier>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(idxtyp_context,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(idxtyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Scale>'|| replace(replace(replace(replace(replace(translate(idxtyp_scale,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Scale>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(idxtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </IndexType>'
from wqx.Index_type 
order by idxtyp_id ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool LabSamplePreparationMethod.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="LabSamplePreparationMethod.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="LabSample Preparation Method" schemaElement="LabSamplePreparation/LabSamplePreparationMethod/MethodIdentifier" rowCount="'||(select count(*) from wqx.lab_sample_preparation_method)||'" maxLastChangeDate="'||to_char(cast((select max(lspmth_last_change_date) from wqx.lab_sample_preparation_method) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <LabSamplePreparationMethod>' ||chr(10)||
	'    <Domain>Lab Sample Preparation Method(LabSamplePreparationMethod/MethodIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||lspmth_uid||'</UID>' ||chr(10)||
	'      <Identifier>'|| replace(replace(replace(replace(replace(translate(lspmth_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Identifier>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(lspmth_context,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(lspmth_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <QualifierType>'||lspmth_qual_type||'</QualifierType>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(lspmth_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(lspmth_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </LabSamplePreparationMethod>'
from wqx.lab_sample_preparation_method 
order by lspmth_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool MeasureQualifier.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="MeasureQualifier.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Measure Qualifier" schemaElement="MeasureQualifierCode" rowCount="'||(select count(*) from wqx.measure_qualifier)||'" maxLastChangeDate="'||to_char(cast((select max(msrqlf_last_change_date) from wqx.measure_qualifier) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <MeasureQualifier>' ||chr(10)||
	'    <Domain>Measure Qualifier(MeasureQualifierCode)</Domain>' ||chr(10)||
	'      <UID>'||msrqlf_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(msrqlf_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(msrqlf_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(msrqlf_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </MeasureQualifier>'
from wqx.measure_qualifier 
--where msrqlf_deprecated is null
order by msrqlf_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool MeasureQualifierDEPRECATED.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="MeasureQualifierDEPRECATED.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Measure Qualifier DEPRECATED" schemaElement="MeasureQualifierCode" rowCount="'||(select count(*) from wqx.measure_qualifier_legacy)||'" maxLastChangeDate="'||to_char(cast((select max(rmqlf_last_change_date) from wqx.measure_qualifier_legacy) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <MeasureQualifierDEPRECATED>' ||chr(10)||
	'    <Domain>Measure Qualifier DEPRECATED(MeasureQualifierCode)</Domain>' ||chr(10)||
	'      <UID>'||rmqlf_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(rmqlf_cd_old,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <NewCode1>'||msrqlf_cd1||'</NewCode1>' ||chr(10)||
	'      <NewCode2>'||msrqlf_cd2||'</NewCode2>' ||chr(10)||
	'      <NewCode3>'||msrqlf_cd3||'</NewCode3>' ||chr(10)||
	'      <NewCode4>'||msrqlf_cd4||'</NewCode4>' ||chr(10)||
	'      <NewCode5>'||msrqlf_cd5||'</NewCode5>' ||chr(10)||
	'      <NewCode6>'||msrqlf_cd6||'</NewCode6>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rmqlf_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rmqlf_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </MeasureQualifierDEPRECATED>'
from wqx.measure_qualifier_legacy 
order by rmqlf_cd_old ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool MeasurementUnit.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="MeasurementUnit.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Measurement Unit" schemaElement="MeasurementUnitCode" rowCount="'||(select count(*) from wqx.measurement_unit)||'" maxLastChangeDate="'||to_char(cast((select max(msunt_last_change_date) from wqx.measurement_unit) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <MeasurementUnit>' ||chr(10)||
	'    <Domain>Measurement Unit(MeasurementUnitCode)</Domain>' ||chr(10)||
	'      <UID>'||msunt_uid||'</UID>' ||chr(10)||
	'      <Code>'||msunt_cd||'</Code>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(msunt_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <ConvertedUnitCode>'||msunt_target_cd||'</ConvertedUnitCode>' ||chr(10)||
	'      <ConversionFactor>'||msunt_conversion_factor||'</ConversionFactor>' ||chr(10)||
	'      <ConversionCoefficient>'||msunt_conversion_coefficient||'</ConversionCoefficient>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(msunt_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </MeasurementUnit>'
from wqx.measurement_unit 
order by msunt_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool MethodSpeciation.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="MethodSpeciation.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Method Speciation" schemaElement="MethodSpeciationName" rowCount="'||(select count(*) from wqx.method_speciation)||'" maxLastChangeDate="'||to_char(cast((select max(mthspc_last_change_date) from wqx.method_speciation) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <MethodSpeciation>' ||chr(10)||
	'    <Domain>Method Speciation(MethodSpeciationName)</Domain>' ||chr(10)||
	'      <UID>'||mthspc_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(mthspc_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(mthspc_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(mthspc_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </MethodSpeciation>'
from wqx.method_speciation 
order by mthspc_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool MetricType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="MetricType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Metric Type" schemaElement="ActivityMetricType/MetricTypeIdentifier" rowCount="'||(select count(*) from wqx.metric_type)||'" maxLastChangeDate="'||to_char(cast((select max(mettyp_last_change_date) from wqx.metric_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <MetricType>' ||chr(10)||
	'    <Domain>Metric Type(MetricTypeIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||mettyp_uid||'</UID>' ||chr(10)||
	'      <Identifier>'|| replace(replace(replace(replace(replace(translate(mettyp_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Identifier>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(mettyp_context,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(mettyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Scale>'|| replace(replace(replace(replace(replace(translate(mettyp_scale,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Scale>' ||chr(10)||
	'      <FormulaDescription>'|| substr(replace(replace(replace(replace(replace(translate(mettyp_formula_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;')
, 1, 3500) ||
	'</FormulaDescription>'||chr(10)||
	'      <LastChangeDate>'||to_char(cast(mettyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </MetricType>'
from wqx.metric_type 
order by mettyp_id ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool MetricTypeContext.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="MetricTypeContext.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Metric Type Context" schemaElement="MetricTypeIdentifierContext" rowCount="'||(select count(*) from wqx.metric_type_context)||'" maxLastChangeDate="'||to_char(cast((select max(mtctx_last_change_date) from wqx.metric_type_context) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <MetricTypeContext>' ||chr(10)||
	'    <Domain>Metric Type Context(MetricTypeIdentifierContext)</Domain>' ||chr(10)||
	'      <UID>'||mtctx_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(mtctx_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(mtctx_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(mtctx_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(mtctx_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </MetricTypeContext>'
from wqx.metric_type_context 
order by mtctx_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool MonitoringLocationType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="MonitoringLocationType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Monitoring Location Type" schemaElement="MonitoringLocationTypeName" rowCount="'||(select count(*) from wqx.monitoring_location_type)||'" maxLastChangeDate="'||to_char(cast((select max(mltyp_last_change_date) from wqx.monitoring_location_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <MonitoringLocationType>' ||chr(10)||
	'    <Domain>Monitoring Location Type(MonitoringLocationTypeName)</Domain>' ||chr(10)||
	'      <UID>'||mltyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(mltyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(mltyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(mltyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'      <WQPSiteType>'|| replace(replace(replace(replace(replace(translate(mltyp_wqp_site_type,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</WQPSiteType>' ||chr(10)||
	'    </MonitoringLocationType>'
from wqx.monitoring_location_type 
order by mltyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool NetType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="NetType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Net Type" schemaElement="NetTypeName" rowCount="'||(select count(*) from wqx.net_type)||'" maxLastChangeDate="'||to_char(cast((select max(nettyp_last_change_date) from wqx.net_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <NetType>' ||chr(10)||
	'    <Domain>Net Type(NetTypeName)</Domain>' ||chr(10)||
	'      <UID>'||nettyp_uid||'</UID>' ||chr(10)||
	'      <EquipmentType>'|| replace(replace(replace(replace(replace(translate(scetyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</EquipmentType>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(nettyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(nettyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <Abbrevation>'||nettyp_abbrev||'</Abbrevation>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(nettyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </NetType>'
from wqx.net_type nt, wqx.sample_collection_equip_type scet
where nt.scetyp_uid=scet.scetyp_uid
order by nettyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Organization.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Organization.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Organization" schemaElement="OrganizationIdentifier" rowCount="'||(select count(*) from wqx.organization)||'" maxLastChangeDate="'||to_char(cast((select max(org_last_change_date) from wqx.organization) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Organization>' ||chr(10)||
	'    <Domain>Organization(OrganizationIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||o.org_uid||'</UID>' ||chr(10)||
	'      <Identifier>'|| replace(replace(replace(replace(replace(translate(org_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Identifier>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(org_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Type>'||org_type||'</Type>' ||chr(10)||
	'      <TribalCode>'||TRB_CD||'</TribalCode>' ||chr(10)||
--	'      <Name>'||orgtyp_name||'</Name>' ||chr(10)||
	'      <ElectronicAddress>'|| replace(replace(replace(replace(replace(translate(oea.eAddress,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</ElectronicAddress>' ||chr(10)||
	'      <ElectronicAddressType>'|| replace(replace(replace(replace(replace(translate(regexp_substr(oea.eAddress, '[^|]+', 1, 1),'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</ElectronicAddressType>' ||chr(10)||
	'      <ElectronicAddressText>'|| replace(replace(replace(replace(replace(translate(regexp_substr(oea.eAddress, '[^|]+', 1, 2),'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</ElectronicAddressText>' ||chr(10)||
	'      <TelephoneText>'||op.ePhone||'</TelephoneText>' ||chr(10)||
	'      <TelephoneType>'||regexp_substr(op.ePhone, '[^|]+', 1, 1)||'</TelephoneType>' ||chr(10)||
	'      <TelephoneNumberText>'||regexp_substr(op.ePhone, '[^|]+', 1, 2)||'</TelephoneNumberText>' ||chr(10)||
	'      <TelephoneExtensionNumberText>'||regexp_substr(op.ePhone, '[^|]+', 1, 3)||'</TelephoneExtensionNumberText>' ||chr(10)||
	'      <PhysicalAddress>'|| replace(replace(replace(replace(replace(translate(oadd.address,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</PhysicalAddress>' ||chr(10)||
	'      <AddressType>'|| replace(replace(replace(replace(replace(translate(regexp_substr(oadd.address, '[^|]+', 1, 1),'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</AddressType>' ||chr(10)||
	'      <AddressText>'|| replace(replace(replace(replace(replace(translate(regexp_substr(oadd.address, '[^|]+', 1, 2),'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</AddressText>' ||chr(10)||
	'      <SupplementalAddressText>'|| replace(replace(replace(replace(replace(translate(regexp_substr(oadd.address, '[^|]+', 1, 3),'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</SupplementalAddressText>' ||chr(10)||
	'      <Locality>'|| replace(replace(replace(replace(replace(translate(regexp_substr(oadd.address, '[^|]+', 1, 4),'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Locality>' ||chr(10)||
	'      <StateCode>'||regexp_substr(oadd.address, '[^|]+', 1, 5)||'</StateCode>' ||chr(10)||
	'      <PostalCode>'||regexp_substr(oadd.address, '[^|]+', 1, 6)||'</PostalCode>' ||chr(10)||
 	'      <Description>'|| replace(replace(replace(replace(replace(translate(org_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(org_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Organization>'
from wqx.organization O, 
--WQX.ORG_ELECTRONIC_ADDRESS P, WQX.ORG_PHONE Q, WQX.ORG_ADDRESS R, WQX.STATE S, 
WQX.TRIBE T ,
(select org_uid,replace(listagg(phtyp_name||' | '||orgph_num||nullif(' ext: '||orgph_ext,' ext: '),'| ; '),'| ;',' ;') ePhone 
           from (select distinct orgph.org_uid,orgph.orgph_uid,phtyp.phtyp_name,orgph.orgph_num,orgph.orgph_ext from wqx.org_phone orgph, wqx.phone_type phtyp where orgph.org_uid in (select org_uid from kcs.org@owstg) and phtyp.phtyp_uid = orgph.phtyp_uid) 
           where 1=1 group by org_uid) op,
(select org_uid, replace(listagg(addtyp_name||' | '||orgadd_address||' | '||orgadd_address_supplemental||' | '||orgadd_locality_name||' | '||st_cd||' | '||orgadd_postal_cd||' | '||cntry_cd||' | '||lpad(cnty_fips_cd, 3, '0'),'| ; '),'| ;',' ;') address
                 from (select distinct orgadd.org_uid,orgadd.orgadd_uid,orgadd.orgadd_address,orgadd.orgadd_address_supplemental,orgadd.orgadd_locality_name,addtyp.addtyp_name,st.st_cd,orgadd.orgadd_postal_cd,cntry.cntry_cd,cnty.cnty_fips_cd from wqx.org_address orgadd, wqx.address_type addtyp, wqx.state st, wqx.country cntry, wqx.county cnty where orgadd.org_uid in (select org_uid from wqx.organization where org_id NOT in (' ')) and addtyp.addtyp_uid = orgadd.addtyp_uid and cnty.cnty_uid (+) = orgadd.cnty_uid and cntry.cntry_uid (+) = orgadd.cntry_uid and st.st_uid (+) = orgadd.st_uid) 
                 where 1=1 group by org_uid) oadd,
(select org_uid, replace(listagg(eatyp_name||' | '||orgea_text,'| ; '),'| ;',' ;') eAddress
                 from (select distinct orgea.org_uid,orgea.orgea_uid,orgea.orgea_text,eatyp.eatyp_name from wqx.org_electronic_address orgea, wqx.electronic_address_type eatyp where orgea.org_uid in (select org_uid from wqx.organization where org_id NOT in (' ')) and eatyp.eatyp_uid = orgea.eatyp_uid) 
                 where 1=1 group by org_uid) oea 
--WHERE O."ORG_UID" = P."ORG_UID" (+) AND O."ORG_UID" = Q."ORG_UID" (+) AND O."ORG_UID" = R."ORG_UID" (+) AND R."ST_UID" = S."ST_UID" AND 
WHERE O."TRB_UID" = T."TRB_UID" (+) AND o.org_uid = oadd.org_uid (+) AND o.org_uid = oea.org_uid (+) AND o.org_uid = op.org_uid (+)
order by org_id ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool OrganizationType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="OrganizationType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Organization Type" schemaElement="OrganizationTypeName" rowCount="'||(select count(*) from wqx.organization_type)||'" maxLastChangeDate="'||to_char(cast((select max(orgtyp_last_change_date) from wqx.organization_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <OrganizationType>' ||chr(10)||
	'    <Domain>Organization Type(OrganizationTypeName)</Domain>' ||chr(10)||
--	'      <UID>'||orgtyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(org_type,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
--	'      <Name>'||orgtyp_name||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(orgtyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(orgtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </OrganizationType>'
from wqx.organization_type 
order by org_type ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool PhoneType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="PhoneType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Phone Type" schemaElement="Telephonic/TelephoneNumberTypeName" rowCount="'||(select count(*) from wqx.phone_type)||'" maxLastChangeDate="'||to_char(cast((select max(phtyp_last_change_date) from wqx.phone_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <PhoneType>' ||chr(10)||
	'    <Domain>Phone Type(TelephoneNumberTypeName)</Domain>' ||chr(10)||
	'      <UID>'||phtyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(phtyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(phtyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(phtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </PhoneType>'
from wqx.phone_type 
order by phtyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool QAQCCharacteristicValidation.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="QAQCCharacteristicValidation.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="QAQC Characteristic Validation" schemaElement="CharacteristicName" rowCount="'||(select count(*) from wqx.qaqc_characteristic_validation)||'" maxLastChangeDate="'||to_char(cast((select max(qcv_last_change_date) from wqx.qaqc_characteristic_validation) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <QAQCCharacteristicValidation>' ||chr(10)||
	'    <Domain>QAQC Characteristic Validation(CharacteristicName)</Domain>' ||chr(10)||
	'      <UID>'||qcv_uid||'</UID>' ||chr(10)||
	'      <CharacteristicDomain>'||qcv_domain||'</CharacteristicDomain>' ||chr(10)||
	'      <CharacteristicSearch>'|| replace(replace(replace(replace(replace(translate(qcv_chr_name_search,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</CharacteristicSearch>' ||chr(10)||
	'      <ValueSearch>'|| replace(replace(replace(replace(replace(translate(qcv_value_search,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</ValueSearch>' ||chr(10)||
	'      <SourceSearch>'|| replace(replace(replace(replace(replace(translate(qcv_source_search,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</SourceSearch>' ||chr(10)||
	'      <Status>'||qcv_domain_status||'</Status>' ||chr(10)||
	'      <MeasureUnit>'||qcv_value_unit||'</MeasureUnit>' ||chr(10)||
	'      <MeasureMIN>'||qcv_min_value||'</MeasureMIN>' ||chr(10)||
	'      <MeasureMAX>'||qcv_max_value||'</MeasureMAX>' ||chr(10)||
	'      <MeasureConversionFactor>'||qcv_conversion_factor||'</MeasureConversionFactor>' ||chr(10)||
	'      <MeasureConversionCoefficient>'||qcv_conversion_coefficient||'</MeasureConversionCoefficient>' ||chr(10)||
	'      <NotesRecommendations>'|| replace(replace(replace(replace(replace(translate(qcv_notes_recommendation,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</NotesRecommendations>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(qcv_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </QAQCCharacteristicValidation>'
from wqx.qaqc_characteristic_validation 
order by qcv_domain, qcv_chr_name_search ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ReferenceLocationType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ReferenceLocationType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Reference Location Type" schemaElement="ReferenceLocationTypeCode" rowCount="'||(select count(*) from wqx.reference_location_type)||'" maxLastChangeDate="'||to_char(cast((select max(rltyp_last_change_date) from wqx.reference_location_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ReferenceLocationType>' ||chr(10)||
	'    <Domain>Reference Location Type(ReferenceLocationTypeCode)</Domain>' ||chr(10)||
	'      <UID>'||rltyp_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(rltyp_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rltyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rltyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ReferenceLocationType>'
from wqx.reference_location_type 
order by rltyp_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool RelativeDepth.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="RelativeDepth.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Relative Depth" schemaElement="ActivityRelativeDepthName" rowCount="'||(select count(*) from wqx.relative_depth)||'" maxLastChangeDate="'||to_char(cast((select max(reldpth_last_change_date) from wqx.relative_depth) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <RelativeDepth>' ||chr(10)||
	'    <Domain>Relative Depth(ActivityRelativeDepthName)</Domain>' ||chr(10)||
	'      <UID>'||reldpth_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(reldpth_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(reldpth_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <Abbreviation>'||reldpth_abbrev||'</Abbreviation>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(reldpth_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </RelativeDepth>'
from wqx.relative_depth 
order by reldpth_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultDetectionCondition.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultDetectionCondition.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Detection Condition" schemaElement="ResultDetectionConditionText" rowCount="'||(select count(*) from wqx.result_detection_condition)||'" maxLastChangeDate="'||to_char(cast((select max(rdcnd_last_change_date) from wqx.result_detection_condition) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultDetectionCondition>' ||chr(10)||
	'    <Domain>Result Detection Condition(ResultDetectionConditionText)</Domain>' ||chr(10)||
	'      <UID>'||rdcnd_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(rdcnd_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rdcnd_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rdcnd_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultDetectionCondition>'
from wqx.result_detection_condition 
order by rdcnd_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultLabComment.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultLabComment.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Lab Comment" schemaElement="ResultLabInformation/LaboratoryCommentText" rowCount="'||(select count(*) from wqx.result_lab_comment)||'" maxLastChangeDate="'||to_char(cast((select max(rlcom_last_change_date) from wqx.result_lab_comment) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultLabComment>' ||chr(10)||
	'    <Domain>Result Lab Comment(LaboratoryCommentText)</Domain>' ||chr(10)||
	'      <UID>'||rlcom_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(rlcom_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rlcom_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rlcom_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultLabComment>'
from wqx.result_lab_comment 
order by rlcom_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultSamplingPointType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultSamplingPointType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Sampling Point Type" schemaElement="ResultSamplingPointType" rowCount="'||(select count(*) from wqx.result_sampling_point_type)||'" maxLastChangeDate="'||to_char(cast((select max(rsptyp_last_change_date) from wqx.result_sampling_point_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultSamplingPointType>' ||chr(10)||
	'    <Domain>Result Sampling Point Type(ResultSamplingPointType)</Domain>' ||chr(10)||
	'      <UID>'||rsptyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(rsptyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rsptyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rsptyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultSamplingPointType>'
from wqx.result_sampling_point_type 
order by rsptyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool StatisticalBase.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="StatisticalBase.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Statistical Base" schemaElement="StatisticalBaseCode" rowCount="'||(select count(*) from wqx.result_statistical_base)||'" maxLastChangeDate="'||to_char(cast((select max(rsbas_last_change_date) from wqx.result_statistical_base) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <StatisticalBase>' ||chr(10)||
	'    <Domain>Statistical Base(StatisticalBaseCode)</Domain>' ||chr(10)||
	'      <UID>'||rsbas_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(rsbas_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rsbas_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rsbas_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </StatisticalBase>'
from wqx.result_statistical_base 
order by rsbas_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultStatus.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultStatus.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Status" schemaElement="ResultStatusIdentifier" rowCount="'||(select count(*) from wqx.result_status)||'" maxLastChangeDate="'||to_char(cast((select max(ressta_last_change_date) from wqx.result_status) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultStatus>' ||chr(10)||
	'    <Domain>Result Status(ResultStatusIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||ressta_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(ressta_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(ressta_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(ressta_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultStatus>'
from wqx.result_status 
order by ressta_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool TargetCount.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="TargetCount.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Target Count" schemaElement="TargetCount" rowCount="'||(select count(*) from wqx.result_target_count)||'" maxLastChangeDate="'||to_char(cast((select max(rtc_last_change_date) from wqx.result_target_count) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <TargetCount>' ||chr(10)||
	'    <Domain>Target Count(TargetCount)</Domain>' ||chr(10)||
	'      <UID>'||rtc_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(rtc_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rtc_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rtc_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </TargetCount>'
from wqx.result_target_count 
order by rtc_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultTemperatureBasis.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultTemperatureBasis.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Temperature Basis" schemaElement="ResultTemperatureBasisText" rowCount="'||(select count(*) from wqx.result_temperature_basis)||'" maxLastChangeDate="'||to_char(cast((select max(rtmpb_last_change_date) from wqx.result_temperature_basis) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultTemperatureBasis>' ||chr(10)||
	'    <Domain>Result Temperature Basis(ResultTemperatureBasisText)</Domain>' ||chr(10)||
	'      <UID>'||rtmpb_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(rtmpb_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rtmpb_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rtmpb_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultTemperatureBasis>'
from wqx.result_temperature_basis 
order by rtmpb_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultTimeBasis.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultTimeBasis.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Time Basis" schemaElement="ResultTimeBasisText" rowCount="'||(select count(*) from wqx.result_time_basis)||'" maxLastChangeDate="'||to_char(cast((select max(rtimb_last_change_date) from wqx.result_time_basis) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultTimeBasis>' ||chr(10)||
	'    <Domain>Result Time Basis(ResultTimeBasisText)</Domain>' ||chr(10)||
	'      <UID>'||rtimb_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(rtimb_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rtimb_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rtimb_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultTimeBasis>'
from wqx.result_time_basis 
order by rtimb_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultValueType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultValueType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Value Type" schemaElement="ResultValueTypeName" rowCount="'||(select count(*) from wqx.result_value_type)||'" maxLastChangeDate="'||to_char(cast((select max(rvtyp_last_change_date) from wqx.result_value_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultValueType>' ||chr(10)||
	'    <Domain>Result Value Type(ResultValueTypeName)</Domain>' ||chr(10)||
	'      <UID>'||rvtyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(rvtyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rvtyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rvtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultValueType>'
from wqx.result_value_type 
order by rvtyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ResultWeightBasis.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ResultWeightBasis.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Result Weight Basis" schemaElement="ResultWeightBasisText" rowCount="'||(select count(*) from wqx.result_weight_basis)||'" maxLastChangeDate="'||to_char(cast((select max(rwbas_last_change_date) from wqx.result_weight_basis) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ResultWeightBasis>' ||chr(10)||
	'    <Domain>Result Weight Basis(ResultWeightBasisText)</Domain>' ||chr(10)||
	'      <UID>'||rwbas_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(rwbas_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(rwbas_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(rwbas_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ResultWeightBasis>'
from wqx.result_weight_basis 
order by rwbas_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool SampleCollectionMethodContext.xml
select	'<?xml version="1SampleCollectionMethodContext.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||	'xsi:schemaLocation="SampleCollectionMethodContext.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Sample Collection Method Context" schemaElement="SampleCollectionMethod/MethodIdentifierContext" rowCount="'||(select count(*) from wqx.sample_collect_method_context)||'" maxLastChangeDate="'||to_char(cast((select max(scmctx_last_change_date) from wqx.sample_collect_method_context) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <SampleCollectionMethodContext>' ||chr(10)||
	'    <Domain>Sample Collection Method Context(MethodIdentifierContext)</Domain>' ||chr(10)||
	'      <UID>'||scmctx_uid||'</UID>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(scmctx_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(scmctx_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(scmctx_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(scmctx_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </SampleCollectionMethodContext>'
from wqx.sample_collect_method_context 
order by scmctx_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool SampleCollectionEquipment.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="SampleCollectionEquipment.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Sample Collection Equipment" schemaElement="SampleCollectionEquipmentName" rowCount="'||(select count(*) from wqx.sample_collection_equip)||'" maxLastChangeDate="'||to_char(cast((select max(sceqp_last_change_date) from wqx.sample_collection_equip) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <SampleCollectionEquipment>' ||chr(10)||
	'    <Domain>Sample Collection Equipment(SampleCollectionEquipmentName)</Domain>' ||chr(10)||
	'      <UID>'||sceqp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(sceqp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(sceqp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <Abbreviation>'||sceqp_abbrev||'</Abbreviation>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(sceqp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </SampleCollectionEquipment>'
from wqx.sample_collection_equip 
order by sceqp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool SampleCollectionEquipmentType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="SampleCollectionEquipmentType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Sample Collection Equipment Type" schemaElement="SampleCollectionEquipmentTypeName" rowCount="'||(select count(*) from wqx.sample_collection_equip_type)||'" maxLastChangeDate="'||to_char(cast((select max(scetyp_last_change_date) from wqx.sample_collection_equip_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <SampleCollectionEquipmentType>' ||chr(10)||
	'    <Domain>Sample Collection Equipment Type(SampleCollectionEquipmentTypeName)</Domain>' ||chr(10)||
	'      <UID>'||scetyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(scetyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(scetyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(scetyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </SampleCollectionEquipmentType>'
from wqx.sample_collection_equip_type 
order by scetyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool SampleCollectionMethod.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="SampleCollectionMethod.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Sample Collection Method" schemaElement="SampleCollectionMethod/MethodIdentifier" rowCount="'||(select count(*) from wqx.sample_collection_method where org_uid is null)||'" maxLastChangeDate="'||to_char(cast((select max(scmth_last_change_date) from wqx.sample_collection_method where org_uid is null) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <SampleCollectionMethod>' ||chr(10)||
	'    <Domain>Sample Collection Method(MethodIdentifier)</Domain>' ||chr(10)||
	'      <UID>'||scmth_uid||'</UID>' ||chr(10)||
	'      <Identifier>'|| replace(replace(replace(replace(replace(translate(scmth_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Identifier>' ||chr(10)||
	'      <Context>'|| replace(replace(replace(replace(replace(translate(scmctx_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Context>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(scmth_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <QualifierType>'|| replace(replace(replace(replace(replace(translate(scmth_qual_type,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</QualifierType>' ||chr(10)||
	'      <Description>'|| substr(replace(replace(replace(replace(replace(translate(scmth_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;')
, 1, 3000) ||
	'</Description>' ||chr(10)|| 
	'      <LastChangeDate>'||to_char(cast(scmth_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </SampleCollectionMethod>'
from wqx.sample_collection_method scm, wqx.sample_collect_method_context scmc
where scm.scmctx_uid=scmc.scmctx_uid and scm.org_uid is null
order by scmth_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off


--
spool SampleFraction.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="SampleFraction.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Sample Fraction" schemaElement="ResultSampleFractionText" rowCount="'||(select count(*) from wqx.sample_fraction)||'" maxLastChangeDate="'||to_char(cast((select max(smfrc_last_change_date) from wqx.sample_fraction) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <SampleFraction>' ||chr(10)||
	'    <Domain>Sample Fraction(ResultSampleFractionText)</Domain>' ||chr(10)||
	'      <UID>'||smfrc_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(smfrc_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(smfrc_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(smfrc_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </SampleFraction>'
from wqx.sample_fraction 
order by smfrc_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool SampleTissueAnatomy.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="SampleTissueAnatomy.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Sample Tissue Anatomy" schemaElement="SampleTissueAnatomyName" rowCount="'||(select count(*) from wqx.sample_tissue_anatomy)||'" maxLastChangeDate="'||to_char(cast((select max(stant_last_change_date) from wqx.sample_tissue_anatomy) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <SampleTissueAnatomy>' ||chr(10)||
	'    <Domain>Sample Tissue Anatomy(SampleTissueAnatomyName)</Domain>' ||chr(10)||
	'      <UID>'||stant_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(stant_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(stant_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(stant_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </SampleTissueAnatomy>'
from wqx.sample_tissue_anatomy 
order by stant_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool SamplingDesignType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="SamplingDesignType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Sample Design Type" schemaElement="SamplingDesignTypeCode" rowCount="'||(select count(*) from wqx.sampling_design_type)||'" maxLastChangeDate="'||to_char(cast((select max(sdtyp_last_change_date) from wqx.sampling_design_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <SamplingDesignType>' ||chr(10)||
	'    <Domain>Sample Design Type(SamplingDesignTypeCode)</Domain>' ||chr(10)||
	'      <UID>'||sdtyp_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(sdtyp_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(sdtyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(sdtyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </SamplingDesignType>'
from wqx.sampling_design_type 
order by sdtyp_cd ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool State.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="State.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="State" schemaElement="StateCode" rowCount="'||(select count(*) from wqx.state)||'" maxLastChangeDate="'||to_char(cast((select max(st_last_change_date) from wqx.state) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <State>' ||chr(10)||
	'    <Domain>State(StateCode)</Domain>' ||chr(10)||
	'      <UID>'||st_uid||'</UID>' ||chr(10)||
	'      <Country>'|| replace(replace(replace(replace(replace(translate(cntry_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Country>' ||chr(10)||
	'      <Code>'||st_cd||'</Code>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(st_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <FIPSCode>'||st_fips_cd||'</FIPSCode>' ||chr(10)||
	'      <EPARegion>'|| replace(replace(replace(replace(replace(translate(er_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</EPARegion>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(st_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </State>'
from wqx.state s, wqx.country c, wqx.epa_region er
where s.cntry_uid=c.cntry_uid and s.er_uid=er.er_uid
order by st_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Taxon.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Taxon.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Taxon" schemaElement="SubjectTaxonomicName" rowCount="'||(select count(*) from wqx.taxon)||'" maxLastChangeDate="'||to_char(cast((select max(tax_last_change_date) from wqx.taxon) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Taxon>' ||chr(10)||
	'    <Domain>Taxon(SubjectTaxonomicName)</Domain>' ||chr(10)||
	'      <UID>'||t.tax_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(t.tax_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <RankName>'|| replace(replace(replace(replace(replace(translate(txrnk_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</RankName>' ||chr(10)||
	'      <ExternalID>'||t.tax_extrnl_id||'</ExternalID>' ||chr(10)||
	'      <STORET_ID>'||t.tax_storet_id||'</STORET_ID>' ||chr(10)||
	'      <SRS_ID>'||t.tax_srs_id||'</SRS_ID>' ||chr(10)||
	'      <KingdomName>'||tk.tax_name||'</KingdomName>' ||chr(10)||
	'      <GroupName>'|| replace(replace(replace(replace(replace(translate(taxgrp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</GroupName>' ||chr(10)||
	'      <Status>'||dvsta_name||'</Status>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(t.tax_description,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(t.tax_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Taxon>'
from wqx.taxon t, wqx.taxon tk, wqx.taxon_rank tr, wqx.taxon_group tg, wqx.domain_value_status dvs
where t.tax_uid_kingdom=tk.tax_uid and t.txrnk_uid=tr.txrnk_uid and t.taxgrp_uid=tg.taxgrp_uid and t.dvsta_uid=dvs.dvsta_uid
order by t.tax_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool TaxonAlias.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="TaxonAlias.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Taxon Alias" schemaElement="SubjectTaxonomicName" rowCount="'||(select count(*) from wqx.taxon_alias)||'" maxLastChangeDate="'||to_char(cast((select max(taxals_last_change_date) from wqx.taxon_alias) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <TaxonAlias>' ||chr(10)||
	'    <Domain>Taxon Alias(SubjectTaxonomicName)</Domain>' ||chr(10)||
	'      <UID>'||taxals_uid||'</UID>' ||chr(10)||
	'      <AliasType>'|| replace(replace(replace(replace(replace(translate(alstyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</AliasType>' ||chr(10)||
	'      <AliasName>'|| replace(replace(replace(replace(replace(translate(taxals_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</AliasName>' ||chr(10)||
	'      <TaxonName>'|| replace(replace(replace(replace(replace(translate(tax_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</TaxonName>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(taxals_description,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(taxals_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </TaxonAlias>'
from wqx.taxon_alias ta, wqx.taxon t, wqx.alias_type at
where ta.alstyp_uid=at.alstyp_uid and ta.tax_uid=t.tax_uid
order by alstyp_name, taxals_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool TaxonGroup.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="TaxonGroup.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Taxon Group" schemaElement="TaxonGroupName" rowCount="'||(select count(*) from wqx.taxon_group)||'" maxLastChangeDate="'||to_char(cast((select max(taxgrp_last_change_date) from wqx.taxon_group) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <TaxonGroup>' ||chr(10)||
	'    <Domain>Taxon Group(TaxonGroupName)</Domain>' ||chr(10)||
	'      <UID>'||taxgrp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(taxgrp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(taxgrp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(taxgrp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </TaxonGroup>'
from wqx.taxon_group 
order by taxgrp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool TaxonRank.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="TaxonRank.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Taxon Rank" schemaElement="TaxonRankName" rowCount="'||(select count(*) from wqx.taxon_rank)||'" maxLastChangeDate="'||to_char(cast((select max(txrnk_last_change_date) from wqx.taxon_rank) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <TaxonRank>' ||chr(10)||
	'    <Domain>Taxon Rank(TaxonRankName)</Domain>' ||chr(10)||
	'      <UID>'||txrnk_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(txrnk_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
--	'      <Description>'|| replace(replace(replace(replace(replace(translate(txrnk_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(txrnk_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </TaxonRank>'
from wqx.taxon_rank 
order by txrnk_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool TaxonParent.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="TaxonParent.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Taxon Parent" schemaElement="SubjectTaxonomicName" rowCount="'||(select count(*) from wqx.taxon_rank)||'" maxLastChangeDate="'||to_char(cast((select max(txrnk_last_change_date) from wqx.taxon_rank) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <TaxonParent>' ||chr(10)||
	'    <Domain>Taxon Parent(SubjectTaxonomicName)</Domain>' ||chr(10)||
	'      <UID>'||tax_uid||'</UID>' ||chr(10)||
	'      <Rank>'||rank_name||'</Rank>' ||chr(10)||
	'      <TaxonName>'|| replace(replace(replace(replace(replace(translate(tax_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</TaxonName>' ||chr(10)||
	'      <KingdomName>'||kingdom_name||'</KingdomName>' ||chr(10)||
	'      <HierarchyString>'||hierarchy_string||'</HierarchyString>' ||chr(10)||
	'      <HierarchyLevel>'||hlevel||'</HierarchyLevel>' ||chr(10)||
	'      <PhylumName>'||phylum||'</PhylumName>' ||chr(10)||
--	'      <Description>'||txrnk_desc||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(taxpar_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </TaxonParent>'
from wqx.taxon_parent 
order by tax_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ThermalPreservativeUsed.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ThermalPreservativeUsed.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Thermal Preservative Used" schemaElement="ThermalPreservativeUsedName" rowCount="'||(select count(*) from wqx.thermal_preservative)||'" maxLastChangeDate="'||to_char(cast((select max(thprsv_last_change_date) from wqx.thermal_preservative) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ThermalPreservativeUsed>' ||chr(10)||
	'    <Domain>Thermal Preservative Used(ThermalPreservativeUsedName)</Domain>' ||chr(10)||
	'      <UID>'||thprsv_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(thprsv_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(thprsv_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(thprsv_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ThermalPreservativeUsed>'
from wqx.thermal_preservative 
order by thprsv_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool TimeZone.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="TimeZone.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Time Zone" schemaElement="TimeZoneCode" rowCount="'||(select count(*) from wqx.time_zone)||'" maxLastChangeDate="'||to_char(cast((select max(tmzone_last_change_date) from wqx.time_zone) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <TimeZone>' ||chr(10)||
	'    <Domain>Time Zone(TimeZoneCode)</Domain>' ||chr(10)||
	'      <UID>'||tmzone_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(tmzone_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(tmzone_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <OffSet>'||tmzone_offset||'</OffSet>' ||chr(10)||
--	'      <Description>'|| replace(replace(replace(replace(replace(translate(tmzone_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(tmzone_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </TimeZone>'
from wqx.time_zone 
order by tmzone_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool ToxicityTestType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="ToxicityTestType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Toxicity Test Type" schemaElement="ToxicityTestType" rowCount="'||(select count(*) from wqx.toxicity_test_type)||'" maxLastChangeDate="'||to_char(cast((select max(tttyp_last_change_date) from wqx.toxicity_test_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <ToxicityTestType>' ||chr(10)||
	'    <Domain>Toxicity Test Type(ToxicityTestType)</Domain>' ||chr(10)||
	'      <UID>'||tttyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(tttyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(tttyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(tttyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </ToxicityTestType>'
from wqx.toxicity_test_type 
order by tttyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Tribe.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Tribe.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Tribe" schemaElement="TribalCode" rowCount="'||(select count(*) from wqx.tribe)||'" maxLastChangeDate="'||to_char(cast((select max(trb_last_change_date) from wqx.tribe) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Tribe>' ||chr(10)||
	'    <Domain>Tribe(TribalCode)</Domain>' ||chr(10)||
	'      <UID>'||trb_uid||'</UID>' ||chr(10)||
	'      <Code>'|| replace(replace(replace(replace(replace(translate(trb_cd,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Code>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(trb_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <EPAID>'|| replace(replace(replace(replace(replace(translate(trb_epa_id,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</EPAID>' ||chr(10)||
	'      <EPAName>'|| replace(replace(replace(replace(replace(translate(trb_epa_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</EPAName>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(trb_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(trb_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Tribe>'
from wqx.tribe 
order by trb_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool VerticalCollectionMethod.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="VerticalCollectionMethod.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Vertical Collection Method" schemaElement="VerticalCollectionMethodName" rowCount="'||(select count(*) from wqx.vertical_collection_method)||'" maxLastChangeDate="'||to_char(cast((select max(vcmth_last_change_date) from wqx.vertical_collection_method) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <VerticalCollectionMethod>' ||chr(10)||
	'    <Domain>Vertical Collection Method(VerticalCollectionMethodName)</Domain>' ||chr(10)||
	'      <UID>'||vcmth_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(vcmth_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(vcmth_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(vcmth_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </VerticalCollectionMethod>'
from wqx.vertical_collection_method 
order by vcmth_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool VerticalCoordinateReferenceSystemDatum.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="VerticalCoordinateReferenceSystemDatum.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Vertical Coordinate Reference System Datum" schemaElement="VerticalCoordinateReferenceSystemDatumName" rowCount="'||(select count(*) from wqx.vertical_reference_datum)||'" maxLastChangeDate="'||to_char(cast((select max(vrdat_last_change_date) from wqx.vertical_reference_datum) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <VerticalCoordinateReferenceSystemDatum>' ||chr(10)||
	'    <Domain>Vertical Coordinate Reference System Datum(VerticalCoordinateReferenceSystemDatumName)</Domain>' ||chr(10)||
	'      <UID>'||vrdat_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(vrdat_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(vrdat_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(vrdat_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </VerticalCoordinateReferenceSystemDatum>'
from wqx.vertical_reference_datum 
order by vrdat_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool Voltinism.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="Voltinism.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Voltinism" schemaElement="VoltinismName" rowCount="'||(select count(*) from wqx.Voltinism)||'" maxLastChangeDate="'||to_char(cast((select max(volt_last_change_date) from wqx.Voltinism) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <Voltinism>' ||chr(10)||
	'    <Domain>Voltinism(VoltinismName)</Domain>' ||chr(10)||
	'      <UID>'||volt_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(volt_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(volt_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(volt_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </Voltinism>'
from wqx.Voltinism 
order by volt_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool WellFormationType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="WellFormationType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Well Formation Type" schemaElement="WellInformation/FormationTypeText" rowCount="'||(select count(*) from wqx.well_formation_type)||'" maxLastChangeDate="'||to_char(cast((select max(wftyp_last_change_date) from wqx.well_formation_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <WellFormationType>' ||chr(10)||
	'    <Domain>Well Formation Type(FormationTypeText)</Domain>' ||chr(10)||
	'      <UID>'||wftyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(wftyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(wftyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(wftyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </WellFormationType>'
from wqx.well_formation_type 
order by wftyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off

--
spool WellType.xml
--headerinfo: 
select	'<?xml version="1.0" encoding="UTF-8"?>' ||chr(10)||
	'<WQXDomainValue xmlns="http://www.exchangenetwork.net/schema/wqx/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' ||chr(10)||
'xsi:schemaLocation="WellType.xsd http://www.exchangenetwork.net/schema/wqx/3 http://www.exchangenetwork.net/schema/wqx/3/index.xsd">' ||chr(10)||
--	'  <WQXEntity>' ||chr(10)||
	'    <WQXTable headerInfoBegin="" domainEntity="Well Type" schemaElement="WellInformation/WellTypeText" rowCount="'||(select count(*) from wqx.well_type)||'" maxLastChangeDate="'||to_char(cast((select max(weltyp_last_change_date) from wqx.well_type) as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SSTZR')||'" headerInfoEnd="">'
from dual;
select 
	'    <WellType>' ||chr(10)||
	'    <Domain>Well Type(WellTypeText)</Domain>' ||chr(10)||
	'      <UID>'||weltyp_uid||'</UID>' ||chr(10)||
	'      <Name>'|| replace(replace(replace(replace(replace(translate(weltyp_name,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Name>' ||chr(10)||
	'      <Description>'|| replace(replace(replace(replace(replace(translate(weltyp_desc,'&<>"''','+{}^`'), '+','&amp;'), '{','&lt;'), '}','&gt;'), '^','&quot;'), '`','&apos;') ||'</Description>' ||chr(10)||
	'      <LastChangeDate>'||to_char(cast(weltyp_last_change_date as timestamp with LOCAL time zone), 'YYYY-MM-DD"T"HH24:MI:SS TZR')||'</LastChangeDate>' ||chr(10)||
	'    </WellType>'
from wqx.well_type 
order by weltyp_name ;
--footerinfo: 
select 
	'    </WQXTable>' ||chr(10)||
--	'  </WQXEntity>' ||chr(10)||
	'</WQXDomainValue>' 
from dual;
spool off


