Cheking for no difference with XMLDIFF

Hello

I don't know any with XML so apologies if the answer is trivial for many.

I want to compare the same object of 2 diagrams to find the differences. I thought about using DBMS_METADATA with XML, examples of the documentation.

I use a PL/SQL block, because I want the comparison ignores patterns. My version of DB is 11.2.0.3 standard edition (so I can't use DBMS_METADATA_DIFF).

I started my process with TYPES.

That's what I've done mainly so far:

-- Create the same TYPE in 2 different schemas for comparison
create user schema1 identified by schema1;
create user schema2 identified by schema2;

create type schema1.my_type as object(id number);
create type schema2.my_type as object(id number);

These 2 guys are identical, so there should be no observed difference comparing:

-- Use a PL/SQL block to do the comparison
DECLARE
h1   NUMBER; 
th1  NUMBER; 
doc1 CLOB;

h2   NUMBER; 
th2  NUMBER; 
doc2 CLOB;

diff xmltype;
val  varchar2(4000);

BEGIN
     -- Specify the object type.
     h1 := DBMS_METADATA.OPEN('TYPE');
     h2 := DBMS_METADATA.OPEN('TYPE');
       
     -- Use filters to specify the particular object desired.
     DBMS_METADATA.SET_FILTER(h1,'SCHEMA','SCHEMA1');
     DBMS_METADATA.SET_FILTER(h1,'NAME','MY_TYPE');
       
     DBMS_METADATA.SET_FILTER(h2,'SCHEMA','SCHEMA2');
     DBMS_METADATA.SET_FILTER(h2,'NAME','MY_TYPE');
    
     -- Remap the schema name to NULL so that types can be compared irrespective of their owner
     th1 := DBMS_METADATA.ADD_TRANSFORM(h1,'MODIFY');
     DBMS_METADATA.SET_REMAP_PARAM(th1,'REMAP_SCHEMA','SCHEMA1',NULL);
       
     th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'MODIFY');
     DBMS_METADATA.SET_REMAP_PARAM(th2,'REMAP_SCHEMA','SCHEMA2',NULL);
       
     -- Request that the metadata be transformed into creation SXML
     th1 := DBMS_METADATA.ADD_TRANSFORM(h1,'SXML');
     th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'SXML');
     
     -- Fetch the object.
     doc1 := DBMS_METADATA.FETCH_CLOB(h1);
     dbms_output.put_line(doc1);

     doc2 := DBMS_METADATA.FETCH_CLOB(h2);
     dbms_output.put_line(doc2);
     
     -- Use dbms_lob.compare  
     dbms_output.put_line('DBMS_LOB.COMPARE result : ' || dbms_lob.compare(doc1, doc2));
     
     -- Use XMLDIFF 
     select xmldiff(xmltype(doc1), xmltype(doc2)) into diff from dual;
     
     -- Check if the result is NULL
     if diff is null
       then dbms_output.put_line('XMLDIFF found no diff');
       else dbms_output.put_line('XMLDIFF found some diff');
     end if;
     
     -- Display the diff
     select '-->' || xmlcast(diff as varchar2(4000)) || '<--' into val from dual;
     dbms_output.put_line(val);

END;

The result:

" < TYPE_SPEC xmlns =" http://xmlns.Oracle.com/Ku "version ="1.0"> "

< SCHEMA > < / SCHEMA >

< NAME > MY_TYPE < / NAME >

< OBJECT >

< ATTRIBUTE_LIST >

< ATTRIBUTE_LIST_ITEM >

< NAME > ID < / NAME >

NUMBER of <>DATA type < / DATATYPE >

< / ATTRIBUTE_LIST_ITEM >

< / ATTRIBUTE_LIST >

< / OBJECT >

< / TYPE_SPEC >

" < TYPE_SPEC xmlns =" http://xmlns.Oracle.com/Ku "version ="1.0"> "

< SCHEMA > < / SCHEMA >

< NAME > MY_TYPE < / NAME >

< OBJECT >

< ATTRIBUTE_LIST >

< ATTRIBUTE_LIST_ITEM >

< NAME > ID < / NAME >

NUMBER of <>DATA type < / DATATYPE >

< / ATTRIBUTE_LIST_ITEM >

< / ATTRIBUTE_LIST >

< / OBJECT >

< / TYPE_SPEC >

DBMS_LOB.compare result: 0

XMLDIFF found a few diff

-> < -.

PL/SQL procedure successfully completed



My problem as you see is with the XMLDIFF function. I thought that he would return NULL for XML identical documents (even if the documentation never accurate!), but it seems that the return value is not zero, while XMLCAST shows nothing and DBMS_LOB.compare can find no difference.

So, how to test for no difference using XMLDIFF?

Thank you

Greg,

Function XMLDiff() returns a Xdiff document, which is an XML document containing the insert/update/delete primitives describing the differences.

Even if there is no difference, it always produces a Xdiff document with no primitive.

All you have to do is to test if the document contains primitives.

XMLExists function can be used for this task, for example

Select case when xmlexists (' declare default element namespace "http://xmlns.oracle.com/xdb/xdiff.xsd"; / xdiff / *')

passage xmldiff (xmltype (doc1), xmltype (doc2)))

then 'Y '.

another "n".

end

Double;

will return 'Y' if there is no difference, any other 'n'.

To answer the underlying question to know why XMLCast returns an empty string, it's because XMLCast simply extracted all the text() nodes of the document and throw to the specified SQL scalar data type.

When the Xdiff document describes no difference, there is no node text(), only a single root of vacuum ('xdiff') element.

Tags: Database

Similar Questions

  • Is it possible for MapleStory compatible with Windows Vista?

    If necessary, it lists a lot of details and my only difference with it, is that I have Windows Vista. Does th to much difference?

    I have not had, never tried, but a quick google reveals:

    MS Vista claims to be unknown - MapleStory on Vista

    W7 MS claims it does - MapleStory on W7 (so if it turns on W7, I would say there's a good chance he's going on Vista)

    But it claims that it can and does and shows how.

    As I say, I have not tried so can't say for sure, but hope it helps.

  • Sleeve for Lenovo x230t with battery 6 cells

    I'm having a lot of trouble finding a good fitting sleeve for laptop lenovo x230t which has a battery of 6 cells. If anyone knows a sleeve for it, help would be appreciated

    I finally found the cover for laptop ThinkPad 51J0476 12W - 10.83 "x 12" x 0.98"- neoprene from amazon: http://www.amazon.com/gp/product/B002MVXGM4/ref=oh_details_o00_s00_i00. " Handle fits perfectly. The two zippers zipper down all the way on both sides. For me, I'd prefer just to zip down to halfway on both sides, but that of my preference and is not that annoying the outer material feels good, not very well. The inside is red and feels as well. Not a lot of cushion support, but it will certainly protect from scratches and etc. ; It does what it is supposed to do. It was the best I could find and I am happy with the product. Looks like the price on amazon has increased. I bought it for 14.95 with 3.98 shipping for a total of 18.93. At the moment it is 19.95 with free shipping, not much difference, but a bit. I hope this helps the person who had the same issue as me.

  • Anyone of you happen to know what is the difference with a certificate in certificate authorities roots of trust?

    Hi all

    I am trying to solve the mystery of the ICP and have a question about the certificate stores, it would be very cool to have answered. Anyone of you happen to know what is the difference with a trusted certificate root, Enterprise Trust, intermediate Certification authorities CAs, publishers, to the third-party root CA, Active Directory object and so on?

    And does it matter where the physical store? Is there a difference if you use the registry, Local computer, group policy, AIA and so on?

    I noticed that you use the CA store root of trust to validate the server self-signed https, but apparently not so simple with tokens, access control with the EAP protocol network and so on.

    Best regards
    Alex

    Hi Alexander,.

    Thanks for posting your query on the Microsoft Community.

    With the description, I understand that you have a question about the certificate stores on your Windows 7 computer. I will certainly help you to the query.

    I suggest you refer to the of the items listed below and check if this is useful:

    Operating a Windows PKI: Certification Authority certificate life cycle and renewals

    https://blogs.technet.Microsoft.com/xdot509/2013/05/27/operating-a-Windows-PKI-certification-authority-certificate-lifecycle-and-renewals/

    ICP-the key usage attribute

    https://msdn.Microsoft.com/en-us/library/Windows/desktop/ms679125%28V=vs.85%29.aspx?f=255&MSPPError=-2147217396

    If the link above is not enough, then please visit the link below to post your query in the TechNet forums:

    https://social.technet.Microsoft.com/forums/en-us/home?category=w7itpro

    Hope this information is useful. Please come back to write to us if you need more help, we will be happy to help you.

  • It would make a difference with the network to change to Wireless Broadband?

    original title: Iam moving so I had Internet & cable t switch now I use Wireless Broadband would be - that make a difference with the network?

    Just need to know if from cable Internet broadband wireless to have an effect on my computer >

    as with the network, I know that I have to change my USB connection?

    Hi pattylopezSP,

    See these articles for more information on the wireless connection.

    5 steps: how to set up your network wireless home

    Wireless network card: frequently asked questions

    The network connection is based on the Internet (FSI) Service provider. Speed and other features depend on the tariff or package you are using. You can also contact the ISP for further assistance and information.

  • Thunderbird 38.3.0: No writable calendars are configured for the invitations with the provider for Google Calendar 1.0.4

    Hello

    I searched many hours today in the internet and your forums, but it seems that this problem is not solved yet:

    No writable calendars are configured for the invitations with the provider for Google Calendar.

    My Thunderbird is 38.3.0 and the provider for Google Calendar 1.0.4.

    I put calendar.google.enableEmailInvitations; true but it did not help. I also tried [email protected]... @googlemail.com. Calendar works fine, it syncs, I see all the entries etc. But I can't accept invitations even IF she must have write access.

    What can I do? Is there a solution for this?

    Thank you!
    Daniel

    Use CalDAV here to access Google Calendar via lightning. I have no experience with the add-on of the provider.
    In any case, it is my understanding that you must assign an e-mail address to a calendar in order to be able to accept the invitations for this calendar. I see that in your screenshot.
    You can try to remove the Google calendar in lightning and re-create it. Given that all the data is on the server nothing will get lost.
    Or you may want to try CalDAV.
    https://blog.Mozilla.org/calendar/2013/09/Google-is-changing-the-location-URL-of-their-CalDAV-calendars/

  • When you attempt to load an album for listening offline with Apple music sometimes only some of the songs on the album are made available. For example, Weezer White Album. Why?

    When you attempt to load an album for listening offline with Apple music sometimes only some of the songs on the album are made available. For example, Weezer White Album. Why?

    What country do you live? Because I just checked this album and all songs should be available in the Apple music - and thus be downloadable. (I live in the US BTW.)

  • Where is the support for the iPhone with some of these issues?  It's amazing that none of the iphone Tech responded to the unanswered questions.

    Where is the support for the iPhone with some of these issues?  It's amazing that none of the iphone Tech responded to the unanswered questions.

    This is a user forum. You to read the terms of use to which you agreed to when registering, you would have been aware that the participation of Apple here is minimal.

  • I have canned music downloaded on my mac for listening offline with a paid subscription, if I finish the said accession?

    I have canned music downloaded on my mac for listening offline with a paid subscription, if I finish the said accession?

    N °

    (141122)

  • Has anyone got the upgrade of GPU for H8-1234 with motherboard HP M3970AM HP (Angelica2)?

    I improved my diet for a Corsair CX series CX500M 500W ATX 80 Plus Bronze modular power supply 12V successfully and I want to assure you that I have buy a compatible GPU for the motherboard.

    If I go to http://www.pc-specs.com/mobo/HP/HP_M3970AM-HP (Angelica2) _ / 2042 and click on compatible GPU it lists AMD and Nvidia cards.

    The series of HD AMD goes up to the HD6000 series and does not list any HD 7000 series.

    The only Nvidia 600 series which is decent is the GeForce GTX-660-670-680 or 690.

    The site also shows (these graphics cards have an appropriate interface to work with and integrate into the HP M3970AM - (Angelica2). Because this motherboard does not have a GPU chip on board, we have also limited GPU integrated only to those which are integrated to die of a CPU.)

    Cards GTX listed are all much more expensive than 650 Ti DirectCU OC Boost 1085 MHZ 2 GHz 6.0 GB GDDR5 2xDVI card PCI-E HDMI DP that is not listed or even GTX550 TI, which is not listed

    The Amd HD listed series cards are unavailable or more expensive than most of the HD 7000 series.

    Has anyone successfully installed a card $ 100 from low to medium priced which is a significant improvement on the hd 7450? If you could please let me know what graphics card you purchaced.

    Thank you

    Gbrown13, welcome to the forum.

    The limiting factor for the video card upgrade is the power supply unit (PSU).  It is 300W.  Intermediate level maps latest require at least 400W to work properly.  7450 HD comes with the computer has been designed for HP operate with OEM PSU.  A detail 7450 HD very probably would not work.  In addition, you should limit the length of the video card to no more than 9 ".  This ensures that it fits in the space provided.  The majority of the double cards are 1.5 "wide.  These are normally without any problems.

    I hesitate to recommend a video card on the grounds that it will be much better than an existing map.  It is difficult to say that this is the case.  Here is a map which might work for you, with an upgrade of the power supply.  Read the reviews to see what users have to say about it.

    If your problem is solved, please click "accept as a Solution.

  • Credit card was stolen. How can I pay for storage iCloud with Tunes gift card?

    Credit card was stolen. How can I pay for storage iCloud with Tunes gift card?

    Buy the card normally and wait for it to be loaded.

    (139690)

  • I have an old iMac for 5 year with El Capitan and need to upgrade to Pages 5.6.1.to be able to open docs on my iPad. Everytime I try and open it on the Apple Store it just shows my old docs pages on the iMac. any suggestions?

    I have an old iMac for 5 year with El Capitan and need to upgrade to Pages 5.6.1.to be able to open docs on my iPad. Everytime I try and open it on the Apple Store it just shows my old docs pages on the iMac. any suggestions?

    The App Store has to do with your documents?

    The App Store allows you to buy and download Apps, as its name suggests.

    Peter

  • New driver for Qosmio G20 with Vista installed

    Hello

    There are new drivers for Qosmio G20 with Vista installed.

    Right now, it's Nvidia Video 169,25 version of the driver for Windows Vista.
    No blue screen after installing this driver, at all.
    I think that this new driver will solve the following problem:

    * Power failure screen after you have closed the lid on Vista *.

    You can try it, remembering that the installation must be handwritten. And you must choose the graphics card Nvidia Geforce 6600, during installation.
    Download here:

    http://www.rabayjr.com/Vista/169.25_vista.rar

    Cheers from the Brazil,
    FranciscoJr

    Anyone try and use the Vista on the Qosmio G20 series should check this crazy thread long but very useful:
    http://forums.computers.Toshiba-Europe.com/forums//message.jspa?MessageID=75318#75318

    Thanks to the FranciscoJr-> God of the G20 and Vista :D

  • purchase for microsoft 365 with intentions, it works in offline mode when site crashed try to complete 1 document attempt

    MG * XZH Hi I made a purchase for microsoft 365 with intentions, it works in offline mode when site crashed try to complete 1 document attempt. In the future I'll be buying capable software offline and request a refund for 365 windows thanks sorry for any inconvience

    Answers.Microsoft.com

  • Can LabVIEW Embedded for ARM works with any Board or just with a few predefined?

    Hello

    Can LabVIEW Embedded for ARM works with any evaluation committee or just with a few predefined (MCB2300, MCB2400 and EK-LM3S8962)? I ask this question because even if I chose "another processor" in the definition of the new project only 3 options are the corresponding arm of Phillips and LuminaryMicro.

    Thanks in advance,

    Howdy,

    LabVIEW for ARM supports the feature of targets for tier 1 (the mentioned Evaluation Committee) following this schema:

    http://zone.NI.com/DevZone/CDA/tut/p/ID/7066

    But you can transfer to other weapons if you follow this porting guide:

    http://zone.NI.com/DevZone/CDA/tut/p/ID/6994

    The uProcesser SDK is intended for the port of other targets of DEPENDENCE (32-bit, of course) and technically it covers ARM as well. Alternatively, there are the LabVIEW C Code Generator: http://sine.ni.com/nips/cds/view/p/lang/en/nid/209015

Maybe you are looking for

  • P6510F: p6000

    Hello, after upgrading to Windows 10 my computer worked for several days without any problem. The other day I went to use and he got stuck on a blue screen that says "select keyboard layout" and contained what seems to be languages very various. I co

  • HP Envy 5540: Cannot print after canceling the print job

    I cancelled a print job and now my printer does not print, and it has "!" next to the selection in the print dialog box. I turned the printer on and rebooted my Mac, but it still does not print.

  • HP officejet pro 8600 fone display size

    Hello My grandfather has a - i - o mentioned above and struggled to read the size of the font on the default display of touch screen before. Is there a possibility to enlarge the font of the display? Thank you very much BN

  • The client (Windows XP, Vista, Windows 7) users can connect to Microsoft Small Business Server 2008?

    Dear all, I intend to install on Server 2008 SBS Active Directory domain controller. In this session, I would like to know the client users can connect to the SBS server or not. If CAN, I want to know the steps & solutions on this answer and if NOT,

  • Momentics IDE crash when opening

    It was a problem when I switched to Windows 10, my computer laptop windows 7 Accuracy never this crash in momentics problem. Now recently this month I bought the new laptop for some reason and it's windows 10. Now, I have installed the Gold Momentics