Jump to content
Server Maintenance This Week. ×

XSLT Style Sheet help


blanky2

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

Recommended Posts

I am not a programmer, and know very little about XSLT style sheets. I have some xml information that i need to import into filemaker pro 10.

Can someone show me how to do this? Here is my sample XML code:


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



14790973

2009-02-24T21:45:17Z

2009-02-24T21:47:03Z

133003

Everyone

A Bunch of info



	

		
5843393 23 John Doe Lane Ln. Parkland FL 33076 Work
Magazine 378067 Book 378068 John Doe 14790972

Link to comment
Share on other sites

This may take more than a simple "do this". Looking at your sample, one person can have many addresses, and also many tags. If you intend to maintain the same data structure in Filemaker, you will need to import the data three times, each time into a different table - and using a different stylesheet for each.

---

BTW, the example is not valid XML (look at the tags around "Doe"). I also suspect that it may not be representative (only one person every time? No enclosing element for multiple people?).

Edited by Guest
Link to comment
Share on other sites

You are correct, it is multiple persons. Here is the corrected code:


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





14790973

2009-02-24T21:45:17Z

2009-02-24T21:47:03Z

133003

Everyone

A Bunch of info



	

		
5843393 23 John Doe Lane Ln. Parkland FL 33076 Work
Magazine 378067 Book 378068 John Doe 14790972

From what I've read, I kind of thought I might have to import 3 times, and would be able to link the relationships in my database. However, I couldn't find any examples of how to do the XSLT sheet for this kind of data. Can anyone point me in the right direction?

Link to comment
Share on other sites

Here is a partial start, on the Persons xsl stylesheet. You'd need to add more fields, both to the Metadata section, and to the lower part. All the plain Person fields are at the same level. The Addresses would be a different xsl file, somewhat similar, but getting data from the

level.

There is a question about what to do with the . You could either put them into their own table, in which case you'd want to also get the person's ID. Or you could just grab them as text and put them into a field in the Person table.

What I said above, about grabbing the Person ID, would also apply to Addresses. Because you'd need to tie each address to its person. But that brings up a question. The XML file has 2 "id"s. "id" and "author-id". Which is going to be used by the database? Or, do you want to use your own Person auto-enter serial ID? Either is possible, but the latter is more work; it would require a "switcheroo" after import.


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





	

		

			0

			

			

			

				

				

			

			

				

					

						0

						

						

							

								

							

						

						

							

								

							

						

						

				

			

		

	

Link to comment
Share on other sites

You were extremely helpful! I've got it working now where I can pull the names and dates.

Quick question on the dates: you will notice that my xml file has the date/time all together. How can I handle this in my XSL file? I tried using "Timestamp", and that brings in all the info--I can make that work for me, though slightly annoying. Is there a way to make FMP recognize it as a date and time (so I can format it differently)?

Also, right now, all I will have is one address (though my data source--highrisehq--is set up to handle multiple addresses. What would be the METADATA format to just pull the State from this file?

Regarding the tags, I would like to just pull the text for all tags and put that into a field (with maybe a comma or space delimiter). How would I do that?

Any help is greatly appreciated!

Link to comment
Share on other sites

Ok, by playing around a little bit, I was able to figure out how to pull the State into the table.

I've figured out how to pull the first tag, but I am clueless how to pull all tags and put them into one field. Any ideas? Here is my current code:


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





    

        

            0

            

            

            

                

                

				

                

                

                

                

            

            

                

                    

                        0

                        

                        

                            

                                

                            

                        

                        

                            

                                

                            

                        

                        

                            

                                

                            

                        

                        

                            

                                

                            

                        

                        

                            

                                

                            

                        

                        

                            

                                

                            

                        

                        

                            

                                

                            

                        

                        

                

            

        

    

 

Link to comment
Share on other sites

RE: dates. Post process with an auto-enter calculation field in FileMaker would be my choice. Use Text functions to take it apart and put it back together.

I don't really see why you're pulling only 1 state into the Person, when you might have multiple addresses, and one of them could be from another state. I suppose if there is only one address, ever, then it makes sense (which we have no way of knowing), or if you are saying, "I only care about the 1st one." Are you also saying, "I don't want the address, just the state"?

Here is a way to bring in the multiple tags separate by a carriage return. I would do that instead of commas, as it's more useful to FileMaker.




   

   

Edited by Guest
Link to comment
Share on other sites

Great! I got all my tags into Filemaker now.

To answer your question, I will only have 1 address per contact (though there is built in functionality to have multiple). Currently, I only need the State - though that will probably change in the future.

I will work on the date formatting as you suggested, and let you know if I have any problems.

Thanks again!

Link to comment
Share on other sites

I just came across this calculation, on another list, to convert an ISO timestamp (TS_ISO in this case) to a FileMaker timestamp (result), by raybaudi. I had one similar, but his is better :-]

Let ( [

decimalSep = Left ( 1/2 ; 1 ) ;

adj = Substitute ( TS_ISO ; [ "-" ; ¶ ] ; [ "T" ; ¶ ] ; [ ":" ; ¶ ]  ; [ "." ; decimalSep ] ; [ "Z" ; "" ]) ;

year = GetValue ( adj ; 1 );

month = GetValue ( adj ; 2 );

day = GetValue ( adj ; 3 );

hours = GetValue ( adj ; 4 );

minutes = GetValue ( adj ; 5 );

seconds = GetValue ( adj ; 6 )

];

Date ( month ; day ; year ) & " " & Time ( hours ; minutes ; seconds )

)

Link to comment
Share on other sites

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