Preserve spaces in XMLTYPE from file
988994Feb 4 2013 — edited Feb 12 2013Hi,
I'm having trouble preserving spaces in xml tag values when reading from file as XmlType.
Oracle version: 11.2.
Table to store the xml:
CREATE OR REPLACE GLOBAL TEMPORARY TABLE GPH_XML_TAB OF XMLType
ON COMMIT PRESERVE ROWS
XMLTYPE STORE AS BINARY XML
XMLSCHEMA "PartsRequest.xsd" ELEMENT "Parts";
Loading the table:
INSERT INTO GPH_XML_TAB VALUES(XMLTYPE(bfilename('XML_DIR', 'parts.xml'), NLS_CHARSET_ID('WE8ISO8859P1')));
parts.xml with only spaces in the FunctionGroup tag:
<?xml version="1.0" encoding="Windows-1252"?>
<Parts>
<Part>
<RecordType>002</RecordType>
<FunctionGroup> </FunctionGroup>
</Part>
</ns0:Parts>
This results in a CLOB object with an empty "<FunctionGroup/>" tag, the spaces are lost. This is my problem.
A value like "<FunctionGroup> a</FunctionGroup>" preserves the spaces.
I've tried setting an xsd restriction with no success:
<xs:element minOccurs="0" maxOccurs="1" name="FunctionGroup">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Any help on this would be appreciated. Thanks.
Edited by: user2515287 on 2013-feb-04 23:10
Added DB version.