5 Replies Latest reply on Aug 20, 2010 8:24 AM by pguerett

    XML Schema questions

    davidpath

      Question 1:

      If I have a many to many relationship that I want to display within multiple tables.  Is there a straightforward way to bind that?

      An example would be an automobile that use similar parts (seats etc).  I dont think livecycle supports keys

      So the xml looks like

       

      <orderCatalog>

        <automobile>

           <modelNumber>auto1</modelNumber>

            ... year etc

        </automobile>

        <part>

               <partNo>part1</partNo>

        </part>

         <joinAutoPart>

                <modelNumber>auto1</modelNumber>

                <partNo>part1</partNo>

         </joinAutoPart>

      </orderCatalog>

       

      I would like to point this to

      Subform pointing to joinAutoPart

      Header field pointing to automobile (with model number and name)

      Table with part information pointing to partNo (with partName and partNo and price)

       

      That way I would have a table per automobile with all of the individual parts listed

       

      Question 2:

      Can reader load an xml file over the internet by pressing a button like loadXML?

       

      Question 3: non xml related

      Is there a way to save a link from a table row to another table row

       

      Using the above example if I had multiple auto tables with multiple parts.  The user selects a part which I add to an order table.

      I would like to highlight that field showing they have ordered the part and grey out the button.

      However, if they remove the item from their order I would like to add it back without having to search every field in every table to find the part number.

        • 1. Re: XML Schema questions
          pguerett Level 6

          Q1 - You can bind a node in your XML to multiple fields on your form....and the value of that node will show up in all of those places where it is bound. So PartNo in the data can be bound to multiple tables that have a partno.

           

          Q2 - No ....there is always a security concern when Reader has to go outside of its sandbox. You can get that XML file from a soap call then load it into the dom via commands but an xfa.importData command will not load anything without the user intervening (i.e. choosing the file). You can combine the data and form and the server ...if you are rendering through Form Server though....but once the form is rendered getting external resources can only be done through ODBC or SOAP.

           

          Q3 - There is nothing automatic ....you woudl have to do this through script. Add a row in the 2nd table, assign the values for each field that you want to move from Table 1 to Table 2, Remove the row from the 1st table.

           

          Make sense?

           

          Paul

          • 2. Re: XML Schema questions
            davidpath Level 1

            Thanks again for the response.

             

            Q1: If I have a join table - given that I have a many - to - many relation with multiple autos and multiple parts

            How do I connect the partNo to the description in the table from the xml

            If I create a table that I want to have

            <orderCatalog>

              <automobile>

                 <modelNumber>auto1</modelNumber>

                 <modelName>Mustang</modelName>

                  ... year etc

              </automobile>

              <part>

                     <partNo>part1</partNo>

                     <partName>Headrest</partName>

              </part>

               <joinAutoPart>

                      <modelNumber>auto1</modelNumber>

                      <partNo>part1</partNo>

               </joinAutoPart>

            </orderCatalog>

             

            Automobile Model #,  Make, ....

            ---------------------------------------

            PartNo |  Part Description | Order Button

             

            I can bind joinAutoPart table to the Automobile header, but how to I convert that to a text Model Name vs a number

            I can join PartNo to the entries of a table, but can I fill the descriptions of each

            I want to do select partdescription, colorOptions, etc from partTable where PartNo = part1 then use those values - using binding or xml syntax

             

            I can reform the xml from my data to be the following, but this requires a lot of duplicate data and is very error prone to have one part name or number that is one off

            <automobile>

                <partList>

                     <part>

                             <partNumber>part1<partNumber>

                             <partName>partName</partName>

                     </part>

                </partList>

            </automobile>

             

             

            Q2: ok

            Ideally, I would like to have a dropdown box where the user selects say a  model name.  Then it builds a list of tables from an xml file - so there are a few common tables - like t-shirts, coffee cups etc that would show up on every form and the rest are dynamic.

            For ODBC, am I correct in thinking that the link has to be established at the client to the server outside of reader before a connection can be made within reader?

             

            Q3:  I am doing the add programatically, but if I have a part number from a built xml with many tables - is there a way to identify which table it is coming from?

            I don't on the order form have  | ModelNumber | PartNumber, so I don't have an easy way to reference back. And if I did I would still have to do multiple linear searches.  I assume the performance wouldn't be too bad, but it is not pretty.

            i = 0;

            j=0;

            while(i < (ModelTableForm.count-1))

               if (xyz.resolveNode("foo[" + i + "]").modelNumberField.rawValue == modelNumber)

             

                      j = 0;

                     while(j< (abc.resolveNode("bar[" + i + "]").count-1))

                         if(abc.resolveNode("bar[" + i + "]").partNumberField.rawValue == partNo)

                                 abc.resolveNode("bar[" + i + "]").addButton.prescence="visible"

             

               i++;

             

             

            I was hoping for an extra field or way to extend the row object I could add referringNode or something to that effect and just say OrderRow.refferingNode.button.presence = "visible"

             

            I think I found one way to get around this.  I think I can create 0 width colums for indexes to the tables

            That way I could say  xyz.resolveNode("foo[" + modelIndex + "]").abc.resolveNode("bar[" + partIndex + "]")

            • 3. Re: XML Schema questions
              pguerett Level 6

              Q1 - Not sure that I follow (I am not a DB expert by any stretch) but my inderstanding is that the SQL command you

              come up with will return a certain XML structure and everything  you need must be somewhere in that structure. If you need something to appear in multipl places you should be able to bind the same node in the XML to multiple fields in the form.

               

              Q2 - Yes an DSN must be set up and accessible to the program from the OS before ODBC can be used. Also if you are using Reader then the form must be Reader extended. I do not recommend this. I would prefer a SOAP call to retrieve the information (no mods on the client needed) but you wil still have to Reader Extend to allow a soap call to be made.

               

              Q3 - short of keeping track of it yourself (i.e. write the soure for the row in a hidden field) I do not see a way for you to get this. You can get  access to the binding instruction and you may be able to parse that to get the source for this (note that you cannot modify it - read only). That will depend on how you setup your binding.

               

              Paul

              • 4. Re: XML Schema questions
                davidpath Level 1

                Q1:  Sorry if it was confusing, I was just using SQL as an example for how I would grab the data if I could get it from a database.  I have to get it from the XML and it doesn't accept SQL queries from what I can tell.

                Is the xml file is kept active in a DOM within reader?  Are there functions to access it?  so I can jump down it to get specific data, or build the tables?  I guess I thought the data was read in and the xml file was closed at the end.

                 

                Q2: I am not sure about the SOAP call I will have to see if we have the resources to configure it.  Does it handle failover?  - can I revert to a less complex form if it cannot make the connection?

                 

                Q3: answered

                • 5. Re: XML Schema questions
                  pguerett Level 6

                  Q1 - Yes when XML is loaded into the form it goes into a node called xfa.datasets.data. You can also load your own into your own area so it does not conflict with what the form is doing (highly recommended). There are a coomplete set of functions for dealing with the dom or you can create an E4X object in javascript and use the standard E4X tools to manipulate it.

                   

                  Q2 - Depends how you build it. If the SOAP call fails it will time out and you can trap it and report accordingly. Then you coudl continue in the form without that data (if you permit it).

                   

                  Paul