Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

Hello there,

 

I'm working on using XSL to change a Filemaker export using FMPXMLRESULT grammar to a different XML structure. Only a single field is needed from the Filemaker export file, however the closest i've gotten to successfully change the format is by setting <xsl:template match="/"> yet displays the error code of 0. I've tried to specify my match field to<xsl:template match="fmp:FMPXMLRESULT/fmp:RESULTSET" > however that causes my format to disappear and still display the error code. Any assistance to point me in the right direction or point out my mistakes would be greatly appreciated.

 

FMP XML:

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

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">

<ERRORCODE>0</ERRORCODE>

<PRODUCT BUILD="01-09-2015" NAME="FileMaker" VERSION="ProAdvanced 13.0v5"/>

<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="" RECORDS="2" TIMEFORMAT="h:mm:ss a"/><METADATA>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ex" TYPE="TEXT"/>

</METADATA>

<RESULTSET FOUND="1">

<ROW MODID="6" RECORDID="2">

<COL>

<DATA>asdasdasd</DATA>

</COL>

</ROW>

</RESULTSET>

</FMPXMLRESULT>

 

XSL:

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fmp="http://www.filemaker.com/FMPXMLRESULT" exclude-result-prefixes="fmp">

<xsl:output method="xml" indent="yes" encoding="UTF-8" version="1.0"/>

 

<xsl:template match="/">

     <RESPONSE>

   <SAY>

     <xsl:call-template name="info"/>

    </SAY>

     </RESPONSE>

    </xsl:template>

  

    <xsl:template match="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW" name="info">

    <xsl:value-of select="fmp:COL[1]/fmp:DATA"/>

    </xsl:template>

  

  </xsl:stylesheet>

 

OUTPUT:

 

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

 

DESIRED OUTPUT:

<RESPONSE>

<SAY>

Field value (Which is asdasdasd right now)

</SAY>

</RESPONSE>

Posted

There are several reasons why your stylesheet doesn't work, the first being that XML is case-sensitive and your declaration:

xmlns:fmp="http://www.filemaker.com/FMPXMLRESULT"

does not match the Filemaker namespace declared in the XML source:

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">

The second reason is that when you call a template by name, its match attribute is ignored and the current context (which is the "/" root node in your case) is not changed. From that context, the path you use in:

<xsl:value-of select="fmp:COL[1]/fmp:DATA"/>

does not select anything, because COL is not a child of the root node.

 

 

If your export has only one record and one field, you could make this much simpler:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fmp="http://www.filemaker.com/fmpxmlresult"
exclude-result-prefixes="fmp">
<xsl:output method="xml" indent="yes" encoding="UTF-8" version="1.0"/>

<xsl:template match="/">
   <RESPONSE>
      <SAY>
         <xsl:value-of select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW/fmp:COL/fmp:DATA"/>
      </SAY>
  </RESPONSE>
</xsl:template>

</xsl:stylesheet>
  • Like 1
  • Newbies
Posted

Thank you for the concise explanation! The different in xlms:fmp case caused me hours of trouble, I won't be making that mistake again. 

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