Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...On your site I feel quite confident that the contacts and feedback will make my life a little less hectic..."

Geography

Where in the world do Tek-Tips members come from?
CryoGen (MIS)
15 Aug 07 16:11
OK, I'm fairly new to XML and FileMaker.  I keep getting an error:  "XML Parsing Error:  The main document cannot be empty".  I'm a little fuzzy on the syntax.

The import I'm trying to accomplish has three parts:  the FMP database, an XML output file from a third-party program that churns out the file names in a given Windows XP directory, and an XSL stylesheet that is supposed to transform the XML file to a workable format.

To-Be-Imported XML File: xml_listing.xml

CODE

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hdlg:filesystem SYSTEM "http://www.hdlg.info/XML/filesystem.dtd">
<hdlg:filesystem xmlns:hdlg="http://www.hdlg.info/XML/filesystem">
   <hdlg:folder name="pdfs" url="file:/c:/pdfs/">
      <hdlg:file name="FEB248.pdf" size="17407400" type="unknown" url="file:/c:/pdfs/FEB248.pdf">
      </hdlg:file>
      <hdlg:file name="FEB249.pdf" size="13918425" type="unknown" url="file:/c:/pdfs/FEB249.pdf">
      </hdlg:file>
      <hdlg:file name="FEB250.pdf" size="38914" type="unknown" url="file:/c:/pdfs/FEB250.pdf">
      </hdlg:file>
      <hdlg:file name="FEB251.pdf" size="21109720" type="unknown" url="file:/c:/pdfs/FEB251.pdf">
      </hdlg:file>
      <hdlg:file name="FEB252.pdf" size="35559" type="unknown" url="file:/c:/pdfs/FEB252.pdf">
      </hdlg:file>
      <hdlg:file name="FEB253.pdf" size="7288156" type="unknown" url="file:/c:/pdfs/FEB253.pdf">
      </hdlg:file>
      <hdlg:file name="FEB254.pdf" size="11409973" type="unknown" url="file:/c:/pdfs/FEB254.pdf">
      </hdlg:file>
      <hdlg:file name="pdf_listing.html" size="7368" type="unknown" url="file:/c:/pdfs/pdf_listing.html">
      </hdlg:file>
      <hdlg:file name="xml_listing.xml" size="0" type="unknown" url="file:/c:/pdfs/xml_listing.xml">
      </hdlg:file>
   </hdlg:folder>
</hdlg:filesystem>

XSL Stylesheet: k4_import.xsl

CODE

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" method="xml"/>
    <xsl:template match="k4_file_names">
        <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
            <ERRORCODE>0</ERRORCODE>
            <PRODUCT BUILD="08-14-2007" NAME="FileMaker Pro" VERSION="8.0v3"/>
            <DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="k4_file_names.fp7" RECORDS="10" TIMEFORMAT="h:mm:ss a"/>
            <METADATA>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="size" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="type" TYPE="TEXT"/>
                <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="url" TYPE="TEXT"/>
            </METADATA>
            <RESULTSET FOUND="10">
                <xsl:for-each select="k4_file_names">
                    <ROW MODID="0" RECORDID="{position()}">
                        <COL>
                            <DATA>
                                <xsl:value-of select="name"/>
                            </DATA>
                        </COL>
                        <COL>
                            <DATA>
                                <xsl:value-of select="size"/>
                            </DATA>
                        </COL>
                        <COL>
                            <DATA>
                                <xsl:value-of select="type"/>
                            </DATA>
                        </COL>
                        <COL>
                            <DATA>
                                <xsl:value-of select="url"/>
                            </DATA>
                        </COL>
                    </ROW>
                </xsl:for-each>
            </RESULTSET>
        </FMPXMLRESULT>
    </xsl:template>
</xsl:stylesheet>

I thought I had everything formatted properly, but I guess not.  The database file has four fields: name, size, type and url.  Here is the XML file I want to import, and and XSL stylesheet I want to use to do the import.  I continue to get the error above.  I can't figure out what's wrong, so any help is appreciated.
philhege (Programmer)
17 Aug 07 13:04
The stylesheet is looking for an element named "k4_file_names", which I don't see in the XML document here.  Does FM do some sort of internal translation?

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
http://www.iimak.com
-----------
Pity the insomniac dyslexic agnostic.  He stays up all night, wondering if there really is a dog.

CryoGen (MIS)
18 Aug 07 14:39
No, it might have more to do with ignorance.  The stylesheet is calling "k4_file_names" ... which is the name of the database, but not the XML file.  Might I be better off by naming the XML file "k4_file_names.xml"?
philhege (Programmer)
18 Aug 07 20:37
The stylesheet directive <xsl:for-each select="k4_file_names"> normally searches an XML document for every instance of an element identified in the select attribute.

So if I have an XML file like

<root name="myinfo">
<k4_file_names directory="mydirectory">
<file name="whatever" size="148KB">
<file....
</k4_file_names>
.
.
.

The for-each directive would find every element "k4_file_names" and, from there, can perform XSL actions on the attributes (such as directory) and sub-elements (such as file) that are found.

As I said before, I'm not familiar with the way that FM manages XML.  Can the database generate an XML document or variable on which you can apply an XSL stylesheet?

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close