xml - Create parent node in XMLSCHEMA -


have objects:

create or replace type test.type_numberlist table of number; /  create or replace type test.type_test object (     list  test.type_numberlist   , obj1  number   , obj2  number ) / 

create simple xml schema:

begin dbms_xmlschema.registerschema(   schemaurl => 'testschema.xsd',   schemadoc => '<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"             xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"             xmlns:xdb="http://xmlns.oracle.com/xdb"             xsi:schemalocation="http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/xdbschema.xsd">   <xsd:element name="document" type="type_testtype" xdb:sqltype="type_test" xdb:sqlschema="test"/>   <xsd:complextype name="type_testtype" xdb:sqltype="type_test" xdb:sqlschema="test" xdb:maintaindom="false">   <xsd:sequence>    <xsd:element name="list" type="xsd:double" maxoccurs="unbounded" minoccurs="0" xdb:sqlname="list" xdb:sqlcolltype="type_numberlist" xdb:sqltype="number" xdb:sqlcollschema="test"/>    <xsd:element name="obj1" type="xsd:double" xdb:sqlname="obj1" xdb:sqltype="number"/>    <xsd:element name="obj2" type="xsd:double" xdb:sqlname="obj2" xdb:sqltype="number"/>   </xsd:sequence>  </xsd:complextype> </xsd:schema>',    local     => false,     gentypes  => false,    owner     => 'test');  end; / 

test generation xml object:

declare    test.type_test := new test.type_test(list => test.type_numberlist(1,2)                                         ,obj1 => 1                                         ,obj2 => 2);   v_xml xmltype; begin   v_xml := xmltype( xmldata =>                   , schema => 'testschema.xsd'                   , element => 'document'                   , validated => 1);   dbms_output.put_line(v_xml.getstringval()); end; 

get xml:

<document>   <list>1</list>   <list>2</list>   <obj1>1</obj1>   <obj2>2</obj2> </document> 

list on same level obj1, obj2. there way change xmlschema create parent node list create xml like:

<document>   <list>     <value>1</value>     <value>2</value>   </list>   <obj1>1</obj1>   <obj2>2</obj2> </document> 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -