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

how do i map it?

Expand Messages
  • Rajiv Bhattacharya
    hi, I want to transfer a test.xml file data to the database. I am trying to write a map file for a test.xml file. Q1. how do i Map the and element
    Message 1 of 2 , Jul 20, 2005
    • 0 Attachment
      hi,
      I want to transfer a test.xml file data to the database.
      I am trying to write a map file for a test.xml file.

      Q1. how do i Map the <ip> and <addr> element types?

      Q2.I also dont know if xmldbms will work considering that the last 2nd
      <pint> </pint> doesnt have the <lint>---</lint> in it.

      The XML file is as follows:-
      -----------------------------------------------------------------------
      <info>
      <pint>
      <pname>P1</pname>
      <status>up</status>
      <lint>
      <lname>L1</lname>
      <desc>D1</desc>
      <traf>
      <ip>200</ip>
      </traf>
      <family>
      <int>
      <addr>192.1.3.5</addr>
      </int>
      </family>
      </lint>
      <lint>
      <lname>L2</lname>
      <desc>D2</desc>
      <traf>
      <ip>200</ip>
      </traf>
      <family>
      <int>
      <addr>10.19.13.15</addr>
      </int>
      </family>
      </lint>
      <lint>
      <lname>L3</lname>
      <desc>D3</desc>
      <family>
      <int>
      <addr>192.10.13.15</addr>
      </int>
      </family>
      </lint>
      </pint>
      <pint>
      <pname>P2</pname>
      <status>down</status>
      </pint>
      </info>
      ----------------------------------------------------------------------
      Th tables i have created are

      I. PINT
      with coloums PNAME and STATUS.
      PNAME is the primary key.

      II. LINT
      with coloums PNAME,LNAME,DESC,IP,ADDR.
      LNAME is the primary key.
      PNAME is the foreign key which refrences PINT table.

      I dont want to create more tables as it will scatter the data.
      ---------------------------------------------------------------------


      I have written part of the map file as follows:-
      -------------------------------------------------------------------

      <?xml version="1.0" ?>
      <!DOCTYPE XMLToDBMS SYSTEM "./xmldbms.dtd">
      <XMLToDBMS Version="1.0">
      <Maps>
      <IgnoreRoot>
      <ElementType Name="info"/>
      <PseudoRoot>
      <ElementType Name="pint"/>
      </PseudoRoot>
      </IgnoreRoot>
      <ClassMap>
      <ElementType Name="pint"/>
      <ToClassTable>
      <Table Name="PINT"/>
      </ToClassTable>
      <PropertyMap>
      <ElementType Name="pname"/>
      <ToColumn>
      <Column Name="PNAME"/>
      </ToColumn>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="status"/>
      <ToColumn>
      <Column Name="STATUS"/>
      </ToColumn>
      </PropertyMap>
      <RelatedClass KeyInParentTable="Candidate">
      <ElementType Name="lint"/>
      <CandidateKey Generate="No">
      <Column Name="lname"/>
      </CandidateKey>
      <ForeignKey>
      <Column Name="pname"/>
      </ForeignKey>
      </RelatedClass>
      </ClassMap>
      <ClassMap>
      <ElementType Name="lint"/>
      <ToClassTable>
      <Table Name="LINT"/>
      </ToClassTable>
      <PropertyMap>
      <ElementType Name="lname"/>
      <ToColumn>
      <Column Name="LNAME"/>
      </ToColumn>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="desc"/>
      <ToColumn>
      <Column Name="DESC"/>
      </ToColumn>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="ip"/>
      <ToColumn>
      <Column Name="IP"/>
      </ToColumn>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="addr"/>
      <ToColumn>
      <Column Name="ADDR"/>
      </ToColumn>
      </PropertyMap>
      </ClassMap>
      </Maps>
      </XMLToDBMS>

      ---------------------------------------------------------------------
      I have to meet a deadline.Could anyone guide me as to what change do i
      have to make in my map file.

      Thanks,
      -Rajiv
    • Ronald Bourret
      Hello, Sorry I never replied to your earlier messages. I was on vacation and have been busy with other projects. I assume you figured out the answers? 1) The
      Message 2 of 2 , Jul 20, 2005
      • 0 Attachment
        Hello,

        Sorry I never replied to your earlier messages. I was on vacation and
        have been busy with other projects. I assume you figured out the answers?

        1) The map file you show below is correct except as follows. The
        RelatedClass element should be:

        <RelatedClass KeyInParentTable="Candidate">
        <ElementType Name="lint"/>
        <CandidateKey Generate="No">
        <!-- Change name from lname to PNAME -->
        <Column Name="PNAME"/>
        </CandidateKey>
        <ForeignKey>
        <!-- Change name from pname to PNAME -->
        <Column Name="PNAME"/>
        </ForeignKey>
        </RelatedClass>
        </ClassMap>

        2) In answer to your question 1, the property maps for ip and addr won't
        work. The reason for this is that there are other elements wrapping the
        ip and addr elements. You have two choices:

        a) If you use XML-DBMS version 1.x, you will need to use XSLT to
        transform lint elements to the following before inserting the data. That
        is, you will need to remove the traf, family, and int elements.

        <lint>
        <lname>L1</lname>
        <desc>D1</desc>
        <ip>200</ip>
        <addr>192.1.3.5</addr>
        </lint>

        Similarly, when retrieving the data from the database, you will need to
        use XSLT to add the traf, family, and int elements after XML-DBMS
        constructs the XML document.

        b) Use XML-DBMS version 2.0 alpha 3 (available from
        http://www.rpbourret.com/xmldbms) and use the InlineMap element. For
        more information about the InlineMap element, see:

        http://groups.yahoo.com/group/xml-dbms/message/3345

        Personally, I think option (b) is a much better choice, as version 2.0
        has many more features than version 1.x.

        3) In answer to your question 2, the lack of lint elements in the second
        pint element is not a problem. The result will be that a row is
        inserted in the PINT table and no rows are inserted into the LINT table.

        -- Ron

        Rajiv Bhattacharya wrote:

        > hi,
        > I want to transfer a test.xml file data to the database.
        > I am trying to write a map file for a test.xml file.
        >
        > Q1. how do i Map the <ip> and <addr> element types?
        >
        > Q2.I also dont know if xmldbms will work considering that the last 2nd
        > <pint> </pint> doesnt have the <lint>---</lint> in it.
        >
        > The XML file is as follows:-
        > -----------------------------------------------------------------------
        > <info>
        > <pint>
        > <pname>P1</pname>
        > <status>up</status>
        > <lint>
        > <lname>L1</lname>
        > <desc>D1</desc>
        > <traf>
        > <ip>200</ip>
        > </traf>
        > <family>
        > <int>
        > <addr>192.1.3.5</addr>
        > </int>
        > </family>
        > </lint>
        > <lint>
        > <lname>L2</lname>
        > <desc>D2</desc>
        > <traf>
        > <ip>200</ip>
        > </traf>
        > <family>
        > <int>
        > <addr>10.19.13.15</addr>
        > </int>
        > </family>
        > </lint>
        > <lint>
        > <lname>L3</lname>
        > <desc>D3</desc>
        > <family>
        > <int>
        > <addr>192.10.13.15</addr>
        > </int>
        > </family>
        > </lint>
        > </pint>
        > <pint>
        > <pname>P2</pname>
        > <status>down</status>
        > </pint>
        > </info>
        > ----------------------------------------------------------------------
        > Th tables i have created are
        >
        > I. PINT
        > with coloums PNAME and STATUS.
        > PNAME is the primary key.
        >
        > II. LINT
        > with coloums PNAME,LNAME,DESC,IP,ADDR.
        > LNAME is the primary key.
        > PNAME is the foreign key which refrences PINT table.
        >
        > I dont want to create more tables as it will scatter the data.
        > ---------------------------------------------------------------------
        >
        >
        > I have written part of the map file as follows:-
        > -------------------------------------------------------------------
        >
        > <?xml version="1.0" ?>
        > <!DOCTYPE XMLToDBMS SYSTEM "./xmldbms.dtd">
        > <XMLToDBMS Version="1.0">
        > <Maps>
        > <IgnoreRoot>
        > <ElementType Name="info"/>
        > <PseudoRoot>
        > <ElementType Name="pint"/>
        > </PseudoRoot>
        > </IgnoreRoot>
        > <ClassMap>
        > <ElementType Name="pint"/>
        > <ToClassTable>
        > <Table Name="PINT"/>
        > </ToClassTable>
        > <PropertyMap>
        > <ElementType Name="pname"/>
        > <ToColumn>
        > <Column Name="PNAME"/>
        > </ToColumn>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="status"/>
        > <ToColumn>
        > <Column Name="STATUS"/>
        > </ToColumn>
        > </PropertyMap>
        > <RelatedClass KeyInParentTable="Candidate">
        > <ElementType Name="lint"/>
        > <CandidateKey Generate="No">
        > <Column Name="lname"/>
        > </CandidateKey>
        > <ForeignKey>
        > <Column Name="pname"/>
        > </ForeignKey>
        > </RelatedClass>
        > </ClassMap>
        > <ClassMap>
        > <ElementType Name="lint"/>
        > <ToClassTable>
        > <Table Name="LINT"/>
        > </ToClassTable>
        > <PropertyMap>
        > <ElementType Name="lname"/>
        > <ToColumn>
        > <Column Name="LNAME"/>
        > </ToColumn>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="desc"/>
        > <ToColumn>
        > <Column Name="DESC"/>
        > </ToColumn>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="ip"/>
        > <ToColumn>
        > <Column Name="IP"/>
        > </ToColumn>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="addr"/>
        > <ToColumn>
        > <Column Name="ADDR"/>
        > </ToColumn>
        > </PropertyMap>
        > </ClassMap>
        > </Maps>
        > </XMLToDBMS>
        >
        > ---------------------------------------------------------------------
        > I have to meet a deadline.Could anyone guide me as to what change do i
        > have to make in my map file.
        >
        > Thanks,
        > -Rajiv
        >
        >
        >
        >
        >
        >
        > 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
        >
        >
        >
        >
        >
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.