Jump to content

Import XML exported from Indesign


Corys

This topic is 7358 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hoping someone here can help me..I know almost nothing about XML/XSLT, and am trying to import a very very simple XML doc into filemaker..

this is what my XML file looks like

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

<Root>

<plate_code>34-101</plate_code>

<plate_code>34-101</plate_code>

<plate_code>34-103</plate_code>

</Root>

I just want the plate code to be entered into a field within filemaker while importing.

guessing I need an XSLT to do that?

any help would be appreciated!

thanks

Link to comment
Share on other sites

<?xml version='1.0' encoding='UTF-8' ?>

<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output version='1.0' encoding='UTF-8' indent='no' method='xml' />

<xsl:template match='/'>

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

<ERRORCODE>0</ERRORCODE>

<PRODUCT BUILD="11/13/2002" NAME="FileMaker Pro" VERSION="6.0v4"/>

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

<METADATA>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Plate_code" TYPE="TEXT"/>

</METADATA>

<RESULTSET FOUND="">

<xsl:for-each select="Root/plate_code">

<ROW MODID="" RECORDID="">

<COL><DATA><xsl:value-of select="." /></DATA></COL>

</ROW>

</xsl:for-each>

</RESULTSET>

</FMPXMLRESULT>

</xsl:template>

</xsl:stylesheet>

Plate_codeXML.zip

Link to comment
Share on other sites

As far as books, the code I posted is a modification of code from the example files that come with "Filemaker Pro 6 Developer's Guide to Xml/Xsl" by Beverly Voth. This book is required reading to use XML with FileMaker. It is a little terse for XML newbies, and you're better off reading a plain jane XML book first.

Advanced FileMaker Pro 6 Web Development by Bob Bowers and Steve Lane also has substantial XML chapters. The two books compliment each other, because each uses a slightly different style of XML, which I would characterize as "linear" vs. "template-based" (I just made those up, but there is a difference, which confused me for a while anyway).

For tools, it matters which platform you're on. On Windows there are several XML editors available, several free (lucky dogs). I'm on Mac OS X, which has fewer. There are a few Java-based editors, which are of course multi-platform. I don't use these much, as yet (read on). They offer a great deal of functionality, but they are just slower and clunkier that OS X native apps.

Java-based examples are Morphon, EditiX, JEdit, Oxygen. All of them use the file navigation of Java, which is like Windows (95). Compared to OS X file navigation, enhanced by Default Folder, it seems medieval. XML often requires opening multiple small files, from various places. Traversing the entire hard drive to find each is painful. IMHO, this is one reason Java apps don't really catch on on Macs, because they don't have native navigation. There's also Elf XML Editor, which is built with Real Basic, hence closer to native. It's faster than Java, but less features, also older.

What I use is a combination of the text editor BBEdit, which is simply the best text editor; but it is correspondingly pricey ($150?). Its "light" version, TextWrangler, has most functionality you'd need, for $50. Both have support for several programming languages, with coloring (cute), incl. XML.

There is a version of the Tidy HTML-XML validation engine available as a BBEdit extension, for all flavors of BBEdit (as well as a stand-alone application). You can use it from the Tools menu of BBEdit to validate and indent your XML. Get the latest version.

There's also an application named Balthisar Tidy by James S. Derry which is good, with a more modern interface; but it doesn't have a BBEdit extension.

The full version has a wonderful feature called "Glossaries." These a small regular text files which can be arranged in folders, viewed hierarchially, then double-clicked to insert into the current document. Several people have developed glossaries, incl. one for XSL, which has many of the often-used phrases.

Which brings us to what I use as a rendering application, because the same person created the XSL glossary, Marc Liyanage. It is named TestXSLT, both it and the XSLT glossary are available free at: http://www.entropy.ch/software/macosx/

(As well as a easy installer for PHP)

TestXSLT is a wonderful program, hopefully the future direction of Mac software. You can put your XML in one tabbed window, your XSL in another, then choose to view the result as either Text, XML output, HTML output, FO output, or rendered as a web page! This last is possible because he has tied into the core HTML rendering that Safari uses.

You have your choice of 4 parsers, incl. Xalan, which is I think what FileMaker uses (but they all are about the same, except for speed). The error reporting is pretty good. If your code has an error (like mine usually does), then it will stop and tell you where, and a hint what. But it's not a "list" like Tidy will give you.

He has created a tie to BBEdit. If you open BBEdit files for the XML and XSL windows, then you can edit in BBEdit and saved changes will be passed to TestXSLT (which is a great parser, but a very plain editor). This combination gives you the best of both worlds.

It does not, however, view your XML as a true XML editor does, as structural element blocks (which can be clunky, but is useful on big complex files; which I don't write, yet). Only Java apps can do that.

One day there will be an awesome OS X native XML editor/parser/renderer for a reasonable price. But if there is one now I don't know it.

Link to comment
Share on other sites

For windows, I've heard that XML Spy is excellent (although extremely expensive). Microsoft Visual Studio also has a built in XML editor which is very nice and handy. It automatically formats the XML, and can also display the contents of the XML file in a data grid at the click of a button.

What did you think of Beverly Voth's book, Fenton? I own a copy and have been pretty dissappointed. It felt unorganized as I read it, jumping here and there but never really covering any issue very well. I'd have preferred it to cover XSL more carefully. I got a feeling of "here, look at this code; it works and you can use it" rather than "this code works because of the following principles: ...". I agree, if you're learning XML/XSL, this is probably not the best book (p/u a regular XSL book). But it does have a few useful reference points for FileMaker developers.

Link to comment
Share on other sites

I must preface any rejoinder by saying that I have read Beverly Voth's postings on an email list she used to be on for years, and corresponded with her personally, so I cannot be objective.

Also, I know this book was difficult and took a long time to write; I was waiting after publishing was delayed. I doubt if she's sold all that many either; FileMaker XML users are not a large buying public.

I know what you mean however. That's why I said one should read some beginner information about XML before you read it. It is not so much that it does not begin with the basics, but that it is somewhat terse (I said that too). Learning XML is like learning a foreign language. It all makes perfect sense, but is gibberish to you at first. It takes a while for it to sink in. You have to come back to it again and again.

XML is very different from programming languages. It's hard for me to describe how, as I'm no expert at either; I'm just a FileMaker guy trying to expand my abilities. It's a big subject, and it does have strict rules, which must be followed, or it doesn't work. So anyone describing it has to be careful. That's what I feel about her book. It's careful. It tells you about the rules.

It doesn't always tell, in detail, exactly why XML was written to be that way, and the ramifications for other different situations. I think that a book that did so would be at least a thousand pages long (which most of them are).

I also agree that I wished there were more and various examples of XSL, rather than say the examples of XHTML and CSS, the general web stuff. I already knew most of that, but didn't know the XSL. On the other hand, if you didn't know that stuff, you'd need to know it, because XSL can interweave it with that older markup. Beverly's a FileMaker web expert, so this content was expected; and it was well done.

I thought she carefully built up exactly what you would need to be using XSL to Import to or Export from FileMaker, as XML or HTML. This is the guts of the book, information that you will not see explained comprehensively anywhere else.

The other book I mentioned has XML transformations also, but not as extensive. It does however use the "template" based XSL method almost exclusively, which is different from Beverly's usual use of a more linear method. So I felt the books were complimentary. Because unless you understand both ways of matching you're going to be confused by different examples. I had to read a beginning XML book to get a clue about this, and he took several chapters to explain the difference (which I can't really, not easily).

It would be great to have more FileMaker XML books, an intermediate "FileMaker XSL Cookbook" with lots of real-world examples comes to mind. But who's going to write it? People with that kind of knowledge are busy, making a lot more money with less frustration than writing books for only a few other people (in book sales numbers).

Link to comment
Share on other sites

I personally think Beverly's book was great. I was introduced into XML and XSL as well as interweaving FileMaker with the web with this book. I thought it was easily understood if you read it from cover to cover. And yes, Beverly does try to correspond with many people and helped me for a long time. She is a very frequent poster in xml talk in the filemaker website.

One thing about this book to realize is that it focuses on importing xml with an xsl stylesheet which is what xsl is primarily for. Although it can be used as a tool to web publish your database, I would not reccommend it. I have spent the last 5 months on a project using xsl and I believe now that if I would have started on it using a middleware scripting language like php, I would have been done a long time ago.

Just an important note. XML is as Mariano said in a previous post, the next universal language. But xsl is not. It does have its uses, importing for example, but the real universal language is php. I see a number of people posting in this forum looking for a web-based solution using xsl and xml. I know it is only my opinion but I will say this, look into another solution.

I agree with Fenton, there should definitly be more examples of xsl. Why don't we start a collection of sample xsl files in this forum? That way someone could browse the collection and could save valuable time.

Justin Grewe

Link to comment
Share on other sites

I thought Beverly's book was great also. It did however make me realize that I did not completely understand the basic mechanism of XSL. I later got a beginners book, Sams "Teach Yourself XSLT in 21 Days," which, somewhat to my surpise, was excellent. He, Michiel van Otegem, spent several chapters explaining the 2 ways this mechanism works. This made many things clear, as people tend to use one mechanism or the other, or even mix them. Without understanding this, you will continually either get more or less data returned than you expect (or none :-). It's kind of an old book, however.

Beverly tends to use the "linear" method, using "<xsl:for-each select=".">," whereas Bob Bowers tends to use "<xsl:apply-templates/>" method, with templates at the bottom of the page. That's why the books are so complementary. They do their XSL entirely different.

I agree that XSL has limited applications. Its processing "all at once" and "variables keep the value they were assigned" would make some operations harder than with a programming language, or with FileMaker, which is similar to a programming language (within its limitations). XSL seems well suited for transformations of text, import and export; though even there, AppleScript and a text editor would do better at some things. I guess it partly depends on which you know best.

PHP seems very flexible. But talk about a learning curve. It's a real programming language, not too hard to just read the basics, but oh my; there's hundreds of functions. Probably you don't need most of them for basic web work however.

The developer who knew when to use each of the different languages in combination with each other and with FileMaker would be one smart guy.

I'm afraid I don't yet have many XSL templates that would be of much use to anyone else. The more general ones I do have are often modifications of other people's files, so I can't really post them as my own. I'm more at the "copy the good stuff from the guys who know it, and mess around with it" stage of XSL.

Link to comment
Share on other sites

This topic is 7358 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.