Loading ...
Sorry, an error occurred while loading the content.

Re: [xml-dbms] Re: Use of InlineMap Element

Expand Messages
  • Ronald Bourret
    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
    Message 1 of 4 , Jun 1, 2009
    • 0 Attachment

      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="<HUPATH>\FLOSS\Docs\gaim-sample\gaim-2004-06-23-18-10-00-37-3216.txt" mime="text/plain" />
      >>> <dataSource id="2" loc="<HUPATH>\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
    Your message has been successfully submitted and would be delivered to recipients shortly.