« Options | Main | Linked fields »

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341d284e53ef00d834ebf3d769e2

Listed below are links to weblogs that reference Modular XSLT, part 2: Simple export:

Comments

Davis

Mikhail,

Thank you for posting this information. It has saved me from having to read cover to cover some of the XSLT books on the shelves.

I just have one question and I'll preface my question with some info. Going from FMP to cXML.
cXML output should look like the following for the Header section (has many sections with similar element:attribute pairs):

[Header]
[From]
[Credential domain="NetworkID"]
[Identity]007[/Identity]
[/Credential]
[/From]
[To]
[Credential domain="NetworkId"]
[Identity]1463[/Identity]
[/Credential]
[/To]
[Sender]
[Credential domain="NetworkID"]
[Identity]9647[/Identity]
[SharedSecret]banana[/SharedSecret]
[/Credential]
[UserAgent] Supplier [/UserAgent]
[/Sender]
[/Header]

My question is wether I should treat the [Header] element as the template; use [From] [To] [Sender] as templates; or nest them all into one big one? Does templating support nested templates so that the Sender Credential Identity is accessed seperately from the To Credential Identity?

Thank you for your time,
Davis

Sorry for the bad markup.

m.edoshin

f the header has only one "from", "to", and "sender", then technically there's no difference. Only your personal style does matter I typically make such elements separate templates because to me it seems clearer, less ambiguous when I read the code later. I.e.:

[xsl:template name="header"]
[xsl:param name="from" /]
[xsl:param name="to" /]
[xsl:param name="sender" /]
[/xsl:template]

[xsl:template name="from"]
[xsl:param name="credential" /]
[/xsl:template]

[xsl:template name="to"]
[xsl:param name="credential" /]
[/xsl:template]

[xsl:template name="sender"]
[xsl:param name="credential" /]
[xsl:param name="user-agent" /]
[/xsl:template]

[xsl:template name="credential"]
[xsl:param name="identity" /]
[xsl:param name="shared-secret" /]
[/xsl:template]

is probably longer, but very simple: there's no confusion about what's what.

davis

Just incase you don't see this on FMForums:

Ahh the cloud cover has lifted.

Thank you for your time and assistance.

One remaining question:
You mention "If the header has only one", I guess logically there could be many. How would one handle that?

For instance:

[Invoice Partner]
[Contact role="soldTo"]
[Name>Jimmy[/Name]
[/Contact]
[/Invoice Partner]

[Invoice Partner]
[Contact role="remitTo"]
[Name>Jimmy[/Name]
[/Contact]
[/Invoice Partner]

[Invoice Partner]
[Contact role="shipTo"]
[Name>Jimmy[/Name]
[/Contact]
[/Invoice Partner]

I would assume that I would just make individual templates for the different roles:
[xsl:template name="Contact" role="shipTo"]
[xsl:param name="Name" /]
[/xsl:template]

Thanks again,
d

m.edoshin

Since the structures are nearly identical, it's certainly better to make a single template that handles them all and then pass the role as a parameter. I.e.

[xsl:template name="contact"]
[xsl:param name="role" /]
[xsl:param name="name" /]

[Contact role="{$role}"]
[Name][xsl:value-of select="$name"][/Name]
[/Contact]
[/xsl:template]

neessyNum

hi,
good site :) Whish you good luck!

Dorian Cougias

The big question is, how do you parse filemaker's date time stamp to something in RFC3339 format?

m.edoshin

I see converting date into a timestamp as a coding task only. That is with export we'll probably better to do this in FileMaker itself; if we use the XSLT API we can probably employ those nice date & time functions.

ZoXo

Thanks for posting this, it is the most comprehensive and informative introduction to creating and XML document from FileMaker.

I am mostly successful in creating the correct format for Worldship XML auto import, but I am unsure of how to handle attributes to an element
that are being expressed within the element line:

for example, the Worldship XML file looks something like this ( replaced with '-' so this post will display the code):

-OpenShipments xmlns="x-schema:OpenShipments.xdr-
-OpenShipment ShipmentOption="" ProcessStatus=""-
-ShipTo-
-CustomerID-This is only the first field-/CustomerID-
-/ShipTo-
-ShipmentInformation-
-VoidIndicator-This is only the first field-/VoidIndicator-
-/ShipmentInformation-
-/OpenShipment-
-/OpenShipments-

I am able to output this exactly from your info, but I am not sure how I should introduce the two attributes that go along
with OpenShipment (ShipmentOption and ProcessStatus)

Here is a portion of the schema as given by the Worldship application:

-ElementType name = "OpenShipments" content = "eltOnly" order = "seq" model = "closed"-
-element type = "OpenShipment" minOccurs = "1" maxOccurs = "*"/-
-/ElementType-

-ElementType name = "OpenShipment" content = "eltOnly" order = "seq" model = "closed"-
-AttributeType name = "ProcessStatus" dt:type = "string" required = "yes"/-
-AttributeType name = "ShipmentOption" dt:type = "string" required = "no"/-
-attribute type = "ProcessStatus" /-
-attribute type = "ShipmentOption" /-
-element type = "Receiver" minOccurs = "0" maxOccurs = "1"/-
-element type = "ReturnTo" minOccurs = "0" maxOccurs = "1"/-

Thank you again, I would not have gotten this far without your tutorial, but I have yet to come up with the final
part of my solution, and I appreciate any further help.


Broken Acorn

I can get this export to work great with one record, but how to I get it to export a found set of multiple records?

m.edoshin

Doesn't it work out of the box? I mean, there seems to be all the necessary preparations, mostly in the line:

xsl:for-each select="//fmp:ROW"

So it should repeat the parameter for all rows in the exported set.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment