Jump to content
Server Maintenance This Week. ×

Combine multiple XML exports with document()


smishler

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

Recommended Posts

I am doing XML exports from multiple tables and the resulting XML is working well when I concatenate the XML data into a single file. I have done a lot of reading here about exporting related tables from grandchild to parent and vice versa and it gets a bit over my head fairly quickly. Given where I'm at right now, it seems most efficient to use document() to combine these XML exports via XSLT but I haven't found any examples of how to do that. Could anyone share a simple example of that using FMPXMLRESULT? Thanks.

Link to comment
Share on other sites

Since posting this I may have found an example, though I can't say I understand it but I basically have the same issue that others have described here. I have 4 related tables and I need a found set of data from each table in the relationships. If I export the data as individual XML files (using separate XSLT stylesheets) the data is formatted exactly as the import application would like it. I can not give them multiple files so I concatenated it into a single file and it works fairly well.

If I go to atomic table I will get lots of duplication of fields from the parent tables. I was encouraged when I found this discussion: http://attic.fmforum...php?tid/214940/ specifically the quote shown here:

I have since found some examples of combining multiple XML docs into a single XML doc using XSLT such as here: http://www.abbeyworkshop.com/howto/xslt/document/index.html but I'm not sure this can be done as a scripted routine in FMP.

Since I've made so much progress in getting my XML export formatted properly with individual exports, I am reluctant to "start over" and try some sort of looping through related tables and somehow ignoring all the duplicated data (and most of the examples I have found here use FMPDSORESULT as they are older posts).

Here is the screen shot that did not get pasted into my reply above.

Link to comment
Share on other sites

I have 4 related tables and I need a found set of data from each table in the relationships.

Well, it depends on how the 4 tables are related. Also, it doesn't make much sense to consider the found set in each table; you probably want a found set in one table, along with all related records in other tables. Duplication of parent data can be removed by the stylesheet - it all depends on how you want your result to be structured. IOW, there are no off-the-rack solutions here - it must be tailor-made.

---

P.S. Your screenshot shows a "No Permission" sign.

Link to comment
Share on other sites

I changed the image permissions so hopefully you can see it now.

I follow you with regard to there being no off-the-rack solutions and you are right, I may have to crack this nut with a single found set export and use XSLT to remove the duplicate data, but it I was encouraged by the possibility that it would be possible to use XSLT to combine the multiple exports into a single XML file by references that it is possible.

Link to comment
Share on other sites

the possibility that it would be possible to use XSLT to combine the multiple exports into a single XML file by references that it is possible.

Yes, it is possible - provided the stylesheet used for the last export knows where to find the previously exported file/s. That shouldn't be difficult if the entire procedure is scripted. Whether it's the best method given your data and your intended result is another question.

Link to comment
Share on other sites

  • 2 weeks later...

HI all,

I'm now rolling up my sleeves on this and am so not getting very far, so I'm making an appeal to XSL gurus. I basically have 7 XML docs and I need to combine them into a single document (see linked zip file: the 7 docs plus ALL_COMBINED.xml).

I'm attempting to do this with document() and as far as I can tell I need to define an index.xml that lists all documents (except for the final one), and then include the code necessary to combine those 6 documents with the output of the final document to get something like ALL_COMBINED.xml.

I'm off to bury my head in Doug Tidwell's XSLT, but was hoping someone here could give me some guidance. I was able to produce stylesheets for the initial exports but this portion is getting very confusing. Thanks.

https://files.me.com/smishler/sinbe6

Link to comment
Share on other sites

as far as I can tell I need to define an index.xml that lists all documents

I don't think so.

I basically have 7 XML docs and I need to combine them into a single document (see linked zip file: the 7 docs plus ALL_COMBINED.xml).

Are these exported from Filemaker?

BTW, it's difficult to see what benefits will come from "combining" (i.e. concatenating) the documents. In any case, perhaps you should start with only 2 and work your way up to 7.

Link to comment
Share on other sites

  • 4 weeks later...

I do this all the time. But that's me. You have to have the PATH to each export be where the XSLT can find it. I tend to prefer the same folder (locally) as the XSLT (or one folder off).

1. create each export with a separate XSLT, as needed, and name them something the xslt can read (.xml!)

2. the *final* export XSLT can use document() to bring in the previous exported/transformed xml.

sometimes it has to do with namespaces (if any).

Here's how I use it (comments are ignored, but I can see them if I test the transformation in another editor:


 

<xsl:comment>insert first xml begins here</xsl:comment>

<xsl:copy-of select="document('firstInsert.xml')" />

<xsl:comment>insert first xml ends here</xsl:comment>

repeat the xsl:copy-of wherever you need to bring in the the previous exports with document()

HTH

Link to comment
Share on other sites

  • 3 months later...
  • 2 weeks later...

Thanks Beverly. I ended up doing the same with an OS batch script as I got stuck with the XSLT, but I will give it a try with your method.

:laugh2: Well there's that! I've also used scripted/calculated XML export when it got complex. I just wanted you to know that it's possible to call the previous .xml documents with the final XSLT/export. "xsl:copy-of" & the document() function is the key, as is the location of the documents so the XSLT can find them.

Beverly

Link to comment
Share on other sites

This topic is 4462 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.