Category: XML

How to create all and Complex type in XML?

December 30, 2009 | Filed Under XML | Leave a Comment

<strong>File: Data.xml

<?xml version=”1.0″?>
<Books xmlns=”http://www.phpinterviewquestion.com”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.phpinterviewquestion.com Schema.xsd”>
<Book>
<Date>2009</Date>
<Title>title 1</Title>
<Author>author 1</Author>
<ISBN>1-11111-111-1</ISBN>
<Publisher>Publisher 1</Publisher>
</Book>
<Book>
<ISBN>0-111-11111-1</ISBN>
<Title>title 2</Title>
<Author>author 2</Author>
<Date>2008</Date>
<Publisher>Publisher 2</Publisher>
</Book>
<Book>
<Publisher>Publisher 3</Publisher>
<Title>title 3</Title>
<Author>author 3</Author>
<Date>2004</Date>
<ISBN>0-11-111111-1</ISBN>
</Book>
</Books>
File: Schema.xsd
<?xml version=”1.0″?>
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
targetNamespace=”http://www.phpinterviewquestion.com”
xmlns=”http://www.java2s.com”
elementFormDefault=”qualified”>
<xsd:element name=”Books”>
<xsd:complexType>
<xsd:sequence>
<xsd:element name=”Book” maxOccurs=”unbounded”>
<xsd:complexType>
<xsd:all>
<xsd:element name=”Title” type=”xsd:string”/>
<xsd:element name=”Author” type=”xsd:string”/>
<xsd:element name=”Date” type=”xsd:string”/>
<xsd:element name=”ISBN” type=”xsd:string”/>
<xsd:element name=”Publisher” type=”xsd:string”/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>…………….</strong>

Article written by urooj

How to create Count(*) and existsnode() in XML?

December 30, 2009 | Filed Under XML | Leave a Comment

Count(*) and existsnode():—-
SQL> CREATE TABLE myTable
2 (id NUMBER PRIMARY KEY
3 ,doc XMLType NOT NULL)
4 XMLTYPE doc STORE AS CLOB
5 /

Table created.

SQL>
SQL> select COUNT(*) from myTable
2 where existsnode(doc, ‘/message/greeting’) = 1
3 /

COUNT(*)
———-
0

1 row selected.

SQL> drop table myTable;

Table dropped.

Article written by urooj

How create Oracle XML function ExistsNode.

December 30, 2009 | Filed Under XML | 2 Comments

Oracle XML function ExistsNode
SQL>
SQL> CREATE TABLE myTable(
2 id NUMBER PRIMARY KEY
3 ,doc XMLType NOT NULL
4 )
5 XMLTYPE doc STORE AS CLOB
6 /

Table created.

SQL>
SQL> — Demo the selfish style of invocation
SQL> select COUNT(*)
2 from myTable x
3 where x.doc.existsnode(’/message/greeting’) = 1
4 /

COUNT(*)
———-
0

1 row selected.

SQL>
SQL> drop table myTable;

Table dropped.

Article written by urooj

© PHPInterviewQuestion.com 2009 - 2010

eXTReMe Tracker