Anna.anto Posted September 23, 2016 Posted September 23, 2016 Attention: Before posting in the general discussion forum please review the other forums that would best suit your topic. If you cannot find one then you may delete this text and post your topic in this forum. Hi all, I need to import into filemaker table an XML file as this: <?xml version="1.0" encoding="utf-8"?> <Account> <Field APIName="WrntyID">6029065</Field> <Field APIName="ExternalID">1761A</Field> <Field APIName="Name">sayIT SA</Field> </Account> now I'am trying to create the xls file. This is my xls file.... <?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <METADATA> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="WrntyID" TYPE="TEXT"/> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ExternalID" TYPE="TEXT"/> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Name" TYPE="TEXT"/> </METADATA> <RESULTSET> <ROW> <COL> <DATA><xsl:value-of select=“Account/Field[1]" /></DATA> </COL> <COL> <DATA><xsl:value-of select=“Account/Field[2]” /></DATA> </COL> <COL> <DATA><xsl:value-of select=“Account/Field[3]” /></DATA> </COL> </ROW> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet> This instruction <xsl:value-of select=“Account/Field[1]"/> doesn't work. What is the right syntax to retrive the value of the first TAG FIELD? Then the second end so on...? Many thanks Anna
comment Posted September 23, 2016 Posted September 23, 2016 (edited) Did you write your XSLT stylesheet in a word processor? Because the real problem with: <xsl:value-of select=“Account/Field[1]" /> are the curly (smart) quotes surrounding the value of the select attribute. Replace them with regular quotes (Char (34)) and all will work as intended. BTW, you could shorten the whole thing to: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/Account"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <METADATA> <FIELD NAME="WrntyID"/> <FIELD NAME="ExternalID"/> <FIELD NAME="Name"/> </METADATA> <RESULTSET> <ROW> <xsl:for-each select="Field"> <COL><DATA><xsl:value-of select="."/></DATA></COL> </xsl:for-each> </ROW> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet> Note that this is assuming the source fields will always be in the given order - as does your stylesheet. Otherwise you will need to select the fields by their APIName attribute, rather than by their position. Edited September 23, 2016 by comment
Anna.anto Posted September 23, 2016 Author Posted September 23, 2016 Hi, With regular quotes it works! How Can I select the fields by its APIName attribute? Anna
comment Posted September 23, 2016 Posted September 23, 2016 (edited) 22 minutes ago, Anna.anto said: How Can I select the fields by its APIName attribute? Like this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/Account"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <METADATA> <FIELD NAME="WrntyID"/> <FIELD NAME="ExternalID"/> <FIELD NAME="Name"/> </METADATA> <RESULTSET> <ROW> <COL><DATA><xsl:value-of select="Field[@APIName='WrntyID']"/></DATA></COL> <COL><DATA><xsl:value-of select="Field[@APIName='ExternalID']"/></DATA></COL> <COL><DATA><xsl:value-of select="Field[@APIName='Name']"/></DATA></COL> </ROW> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet> Edited September 23, 2016 by comment
Recommended Posts
This topic is 3246 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 accountSign in
Already have an account? Sign in here.
Sign In Now