9 Replies Latest reply on Feb 18, 2010 12:44 PM by comment_1

    XML/XSLT Import Problem

    mgarcia

      Title

      XML/XSLT Import Problem

      Post

      Hello everyone,

       

      I'm fairly new to Filemaker and having trouble importing XML files. I'm trying to import XML generated from WinAudit, a free computer auditing software. I know that the file is not in the correct grammar for Filemaker so I've been trying to find an XSLT stylesheet that can allow me to easily import these files (as there are many computers that will need auditing).

       

      Basically, the XML from Winaudit looks like this:

       

      <?xml version="1.0" encoding="utf-8" standalone="yes"?>

      <computeraudit>

      <title>Computer Audit :: 2/15/2010 1:04:42 PM</title>

      <category title="System Overview">

      <subcategory title="">

      <recordset title="">

      <fieldname>Item</fieldname>

      <fieldname>Value</fieldname>

      <datarow>

      <fieldvalue>Computer Name</fieldvalue>

      <fieldvalue>INTERCAL</fieldvalue>

      </datarow>

      <datarow>

      <fieldvalue>Domain Name</fieldvalue>

      <fieldvalue>WORKGROUP</fieldvalue>

      </datarow>

       

      </recordset>

      </subcategory>

      </category>

      <disclaimer>Names mentioned herein maybe trademarks or service marks of their respective holders. Errors and Omissions Excepted. Generated by WinAudit Freeware v2.28.2</disclaimer>

      </computeraudit>


       

      I tried to use a stylesheet provided by Filemaker: mdso_elem.xslt. But Filemaker doesn't like it. I also don't have much experience with XML or XSLT so any information would be greatly appreciated.

       

      Also, I'm using Filemaker Pro 9 Advanced on Mac OSX.

       

      Thanks for the help,

      Mercedes 

        • 1. Re: XML/XSLT Import Problem
          comment_1
            

          An XSLT stylesheet must be custom-tailored to the source schema (and, of course, to Filemaker's FMPXMLRESULT schema on the output side). It also depends on what exactly you want to import, into what fields/records.

           

          The schema of your source is not quite clear to me: first, it declares fieldnames - but then all the fieldvalues come in name/value pairs, so I am not sure what would signify the beginning of a new record.

          • 2. Re: XML/XSLT Import Problem
            mgarcia
              

            I know it is a little weird. Each <datarow> should be a new record. I've tried writing this but I just don't know enough about XML/XSL. I have tried using something like this:

             

            <?xml version="1.0" encoding="utf-8"?>

            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.filemaker.com/fmpxmlresult">

            <xsl:template match="/">

            <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">

            <ERRORCODE>0</ERRORCODE>

            <PRODUCT BUILD="" NAME="" VERSION=""/>

            <DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="" RECORDS="0" TIMEFORMAT="h:mm:ss a"/>

            <METADATA>

            <FIELD>

            <xsl:attribute name="EMPTYOK">YES</xsl:attribute>

            <xsl:attribute name="MAXREPEAT">1</xsl:attribute>

            <xsl:attribute name="NAME">Computer Name</xsl:attribute>

            <xsl:attribute name="TYPE">TEXT</xsl:attribute>

            </FIELD>

            <FIELD>

            <xsl:attribute name="EMPTYOK">YES</xsl:attribute>

            <xsl:attribute name="MAXREPEAT">1</xsl:attribute>

            <xsl:attribute name="NAME">Domain Name</xsl:attribute>

            <xsl:attribute name="TYPE">TEXT</xsl:attribute>

            </FIELD>

            </METADATA>

            <RESULTSET>

            <xsl:attribute name="FOUND">0</xsl:attribute>

            <xsl:for-each select="/FMPReport/File/LayoutCatalog/Layout">

            <ROW>

            <xsl:attribute name="MODID">0</xsl:attribute>

            <xsl:attribute name="RECORDID">0</xsl:attribute>

            <COL>

            <DATA>

            <xsl:value-of select="@ComputerName"/>

            </DATA>

            </COL>

            <COL>

            <DATA>

            <xsl:value-of select="@DomainName"/>

            </DATA>

            </COL>

            </ROW>

            </xsl:for-each>

            </RESULTSET>

            </FMPXMLRESULT>

            </xsl:template>

            </xsl:stylesheet>

             

            Filemaker doesn't give me an error when I do this but it doesn't import anything either. I'm sorry if this question has been answered before. This seems like a common new person's problem.

             

            Thanks again. 

            • 3. Re: XML/XSLT Import Problem
              comment_1
                

              I am still not sure what you want as the result. If imported "as is" (i.e. each <datarow> is a record), you'll get two records:

               

              Item                Value
              Computer Name       INTERCAL
              Domain Name         WORKGROUP

               

               

               

              • 4. Re: XML/XSLT Import Problem
                mgarcia
                  

                Sorry for not specifying this from the beginning. So I have fields on filemaker that are "Computer Name", "Domain Name", etc. I only want to import the values of these and match the names to the fields that are already in the database.

                 

                Can I do this without having to rewrite the XML? 

                • 5. Re: XML/XSLT Import Problem
                  comment_1
                    

                  mgarcia wrote:

                  I have fields on filemaker that are "Computer Name", "Domain Name", etc.


                  I believe it should be possible to import the proper data into the two fields. I am not sure about the etc. part...


                  • 6. Re: XML/XSLT Import Problem
                    comment_1
                       Sorry, I should have added this:

                     

                    If "Computer Name" and "Domain Name" are fields, then it takes TWO datarows to make up a record - and there's no record separator in the XML source. That is, unless it's assumed that the entire document is a single record. It's always difficult to make such judgements based on a single example.

                    • 7. Re: XML/XSLT Import Problem
                      mgarcia
                         I only meant that the original document is much longer than those two fields. But that is essentially all I want to do for the entire document. I just want to import the values and the fields are already in Filemaker.
                      • 8. Re: XML/XSLT Import Problem
                        mgarcia
                          

                        I'm not sure how it needs two data rows for one record. Each data row has an item and a value:

                         

                        <datarow>

                        <fieldvalue>Computer Name</fieldvalue>

                        <fieldvalue>INTERCAL</fieldvalue>

                        </datarow> 

                         

                        And I just want to use the item name to match the field names in the database and then import the value data.

                        • 9. Re: XML/XSLT Import Problem
                          comment_1
                            

                          mgarcia wrote:

                          I'm not sure how it needs two data rows for one record.


                          "Computer Name" (and its value) is one datarow. "Domain Name" is another. If these are to be two fields in the same record, then it takes two datarows to make up one record.

                           

                           

                          I'd suggest you post a longer example, and also a list of the Filemaker fields that you want to import into.