User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the XML, XSLT and XPATH section within the Software Development category of DaniWeb, a massive community of 456,573 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,565 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our XML, XSLT and XPATH advertiser: Programming Forums
Views: 6736 | Replies: 49
Reply
Join Date: Oct 2007
Posts: 21
Reputation: v.godhe is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
v.godhe v.godhe is offline Offline
Newbie Poster

Re: XML Schema/Relational Schema in DB29

  #31  
Nov 28th, 2007
How to check the information about the XML schemas in the XSR?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: XML Schema/Relational Schema in DB29

  #32  
Nov 30th, 2007
DB2 stores information about XML Schemas in a system catalog view SYSCAT.XSROBJECTS. This view can be queried to retrieve information like the object schema, object name, target namespace, and schema location. The actual schema documents are stored in catalog SYSCAT.XSROBJECTCOMPONENT. The SYSCAT.XSROBJECTS catalog view contains 1 row per XML Schema. On the other hand, SYSCAT.XSROBJECTCOMPONENT catalog has 1 row per schema document.
You can use following queries to get the information:

SELECT objectschema, objectname, targetnamespace, schemalocation FROM syscat.xsrobjects
SELECT objectschema, objectname, targetnamespace, schemalocation from syscat.xsrobjectcomponents
Reply With Quote  
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: XML Schema/Relational Schema in DB29

  #33  
Dec 2nd, 2007
And how do I drop a registered schema?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: XML Schema/Relational Schema in DB29

  #34  
Dec 3rd, 2007
A registered schema can be dropped by using Drop XSRObject command. The schema repository does not have a notion of individual schema documents. It only has a notion of an XML Schema, which is a collection of 1 or more schema documents. Thus, to drop an XSR Object implies deleting all schema documents associated with that XSR Object.
Reply With Quote  
Join Date: Oct 2007
Posts: 31
Reputation: ssahil11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ssahil11 ssahil11 is offline Offline
Light Poster

Re: XML Schema/Relational Schema in DB29

  #35  
Dec 13th, 2007
Can you give a sample query for using XMLNamespaces functions?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: XML Schema/Relational Schema in DB29

  #36  
Dec 18th, 2007
Below example generates an "employee" element for each employee. The employee element is associated with XML namespace "urn:bo', which is bound to prefix "bo". The element contains attributes for names and a hiredate subelement.

SELECT e.empno, XMLSERIALIZE(XMLELEMENT(NAME "bo:employee",
XMLNAMESPACES('urn:bo' as "bo"), XMLATTRIBUTES(e.lastname, e.firstnme), XMLELEMENT(NAME "bo:hiredate", e.hiredate)) AS CLOB(50)) FROM employee e where e.edlevel = 12;

The result of the query would be similar to the following result:

<bo:employee xmlns:bo="urn:bo" LASTNAME="PARKER" FIRSTNME="JOHN">
<bo:hiredate>198-5-3</bo:hiredate></bo:employee><bo:employee
xmlns:bo="urn:bo"
LASTNAME="SETRIGHT"FIRSTNME="MAUDE"><bo:hiredate>1964-9-12</bo:hiredate></bo:employee>


Another example: generate two elements for each employee using XMLFOREST. The first "lastname" element is associated with the default namespace "http://hr.org", and the second "job" element is associated with XML namespace "http://fed.gov", which is bound to prefix "d".

SELECT empno, XMLSERIALIZE(XMLFOREST(XMLNAMESPACES(DEFAULT 'http://hr.org', 'http://fed.gov' AS "d"),lastname, job AS "d:job") AS CLOB(50)) FROM employee where edlevel = 12;

The result of the query would be similar to the following result:

<LASTNAME xmlns=http://hr.org xmlns:d="http://fed.gov
">PARKER</LASTNAME><d:job xmlns="http://hr.org" xmlns:d="http://fed.gov">OPERATOR</d:job>
<LASTNAME xmlns="http://hr.org"
xmlns:d="http://fed.gov">SETRIGHT</LASTNAME><d:job xmlns="http://hr.org" xmlns:d="http://fed.gov">OPERATOR</d:job>

MTK can be downloaded at
http://www-306.ibm.com/software/data/db2/migration/mtk/. More information can be found at
http://www-1.ibm.com/support/docview...id=swg27009230.
Reply With Quote  
Join Date: Oct 2007
Posts: 21
Reputation: v.godhe is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
v.godhe v.godhe is offline Offline
Newbie Poster

Re: XML Schema/Relational Schema in DB29

  #37  
Dec 19th, 2007
Could you please explain how DB2 validate XML documents against DTDs?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: XML Schema/Relational Schema in DB29

  #38  
Dec 20th, 2007
You can’t validate XML document against DTDs; DTDs validation not supported. You can validate your XML document against XML schemas only. You can still insert documents that contain a DOCTYPE or that refer to DTDs.

There are tools available, such as those in IBM Rational Application Developer that help you generate XML schemas from various sources, including DTDs, existing tables, or XML documents.

Before you can validate, you must register your XML schema with the built-in XML schema repository (XSR). This process involves registering each XML schema document that makes up the XML schema. Once all XML schema documents have been successfully registered, you must complete the registration. One method of registering an XML schema is through commands.

Register and complete registration of the posample.customer XML schema as follows, providing the absolute path to the sqllib/samples/xml directory on your system:
REGISTER XMLSCHEMA 'http://posample.org' FROM 'file:///<c:/sqllib/samples/xml>customer.xsd' AS posample.customer COMPLETE

You can verify that the XML schema was successfully registered by using follow query:

SELECT OBJECTSCHEMA, OBJECTNAME FROM SYSCAT.XSROBJECTS

MTK can be downloaded at
http://www-306.ibm.com/software/data/db2/migration/mtk/. More information can be found at
http://www-1.ibm.com/support/docview...id=swg27009230.
Reply With Quote  
Join Date: Oct 2007
Posts: 21
Reputation: v.godhe is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
v.godhe v.godhe is offline Offline
Newbie Poster

Re: XML Schema/Relational Schema in DB29

  #39  
Dec 26th, 2007
How to validate XML data with a XML schema while inserting XML data?
Reply With Quote  
Join Date: Oct 2007
Posts: 76
Reputation: dilasing is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dilasing dilasing is offline Offline
Junior Poster in Training

Re: XML Schema/Relational Schema in DB29

  #40  
Dec 27th, 2007
The following INSERT statement inserts a new XML document into the Info column of the Customer table, only if the document is valid according to the posample.customer XML schema previously registered.

INSERT INTO Customer(Cid, Info) VALUES (1003, XMLVALIDATE (XMLPARSE (DOCUMENT
'<customerinfo xmlns="http://posample.org" Cid="1003">
<name>Robert Shoemaker</name>
<addr country="Canada">
<street>1596 Baseline</street>
<city>Aurora</city>
<prov-state>Ontario</prov-state>
<pcode-zip>N8X 7F8</pcode-zip>
</addr>
<phone type="work">905-555-7258</phone>
<phone type="home">416-555-2937</phone>
<phone type="cell">905-555-8743</phone>
<phone type="cottage">613-555-3278</phone>
</customerinfo>' PRESERVE WHITESPACE )
ACCORDING TO XMLSCHEMA ID posample.customer ))

XMLVALIDATE operates on XML data. Because the XML document in this example is passed as character data, and character data can only be assigned directly to XML in INSERT, UPDATE, or DELETE statements, the XMLPARSE function must be used in this case. The XMLPARSE function parses its argument as an XML document and returns an XML value.

To verify that the validation and insert were successful, query the Info column:

SELECT Info FROM Customer
This query should return three XML documents, one of which is the document just inserted.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb XML, XSLT and XPATH Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the XML, XSLT and XPATH Forum

All times are GMT -4. The time now is 6:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC