Jump to content
Server Maintenance This Week. ×

XML import checkboxes


djhopalong

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

Recommended Posts

I'm trying to import some form information but I can't get the checkboxes info to transfer. I setup a simple test file and have a separate XSLT. All the other fields I got working alright. But if there is more than one box selected none of the choices transfer. I'm sure it's a syntax issue. My code looks like this:

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



	

		White

		Mark

		323-1111

		pp100

		All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. 



All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. 

		Female

		Transfer StudentOther

	

Most of the fields are a simple text transfer. Gender is a radio button and that works fine. State is a text field where a short essay is entered. "applyingas" is where the checkboxes are and that is no go right now.

Link to comment
Share on other sites

Since the values in the checkbox are all in the same xml element they are coming in as one thing (at least they should be; I have no idea why they would not come in at all). You then have 2 choices. You can use the (minimal) string processing available in xsl (version 1 anyway), or you can separate them in FileMaker after import. I think I'd go for the later. FileMaker has more and easier to use functions.

Link to comment
Share on other sites

I believe they are coming in as one thing. My thoery is: since I haven't set up a value that is "Transfer StudentOther" nothing is selected. If it's just "Transfer Student" input then that is selected. If I put a return in it or a "-" it still isn't read.

I have some checkboxes that have several choices for this example I'm just trying to get 2 to work. I don't know if that makes a difference to your solution, but I thought I should mention it.

you can separate them in FileMaker after import.

How would that work? I would set up a script to import automatically then it would go through the xml with an if/then statement maybe? My filemaker script-fu is not so tight. Any examples you could provide would help enormously.

Link to comment
Share on other sites

I don't really know why you wouldn't know what they are coming in as. Apparently your source is some kind of HTML form, which you're writing out as xml?

So I don't know how you're writing the multiple checkboxes into the element(s), nor am I knowlegable on how it would be done. It seems there would be routines to do that, as it seems like it would be a common thing to do.

I'm just saying that if the data is returned in the xml within only 1 element, then it's easier to parse it out later in FileMaker, after the import (maybe use an auto-enter, by calculation, that would trigger on the import).

You would not be "going through the xml" in FileMaker, because FileMaker does not import the xml, it imports the data text values in the xml. It doesn't import the xml itself, unless your xsl specifies that (which would normally be kind of crazy).

Edited by Guest
Link to comment
Share on other sites

I'm using PHP to output the data from a HTML form as a string. I don't know you're knowledge of PHP but as an example it outputs something like this:

applyingas[] is the string and values in the string are represented as - applyingas[1] = incoming freshmen, applyingas[2] = transfer student, etc.

I know what it is outputting as. I get that filemaker is simply importing the information in the xml code. I had it set up originally as a tab delinated file and filemaker wouldn't interpret the information until I phrased it in the following way:

Incoming FreshmenTransfer StudentOtherIncoming FreshmenTransfer StudentOther

You can't tell on here, but there are returns inbetween the selections. I think they are Unicode returns but I'm not sure. I figured out the syntax filemaker needed by exporting the checkbox fields from filemaker and opening the export in dreamweaver which shows the returns as rectangles. All other types of returns I've entered do not work. Filemaker can't or won't parse the information. When I try to output the fields in xml it doesn't translate them the same way. I get an error message.

The xsl I'm using I downloaded from filemakers website. Obviously, I don't know xml. The xsl is below.

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



       

	

		

			0

			

			

			

				

					

						YES

						1

						

						TEXT

					

				

			

			

				

				

					

						0

						0

						

							

								

									

								

							

						

					

				

			

		

	

Isn't this just a syntax error? If I can get the information to work in a tab delineated file, shouldn't it work (with the proper syntax) in an xml file?

Just to head off an obvious question - I can't use the tab file because I have a field that needs a large amount of text with a potential for tabs and returns. If entered they mess up the formatting and ruin a proper import.

Link to comment
Share on other sites

Thanks David. I've setup a field that uses a checkbox value list with the following: Transfer Student, Incoming Freshmen, Current Student, Other. When I import into filemaker and the import file has only one box checked it works fine. If there are more then one boxes checked it simply ignores the entry for that field.

If you look at my first example above, when it imports one checked box correctly the xml output looks like this:

Transfer Student

In this case the Transfer Student checkbox works.

I'm trying to make it so that if they (for whatever reason) need to check more then one box on the form it will show up in filemaker.

Link to comment
Share on other sites

I don't know if my example was clear. After the import when more than one box is checked filemaker leaves all boxes unchecked. It seems to just ignore the information pertaining to that field. All other fields are unaffected.

In xml the information between the tags

Transfer Student

is what filemaker is trying to parse. In this case "Transfer Student." If I knew what phrasing filemaker liked I might be able to output it that way.

I have a feeling I need to get xsl to let filemaker know how to interpret the info. I might need to do something like add a child attribute to the xml applyingas or something. I know xml isn't your specialty but I'm sure any suggestions on how else to output the data would be helpfull.

Link to comment
Share on other sites

Basically a "checkbox" field is just a way of making it appear on the layout, with an X when the value of A LINE matches a value of the value list index. Both are return-separated.

Transfer

Student

will show, "Transfer Student" will not.

So, you could use either xsl string functions, which are kind of sparse*. Or you could use FileMaker text functions, which are more robust. The trick to using the FileMaker text functions in an auto-enter calculation is to get them to run during/after the import.

*translate('the text', 'character1', 'character2')

Character1 would be a space, character2 would be a return. You'd have to use an ASCII reference for the return, as xsl would ignore it as whitespace I believe. Probably easiest to put it into a variable first, then use that in the function.

Edited by Guest
translate
Link to comment
Share on other sites

You can't tell on here, but there are returns inbetween the selections.

It doesn't look like they are there, because then the element would look like this:

Transfer Student

Other


and it would work when you import it into Filemaker.



You could also use the code for a carriage return which is really hard to reproduce here, but it would look almost like this:


Transfer Student$#x000D;Other

except it needs to be an ampersand instead of the dollar sign.

Link to comment
Share on other sites

Thanks David. I've setup a field that uses a checkbox value list with the following: Transfer Student, Incoming Freshmen, Current Student, Other. When I import into filemaker and the import file has only one box checked it works fine. If there are more then one boxes checked it simply ignores the entry for that field.

As others have said, the data is probably importing, but is not formatted correctly for a checkbox. Change the field to a regular edit box and see what the data looks like. It'll probably be one long string rather than a return-delimted list.

If you can't get the import to come out right, you'll need to convert within FileMaker, probably using an auto-enter calculation.

How the data actually looks will make a difference in the calculation you use...for instance if there are spaces between the values the following calculation will need adjusting. But essentially what you need to do is get the values on their own line. If there are only 4 options, it's not that hard.

The calculation will be a couple nested Substitutes...something along the lines of:


//Begin outer Sub

Substitute(



//Begin inner Sub

Substitute( importTable::ApplyingAs; 



//This innermost Sub brackets the values with pipe characters

["Transfer Student";"|Transfer Student|"]; 

["Incoming Freshmen"; "|Incoming Freshman|"] ;

["Current Student" ; "|Current Student|"]; 

["Other"; "|Other|"])

;

//this outer Sub replaces double pipes with carriage returns and then strips the singles out.



["||"; "¶"]; ["|"; ""])

Good luck.

Link to comment
Share on other sites

Thanks everyone for the suggestions. There are a couple of ways that this seems to be working.

As others have said, the data is probably importing, but is not formatted correctly for a checkbox. Change the field to a regular edit box and see what the data looks like. It'll probably be one long string rather than a return-delimted list.

That was the key factor in helping me see what was wrong with the syntax.


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



	

		John

		Transfer Student

		Incoming Freshmen

	







The problem was not with the returns in-between the  tags, it is with the tabs that are automatically entered in dreamweaver.  In the above code you can see "Incoming Freshmen" indented, which screwed everything up.



This works:



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





John

Transfer Student

Incoming Freshmen



Other





The space is where "Current Student" is left-out. Filemaker leaves it unchecked.

comment's code for carriage return works also.

You could also use the code for a carriage return which is really hard to reproduce here, but it would look almost like this:

Code:

Transfer Student$#x000D;Other

except it needs to be an ampersand instead of the dollar sign.

It's probably the easier solution.

Thanks guys.

Link to comment
Share on other sites

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