I register a schema into Oracle XMLDB via the dbms_xmlschema.registerschema() package sub program.
I then select the registered schema from user_xml_schemas.
The schema returns fine, but Oracle has inserted all sorts of Oracle related information into the schema. Here is an example insert (this is just one of many):
xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:storeVarrayAsTable="true" oraxdb:flags="2105633" oraxdb:schemaURL="mySchema.xsd" oraxdb:schemaOwner="bob" oraxdb:numProps="22"
This doesn't concern me for use within the database, however I need to provide the schema to consumers outside the database and the Oracle annotations are simply confusing noise for my target external consumers.
What I would like is the ability to achieve something like the following code using my "invented" dbms_xmlschema_annotate.stripAllOracleAnnotations sub program:
begin
select dbms_xmlschema_annotate.stripAllOracleAnnotations(schema)
into vMyOriginalPreRegisteredSchema
from user_xml_schemas;
...
end;
so I can provide vMyOriginalPreRegisteredSchema to external consumers.
I have hunted but can't find anything that would return me "the original, clean" schema from xml db.
Any assistance would be greatly appreciated.
NOTE: I tried using XSL transformation to strip out the Oracle annotations but although the XSL file I created works perfectly in XMLSpy, Oracle (18c) completes the transformation without error but returns a completely incorrect result. I tested via xmltransform() and xmltype.transform(). I can only assume this is because Oracle is interpreting the oraxdb: nodes internally and "doing it's own thing".
Although this is NOT my preferred method, as catching all cases via regexp can be error prone, the following appears to work and is the only way I can currently find to achieve what I need:
NOTE: As explained in my question edit, although the following XSL transformation works perfectly in XMLspy and would under normal circumstances be my first choice, it produces incorrect output via Oracle xmltransform() or xmltype.transform() because Oracle appears to pollute the output in the transformation with internal annotations:
The above XSL approach utilises Remove namespace declaration from XSLT stylesheet with XSLT (because <xsl:copy> does not work with exclude-result-prefixes for removing the xmlns:oraxdb namespace declaration itself).