Search the web
Sign In
New User? Sign Up
xml-dbms
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 3835 - 3864 of 3864   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries   (Group by Topic) Sort by Date ^  
#3835 From: "Janardhan, Jay" <jjanardhan@...>
Date: Mon Feb 26, 2007 11:01 pm
Subject: RE: Need help on Mapping language.
mrutyun
Offline Offline
Send Email Send Email
 
Thanks for your help Ron. I switched to V2.0. I can't say I still
understand the mapping language well enough!





I was trying out the many-to-many relation example (actor/movie example
copy-paste from the FAQ page.) On MySQL, it somehow fails to insert the
second movie for actor ID=1. After updates this is how things look:



mysql> select * from joinmoviesactors;

+---------+---------+

| actorID | movieID |

+---------+---------+

|       1 |       2 |

|       2 |       2 |

|       3 |       1 |

+---------+---------+



Note: missing actorID=1 and movieID=1.





My mapping file:



===================================================================

<?xml version='1.0' ?>



<XMLToDBMS Version="2.0"
xmlns="http://www.xmlmiddleware.org/xmldbms/v2">

       <Options>

             <SimpleDateFormat Pattern="MM/dd/yyyy"
DefaultForTypes="DATE" />

       </Options>

       <Databases>

             <Database Name="Default">

                   <Catalog>

                         <Schema>

                               <Table Name="actors">

                                     <Column Name="id" DataType="INTEGER"
Nullable="No"/>

                                     <Column Name="name"
DataType="VARCHAR" Length="255" Nullable="Yes"/>

                                     <PrimaryKey>

                                           <UseColumn Name="id"/>

                                     </PrimaryKey>

                               </Table>




                               <Table Name="movies">

                                     <Column Name="id" DataType="INTEGER"
Nullable="No"/>

                                     <Column Name="title"
DataType="VARCHAR" Length="255" Nullable="Yes"/>

                                     <PrimaryKey>

                                           <UseColumn Name="id"/>

                                     </PrimaryKey>

                               </Table>




                               <Table Name="joinmoviesactors">

                                     <Column Name="actorID"
DataType="INTEGER" Nullable="No"/>

                                     <Column Name="movieID"
DataType="INTEGER" Nullable="No"/>

                                     <PrimaryKey>

                                           <UseColumn Name="actorID"/>

                                           <UseColumn Name="movieID"/>

                                     </PrimaryKey>

                                     <ForeignKey Name="actor_FK">

                                           <UseTable Name="actors"/>

                                           <UseUniqueKey
Name="PrimaryKey" />

                                           <UseColumn Name="actorID"/>

                                     </ForeignKey>

                                     <ForeignKey Name="movies_FK">

                                           <UseTable Name="movies"/>

                                           <UseUniqueKey
Name="PrimaryKey" />

                                           <UseColumn Name="movieID"/>

                                     </ForeignKey>

                               </Table>




                         </Schema>

                   </Catalog>

             </Database>

       </Databases>



       <Maps>

             <ClassMap>

                   <ElementType Name="Actor"/>

                   <ToClassTable Name="actors"/>

                   <PropertyMap>

                         <Attribute Name="ID"/>

                         <ToColumn Name="id"/>

                   </PropertyMap>

                   <PropertyMap>

                         <ElementType Name="Name"/>

                         <ToColumn  Name="name"/>

                   </PropertyMap>

                   <RelatedClass KeyInParentTable="Unique">

                         <ElementType Name="Movies" />

                         <UseUniqueKey Name="PrimaryKey" />

                         <UseForeignKey Name="actor_FK"/>

                   </RelatedClass>

             </ClassMap>



             <ClassMap>

                   <ElementType Name="Movies"/>

                   <ToClassTable Name="joinmoviesactors"/>

                   <RelatedClass KeyInParentTable="Foreign">

                         <ElementType Name="Movie" />

                         <UseUniqueKey Name="PrimaryKey" />

                         <UseForeignKey Name="movies_FK"/>

                   </RelatedClass>

             </ClassMap>



             <ClassMap>

                   <ElementType Name="Movie"/>

                   <ToClassTable Name="movies"/>

                   <PropertyMap>

                         <Attribute Name="ID"/>

                         <ToColumn Name="id"/>

                   </PropertyMap>

                   <PropertyMap>

                         <ElementType Name="Title"/>

                         <ToColumn  Name="title"/>

                   </PropertyMap>

             </ClassMap>



       </Maps>

</XMLToDBMS>

===================================================================

Action file:



<Actions Version="2.0"
xmlns="http://www.xmlmiddleware.org/xmldbms/actions/v2">

    <DefaultAction>

       <Insert />

    </DefaultAction>

    <Action>

         <ElementType Name="Movie"/>

         <SoftInsert/>

    </Action>

</Actions>







Thanks,

-Jay











________________________________

From: xml-dbms@yahoogroups.com [mailto:xml-dbms@yahoogroups.com] On
Behalf Of Ronald Bourret
Sent: Sunday, February 18, 2007 4:29 PM
To: xml-dbms@yahoogroups.com
Subject: Re: [xml-dbms] Need help on Mapping language.



No. To do this, you would need to use XSLT to transform the document
first. You would then map the transformed document to the database. In
your case, you would need to transform the document to the following:

<results>
<TableOne>
<id> 1 </id>
<data/>
</TableOne>
<TableTwo>
<id> 1 </id>
<data/>
</TableTwo>
</results>

Using XSLT with XML-DBMS is a fairly common occurrence. As a general
rule, the structure of the XML document needs to "match" the structure
of the database schema.

Note that you are also trying to do something else that is not supported

by XML-DBMS. In particular, the id element is a sibling of the table
elements. Elements mapped to columns must be children (or in some cases,

descendants) of elements mapped to tables.

-- Ron

P.S. I believe some commercial software, such as HiT Allora, can do what

you ask for.

Janardhan, Jay wrote:

> Thanks for the reply Ron.
>
>
>
> I'm switching to Java V2.0. While I start experimenting with V2.0, I
> have a quick question. Is it possible to map an element from the XML
> file to columns in different tables?
>
>
>
> For example,
>
>
>
> <results>
>
> <id> 1 </id>
>
> <TableOne>
>
> <data/>
>
> </TableOne>
>
> <TableTwo>
>
> <data/>
>
> </TableTwo>
>
> </results>
>
>
>
> Table: TableOne
>
> ID NOT NULL,
>
> Column1
>
> Coulmn2
>
>
>
> Table: TableTwo
>
> ID NOT NULL,
>
> Column1
>
>
>
> In this example, is it possible to map <id> (from the XML file) to
> TableOne::ID and TableTwo::ID?
>
> Appreciate your assistance.
>
> Thanks,
>
> -Jay





[Non-text portions of this message have been removed]

#3836 From: Ronald Bourret <rpbourret@...>
Date: Tue Feb 27, 2007 7:25 pm
Subject: Re: Need help on Mapping language.
xmldbms
Offline Offline
Send Email Send Email
 
This is probably because the document shown in the FAQ isn't correct, as
is noted in the IMPORTANT! paragraph. (When I discovered the error, I
didn't have time to fix the FAQ.) The correct document is probably as is
shown below. Let me know if you're still having trouble. (Your map and
action files look correct, but I don't have time to test them right now.)

-- Ron

Corrected XML document. Note the additional Movies element around the
second movie for actor 1.

     <Actors>
        <Actor ID="1">
           <Name>Al Pacino</Name>
           <Sex>M</Sex>
           <Movies>
              <Movie ID="1">
                 <Title>Serpico</Title>
                 <Rating>R</Rating>
              </Movie>
           </Movies>
           <Movies>
              <Movie ID="2">
                 <Title>The Godfather</Title>
                 <Rating>R</Rating>
              </Movie>
           </Movies>
        </Actor>
        <Actor ID="2">
           <Name>Marlon Brando</Name>
           <Sex>M</Sex>
           <Movies>
              <Movie ID="2">
                 <Title>The Godfather</Title>
                 <Rating>R</Rating>
              </Movie>
           </Movies>
        </Actor>
        <Actor ID="3">
           <Name>Jack Kehoe</Name>
           <Sex>M</Sex>
           <Movies>
              <Movie ID="1">
                 <Title>Serpico</Title>
                 <Rating>R</Rating>
              </Movie>
           </Movies>
        </Actor>
     </Actors>



Janardhan, Jay wrote:

> Thanks for your help Ron. I switched to V2.0. I can't say I still
> understand the mapping language well enough!
>
>
>
>
>
> I was trying out the many-to-many relation example (actor/movie example
> copy-paste from the FAQ page.) On MySQL, it somehow fails to insert the
> second movie for actor ID=1. After updates this is how things look:
>
>
>
> mysql> select * from joinmoviesactors;
>
> +---------+---------+
>
> | actorID | movieID |
>
> +---------+---------+
>
> |       1 |       2 |
>
> |       2 |       2 |
>
> |       3 |       1 |
>
> +---------+---------+
>
>
>
> Note: missing actorID=1 and movieID=1.
>
>
>
>
>
> My mapping file:
>
>
>
> ===================================================================
>
> <?xml version='1.0' ?>
>
>
>
> <XMLToDBMS Version="2.0"
> xmlns="http://www.xmlmiddleware.org/xmldbms/v2">
>
>       <Options>
>
>             <SimpleDateFormat Pattern="MM/dd/yyyy"
> DefaultForTypes="DATE" />
>
>       </Options>
>
>       <Databases>
>
>             <Database Name="Default">
>
>                   <Catalog>
>
>                         <Schema>
>
>                               <Table Name="actors">
>
>                                     <Column Name="id" DataType="INTEGER"
> Nullable="No"/>
>
>                                     <Column Name="name"
> DataType="VARCHAR" Length="255" Nullable="Yes"/>
>
>                                     <PrimaryKey>
>
>                                           <UseColumn Name="id"/>
>
>                                     </PrimaryKey>
>
>                               </Table>
>
>
>
>
>                               <Table Name="movies">
>
>                                     <Column Name="id" DataType="INTEGER"
> Nullable="No"/>
>
>                                     <Column Name="title"
> DataType="VARCHAR" Length="255" Nullable="Yes"/>
>
>                                     <PrimaryKey>
>
>                                           <UseColumn Name="id"/>
>
>                                     </PrimaryKey>
>
>                               </Table>
>
>
>
>
>                               <Table Name="joinmoviesactors">
>
>                                     <Column Name="actorID"
> DataType="INTEGER" Nullable="No"/>
>
>                                     <Column Name="movieID"
> DataType="INTEGER" Nullable="No"/>
>
>                                     <PrimaryKey>
>
>                                           <UseColumn Name="actorID"/>
>
>                                           <UseColumn Name="movieID"/>
>
>                                     </PrimaryKey>
>
>                                     <ForeignKey Name="actor_FK">
>
>                                           <UseTable Name="actors"/>
>
>                                           <UseUniqueKey
> Name="PrimaryKey" />
>
>                                           <UseColumn Name="actorID"/>
>
>                                     </ForeignKey>
>
>                                     <ForeignKey Name="movies_FK">
>
>                                           <UseTable Name="movies"/>
>
>                                           <UseUniqueKey
> Name="PrimaryKey" />
>
>                                           <UseColumn Name="movieID"/>
>
>                                     </ForeignKey>
>
>                               </Table>
>
>
>
>
>                         </Schema>
>
>                   </Catalog>
>
>             </Database>
>
>       </Databases>
>
>
>
>       <Maps>
>
>             <ClassMap>
>
>                   <ElementType Name="Actor"/>
>
>                   <ToClassTable Name="actors"/>
>
>                   <PropertyMap>
>
>                         <Attribute Name="ID"/>
>
>                         <ToColumn Name="id"/>
>
>                   </PropertyMap>
>
>                   <PropertyMap>
>
>                         <ElementType Name="Name"/>
>
>                         <ToColumn  Name="name"/>
>
>                   </PropertyMap>
>
>                   <RelatedClass KeyInParentTable="Unique">
>
>                         <ElementType Name="Movies" />
>
>                         <UseUniqueKey Name="PrimaryKey" />
>
>                         <UseForeignKey Name="actor_FK"/>
>
>                   </RelatedClass>
>
>             </ClassMap>
>
>
>
>             <ClassMap>
>
>                   <ElementType Name="Movies"/>
>
>                   <ToClassTable Name="joinmoviesactors"/>
>
>                   <RelatedClass KeyInParentTable="Foreign">
>
>                         <ElementType Name="Movie" />
>
>                         <UseUniqueKey Name="PrimaryKey" />
>
>                         <UseForeignKey Name="movies_FK"/>
>
>                   </RelatedClass>
>
>             </ClassMap>
>
>
>
>             <ClassMap>
>
>                   <ElementType Name="Movie"/>
>
>                   <ToClassTable Name="movies"/>
>
>                   <PropertyMap>
>
>                         <Attribute Name="ID"/>
>
>                         <ToColumn Name="id"/>
>
>                   </PropertyMap>
>
>                   <PropertyMap>
>
>                         <ElementType Name="Title"/>
>
>                         <ToColumn  Name="title"/>
>
>                   </PropertyMap>
>
>             </ClassMap>
>
>
>
>       </Maps>
>
> </XMLToDBMS>
>
> ===================================================================
>
> Action file:
>
>
>
> <Actions Version="2.0"
> xmlns="http://www.xmlmiddleware.org/xmldbms/actions/v2">
>
>    <DefaultAction>
>
>       <Insert />
>
>    </DefaultAction>
>
>    <Action>
>
>         <ElementType Name="Movie"/>
>
>         <SoftInsert/>
>
>    </Action>
>
> </Actions>
>
>
>
>
>
>
>
> Thanks,
>
> -Jay
>
>
>
>
>
>
>
>
>
>
>
> ________________________________
>
> From: xml-dbms@yahoogroups.com [mailto:xml-dbms@yahoogroups.com] On
> Behalf Of Ronald Bourret
> Sent: Sunday, February 18, 2007 4:29 PM
> To: xml-dbms@yahoogroups.com
> Subject: Re: [xml-dbms] Need help on Mapping language.
>
>
>
> No. To do this, you would need to use XSLT to transform the document
> first. You would then map the transformed document to the database. In
> your case, you would need to transform the document to the following:
>
> <results>
> <TableOne>
> <id> 1 </id>
> <data/>
> </TableOne>
> <TableTwo>
> <id> 1 </id>
> <data/>
> </TableTwo>
> </results>
>
> Using XSLT with XML-DBMS is a fairly common occurrence. As a general
> rule, the structure of the XML document needs to "match" the structure
> of the database schema.
>
> Note that you are also trying to do something else that is not supported
>
> by XML-DBMS. In particular, the id element is a sibling of the table
> elements. Elements mapped to columns must be children (or in some cases,
>
> descendants) of elements mapped to tables.
>
> -- Ron
>
> P.S. I believe some commercial software, such as HiT Allora, can do what
>
> you ask for.
>
> Janardhan, Jay wrote:
>
>
>>Thanks for the reply Ron.
>>
>>
>>
>>I'm switching to Java V2.0. While I start experimenting with V2.0, I
>>have a quick question. Is it possible to map an element from the XML
>>file to columns in different tables?
>>
>>
>>
>>For example,
>>
>>
>>
>><results>
>>
>><id> 1 </id>
>>
>><TableOne>
>>
>><data/>
>>
>></TableOne>
>>
>><TableTwo>
>>
>><data/>
>>
>></TableTwo>
>>
>></results>
>>
>>
>>
>>Table: TableOne
>>
>>ID NOT NULL,
>>
>>Column1
>>
>>Coulmn2
>>
>>
>>
>>Table: TableTwo
>>
>>ID NOT NULL,
>>
>>Column1
>>
>>
>>
>>In this example, is it possible to map <id> (from the XML file) to
>>TableOne::ID and TableTwo::ID?
>>
>>Appreciate your assistance.
>>
>>Thanks,
>>
>>-Jay
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
> To post a message, send it to: xml-dbms@yahoogroups.com
> To unsubscribe, send a blank message to: xml-dbms-unsubscribe@yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>

#3837 From: "ask me" <sanzap_21@...>
Date: Tue Mar 20, 2007 8:40 am
Subject: Can you help me Ron?
sanzap_21
Offline Offline
Send Email Send Email
 
I needed to transfer the datas in the XML file into Oracle8i, and by
seraching internet i came across the very helpful site
http://www.rpbourret.com <http://www.rpbourret.com>  . I downloaded the
xml-dbms version 2.0

Although being new to java , i gone through the readme file and had all
the classpath set for xmldbms20.jar and xerces.jar and then compiled the
.java files one by one ,blindly just compiled all the files

Didn't find where to mention the  "my database_name " and "drivers"
,"userid" and "password"

First of all i started with the samples  and am still stuck there...

I edited the sql script to create the tables...... which is

CREATE TABLE  Customers  ( Cus_Number  VARCHAR2(10) NOT NULL,  Name
VARCHAR2(80) NOT NULL,  Street  VARCHAR2(50),  City  VARCHAR2(50),
State  VARCHAR2(20),  PostalCode  VARCHAR2(10), CONSTRAINT PrimaryKey
PRIMARY KEY ( Cus_Number ))
/
CREATE TABLE  Parts  (
   part_Number  VARCHAR2(10) NOT NULL,
   Description  VARCHAR2(255),
Price  number(10) NOT NULL, CONSTRAINT PrimaryKey_parts PRIMARY KEY (
part_Number ))
/
CREATE TABLE  Orders  (
Order_Number  VARCHAR(10) NOT NULL,
CustNumber  VARCHAR(10) NOT NULL,
order_Date  DATE,
CONSTRAINT PrimaryKey_order PRIMARY KEY ( order_Number ),
CONSTRAINT FK_Customers_orders FOREIGN KEY ( CustNumber ) REFERENCES
Customers  ( cus_Number ))
/

CREATE TABLE  Items  (
SO_Number  VARCHAR2(10) NOT NULL,
item_Number  number(10) NOT NULL,
Part  VARCHAR2(10) NOT NULL,
Quantity  number(4) NOT NULL,
CONSTRAINT PrimaryKey_items PRIMARY KEY ( SO_Number ,  item_Number ),
CONSTRAINT FK_SalesOrder FOREIGN KEY ( SO_Number ) REFERENCES  Orders  (
Order_Number ),
CONSTRAINT FK_Parts FOREIGN KEY ( Part ) REFERENCES  Parts  (
part_Number ))
/


Edited the orders.map as .....

<?XML VERSION='1.0' ?>

<!--

THIS SAMPLE IS ROUGHLY EQUIVALENT TO THE VERSION 1.0 SAMPLE

SALES.MAP. THE ONLY REAL DIFFERENCES ARE A FEW NAME CHANGES.

-->

<!DOCTYPE XMLTODBMS SYSTEM "XMLDBMS2.DTD" >

<XMLTODBMS VERSION="2.0"
XMLNS="HTTP://WWW.XMLMIDDLEWARE.ORG/XMLDBMS/V2">

<OPTIONS>

<SIMPLEDATEFORMAT PATTERN="MM.DD.YY" DEFAULTFORTYPES="DATE" />

</OPTIONS>

<DATABASES>

<DATABASE NAME="BDF01">

<CATALOG>

<SCHEMA>

<TABLE NAME="CUSTOMERS">

<COLUMN NAME="STREET" DATATYPE="VARCHAR2" LENGTH="50" NULLABLE="NO"/>

<COLUMN NAME="NAME" DATATYPE="VARCHAR2" LENGTH="80" NULLABLE="NO"/>

<COLUMN NAME="NUMBER" DATATYPE="VARCHAR2" LENGTH="10" NULLABLE="NO" />

<COLUMN NAME="CITY" DATATYPE="VARCHAR2" LENGTH="50" NULLABLE="NO"/>

<COLUMN NAME="POSTALCODE" DATATYPE="VARCHAR2" LENGTH="10"
NULLABLE="YES"/>

<COLUMN NAME="STATE" DATATYPE="VRCHAR2" LENGTH="2" NULLABLE="NO"/>

<PRIMARYKEY KEYGENERATOR="DATABASE">

<USECOLUMN NAME="CUS_NUMBER"/>

</PRIMARYKEY>

</TABLE>

<TABLE NAME="ITEMS">

<COLUMN NAME="PART" DATATYPE="VARCHAR2" LENGTH="10" NULLABLE="NO"/>

<COLUMN NAME="ITEM_NUMBER" DATATYPE="NUMBER" LENGTH="4" NULLABLE="NO"/>

<COLUMN NAME="QUANTITY" DATATYPE="NUMBER" LENGTH="4" NULLABLE="NO"/>

<COLUMN NAME="SO_NUMBER" DATATYPE="VARCHAR2" LENGTH="10" NULLABLE="NO"/>

<PRIMARYKEY>

<USECOLUMN NAME="SO_NUMBER"/>

<USECOLUMN NAME="ITEM_NUMBER"/>

</PRIMARYKEY>

<FOREIGNKEY NAME="PART_FK">

<USETABLE NAME="PARTS" />

<USEUNIQUEKEY NAME="PRIMARYKEY" />

<USECOLUMN NAME="PART_NUMBER"/>

</FOREIGNKEY>

<FOREIGNKEY NAME="SO_FK">

<USETABLE NAME="ORDERS" />

<USEUNIQUEKEY NAME="PRIMARYKEY" />

<USECOLUMN NAME="SO_NUMBER"/>

</FOREIGNKEY>

</TABLE>

<TABLE NAME="ORDERS">

<COLUMN NAME="CUSTNUMBER" DATATYPE="VARCHAR2" LENGTH="10"
NULLABLE="NO"/>

<COLUMN NAME="ORDER_NUMBER" DATATYPE="VARCHAR2" LENGTH="10"
NULLABLE="NO"/>

<COLUMN NAME="ORDER_DATE" DATATYPE="DATE" NULLABLE="YES"/>

<PRIMARYKEY>

<USECOLUMN NAME="ORDER_NUMBER"/>

</PRIMARYKEY>

<FOREIGNKEY NAME="CUST_FK">

<USETABLE NAME="CUSTOMERS" />

<USEUNIQUEKEY NAME="PRIMARYKEY" />

<USECOLUMN NAME="CUSTNUMBER"/>

</FOREIGNKEY>

</TABLE>

<TABLE NAME="PARTS">

<COLUMN NAME="PART_NUMBER" DATATYPE="VARCHAR2" LENGTH="10"
NULLABLE="NO"/>

<COLUMN NAME="PRICE" DATATYPE="NUMBER" NULLABLE="NO"/>

<COLUMN NAME="DESCRIPTION" DATATYPE="VARCHAR2" LENGTH="255"
NULLABLE="YES"/>

<PRIMARYKEY>

<USECOLUMN NAME="PART_NUMBER"/>

</PRIMARYKEY>

</TABLE>

</SCHEMA>

</CATALOG>

</DATABASE>

</DATABASES>

<MAPS>

<CLASSMAP>

<ELEMENTTYPE NAME="ITEM"/>

<TOCLASSTABLE NAME="ITEMS"/>

<PROPERTYMAP>

<ATTRIBUTE NAME="LINENUMBER"/>

<TOCOLUMN NAME="SO_NUMBER"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="QUANTITY"/>

<TOCOLUMN NAME="QUANTITY"/>

</PROPERTYMAP>

<RELATEDCLASS KEYINPARENTTABLE="FOREIGN">

<ELEMENTTYPE NAME="PART"/>

<USEUNIQUEKEY NAME="PRIMARYKEY"/>

<USEFOREIGNKEY NAME="PART_FK"/>

</RELATEDCLASS>

</CLASSMAP>

<CLASSMAP>

<ELEMENTTYPE NAME="PART"/>

<TOCLASSTABLE NAME="PARTS"/>

<PROPERTYMAP>

<ATTRIBUTE NAME="PARTNUMBER"/>

<TOCOLUMN NAME="PART_NUMBER"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="PRICE"/>

<TOCOLUMN NAME="PRICE"/>

</PROPERTYMAP>

<PROPERTYMAP CONTAINSXML="YES">

<ELEMENTTYPE NAME="DESCRIPTION"/>

<TOCOLUMN NAME="DESCRIPTION"/>

</PROPERTYMAP>

</CLASSMAP>

<CLASSMAP>

<ELEMENTTYPE NAME="CUSTOMER"/>

<TOCLASSTABLE NAME="CUSTOMERS"/>

<PROPERTYMAP>

<ATTRIBUTE NAME="CUSTNUMBER"/>

<TOCOLUMN NAME="CUS_NUMBER"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="STREET"/>

<TOCOLUMN NAME="STREET"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="CUSTNAME"/>

<TOCOLUMN NAME="NAME"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="POSTCODE"/>

<TOCOLUMN NAME="POSTALCODE"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="CITY"/>

<TOCOLUMN NAME="CITY"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="STATE"/>

<TOCOLUMN NAME="STATE"/>

</PROPERTYMAP>

</CLASSMAP>

<CLASSMAP>

<ELEMENTTYPE NAME="SALESORDER"/>

<TOCLASSTABLE NAME="ORDERS"/>

<PROPERTYMAP>

<ATTRIBUTE NAME="SONUMBER"/>

<TOCOLUMN NAME="ORDER_NUMBER"/>

</PROPERTYMAP>

<PROPERTYMAP>

<ELEMENTTYPE NAME="ORDERDATE"/>

<TOCOLUMN NAME="ORDER_DATE"/>

</PROPERTYMAP>

<RELATEDCLASS KEYINPARENTTABLE="FOREIGN">

<ELEMENTTYPE NAME="CUSTOMER"/>

<USEUNIQUEKEY NAME="PRIMARYKEY"/>

<USEFOREIGNKEY NAME="CUST_FK"/>

</RELATEDCLASS>

<RELATEDCLASS KEYINPARENTTABLE="UNIQUE">

<ELEMENTTYPE NAME="ITEM"/>

<USEUNIQUEKEY NAME="PRIMARYKEY"/>

<USEFOREIGNKEY NAME="SO_FK"/>

<ORDERCOLUMN NAME="NUMBER" DIRECTION="SCENDING" />

</RELATEDCLASS>

</CLASSMAP>

</MAPS>

</XMLTODBMS>

And now when i run  manage map.props from command promt it gives

C:\xmldbms20alpha3\samples>manage map.props

C:\xmldbms20alpha3\samples>echo off

C:\xmldbms20alpha3\samples>java
org.xmlmiddleware.xmldbms.tools.MapManager File1=parser.props File2=
db.props File3=map.props
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name
not found and no default dr
iver specified
          at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
          at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
          at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3028)
          at
sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
          at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
          at java.sql.DriverManager.getConnection(DriverManager.java:512)
          at java.sql.DriverManager.getConnection(DriverManager.java:171)
          at
org.xmlmiddleware.db.JDBC1DataSource.createObject(JDBC1DataSource.java:1\
00)
          at org.xmlmiddleware.utils.Pool.checkOut(Pool.java:98)
          at
org.xmlmiddleware.db.ConnectionPool.checkOut(ConnectionPool.java:79)
          at
org.xmlmiddleware.db.JDBC1DataSource.getConnection(JDBC1DataSource.java:\
158)
          at
org.xmlmiddleware.xmldbms.tools.MapManager.createMapFromDTD(MapManager.j\
ava:567)
          at
org.xmlmiddleware.xmldbms.tools.MapManager.dispatch(MapManager.java:407)
          at
org.xmlmiddleware.xmldbms.tools.MapManager.main(MapManager.java:348)



I am feeling like a soldier who has the weapon and the will to fight but
just don't know how to use the weapon. I know it's dumb but that's what
i feel like.  Will you help me out Ron?

Regards,

Saju Sandeep Samuel.





[Non-text portions of this message have been removed]

#3838 From: Ronald Bourret <rpbourret@...>
Date: Thu Mar 22, 2007 5:42 pm
Subject: Re: Can you help me Ron?
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

I haven't looked at your map file yet, but do have the following comments:

1) You do not need to compile the .java files. The compiled files are in
xmldbms20.jar.

2) By default, the samples use the JDBC-ODBC Bridge driver. (This is the
property Driver=sun.jdbc.odbc.JdbcOdbcDriver in db.props.) You will
probably want to change this property to the JDBC driver shipped with
Oracle. You will need to read the documentation for that driver to see
how to enter the user name and password. For example, the driver might
prompt you for them. (You can put them in the db.props file, but this is
not secure.)

3) You are getting an error because the JDBC-ODBC Bridge requires you to
set up an ODBC data source. This error will go away when you set the
driver to the Oracle driver. However, you will need to specify the URL
for your database. See the Oracle JDBC driver documentation for the
format of this URL.

4) You do not need to use MapManager. This is a tool for generating
maps. Since you already have a map, you should use the Transfer tool
(run by transfer.bat in the sample directory) to transfer data.

-- Ron

ask me wrote:

> I needed to transfer the datas in the XML file into Oracle8i, and by
> seraching internet i came across the very helpful site
> http://www.rpbourret.com <http://www.rpbourret.com>  . I downloaded the
> xml-dbms version 2.0
>
> Although being new to java , i gone through the readme file and had all
> the classpath set for xmldbms20.jar and xerces.jar and then compiled the
> .java files one by one ,blindly just compiled all the files
>
> Didn't find where to mention the  "my database_name " and "drivers"
> ,"userid" and "password"
>
> First of all i started with the samples  and am still stuck there...
> And now when i run  manage map.props from command promt it gives
>
> C:\xmldbms20alpha3\samples>manage map.props
>
> C:\xmldbms20alpha3\samples>echo off
>
> C:\xmldbms20alpha3\samples>java
> org.xmlmiddleware.xmldbms.tools.MapManager File1=parser.props File2=
> db.props File3=map.props
> java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name
> not found and no default dr
> iver specified
>          at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
>          at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
>          at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3028)
>          at
> sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
>          at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
>          at java.sql.DriverManager.getConnection(DriverManager.java:512)
>          at java.sql.DriverManager.getConnection(DriverManager.java:171)
>          at
> org.xmlmiddleware.db.JDBC1DataSource.createObject(JDBC1DataSource.java:1\
> 00)
>          at org.xmlmiddleware.utils.Pool.checkOut(Pool.java:98)
>          at
> org.xmlmiddleware.db.ConnectionPool.checkOut(ConnectionPool.java:79)
>          at
> org.xmlmiddleware.db.JDBC1DataSource.getConnection(JDBC1DataSource.java:\
> 158)
>          at
> org.xmlmiddleware.xmldbms.tools.MapManager.createMapFromDTD(MapManager.j\
> ava:567)
>          at
> org.xmlmiddleware.xmldbms.tools.MapManager.dispatch(MapManager.java:407)
>          at
> org.xmlmiddleware.xmldbms.tools.MapManager.main(MapManager.java:348)
>
>
>
> I am feeling like a soldier who has the weapon and the will to fight but
> just don't know how to use the weapon. I know it's dumb but that's what
> i feel like.  Will you help me out Ron?

#3839 From: "leepf7211" <leepf7211@...>
Date: Mon Oct 22, 2007 12:28 am
Subject: how to using manager tool and transfer the data in xml to sqlserver2000
leepf7211
Offline Offline
Send Email Send Email
 
Hi
After i config the environment ,i use the commandline as follow:
E:\xmldbms20alpha3\samples>java
org.xmlmiddleware.xmldbms.tools.MapManager File1
=parser.props File2=db.props Input=DTD DTDFile=orders.dtd Output1=Map
MapFile=or
ders.map Output2=SQL SQLFile=orders.sql
then the errors occur as follow:
java.lang.NullPointerException
         at
org.xmlmiddleware.xmldbms.tools.MapManager.createMapFromDTD(MapManage
r.java:614)
         at
org.xmlmiddleware.xmldbms.tools.MapManager.dispatch(MapManager.java:407)
         at
org.xmlmiddleware.xmldbms.tools.MapManager.main(MapManager.java:348)
I can not resolve them by myself.help me please

#3840 From: ffffffffffc5fffffffffff4ffffffffffb7ffffffffffc9 ffffffffffc0ffffffffffee <leepf7211@...>
Date: Tue Oct 23, 2007 9:00 am
Subject: how to how to use manager tool and transfer the data in xml to sqlserver2000
leepf7211
Offline Offline
Send Email Send Email
 
After i config the environment ,i use the commandline as follow:
  E:\xmldbms20alpha3\samples>java
  org.xmlmiddleware.xmldbms.tools.MapManager File1
  =parser.props File2=db.props Input=DTD DTDFile=orders.dtd Output1=Map
  MapFile=or
  ders.map Output2=SQL SQLFile=orders.sql
  then the errors occur as follow:
  java.lang.NullPointerException
  at
  org.xmlmiddleware.xmldbms.tools.MapManager.createMapFromDTD(MapManage
  r.java:614)
  at
  org.xmlmiddleware.xmldbms.tools.MapManager.dispatch(MapManager.java:407)
  at
  org.xmlmiddleware.xmldbms.tools.MapManager.main(MapManager.java:348)
  I can not resolve them by myself.help me please


---------------------------------
Ż䣬飡

[Non-text portions of this message have been removed]

#3841 From: meisam sarabadani <lmlelilslalm@...>
Date: Thu Oct 25, 2007 9:54 am
Subject: I am badly confused, please help me
lmlelilslalm
Offline Offline
Send Email Send Email
 
Hi, I am very new to XML-DBMS

but I really do need it, I have read its documentations from beginners to
advances, I have understood only a few things.

but I still do not know how to insert an XML document or DTD to RDBMS? :((( this
is part of my project that i should submit it next week, i have even checked he
samples, I saw many action and props files, please give me some steps to start
the  insertion,

here is my problem:

I need to insert a DTD to relational tables. would you give me the steps of
doing this, but more clear than the its own documentation, I did not understand
the documentation about ManagerTool,would you please help me, I really need
somebody to guide me from the beginning.



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]

#3842 From: meisam sarabadani <lmlelilslalm@...>
Date: Thu Oct 25, 2007 10:27 am
Subject: Insertin XML to DBMS
lmlelilslalm
Offline Offline
Send Email Send Email
 
hi,

while inserting the xml into RDBMS, do we need to specify the name of the tables
somewhere ? if yes? so what is the benefit of insertion? for example each time
we  want to insert the DTD into RDBMS we need to create the Database and tables
after that, then inserting the XML content into the created tables ? it means
XML-DBMS can NOT straightforward insert XML document into RDBMS ? or it can ? I
am confused, please guide me, I appreciate your kind helps.



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]

#3843 From: "Jimmy Zhang" <jzhang2004@...>
Date: Fri Oct 26, 2007 12:00 am
Subject: [ANN] VTD-XML 2.2
jzhang_ximpl...
Offline Offline
Send Email Send Email
 
XimpleWare is proud to announce the the release of version 2.2 of VTD-
XML, the next generation open source XML
parsers/indexer/slicer/editor. This release significantly expands VTD-
XML's ability to slice, split, edit and incrementally update the XML
documents. To this end, we introduce the concept of namespace-
compensated element fragment. This release also adds VTD+XML index
writing capability to the VTD Navigator class. Other enhancements in
this release include index size pre-computation, support for HTTP get,
and some bug fixes.



To download the latest release, please go to
http://sourceforge.net/project/showfiles.php?group_id=110612.

#3844 From: Ronald Bourret <rpbourret@...>
Date: Fri Oct 26, 2007 4:19 am
Subject: Re: how to how to use manager tool and transfer the data in xml to sqlserver2000
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

Sorry it has taken me so long to reply.

I tried this on my computer and was unable to recreate your error. I
then looked at the code for MapManager.createMapFromDTD. I cannot see
any code that looks like it might throw a null pointer exception.

I then tried deleting db.props, parser.props, and orders.dtd, but this
caused a FileNotFoundException.

Can you debug the code and see which line is causing the error? If you
do not have a debugger, you can insert the following line into the code:

    System.out.println("I am here.");

and run the code. When you place this before the statement that causes
the error, this will print "I am here." on your command line. When you
place this after the statement that causes the error, this will not
print out. You will then know which line causes the error.

Thanks,

-- Ron

P.S. This mailing list does not accept attachments. This is to prevent
the spread of viruses. If you want to send text files (such as map
files), you need to include the information in your message. Thanks.

ffffffffffc5fffffffffff4ffffffffffb7ffffffffffc9
ffffffffffc0ffffffffffee wrote:

>  After i config the environment ,i use the commandline as follow:
>  E:\xmldbms20alpha3\samples>java
>  org.xmlmiddleware.xmldbms.tools.MapManager File1
>  =parser.props File2=db.props Input=DTD DTDFile=orders.dtd Output1=Map
>  MapFile=or
>  ders.map Output2=SQL SQLFile=orders.sql
>  then the errors occur as follow:
>  java.lang.NullPointerException
>  at
>  org.xmlmiddleware.xmldbms.tools.MapManager.createMapFromDTD(MapManage
>  r.java:614)
>  at
>  org.xmlmiddleware.xmldbms.tools.MapManager.dispatch(MapManager.java:407)
>  at
>  org.xmlmiddleware.xmldbms.tools.MapManager.main(MapManager.java:348)
>  I can not resolve them by myself.help me please
>
>
> ---------------------------------
> Ż䣬飡
>
> [Non-text portions of this message have been removed]

#3845 From: Ronald Bourret <rpbourret@...>
Date: Fri Oct 26, 2007 4:41 am
Subject: Re: Insertin XML to DBMS
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

XML-DBMS is used to transfer data between an XML document and a
relational database. It does this according to a mapping specified in
the map document. The mapping will be different for each different XML
schema (DTD) that you use. That is, you map elements and attributes in
the XML schema to different tables / columns in the database. To
understand how this mapping works, see:

     http://www.rpbourret.com/xml/DTDToDatabase.htm

The mapping language is a little more flexible than the mapping
described in this paper, but not much.

Please note that XML-DBMS implements what is known as an "XML-enabled"
database. This is software that allows you to transfer data between the
XML data model (as used in an XML document) and another data model -- in
this case, the relational model.

XML-DBMS does not implement a native XML database on top of a relational
database. A native XML database uses the XML data model directly. For a
description of how this can be done, see:

http://www.informatics.bangor.ac.uk/~rich/research/papers/uwb_rge_IDEAL2000.pdf

The important difference between these two is that a native XML database
can accept any XML document (even if it does not have a schema) and
store it directly in the database. In an XML-enabled database, you must
create a mapping between the XML schema (DTD) and the database schema at
design time. At run time, data is transferred according to the mapping.

See also my answers to your questions below.

-- Ron

meisam sarabadani wrote:

> hi,
>
> while inserting the xml into RDBMS, do we need to specify the
  > name of the tables somewhere ?

Yes. In the map document.

> if yes? so what is the benefit
  > of insertion?

You can transfer data between an XML document and a specific set of
tables in a relational database. This is useful when you are using XML
as a data transport. XML-DBMS is not designed to store XML documents
directly.

> for example each time we  want to insert the DTD
  > into RDBMS we need to create the Database and tables after
  > that, then inserting the XML content into the created tables ?

XML-DBMS does not allow you to insert a DTD into the database. It allows
you to take data out of an XML document and put it in specific tables in
the database. Similarly, it allows you to construct an XML document
using data in the relational database.

Before you transfer data, you must create the tables in the database and
write a map document that specifies how to transfer data between the XML
document and the database. You only need to do this once. After you have
created the tables and the mapping, you can transfer as much data as you
want.
  > it means XML-DBMS can NOT straightforward insert XML document
  > into RDBMS ?

That is correct. XML-DBMS does not insert XML documents into the
database. It takes data out of XML documents and puts the data into the
database (and vice versa). It does not store the documents themselves.

For example, it could transfer data from the following XML document:

     <Name>
        <Given>Ronald</Given>
        <Family>Bourret</Family>
     </Name>

into the following row in the Names table:

     Names
     =====
     GivenName  FamilyName
     ---------  ----------
     ...
     Ronald     Bourret
     ...

> or it can ? I am confused, please guide me, I
  > appreciate your kind helps.

#3846 From: Ronald Bourret <rpbourret@...>
Date: Fri Oct 26, 2007 5:40 am
Subject: Re: I am badly confused, please help me
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

Here is a simple example of using XML-DBMS. This example uses the
command line, the MapManager and Transfer tools, and the samples in the
samples subdirectory.

Introduction
============

Before you use XML-DBMS, you need to understand what XML-DBMS does.
XML-DBMS does not directly store XML documents in the database. Instead,
it transfers data between XML documents and the database. It does this
according to an object-relational model. That is, it views an XML
document as if it was a serialized object tree and uses an
object-relational mapping between the object tree and the database. The
map language allows you to customize this mapping a little bit.

I strongly suggest you read the paper:

    http://www.rpbourret.com/xml/DTDToDatabase.htm

before using XML-DBMS. It will help you understand the general model.
The introduction to section 3 and section 3.1 give you an overview of
how the model works.

XML-DBMS has two different phases: a design phase and a run-time phase.
At design time, you must create a mapping between the XML schema / DTD
and the relational schema. The MapManager tool can help you do this. You
must also set up things like filter files, action files, etc.

At run time, you use the Transfer tool (or call XML-DBMS classes
directly) to actually transfer data between the XML document and the
relational database. Data is transferred according to the map document,
filter file, action file, etc.

Design time
===========
1) Create your XML schema and your relational schema. The MapManager
tool can create a DTD from a relational schema or a relational schema
from a DTD. However, if you use the MapManager tool, you will need to
modify the DTD / relational schema by hand. This is because the
generated schemas are generally very inefficient. For example, the
MapManager tool cannot guess which elements or attributes in a DTD
contain primary key information.

To create a relational schema from orders.dtd, you would use the
following command:

c:\xmldbms\samples>java org.xmlmiddleware.xmldbms.tools.MapManager
File1=parser.props File2=db.props Input=DTD DTDFile=orders.dtd
Output=SQL SQLFile=orders.sql

parser.props and db.props contain information about the XML parser and
database you will be using. You can modify the files in the samples
directory for your system.

The Input keyword tells the MapManager what you are starting from. The
possible values are Map, DTD, and Database. In this case, we are
starting with a DTD and want to generate a relational schema (SQL file).

The Output keyword tell MapManager what we want to generate. The
possible values are Map, DTD, and SQL.

The DTDFile and SQLFile keywords give the names of those files. We need
a DTDFile because Input is DTD. We need SQLFile because Output is SQL.

After you run the MapManager, you will need to modify the SQL file by
hand to make any necessary corrections. For example, you will need to
change the data types in the CREATE TABLE statements to the correct data
types (instead of VARCHAR(254)) and you will probably need to change the
PRIMARY KEY clauses to use primary key information from the XML
document. (MapManager assumes you are using database-generated keys.)

For our sample, your completed files should look like orders.sql.

2) Create a mapping from the XML schema to the relational schema. This
is done with a map document. Normally, you must write this document by
hand. If you have a complex schema, this will be a lot of work. For an
overview of the mapping language, see section 4.3 of the XML-DBMS 1.0
readme [1]. The version 2.0 mapping language is a little bit different,
but the ideas are the same. For an example of a complete map document,
see orders.map in the samples directory.

Your relational schema and your XML schema must have roughly the same
structure. If they have very different structures, you will need to
create an XML schema that has the same structure as the relational
schema. You will then need to write an XSLT transformation to transform
XML documents between your original DTD and the DTD that matches the
relational schema. That is:

     XML document (original DTD)
            |
            |    XSLT
            V
     XML document (new DTD)
            |
            |   XML-DBMS
            V
        Database

You can also use MapManager to help you create the mapping. This will
work only if you have a DTD (but not a relational schema) or a
relational schema (but not a DTD). If you already have a relational
schema and a DTD, you will need to create the mapping by hand.

For example, to generate both a relational schema and a map document,
use the following command.

c:\xmldbms\samples>java org.xmlmiddleware.xmldbms.tools.MapManager
File1=parser.props File2=db.props Input=DTD DTDFile=orders.dtd
Output1=Map MapFile=orders.map Output2=SQL SQLFile=orders.sql

Note that we use the Output1 and Output2 keywords because we want both a
map and a relational schema. We also add the MapFile keyword to give the
name of the map file. As before, you will need to modify the map
document and SQL schema by hand to get the mapping you want.

For our sample, your completed files should look like orders.map and
orders.sql.

3) Create an actions document. This specifies what actions you want to
take for each element mapped as a class -- that is, mapped to a table
instead of a column. For example, see orders1.act. This says that, by
default, you simply insert data into the database. There are two
exceptions: for the Part and Customer elements, first check if the data
is in the database. If it is, update it. If it is not, insert it.

You only need an actions document to insert, update, or delete data. You
do not need an actions document to transfer data from the database to XML.

4) Create a filter document. This specifies what data you want to
retrieve from the database. You only need a filter document if you are
transferring data from the database to XML. For example, see orders.ftr.
This says to transfer all data from the Orders table (condition is 0=0).

Run time
========
To transfer data, it is easiest to use the Transfer tool. You will pass
the parser and database information, the map document, the actions
and/or filter documents, and the XML document. You will also specify
what to do -- for example, store data from a document. For example:

c:/xmldbms/samples>java org.xmlmiddleware.xmldbms.tools.Transfer
File1=parser.props File2=db.props Method=StoreDocument
MapFile=orders.map XMLFile=orders.xml ActionFile=orders.act

As before parser.props and db.props provide parser and database information.

The Method keyword specifies what you want to do. In this case,
StoreDocument means you want to transfer data from XML to the database.
(This includes updating data. You specify whether to insert or update
data in the actions document.) Other legal values are
RetrieveDocumentByFilter, RetrieveDocumentBySQL, and DeleteDocument.

The MapFile, XMLFile, and ActionFile keywords give the names of the map,
XML, and action documents.

I hope this helps. Please write if you have specific problems.

-- Ron

[1] http://www.rpbourret.com/xmldbms/readme1x.htm

meisam sarabadani wrote:

> Hi, I am very new to XML-DBMS
>
> but I really do need it, I have read its documentations from beginners to
advances, I have understood only a few things.
>
> but I still do not know how to insert an XML document or DTD to RDBMS? :(((
this is part of my project that i should submit it next week, i have even
checked he samples, I saw many action and props files, please give me some steps
to start the  insertion,
>
> here is my problem:
>
> I need to insert a DTD to relational tables. would you give me the steps of
doing this, but more clear than the its own documentation, I did not understand
the documentation about ManagerTool,would you please help me, I really need
somebody to guide me from the beginning.

#3847 From: "leepf7211" <leepf7211@...>
Date: Mon Nov 5, 2007 2:39 am
Subject: I have met a error of "NullPointerexception" when i use manager tool
leepf7211
Offline Offline
Send Email Send Email
 
Hello,everbody
I have met a error of "NullPointerexception" when i use manager tool
,and i have capture the error position in source code is as follow:
public XMLDBMSMap createMapFromDTD(Properties dbProps, Properties
configProps, String dtdFilename)
       throws XMLMiddlewareException, SQLException
    {
       DBInfo         dbInfo;
       Connection     conn;
       MapFactory_DTD factory;
       String         order, databaseName, catalogName, schemaName;
       Hashtable      namespaceURIs;

       if (dbProps == null) dbProps = emptyProps;
       if (configProps == null) configProps = emptyProps;
       // Create a new map factory.

       factory = new MapFactory_DTD();
       // Set the database properties, if any.

       dbInfo = getDBInfo(dbProps, false);
       if (dbInfo != null)
       {
          conn = dbInfo.dataSource.getConnection(dbInfo.user,
dbInfo.password);
          factory.setConnection(conn);
       }

       // Set the order options, if any.

       order = configProps.getProperty(XMLDBMSProps.ORDERTYPE);

       if (order != null)
       {
          if (order.equals(XMLDBMSProps.FIXED))
          {
             System.out.println("I am here1");
//when i put the statement at here,the error is occur and "I am here"
do not come outmy version of jdk is 1.5.0_08
              factory.setOrderType(MapFactory_DTD.ORDER_FIXED);

          }
          else if (order.equals(XMLDBMSProps.NONE))
          {
             factory.setOrderType(MapFactory_DTD.ORDER_NONE);
          }
          else if (order.equals(XMLDBMSProps.COLUMNS))
          {
             factory.setOrderType(MapFactory_DTD.ORDER_COLUMNS);
          }
          else
             throw new IllegalArgumentException("Invalid value of " +
XMLDBMSProps.ORDERTYPE + " property: " + order);
       }
              ......

#3848 From: rpbourret@...
Date: Wed Nov 7, 2007 7:43 am
Subject: Re: I have met a error of "NullPointerexception" when i use manager tool
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

Sorry I haven't replied sooner.

The statement does not print because you have not reached that section of the
code. You did not supply a value for the ORDERTYPE property, so order is null.
Therefore, the code does not enter the if statement.

Can you continue to test later in the method and see if you can find where the
NullPointerException is occurring?

Thank you for your patience.

-- Ron

leepf7211 wrote:

> Hello,everbody
> I have met a error of "NullPointerexception" when i use manager tool
> ,and i have capture the error position in source code is as follow:
> public XMLDBMSMap createMapFromDTD(Properties dbProps, Properties
> configProps, String dtdFilename)
>       throws XMLMiddlewareException, SQLException
>    {
>       DBInfo         dbInfo;
>       Connection     conn;
>       MapFactory_DTD factory;
>       String         order, databaseName, catalogName, schemaName;
>       Hashtable      namespaceURIs;
>
>       if (dbProps == null) dbProps = emptyProps;
>       if (configProps == null) configProps = emptyProps;
>       // Create a new map factory.
>
>       factory = new MapFactory_DTD();
>       // Set the database properties, if any.
>
>       dbInfo = getDBInfo(dbProps, false);
>       if (dbInfo != null)
>       {
>          conn = dbInfo.dataSource.getConnection(dbInfo.user,
> dbInfo.password);
>          factory.setConnection(conn);
>       }
>
>       // Set the order options, if any.
>
>       order = configProps.getProperty(XMLDBMSProps.ORDERTYPE);
>
>       if (order != null)
>       {
>          if (order.equals(XMLDBMSProps.FIXED))
>          {
>             System.out.println("I am here1");
> //when i put the statement at here,the error is occur and "I am here"
> do not come outmy version of jdk is 1.5.0_08
>              factory.setOrderType(MapFactory_DTD.ORDER_FIXED);
>
>          }
>          else if (order.equals(XMLDBMSProps.NONE))
>          {
>             factory.setOrderType(MapFactory_DTD.ORDER_NONE);
>          }
>          else if (order.equals(XMLDBMSProps.COLUMNS))
>          {
>             factory.setOrderType(MapFactory_DTD.ORDER_COLUMNS);
>          }
>          else
>             throw new IllegalArgumentException("Invalid value of " +
> XMLDBMSProps.ORDERTYPE + " property: " + order);
>       }
>              ......

#3849 From: ffffffffffc5fffffffffff4ffffffffffb7ffffffffffc9 ffffffffffc0ffffffffffee <leepf7211@...>
Date: Fri Nov 23, 2007 6:34 am
Subject: who can tell me how to write my own application using java and xml-dbms
leepf7211
Offline Offline
Send Email Send Email
 
Hi, everybody!
who could tell me how to write my own application using java and xml-dbms ?I
want a completely example which can describe  the  develop   steps.i hava a
example ,but it  have  some errors which  i  can not  correct them.the code is
as follow:

import org.xmlmiddleware.db.*;
import org.xmlmiddleware.utils.XMLMiddlewareException;
import org.xmlmiddleware.xmldbms.*;
import org.xmlmiddleware.xmldbms.tools.*;
import org.xmlmiddleware.xmldbms.actions.ActionCompiler;
import org.xmlmiddleware.xmldbms.actions.*;
import org.xmlmiddleware.xmldbms.datahandlers.*;
import org.xmlmiddleware.xmldbms.filters.*;
import org.xmlmiddleware.xmldbms.keygenerators.*;
import org.xmlmiddleware.xmldbms.maps.*;
import org.xmlmiddleware.xmldbms.maps.factories.*;
import org.xmlmiddleware.xmlutils.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import java.io.*;
import java.util.*;
import javax.sql.*;
public class XMLToDBMSAndViceVersa
{
// Service objects
private DOMToDBMS domToDBMS = null;
private DBMSToDOM dbmsToDOM = null;
private DBMSDelete dbmsDelete = null;
// Credentials for connecting to database
private static String JDBC_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
private static String JDBC_URL = "jdbc:odbc:xmldbms";
private static String JDBC_DBNAME = "test";
private static String JDBC_USER = "sa";
private static String JDBC_PASSWORD = "sa";
// Some file names
private static String mapFilename = "Listing-A.map";
private static String actionFilename = "Listing-C.act";
private static String filterFilename = "Listing-D.act";
// Datahandler class
private static String GENERICHANDLER =
"org.xmlmiddleware.xmldbms.datahandlers.GenericHandler";
// Key generation class
private static String KEYGENERATOR =
"org.xmlmiddleware.xmldbms.keygenerators.KeyGenerator";
// Parser utils class; XML-DBMS does not yet support JAXP, so such operations as
XML parsing and serializing
// needs to be a little customized for each parser. this is the class for
supporting Xerces parser.
private static String PARSERUTILSCLASS =
"org.xmlmiddleware.xmlutils.external.ParserUtilsXerces";
private static boolean VALIDATING_PARSER = false;
public static void main(String [] args) {
// Tell the JVM to run finalizers on exit. This is necessary to ensure
// that database connections are properly closed.
System.runFinalizersOnExit(true);
// Creating parser utilities
ParserUtils utils = (ParserUtils)Class.forName(PARSERUTILSCLASS).newInstance();
// Creating a data source and data handler.
DataSource dataSource = new JDBC1DataSource(JDBC_DRIVER, JDBC_URL);
DataHandler dataHandler =
(DataHandler)Class.forName(GENERICHANDLER).newInstance();
dataHandler.initialize(dataSource, JDBC_USER, JDBC_PASSWORD);
// Compiling and instantiating a Map object
MapCompiler compiler1 = new MapCompiler(utils.getXMLReader(VALIDATING_PARSER));
XMLDBMSMap map = compiler1.compile(new InputSource(new
FileReader(mapFilename)));
// Create an object containing information needed to transfer data
TransferInfo transferInfo = new TransferInfo(map);
transferInfo.addDataHandler(JDBC_DBNAME, dataHandler);
// Compiling and instantiating an Action object
ActionCompiler compiler2 = new
ActionCompiler(utils.getXMLReader(VALIDATING_PARSER));
Actions actions = compiler2.compile(map, new InputSource(new
FileReader(actionFilename)));
// Creating and configuring service object
domToDBMS = new DOMToDBMS();
domToDBMS.setCommitMode(DataHandler.COMMIT_AFTERSTATEMENT);
domToDBMS.stopOnException(true);
domToDBMS.setFilterSetReturned(false);
KeyGenerator keyGen = (KeyGenerator)Class.forName(KEYGENERATOR).newInstance();
domToDBMS.addKeyGenerator("UID", keyGen); // Adding used in Listing-A key
generator named UID
// Getting our XML document into DOM document
Document doc = utils.openDocument(new InputSource(new
StringReader(xmlString)),VALIDATING_PARSER);
// Ooops... and our XML file is already in the database!
domToDBMS.storeDocument(transferInfo, doc, actions);
// Creating FilterSet object for retrieving data
FilterCompiler compiler = new FilterCompiler(utils.getXMLReader(validate));
FilterSetfilterSet = compiler.compile(map, new InputSource(new
FileReader(filterFilename)));
// Creating and configuring another service object
dbmsToDOM = new DBMSToDOM(utils);
dbmsToDOM.setDTDInfo(null, null);
Hashtableparams = new Hashtable();
// And now we are getting a DOM document from database
doc = dbmsToDOM.retrieveDocument(transferInfo, filterSet, params, null);
}
}




---------------------------------
Ż䣬飡

[Non-text portions of this message have been removed]

#3850 From: "Jimmy Zhang" <jzhang2004@...>
Date: Fri Mar 7, 2008 8:13 pm
Subject: VTD-XML 2.3 released
jzhang_ximpl...
Offline Offline
Send Email Send Email
 
Version 2.3 of VTD-XML (http://vtd-xml.sf.net), the next generation
document-centric XML processing model, is now released. To download
the latest version please visit
http://sourceforge.net/project/showfiles.php?
group_id=110612&package_....

Below is a list of new features and enhancements in this version.


* VTDException is now introduced as the root class for all other VTD-
XML's exception classes (per suggestion of Max Rahder).
* Transcoding capability is now added for inter-document cut and
paste. You can cut a chuck of bytes in a UTF-8 encoded document and
paste it into a UTF-16 encoded document and the output document is
still well-formed.
* ISO-8859-10, ISO-8859-11, ISO-8859-12, ISO-8859-13, ISO-8859-14
and
ISO-8859-15 support has now been added
* Zero length Text node is now possible.
* Ability to dump in-memory copy of text is added.
* Various code cleanup, enhancement and bug fixes.


Below are some new articles related to VTD-XML


* Index XML documents with VTD-XML http://xml.sys-
con.com/read/453082.htm
* Manipulate XML content the Ximple Way
http://www.devx.com/xml/Article/36379
* VTD-XML: A new vision of XML
http://www.developer.com/xml/article.php/3714051
* VTD-XML: XML Processing for the future
http://www.codeproject.com/KB/cs/vtd-xml_examples.aspx

#3851 From: "kyle93ser" <kyle@...>
Date: Thu Oct 9, 2008 6:43 pm
Subject: Re: No KeyGenerator added for the key generator named HighLow
kyle93ser
Offline Offline
Send Email Send Email
 
Ron,

Is there a newer release than Alpha3?

I am attempting to use xml-dbms with Nessus a popular security
vulnerability scanner.

I have everything loaded, database seHighLow.javtup and am trying to
test the sample code and am getting the same error as the guy that
started this thread.

I don't know alot about JAVA, and am using your code on an Ubunutu box.

I have never created a jar file, but I'm going to find out how to here
shortly.  I downloaded the HighLow.JAVA file, and will try to build
the jar file with it.

If you have any other inputs, please let me know.. thanks!



--- In xml-dbms@yahoogroups.com, Ronald Bourret <rpbourret@...> wrote:
>
> ardavan_kanani wrote:
>
> > Yes I am using alpha 3.  Is there a newer version?  I downloaded the
> > latest files from CVS and failed to compile the files.
>
> The CVS files are newer than the alpha 3 files, but I have not done a
> formal alpha 4 release yet. I still have more changes I want to make
> before I do this.
>
> Which files failed and what were the compile errors? I would expect that
> the only files you would have trouble with are:
>
> -- the files in org.xmlmiddleware.xmldbms.datahandlers.external
> -- the files in org.xmlmiddlware.db (if you are using JDK 1.2 or later)
>
> The files in org.xmlmiddleware.xmldbms.datahandlers.external do not
> matter if you are not using the specified databases/JDBC drivers.
>
> To compile the files in org.xmlmiddleware.db, you need to uncomment
> various lines in the code -- see the comments in the code for details.
>
> > I am not putting the HighLow and KeyGenerator in orders.map.  In fact
> > I am creating the orders.map and orders.sql using the mapmanager
> > running the following command:
> >
> > java org.xmlmiddleware.xmldbms.tools.MapManager File1=parser.props
> > File2=db.props Input=DTD DTDFile=orders.dtd Output1=Map
> > MapFile=orders.map Output2=SQL SQLFile=orders.sql
>
> You are (indirectly) putting HighLow in orders.map. The map manager
> always uses generated keys and the HighLow key generator when it
> generates a map from a DTD. This is because the map manager cannot
> identify which element types / attributes to use as primary keys, so it
> has no choice but to use generated keys.
>
> This is a perfect example of why you should not use a map generated by
> the map manager without first checking that the generated map makes
> sense. In the case of a map generated from orders.dtd, there are two
> problems:
>
> 1) The map uses generated keys even though there are element types and
> attributes in the DTD that could be used as primary and foreign keys.
>
> 2) The map generator incorrectly determines the relationship between
> some of the tables. For example, it assumes that there is a one-to-many
> relationship between the sales order table and the customers table and
> places the primary key in this relationship in the sales order table. In
> fact, it is the other way around -- there is a many-to-one relationship
> between these two tables and the primary key is in the customers table.
>
> > JavaDoc does not contain any info about
> > org.xmlmiddleware.xmldbms.keygenerators.HighLow.
>
> Worse yet -- I just noticed that the HighLow class isn't even shipped in
> the alpha 3 release. (The reason was that it wasn't written until after
> the alpha 3 release was made.)
>
> You can download this from the CVS tree. Be sure to use version 1.1.
> Later versions probably won't work with the rest of the alpha 3 code.
>
> > I am not exactly sure what you mean by  Tell the high/low key
> > generator how to connect to the database, which
> > > means specifying these properties on your call to Transfer. For
details,
> >
> > Could you send me an example?
>
> Once you've downloaded the correct version of HighLow.java, you can
> either generate the JavaDoc for it or just look at the comments at the
> start of the class -- these contain an example.
>
> > Thanks, Ardavan Kanani
>
> You're welcome, and sorry about all the confusion on this.
>
> -- Ron
>

#3852 From: Ronald Bourret <rpbourret@...>
Date: Fri Oct 10, 2008 5:00 am
Subject: Re: Re: No KeyGenerator added for the key generator named HighLow
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

For some reason, Yahoo Groups won't let me see the entire thread, so I
assume the error you are having is that that HighLow class is not found.
To solve this, you need to download the HighLow.java class, which you
have done, compile it, and somehow include it in your classpath, which
is a list of places Java looks for .class files.

You can either include HighLow.class in the xmldbms20.jar file and point
your classpath at this jar file. Or you can set your classpath to
include both the jar file and the directory containing the HighLow.class
file. For more information about all this Java stuff, see the Java
tutorials on Sun's Web site:

     http://java.sun.com/docs/books/tutorial/

As to whether you even really need the HighLow key generator, my
comments below are still relevant. Maps generated by the MapManager
usually contain mistakes that a human would not make. And, as a general
rule, you only need key generators (which generate primary key values)
in a limited number of cases. Usually, there is an element or attribute
in your XML that can be used as a primary key, such as an order ID. (I
took a quick look at the XML Schema for Nessus files and there are no
obvious candidates for keys, so a key generator might be relevant in
your case.) XML-DBMS can also use keys generated by the database.

As to newer releases, the answer is no, and there probably never will
be. (The code is stable, so I really should just get rid of the alpha 3
name, make a few minor changes, and call it version 2.0...) For reasons
why, see:

     http://www.rpbourret.com/xmldbms/faqs/v20.htm

When you say you are using XML-DBMS with Nessus, I assume you mean you
are using XML-DBMS to store the information generated by Nessus in a
database?

Thanks,

-- Ron

kyle93ser wrote:

> Ron,
>
> Is there a newer release than Alpha3?
>
> I am attempting to use xml-dbms with Nessus a popular security
> vulnerability scanner.
>
> I have everything loaded, database seHighLow.javtup and am trying to
> test the sample code and am getting the same error as the guy that
> started this thread.
>
> I don't know alot about JAVA, and am using your code on an Ubunutu box.
>
> I have never created a jar file, but I'm going to find out how to here
> shortly.  I downloaded the HighLow.JAVA file, and will try to build
> the jar file with it.
>
> If you have any other inputs, please let me know.. thanks!
>
>
>
> --- In xml-dbms@yahoogroups.com, Ronald Bourret <rpbourret@...> wrote:
>
>>ardavan_kanani wrote:
>>
>>
>>>Yes I am using alpha 3.  Is there a newer version?  I downloaded the
>>>latest files from CVS and failed to compile the files.
>>
>>The CVS files are newer than the alpha 3 files, but I have not done a
>>formal alpha 4 release yet. I still have more changes I want to make
>>before I do this.
>>
>>Which files failed and what were the compile errors? I would expect that
>>the only files you would have trouble with are:
>>
>>-- the files in org.xmlmiddleware.xmldbms.datahandlers.external
>>-- the files in org.xmlmiddlware.db (if you are using JDK 1.2 or later)
>>
>>The files in org.xmlmiddleware.xmldbms.datahandlers.external do not
>>matter if you are not using the specified databases/JDBC drivers.
>>
>>To compile the files in org.xmlmiddleware.db, you need to uncomment
>>various lines in the code -- see the comments in the code for details.
>>
>>
>>>I am not putting the HighLow and KeyGenerator in orders.map.  In fact
>>>I am creating the orders.map and orders.sql using the mapmanager
>>>running the following command:
>>>
>>>java org.xmlmiddleware.xmldbms.tools.MapManager File1=parser.props
>>>File2=db.props Input=DTD DTDFile=orders.dtd Output1=Map
>>>MapFile=orders.map Output2=SQL SQLFile=orders.sql
>>
>>You are (indirectly) putting HighLow in orders.map. The map manager
>>always uses generated keys and the HighLow key generator when it
>>generates a map from a DTD. This is because the map manager cannot
>>identify which element types / attributes to use as primary keys, so it
>>has no choice but to use generated keys.
>>
>>This is a perfect example of why you should not use a map generated by
>>the map manager without first checking that the generated map makes
>>sense. In the case of a map generated from orders.dtd, there are two
>>problems:
>>
>>1) The map uses generated keys even though there are element types and
>>attributes in the DTD that could be used as primary and foreign keys.
>>
>>2) The map generator incorrectly determines the relationship between
>>some of the tables. For example, it assumes that there is a one-to-many
>>relationship between the sales order table and the customers table and
>>places the primary key in this relationship in the sales order table. In
>>fact, it is the other way around -- there is a many-to-one relationship
>>between these two tables and the primary key is in the customers table.
>>
>>
>>>JavaDoc does not contain any info about
>>>org.xmlmiddleware.xmldbms.keygenerators.HighLow.
>>
>>Worse yet -- I just noticed that the HighLow class isn't even shipped in
>>the alpha 3 release. (The reason was that it wasn't written until after
>>the alpha 3 release was made.)
>>
>>You can download this from the CVS tree. Be sure to use version 1.1.
>>Later versions probably won't work with the rest of the alpha 3 code.
>>
>>
>>>I am not exactly sure what you mean by  Tell the high/low key
>>>generator how to connect to the database, which
>>>
>>>>means specifying these properties on your call to Transfer. For
>
> details,
>
>>>Could you send me an example?
>>
>>Once you've downloaded the correct version of HighLow.java, you can
>>either generate the JavaDoc for it or just look at the comments at the
>>start of the class -- these contain an example.
>>
>>
>>>Thanks, Ardavan Kanani
>>
>>You're welcome, and sorry about all the confusion on this.
>>
>>-- Ron
>>
>
>
>
>
> ------------------------------------
>
> To post a message, send it to: xml-dbms@yahoogroups.com
> To unsubscribe, send a blank message to:
xml-dbms-unsubscribe@...! Groups Links
>
>
>
>
>

#3853 From: "xia_ibm" <xia_ibm@...>
Date: Thu Mar 12, 2009 12:22 am
Subject: San Jose Bay Area Evaluators Sought for IBM Query Tuning Product
xia_ibm
Offline Offline
Send Email Send Email
 
This is a one-time only activity for about 8 hrs. If you are invited to
participate, you will receive an honorarium of $75/hr for your
participation. No reimbursement for travel.

In order to design usable products with functions and features customers
want, designers and developers at IBM follow User-Centered Design (UCD),
an approach involving input from users. To evaluate an IBM query tuning
product family, we are currently looking for developers (programmers)
with rich SQL writing experience and junior DB2 DBAs. For the purpose of
this study, a junior DBA is a DBA with less than about 3 yrs of
full-time experience with DB2 Z/OS or DB2 LUW, but no limit on total
years of experience with DB2 on all platforms. E.g., a senior LUW DBA
would qualify as a junior DBA on DB2 Z/OS if she just started working on
DB2 Z/OS for couple of years.

As a participant you will perform typical tasks of query tuning using
the existing product, and explore requirements and prototypes for future
designs. The evaluation session will last approximately 8 hrs, including
a series of hands-on tasks followed by your comments and discussions.

The evaluation will take place between March and April 2009 at IBM
Silicon Valley Lab in south San Jose.

If you are interested in participating in this evaluation, please reply
to xia@... <mailto:xia@...>  with subject "IBM
Usability Testing  [Your First Name]". Please briefly list your
experience relevant to the requirements above. You will be contacted if
your experience is considered as a good fit for this particular study.



[Non-text portions of this message have been removed]

#3854 From: "Ruchika Israni" <israniruchika@...>
Date: Tue May 26, 2009 4:51 pm
Subject: Use of InlineMap Element
israniruchika
Offline Offline
Send Email Send Email
 
Hi Ron,

I want to skip certain elements in my xml because they do not correspond to any
structure in the database and map the child to a table in the database. I am not
sure whether or not that can be done with the InlineMap tag. Here is the partial
structure of my xml :
************************************************************
<?xml version="1.0" encoding="utf-8" ?>
<storedHU xmlns:aml="http://www.atlasti.com/hu/ns2003"
lastSaved="2008-09-15T14:28:34" creator="ATLAS.ti" method="AML (ATLAS Markup
Language)" version="WIN 5.2 (Build 0)">

<hermUnit name="masterFLOSSFireandGaimHU09072008" au="Super"
cdate="2007-06-18T20:20:52" mdate="2008-09-08T22:36:17" lastPD="816"
prot="private" />
<coAuthors>
<coAuthor name="coAuthor1">
</coAuthor>
</coAuthors>

<dataSources size="2" >
<dataSource id="1"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2004-06-23-18-10-00-37-3216.txt"
mime="text/plain" />
<dataSource id="2"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2006-01-26-04-30-00-37-7064.txt"
mime="text/plain" />
</dataSources>
**************************************************************

In the above xml, storedHU and hermUnit correspond to their respective tables.
There is no table corresponding to the dataSources element however, I want to
insert data into the datasource table in the database. Is there any way by which
this can be done? I went through the FAQs and related posts in the group and
accordingly tried to play around with the <InlineMap> tag. However, no avail.

Any help in this regard would be appreciated.

Many thanks in anticipation.

Ruchika Israni

#3855 From: Ronald Bourret <rpbourret@...>
Date: Thu May 28, 2009 5:43 am
Subject: Re: Use of InlineMap Element
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

Yes, you can use the InlineMap element for this.

For example, the ClassMap element for storedHU would look something like
this:

<ClassMap>
     <ElementType Name="storedHU" />
     <ToClassTable Name="STOREDHUTABLE" />
     ... PropertyMap elements for lastSaved, creator, method, version ...
     <InlineMap>
        <ElementType Name="dataSources" />
        <RelatedClass KeyInParentTable="Unique">
           <ElementType Name="dataSource" />
           <UseUniqueKey Name="..." />
           <UseForeignKey Name="..." />
        </RelatedClass>
     </InlineMap>
     <RelatedClass KeyInParentTable="Unique">
        <ElementType Name="hermUnit" />
        <UseUniqueKey Name="..." />
        <UseForeignKey Name="..." />
     </RelatedClass>
</ClassMap>

The InlineMap element tells XML-DBMS to ignore the dataSources element
and treat its children and attributes as if they were part of the
storedHU element. This would be the same as mapping the following XML:

     <storedHU ...other attributes... size="2" >
        <hermUnit ...other attributes... />
        <coAuthors>
           <coAuthor name="coAuthor1"></coAuthor>
        </coAuthors>
        <dataSource id="1" loc="..." mime="..." />
        <dataSource id="2" loc="..." mime="..." />
        ...

Notes:

1) The dataSources/@size attribute is treated as if it were an attribute
of storedHU. If you wanted to map it to a column in the STOREDHUTABLE,
you would do this with a PropertyMap element inside the InlineMap element.

2) You can also use the InlineMap element to ignore the coAuthors element.

3) You will need a ClassMap element for the dataSource element.

Hope this helps,

-- Ron

Ruchika Israni wrote:
> Hi Ron,
>
> I want to skip certain elements in my xml because they do not correspond to
any structure in the database and map the child to a table in the database. I am
not sure whether or not that can be done with the InlineMap tag. Here is the
partial structure of my xml :
> ************************************************************
> <?xml version="1.0" encoding="utf-8" ?>
> <storedHU xmlns:aml="http://www.atlasti.com/hu/ns2003"
> lastSaved="2008-09-15T14:28:34" creator="ATLAS.ti" method="AML (ATLAS Markup
Language)" version="WIN 5.2 (Build 0)">
>
> <hermUnit name="masterFLOSSFireandGaimHU09072008" au="Super"
cdate="2007-06-18T20:20:52" mdate="2008-09-08T22:36:17" lastPD="816"
prot="private" />
> <coAuthors>
> <coAuthor name="coAuthor1">
> </coAuthor>
> </coAuthors>
>
> <dataSources size="2" >
> <dataSource id="1"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2004-06-23-18-10-00-37-3216.txt"
mime="text/plain" />
> <dataSource id="2"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2006-01-26-04-30-00-37-7064.txt"
mime="text/plain" />
> </dataSources>
> **************************************************************
>
> In the above xml, storedHU and hermUnit correspond to their respective tables.
There is no table corresponding to the dataSources element however, I want to
insert data into the datasource table in the database. Is there any way by which
this can be done? I went through the FAQs and related posts in the group and
accordingly tried to play around with the <InlineMap> tag. However, no avail.
>
> Any help in this regard would be appreciated.
>
> Many thanks in anticipation.
>
> Ruchika Israni
>
>
>
> ------------------------------------
>
> To post a message, send it to: xml-dbms@yahoogroups.com
> To unsubscribe, send a blank message to:
xml-dbms-unsubscribe@...! Groups Links
>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.339 / Virus Database: 270.12.40/2135 - Release Date: 05/26/09
08:53:00
>

#3856 From: "Ruchika Israni" <israniruchika@...>
Date: Mon Jun 1, 2009 11:40 pm
Subject: Re: Use of InlineMap Element
israniruchika
Offline Offline
Send Email Send Email
 
Thank you for your reply Ron.

Actually, my problem is there is no parent-child relationship between storedHU
and dataSource. Also, there are many such elements (like dataSources) having
size as their attribute.

Is there any way by which this can be accomplished?

Thanks.
Ruchika Israni

--- In xml-dbms@yahoogroups.com, Ronald Bourret <rpbourret@...> wrote:
>
> Hello,
>
> Yes, you can use the InlineMap element for this.
>
> For example, the ClassMap element for storedHU would look something like
> this:
>
> <ClassMap>
>     <ElementType Name="storedHU" />
>     <ToClassTable Name="STOREDHUTABLE" />
>     ... PropertyMap elements for lastSaved, creator, method, version ...
>     <InlineMap>
>        <ElementType Name="dataSources" />
>        <RelatedClass KeyInParentTable="Unique">
>           <ElementType Name="dataSource" />
>           <UseUniqueKey Name="..." />
>           <UseForeignKey Name="..." />
>        </RelatedClass>
>     </InlineMap>
>     <RelatedClass KeyInParentTable="Unique">
>        <ElementType Name="hermUnit" />
>        <UseUniqueKey Name="..." />
>        <UseForeignKey Name="..." />
>     </RelatedClass>
> </ClassMap>
>
> The InlineMap element tells XML-DBMS to ignore the dataSources element
> and treat its children and attributes as if they were part of the
> storedHU element. This would be the same as mapping the following XML:
>
>     <storedHU ...other attributes... size="2" >
>        <hermUnit ...other attributes... />
>        <coAuthors>
>           <coAuthor name="coAuthor1"></coAuthor>
>        </coAuthors>
>        <dataSource id="1" loc="..." mime="..." />
>        <dataSource id="2" loc="..." mime="..." />
>        ...
>
> Notes:
>
> 1) The dataSources/@size attribute is treated as if it were an attribute
> of storedHU. If you wanted to map it to a column in the STOREDHUTABLE,
> you would do this with a PropertyMap element inside the InlineMap element.
>
> 2) You can also use the InlineMap element to ignore the coAuthors element.
>
> 3) You will need a ClassMap element for the dataSource element.
>
> Hope this helps,
>
> -- Ron
>
> Ruchika Israni wrote:
> > Hi Ron,
> >
> > I want to skip certain elements in my xml because they do not correspond to
any structure in the database and map the child to a table in the database. I am
not sure whether or not that can be done with the InlineMap tag. Here is the
partial structure of my xml :
> > ************************************************************
> > <?xml version="1.0" encoding="utf-8" ?>
> > <storedHU xmlns:aml="http://www.atlasti.com/hu/ns2003"
> > lastSaved="2008-09-15T14:28:34" creator="ATLAS.ti" method="AML (ATLAS Markup
Language)" version="WIN 5.2 (Build 0)">
> >
> > <hermUnit name="masterFLOSSFireandGaimHU09072008" au="Super"
cdate="2007-06-18T20:20:52" mdate="2008-09-08T22:36:17" lastPD="816"
prot="private" />
> > <coAuthors>
> > <coAuthor name="coAuthor1">
> > </coAuthor>
> > </coAuthors>
> >
> > <dataSources size="2" >
> > <dataSource id="1"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2004-06-23-18-10-00-37-3216.txt"
mime="text/plain" />
> > <dataSource id="2"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2006-01-26-04-30-00-37-7064.txt"
mime="text/plain" />
> > </dataSources>
> > **************************************************************
> >
> > In the above xml, storedHU and hermUnit correspond to their respective
tables. There is no table corresponding to the dataSources element however, I
want to insert data into the datasource table in the database. Is there any way
by which this can be done? I went through the FAQs and related posts in the
group and accordingly tried to play around with the <InlineMap> tag. However, no
avail.
> >
> > Any help in this regard would be appreciated.
> >
> > Many thanks in anticipation.
> >
> > Ruchika Israni
> >
> >
> >
> > ------------------------------------
> >
> > To post a message, send it to: xml-dbms@yahoogroups.com
> > To unsubscribe, send a blank message to: xml-dbms-unsubscribe@...! Groups
Links
> >
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > No virus found in this incoming message.
> > Checked by AVG - www.avg.com
> > Version: 8.5.339 / Virus Database: 270.12.40/2135 - Release Date: 05/26/09
08:53:00
> >
>

#3857 From: Ronald Bourret <rpbourret@...>
Date: Tue Jun 2, 2009 5:58 am
Subject: Re: Re: Use of InlineMap Element
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

1) If you can, you should redesign your XML so that dataSources is not a
child of storedHU. The current design is misleading, as it implies a
hierarchical relationship between storedHU and dataSources/dataSource.
This might confuse other people who work with your data. In the new
design, you could create a new root element that is a parent of both
storedHU and dataSources.

2) The dataSource element only needs a ClassMap element in your map
document. It does not need a RelatedClass or InlineMap element.

a) If you redesign your XML so dataSources is a sibling of storedHU, you
do not need to do anything else.

b) If you do not redesign your XML, you will need to create an XSLT
stylesheet that transforms your XML document before you pass it to
XML-DBMS. This XSLT stylesheet will create a new root element with
dataSources and storedHU as children. This is because XML-DBMS assumes
that hierarchical relationships in an XML document always match
hierarchical relationships in the database.

Sibling relationships in the XML document -- such as between dataSources
and storedHU in the transformed document -- result in data stored in
separate, unrelated tables in the database.

Note that you do not need to map the dataSources element. For more
information, see http://www.rpbourret.com/xmldbms/faqs/process.htm.

3) Do you need to transfer the value of the dataSources/@size attribute
to the database? Because there is no table in the database that
corresponds to dataSources, I am guessing you do not.

-- Ron

Ruchika Israni wrote:
> Thank you for your reply Ron.
>
> Actually, my problem is there is no parent-child relationship between storedHU
and dataSource. Also, there are many such elements (like dataSources) having
size as their attribute.
>
> Is there any way by which this can be accomplished?
>
> Thanks.
> Ruchika Israni
>
> --- In xml-dbms@yahoogroups.com, Ronald Bourret <rpbourret@...> wrote:
>> Hello,
>>
>> Yes, you can use the InlineMap element for this.
>>
>> For example, the ClassMap element for storedHU would look something like
>> this:
>>
>> <ClassMap>
>>     <ElementType Name="storedHU" />
>>     <ToClassTable Name="STOREDHUTABLE" />
>>     ... PropertyMap elements for lastSaved, creator, method, version ...
>>     <InlineMap>
>>        <ElementType Name="dataSources" />
>>        <RelatedClass KeyInParentTable="Unique">
>>           <ElementType Name="dataSource" />
>>           <UseUniqueKey Name="..." />
>>           <UseForeignKey Name="..." />
>>        </RelatedClass>
>>     </InlineMap>
>>     <RelatedClass KeyInParentTable="Unique">
>>        <ElementType Name="hermUnit" />
>>        <UseUniqueKey Name="..." />
>>        <UseForeignKey Name="..." />
>>     </RelatedClass>
>> </ClassMap>
>>
>> The InlineMap element tells XML-DBMS to ignore the dataSources element
>> and treat its children and attributes as if they were part of the
>> storedHU element. This would be the same as mapping the following XML:
>>
>>     <storedHU ...other attributes... size="2" >
>>        <hermUnit ...other attributes... />
>>        <coAuthors>
>>           <coAuthor name="coAuthor1"></coAuthor>
>>        </coAuthors>
>>        <dataSource id="1" loc="..." mime="..." />
>>        <dataSource id="2" loc="..." mime="..." />
>>        ...
>>
>> Notes:
>>
>> 1) The dataSources/@size attribute is treated as if it were an attribute
>> of storedHU. If you wanted to map it to a column in the STOREDHUTABLE,
>> you would do this with a PropertyMap element inside the InlineMap element.
>>
>> 2) You can also use the InlineMap element to ignore the coAuthors element.
>>
>> 3) You will need a ClassMap element for the dataSource element.
>>
>> Hope this helps,
>>
>> -- Ron
>>
>> Ruchika Israni wrote:
>>> Hi Ron,
>>>
>>> I want to skip certain elements in my xml because they do not correspond to
any structure in the database and map the child to a table in the database. I am
not sure whether or not that can be done with the InlineMap tag. Here is the
partial structure of my xml :
>>> ************************************************************
>>> <?xml version="1.0" encoding="utf-8" ?>
>>> <storedHU xmlns:aml="http://www.atlasti.com/hu/ns2003"
>>> lastSaved="2008-09-15T14:28:34" creator="ATLAS.ti" method="AML (ATLAS Markup
Language)" version="WIN 5.2 (Build 0)">
>>>
>>> <hermUnit name="masterFLOSSFireandGaimHU09072008" au="Super"
cdate="2007-06-18T20:20:52" mdate="2008-09-08T22:36:17" lastPD="816"
prot="private" />
>>> <coAuthors>
>>> <coAuthor name="coAuthor1">
>>> </coAuthor>
>>> </coAuthors>
>>>
>>> <dataSources size="2" >
>>> <dataSource id="1"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2004-06-23-18-10-00-37-3216.txt"
mime="text/plain" />
>>> <dataSource id="2"
loc="&lt;HUPATH&gt;\FLOSS\Docs\gaim-sample\gaim-2006-01-26-04-30-00-37-7064.txt"
mime="text/plain" />
>>> </dataSources>
>>> **************************************************************
>>>
>>> In the above xml, storedHU and hermUnit correspond to their respective
tables. There is no table corresponding to the dataSources element however, I
want to insert data into the datasource table in the database. Is there any way
by which this can be done? I went through the FAQs and related posts in the
group and accordingly tried to play around with the <InlineMap> tag. However, no
avail.
>>>
>>> Any help in this regard would be appreciated.
>>>
>>> Many thanks in anticipation.
>>>
>>> Ruchika Israni

#3858 From: Ronald Bourret <rpbourret@...>
Date: Tue Jun 2, 2009 6:16 am
Subject: New FAQ
xmldbms
Offline Offline
Send Email Send Email
 
Hi,

I've added a new FAQ:

     http://www.rpbourret.com/xmldbms/faqs/process.htm

This describes what (possibly discontiguous) parts of an XML document
can be transferred to the database using XML-DBMS.

-- Ron

#3859 From: "Ruchika Israni" <israniruchika@...>
Date: Wed Jun 3, 2009 7:13 pm
Subject: Out of memory error while importing large xml files
israniruchika
Offline Offline
Send Email Send Email
 
Hi all,

I am using a xml which is 3.08 MB in size. I am running the transfer tool and am
getting the following error. I read somewhere in the previous posts that DOM
parser creates the entire tree from the XML which poses a problem for large xml
files. Is it possible to perhaps use the SAX parser in place of the DOM parser ?

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
         at org.apache.xerces.dom.DeferredDocumentImpl.getNodeObject(Unknown Sour
ce)
         at org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(Unknow
n Source)
         at org.apache.xerces.dom.DeferredElementNSImpl.synchronizeChildren(Unkno
wn Source)
         at org.apache.xerces.dom.ParentNode.getFirstChild(Unknown Source)
         at org.xmlmiddleware.xmlutils.DOMNormalizer.getFirstChild(DOMNormalizer.
java:123)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processChildren(DOMToDBMS.java:60
5)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:54
4)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processRow(DOMToDBMS.java:881)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processFKNodes(DOMToDBMS.java:946
)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:56
6)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processRoot(DOMToDBMS.java:447)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:368)

         at org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:317)

         at org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transf
er.java:840)
         at org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:
479)
         at org.xmlmiddleware.xmldbms.tools.Transfer.dispatchStoreDocument(Transf
er.java:696)
         at org.xmlmiddleware.xmldbms.tools.Transfer.dispatch(Transfer.java:434)
         at org.xmlmiddleware.xmldbms.tools.Transfer.main(Transfer.java:353)

Many thanks in anticipation.
Ruchika Israni

#3860 From: Ronald Bourret <rpbourret@...>
Date: Wed Jun 3, 2009 8:33 pm
Subject: Re: Out of memory error while importing large xml files
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

XML-DBMS does not support SAX because linear processing of documents is
possible only in specific cases. (It is very easy to create an XML
document whose data cannot be transferred to the database in a linear
manner.)

Because of this, you have several choices:

1) Increase the amount of memory Java uses using the -Xmx switch on the
java command. For details, see:

     http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/java.html

Because DOM trees are 5-10 times as large as XML documents, setting
memory usage to 50MB should solve your problem. This is the easiest
solution to your problem.

2) Cut the document into smaller pieces with SAX and pass these pieces
to XML-DBMS as DOM trees. This only works with certain types of
documents. For details, see:

     http://www.rpbourret.com/xmldbms/faqs/large.htm

3) Use a different tool. For example, you could use DataDirect XQuery,
which can store XML documents in a relational database and also
implements XQuery over relational data. Other options are HiT Allora and
XQuare Bridge. (I don't know how well these products work with large XML
documents.)

-- Ron

Ruchika Israni wrote:
> Hi all,
>
> I am using a xml which is 3.08 MB in size. I am running the transfer tool and
am getting the following error. I read somewhere in the previous posts that DOM
parser creates the entire tree from the XML which poses a problem for large xml
files. Is it possible to perhaps use the SAX parser in place of the DOM parser ?
>
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
>         at org.apache.xerces.dom.DeferredDocumentImpl.getNodeObject(Unknown
Sour
> ce)
>         at
org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(Unknow
> n Source)
>         at
org.apache.xerces.dom.DeferredElementNSImpl.synchronizeChildren(Unkno
> wn Source)
>         at org.apache.xerces.dom.ParentNode.getFirstChild(Unknown Source)
>         at
org.xmlmiddleware.xmlutils.DOMNormalizer.getFirstChild(DOMNormalizer.
> java:123)
>         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processChildren(DOMToDBMS.java:60
> 5)
>         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:54
> 4)
>         at org.xmlmiddleware.xmldbms.DOMToDBMS.processRow(DOMToDBMS.java:881)
>         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processFKNodes(DOMToDBMS.java:946
> )
>         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:56
> 6)
>         at org.xmlmiddleware.xmldbms.DOMToDBMS.processRoot(DOMToDBMS.java:447)
>         at
org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:368)
>
>         at
org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:317)
>
>         at
org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transf
> er.java:840)
>         at
org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:
> 479)
>         at
org.xmlmiddleware.xmldbms.tools.Transfer.dispatchStoreDocument(Transf
> er.java:696)
>         at
org.xmlmiddleware.xmldbms.tools.Transfer.dispatch(Transfer.java:434)
>         at org.xmlmiddleware.xmldbms.tools.Transfer.main(Transfer.java:353)
>
> Many thanks in anticipation.
> Ruchika Israni

#3861 From: "Ruchika Israni" <israniruchika@...>
Date: Wed Jun 3, 2009 6:53 pm
Subject: Out of memory error while loading large xml.
israniruchika
Offline Offline
Send Email Send Email
 
Hi all,

I have a xml which is 3.08 MB in size. While I run the Transfer tool of
XML-DBMS, it gives me the following error. I read in previous posts that the DOM
parser builds the entire tree in the memory. Is there any option by which the
memory can be used more effectively? Can we perhaps replace the DOM parser with
SAX parser ?

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
         at org.apache.xerces.dom.DeferredDocumentImpl.getNodeObject(Unknown Sour
ce)
         at org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(Unknow
n Source)
         at org.apache.xerces.dom.DeferredElementNSImpl.synchronizeChildren(Unkno
wn Source)
         at org.apache.xerces.dom.ParentNode.getFirstChild(Unknown Source)
         at org.xmlmiddleware.xmlutils.DOMNormalizer.getFirstChild(DOMNormalizer.
java:123)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processChildren(DOMToDBMS.java:60
5)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:54
4)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processRow(DOMToDBMS.java:881)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processFKNodes(DOMToDBMS.java:946
)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:56
6)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.processRoot(DOMToDBMS.java:447)
         at org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:368)

         at org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:317)

         at org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transf
er.java:840)
         at org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:
479)
         at org.xmlmiddleware.xmldbms.tools.Transfer.dispatchStoreDocument(Transf
er.java:696)
         at org.xmlmiddleware.xmldbms.tools.Transfer.dispatch(Transfer.java:434)
         at org.xmlmiddleware.xmldbms.tools.Transfer.main(Transfer.java:353)

Many thanks.
Ruchika Israni

#3862 From: "Ruchika Israni" <israniruchika@...>
Date: Thu Jun 4, 2009 4:01 am
Subject: Re: Out of memory error while importing large xml files
israniruchika
Offline Offline
Send Email Send Email
 
Thank You Ron. I included -Xmx option into the command and it worked.

Thanks once again.

Ruchika Israni


--- In xml-dbms@yahoogroups.com, Ronald Bourret <rpbourret@...> wrote:
>
> Hello,
>
> XML-DBMS does not support SAX because linear processing of documents is
> possible only in specific cases. (It is very easy to create an XML
> document whose data cannot be transferred to the database in a linear
> manner.)
>
> Because of this, you have several choices:
>
> 1) Increase the amount of memory Java uses using the -Xmx switch on the
> java command. For details, see:
>
>     http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/java.html
>
> Because DOM trees are 5-10 times as large as XML documents, setting
> memory usage to 50MB should solve your problem. This is the easiest
> solution to your problem.
>
> 2) Cut the document into smaller pieces with SAX and pass these pieces
> to XML-DBMS as DOM trees. This only works with certain types of
> documents. For details, see:
>
>     http://www.rpbourret.com/xmldbms/faqs/large.htm
>
> 3) Use a different tool. For example, you could use DataDirect XQuery,
> which can store XML documents in a relational database and also
> implements XQuery over relational data. Other options are HiT Allora and
> XQuare Bridge. (I don't know how well these products work with large XML
> documents.)
>
> -- Ron
>
> Ruchika Israni wrote:
> > Hi all,
> >
> > I am using a xml which is 3.08 MB in size. I am running the transfer tool
and am getting the following error. I read somewhere in the previous posts that
DOM parser creates the entire tree from the XML which poses a problem for large
xml files. Is it possible to perhaps use the SAX parser in place of the DOM
parser ?
> >
> > Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
> >         at org.apache.xerces.dom.DeferredDocumentImpl.getNodeObject(Unknown
Sour
> > ce)
> >         at
org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(Unknow
> > n Source)
> >         at
org.apache.xerces.dom.DeferredElementNSImpl.synchronizeChildren(Unkno
> > wn Source)
> >         at org.apache.xerces.dom.ParentNode.getFirstChild(Unknown Source)
> >         at
org.xmlmiddleware.xmlutils.DOMNormalizer.getFirstChild(DOMNormalizer.
> > java:123)
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processChildren(DOMToDBMS.java:60
> > 5)
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:54
> > 4)
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processRow(DOMToDBMS.java:881)
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processFKNodes(DOMToDBMS.java:946
> > )
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:56
> > 6)
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.processRoot(DOMToDBMS.java:447)
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:368)
> >
> >         at
org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:317)
> >
> >         at
org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transf
> > er.java:840)
> >         at
org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:
> > 479)
> >         at
org.xmlmiddleware.xmldbms.tools.Transfer.dispatchStoreDocument(Transf
> > er.java:696)
> >         at
org.xmlmiddleware.xmldbms.tools.Transfer.dispatch(Transfer.java:434)
> >         at org.xmlmiddleware.xmldbms.tools.Transfer.main(Transfer.java:353)
> >
> > Many thanks in anticipation.
> > Ruchika Israni
>

#3863 From: "jazzgeir" <asgeir.nesoen@...>
Date: Mon Sep 7, 2009 1:31 pm
Subject: UpdateOrInsert action...
jazzgeir
Offline Offline
Send Email Send Email
 
I'm using xml-dbms in a project where I want researchers to be able to update
and insert data in the database by way of XML-DBMS, preferrably both updating
and inserting using the same mapping file.

Typical process: Export a material to xml, edit xml with xml editor, upload to
DB.

Another typical process: Start writing a new XML file and upload to DB.

It is very convenient to use the very same mapping file to make sure there is a
well-defined XML structure

I've been experimenting a bit with the different actions, and found out,
eventually that UpdateOrInsert is quite flexible, but there are a couple of
things that look strange to me.

First of all, when updating, if you leave out properties or attributes from the
XML, these are set to "NULL" in DB when importing back. I find this unnatural,
wouldn't it be better to update just the fields given in XML instead of setting
the non-existing columns = NULL? Or will I have to make a separate mapping file
for entering new data opposed to editing data? Editing data always include
entering new data anyway, so it is not feasable to separate the two...

Next, if you're using an auto incremented primary key, and leave out the primary
key from the XML data, and import again, the record is still updated if all the
columns are equal to the referred row, like I said even if the key is not given
in XML. And I get errors like "data changed"... It would be nice to get an
explanation of when records are updated, and when they are inserted when using
the UpdateOrInsert action for a given table...

As soon as I start importing newly entered new records (i.e. records not present
in DB) in XML, I get the error "Couldn't retrieve inserted row due to changed
values.". I can't specify the primary key, since this is generated by the DB,
and the user would not have any idea of what to enter there anyway...

I will not post map, action and xml files here since they tend to get longish. I
can post fragments if neede, but I thought I'd start with asking a more general
question first...

---Asgeir---

#3864 From: Ronald Bourret <rpbourret@...>
Date: Thu Sep 17, 2009 7:09 am
Subject: Re: UpdateOrInsert action...
xmldbms
Offline Offline
Send Email Send Email
 
Hello,

Sorry it has taken so long to reply. See my answers below.

-- Ron

jazzgeir wrote:
> First of all, when updating, if you leave out properties or
> attributes from the XML, these are set to "NULL" in DB when
> importing back. I find this unnatural, wouldn't it be better to
> update just the fields given in XML instead of setting the
> non-existing columns = NULL? Or will I have to make a separate
> mapping file for entering new data opposed to editing data?
> Editing data always include entering new data anyway, so it is
> not feasable to separate the two...

UpdateOrInsert means that XML-DBMS will first attempt the update the row
in the database. If no row is found, then will insert a new row.

Because XML-DBMS might insert a new row, the document must represent the
complete current state of the data. (If the document did not have
complete data, it would not make sense to insert new rows.) When
data is missing from the document, this corresponds to a NULL in the
database.

If the document only represents some of the data in the database, then
you should use the Update action. With the Update action, the action
document specifies which elements and attributes contain updated data.
For example, if you change only the Address child of the Customer
element, you would use the following action document:

     <Actions>
        <Action>
           <ElementType Name="Customer" />
           <Update>
              <ElementType Name="Address" />
           </Update>
        </Action>
     </Actions>

In this case, if the Address child is missing, XML-DBMS will know to set
the value of the corresponding column to NULL. If any other children are
missing, they will be ignored (and their columns not set to NULL). This
is because you did not tell XML-DBMS to update those columns.

Thus, you can use the Update action with a complete document -- that is,
a document containing all of the data. Or you can use it with a document
that contains only the updated data (and enough structure to find that
data in the database).

Thus, you have two choices:

1) Use UpdateOrInsert and make sure that the document contains all of
the data. In this case, missing data corresponds to NULLs in the
database. (This would happen if the data was originally NULL or a
researcher deleted the data.) This is the easiest solution.

2) Use an xmldiff program to determine what data was changed. (You will
need a copy of the document before it was edited; you will compare this
to the edited document.) Using this information, determine which fields
were changed and generate an action document that specifies which fields
to change in the database. Use this action document with the Update action.

Note that this will work only if the document contains a single set of
data. (A single set of data might span multiple tables.) If the document
contains multiple sets of data, it is likely that different fields were
changed in different data sets. In this case, you cannot create a single
action document that will contain the correct fields to update, since
these are different for different parts of the document.

Can you explain what kind of data you are using and why the documents do
not contain complete data?

> Next, if you're using an auto incremented primary key, and leave out
  > the primary key from the XML data, and import again, the record is
  > still updated if all the columns are equal to the referred row, like
  > I said even if the key is not given in XML. And I get errors like
  > "data changed"...

I don't know what is happening here. The code tries to update the row
using the primary key. Because the primary key is not in the XML
document, it will use a primary key value of NULL. This update will fail
-- there are no rows with a NULL primary key -- so it will insert a new
row of data.

The solution to this problem is to include the primary key in the data.
Without the primary key, XML-DBMS cannot identify the row to be updated.

> It would be nice to get an explanation of when
  > records are updated, and when they are inserted when using the
  > UpdateOrInsert action for a given table...

I agree. However, this is far beyond the current capabilities of
XML-DBMS. If you want to modify the code, I can give you some ideas of
what to do. However, this is not an easy change.

> As soon as I start importing newly entered new records (i.e. records
  > not present in DB) in XML, I get the error "Couldn't retrieve
  > inserted row due to changed values.". I can't specify the primary
  > key, since this is generated by the DB, and the user would not have
  > any idea of what to enter there anyway...

I'm not sure what is happening here either.

When you use keys generated by the database, XML-DBMS needs to retrieve
the generated key value from the database. It inserts this value into
child rows as a foreign key.

Some databases have a special JDBC method that returns the generated
key. To use these methods, you need to implement the DataHandler
interface -- usually by extending the DataHandlerBase class and
implementing the insert method. (For example, see
org.xmlmiddleware.xmldbms.datahandlers.external.PostgresHandler.)

XML-DBMS provides an implementation of DataHandler called
GenericHandler, which is what you are using. To retrieve the generated
key, GenericHandler tries to retrieve the row just inserted by executing
a SELECT statement. The WHERE clause of the SELECT statement contains
all of the values that are not in primary key or unique key columns.

The error you are getting occurs when this SELECT statement fails. That
is, it can't find the row it just inserted. (The error message does not
make sense...) I do not know why this is failing. Could you check that
the row was actually inserted?

Note that JDBC 3.0 has a method for retrieving database-generated keys.
If you are using a JDBC 3.0 or later driver, the best solution would be
to implement the DataHandler interface and use this method. For a
partial implementation, see
org.xmlmiddleware.xmldbms.datahandlers.external.JDBC3Handler.

Messages 3835 - 3864 of 3864   Oldest  |  < Older  |  Newer >  |  Newest
Advanced
Add to My Yahoo!      XML What's This?

Copyright 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help