Jump to content
Server Maintenance This Week. ×

Still stuck with XSLT for XML


CRoberts

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

Recommended Posts

Hi

I am still stuck trying to work out how to create an XSLT from an XML file output via one of our custom systems.

XML is:

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

project_key="PR0001"

project_title="Brochure"

client="A Publisher">

key="000001"

name="Project stage of work"

start_date="2008-01-08"

end_date="2008-01-30"

support_person="A Person"

resources="{List of people}" project_manager="pm"/>

-- end

Any help on creating an XSLT would be very much appreciated.

Regards

C

Edited by Guest
Link to comment
Share on other sites

  • 3 weeks later...

Something clicked and so I've been trying to get my head around the msdso_attrib.xslt example.

I do not understand how the "select" statement works (not the SQL SELECT statement ;-) as in:

"Notice the complex select statement used to handle each of the attributes in the XML input file."

So where it shows:

I do not see how this matches to the xml field data:

Can anyone help or point me at some documentation that explains this in more detail?

Regards

Link to comment
Share on other sites

I don't have that example file in front of me. But basically an asterisk is a "wild card", which will match anything at that level. The "/" slashes determine the level. It's a somewhat loose way to select data. Brackets with a number in them specify an occurrence (like in the FileMaker Position() function).

/*/*[1]/@*

Means (I think), within the 1st element of the 1st node at the 2nd level down from the root, get all the attributes.

In this case it gets:

PR0001

Brochure

A Publisher

(I put returns between them, otherwise they'd just be mushed together; xsl has no "separators," unless you add them.)

Link to comment
Share on other sites

You could take out the [1].

But it's there for a reason. I found the "msdso_attrib.xslt" example and looked at it. There are two sections in that xsl file. The first section, with the [1] is there to build the "metadata" node-set for the FileMaker fields. It is required to tell FileMaker what the fields are when you Import. The xsl only needs to do this once, so it targets only the first element.

It is pulling this from the attribute names (not the values), using the xsl name() function.

If you look further down you will see the section that is actually getting the data for the fields. It does not have [1]. The example xsl will get the multiple elements' (people in its case) attributes.

In your case that just gets the attributes of multiple Projects, it doesn't get the Stage of each. Stage is a child of Project. Would it then be a separate table in FileMaker? It should be if there are possibly multiple Stages.

This is a critical question before writing the xsl, as it would be separate xsl file (similar to the first).

Link to comment
Share on other sites

You're right. Projects do have multiple stages.

Best then to import Project and Stage data in separate steps.

I guess I can refer to Stage data by adding in another layer. XPath gives impression i can use name of element node, so shouldn't this work?

..

..

..

Thanks for your help.

Link to comment
Share on other sites

Well, the thing is, if Stages is a separate table, as is "relationally correct" (RC, like PC, "politically correct" :)-), then it's 2 Imports, which means 2 xsl files, one for Projects, one for Stages, both very similar, but with Stages matching the next node down.

However, one addition to the Stages xsl is to reach "up" one node, and get the "project_key" attribute. This is the ID field that would tie the Project import to its Stages.

You would also need to add that as a Field in the Metadata section. The way it is being done in the msdso_attrib.xslt is very clever and generic, using the wild-card symbol to match elements at the level. The same method can be used to get the project_key, as it is the 1st attribute of the 1st Project.

Though, as you said, you can also specify things by their name, instead of being generic. Attached is a modified version of the msdso_attrib.xslt file, to get the Stages, along with the project_key. I left all the other text in, as it is required.

msdso_attrib_Stages.xslt.zip

Link to comment
Share on other sites

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