2 Replies Latest reply: Oct 20, 2012 6:48 AM by 952738 RSS

    How to Query an XSD

    952738
      Is there a way of getting element names and attributes from a registered Schema in 10gR2.

      During the load we are building up the extract query by hardcoding the attribute names. As the XSD changes I want to do this dynamically based on the schemalocation.

      E.g Hardcoded extracts looks like this:

      Schema A

      Select Extractvalue(value(xml_frag), '/ROOT/@DATETIME) Datetime
      ,Extractvalue(Value(Xml_Frag), '/ROOT/@ELEMENTONE) one
      From xml_table t,Table(Xmlsequence(Extract(t.Xml_Document,'/ROOT'))) Xml_Frag
      Where Existsnode(t.Xml_Document,'/ROOT) > 0;

      Schema B

      Select Extractvalue(value(xml_frag), '/ROOT/@DATETIME) Datetime
      ,Extractvalue(Value(Xml_Frag), '/ROOT/@ELEMENTONE) one
      ,Extractvalue(Value(Xml_Frag), '/ROOT/@ELEMENTTWO) two
      From xml_table t,Table(Xmlsequence(Extract(t.Xml_Document,'/ROOT'))) Xml_Frag
      Where Existsnode(t.Xml_Document,'/ROOT) > 0;
        • 1. Re: How to Query an XSD
          odie_63
          Is there a way of getting element names and attributes from a registered Schema in 10gR2.
          Sure, the same way you would query any other XML document. What did you try?
          As the XSD changes I want to do this dynamically based on the schemalocation.
          That would mean build the query as a string and run it via dynamic SQL. Not a good idea.
          If the schema evolves then change the query accordingly.

          If the schema evolves then the target table has to evolve too right?
          Are you planning on doing that dynamically too?

          Please explain exactly what you want through an example.
          • 2. Re: How to Query an XSD
            952738
            Such simplicity. Hadn't even thought of that.

            Good point - I see what you are saying that the inserts need updated as well.