Jump to content
Andreas T.

BaseElements BE_ApplyXSLT returns blank with no output

Recommended Posts

I need some help in determining if I am missing something crucial here or if there is a limitation or bug in the function BE_ApplyXSLT from the BaseElements plugin. I am using version 3.3.4 (which is the latest) on Mac OS X 10.11.6 using FileMaker 15 Adv. and 16 Adv.

I am unable to get any output from the transformation, nor any error.

According to the documentation, the command shall return either 0 when successful or an error. Link

In my testing it only returns blank, and gives no error even when no output file is generated. It should not return blank in cany case according to the docs. (I suspect there may be a documentation error and that it actually returns blank when there is no error.)
No error is found using Get(LastError). BE_GetLastError returns 0.

The function format is this:

BE_ApplyXSLT ( xmlPath ; xslt ; outputPath )

Here are the input parameters I have used:

BE_ApplyXSLT ( 
    "/var/folders/y6/1yf76qcs5y91h_w4j27hxp980000gp/T/S10.2/ABC_nota_108.xml" ; 
    BE_ReadTextFromFile ( "/var/folders/y6/1yf76qcs5y91h_w4j27hxp980000gp/T/S10.2/HTMLvisning/Stylesheet_Full.xsl" );
    "/var/folders/y6/1yf76qcs5y91h_w4j27hxp980000gp/T/S10.2/output.html"
)

I have verified that the files exist and that both the XML and XSLT are valid. All files are in UTF-8. I can transform the XML with this XSLT using other
methods without errors. I have also tried having the XSLT in a variable.

As I understand it, BaseElements uses the libxml2 engine. I have tried doing the transform from the command line directly and it works as it should:

xsltproc -o /var/folders/y6/1yf76qcs5y91h_w4j27hxp980000gp/T/S10.2/output.html /var/folders/y6/1yf76qcs5y91h_w4j27hxp980000gp/T/S10.2/HTMLvisning/Stylesheet_Full.xsl /var/folders/y6/1yf76qcs5y91h_w4j27hxp980000gp/T/S10.2/ABC_nota_108.xml

It also works fine using the XMLLib OSAX in AppleScript. Unfortunately, I need Windows support also so I would like to get the BaseElements function to work.

I hope somone can shed some light on what may be going on.

Edited by Andreas T.
Corrected OS version

Share this post


Link to post
Share on other sites

Thank you, Comment for your confirmation of the documentation error and your suggestion.

I have already verified the paths with the BE_SelectFile function and they are correct.

Btw, using direct adressing with /private/var or the symlink /var makes no difference in any of the test scenarios I have tried. They both work, except in BE_ApplyXSLT where neither works. 

I think the function somehow chokes on my XML or XSLT, but then there should be an error. Besides, libxml2 transforms the file with no errors or warnings.

Share this post


Link to post
Share on other sites
1 hour ago, Andreas T. said:

I think the function somehow chokes on my XML or XSLT

That should be easy to verify. Run a script like:

Set Variable [ $xmlPath; Value:"/path/to/input.xml" ]
Set Variable [ $xsltPath; Value:"/path/to/stylesheet.xsl" ] 
#
Set Field [ Table::XML; BE_ReadTextFromFile ( $xmlPath ) ]
Set Field [ Table::XSLT; BE_ReadTextFromFile ( $xsltPath ) ]
#
Set Field [ Table::Result; BE_ApplyXSLTInMemory ( Table::XML ; Table::XSLT ) ]

then you'll know exactly at which point/s it fails.

 

Share this post


Link to post
Share on other sites

Thanks again.

I had already tried the BE_ApplyXSLTInMemory function in a similar fashion, but I did try again with your excact example and it fails in the same way with nothing returned. All paths are working and the files are being read into the fields.

The function silently fails.

I am going to try the function with some other XML and see if I can make out where it fails.

Share this post


Link to post
Share on other sites

After spending close to two days on this annoying issue, I've reached the end of my rope and I'm giving up on these functions. They seem to fail to transform or error report many documents, even though I cannot see a pattern to it. 

Simple documents work fine, something a bit more complicated and they often fail silently.

Every other transformer I have found works including Oxygen, libxml2, AppleScript XMLLIB and this Java based (jaxp) online transformer: http://www.utilities-online.info/xsltransformation/#.WRWJHVLJLmE

As I cannot see a way to bug report this without paying $199, I'm out. I'll have to find an XML library I can use on Windows and use Applescript on the Mac.

Thanks for your input , Comment.

Share this post


Link to post
Share on other sites

Could you post the XML and XSLT?

I would suspect a memory problem; see what happens if you reduce the size of the XML.

Share this post


Link to post
Share on other sites

I can send you a PM with the files, if you are willing to give it a try. Would be useful to teste it on another machine, for sure.

The files are small, the XML is about 11K and the XSL with includes totals less than 100K. I have verified that all includes are included.

Share this post


Link to post
Share on other sites
12 minutes ago, Andreas T. said:

and the XSL with includes

Ah! You did not mention includes until now. That is most likely the cause of the disruption. Note that the transformation does not use the XSLT file itself - it requires you to read its contents into memory. 

 

 

Edited by comment

Share this post


Link to post
Share on other sites

Ah, you are probably right, but then it should at least have thrown exceptions about missing references. I have also tried with other XSL-files which have no dependencies and they also silently fail. I will try to combine thes files into one.

Share this post


Link to post
Share on other sites
4 minutes ago, Andreas T. said:

I have also tried with other XSL-files which have no dependencies and they also silently fail.

Do you have an example of that?

Share this post


Link to post
Share on other sites
8 minutes ago, comment said:

Do you have an example of that?

No.... Seems I made a mistake about that, there was an include in the one I was thinking about. Really confusing when the function doesn't report on such errors. That's what tripped me up. I have tested with so many scenarios that I'm not sure anymore what worked and what didn't. Have to assume then that it is missing dependencies that is the general cause. The function should error report on missing dependencies. All other processors do.

Going to start over after I combine the dependencies into the main XSL.

Thank you again so much, Comment for your time.

Share this post


Link to post
Share on other sites

I conducted a small test of my own and I can confirm that including an external stylesheet causes a failure. That's hardly surprising given what I said earlier about the XSLT being applied from memory, even with the BE_ApplyXSLT() function. Strange choice on part of the plugin's author.

 

26 minutes ago, Andreas T. said:

The function should error report on missing dependencies.

Yeah, well, that seems to be a separate issue that muddies the waters. The function does not return any error codes - not even a 0 in case of success. 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks to you I finally managed to get the BE_ApplyXSLT function working after consolidating all external references into the main XSL. Obvious when you think about it it, but I somehow didn't catch that only the unparsed selected file was read in and got hung up in the fact that there seemed to be no errors.

IMO, the function needs some better error handling and the docs needs some error correction as well as maybe a note on this potential pitfall.

Thank you again. :beertime:

Share this post


Link to post
Share on other sites

I have exactly the same problem, but with really simple XML and XSL that has no external references.

I too have checked file paths thoroughly, and can transform successfully using xsltproc with exactly the desired result.

Anyone who wants to look at the files is welcome to :)

Share this post


Link to post
Share on other sites
5 minutes ago, jamesducker said:

Anyone who wants to look at the files is welcome to

Well, what are you waiting for? Just attach them here (preferably reduced to the minimum required to show the problem).

Share this post


Link to post
Share on other sites

I'd rather not post them publicly… will send you a message :)

Just now, comment said:

Well, what are you waiting for? Just attach them here (preferably reduced to the minimum required to show the problem).

 

In my case I **am** able to use BE_ReadTextFromFile to read both files in from their paths, then apply the transformation successfully in memory, then use BE_WriteTextToFile to write it out again. So I have a workaround; the original problem remains interesting though.

Share this post


Link to post
Share on other sites

I would much prefer you sanitize the files so that they can be discussed publicly. 

Share this post


Link to post
Share on other sites

FWIW, I had no problem performing the transformation using the files you sent me in a PM, running BE 3.3.4 in FMP 16 on MacOS Sierra.

Were you able to perform a transformation using other files? 

Share this post


Link to post
Share on other sites

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


×

Important Information

By using this site, you agree to our Terms of Use.