Marius Posted July 29, 2017 Posted July 29, 2017 Ahoy there ! I'm trying to make a xml import, but seams something I'm missing. The import access from the next link : http://www.sagasoft.ro/infoTert.php… The xslt it's here. When I'm importing, shows I have one record , but empty. Where I'm wrong. saga.xslt
comment Posted July 29, 2017 Posted July 29, 2017 1 hour ago, Marius said: Where I'm wrong. You have managed to make three major mistakes in just one short instruction: <xsl:value-of select="tert/@cod_fiscal"/> First, your template matches the / root node, but tert is a child of ds. So already your path will select nothing. Next, cod_fiscal is an element, not an attribute - so you should not be putting a @ in front of it. The third problem is a little more difficult: your XML places all its elements in a namespace. You must declare the same namespace in your stylesheet, assign it a prefix and use that prefix when addressing the elements in the source XML. Try the following stylesheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://tempuri.org/ds.xsd" exclude-result-prefixes="ns"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:template match="/"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <METADATA> <FIELD NAME="Cod Fiscal"/> </METADATA> <RESULTSET> <ROW> <COL><DATA><xsl:value-of select="ns:ds/ns:tert/ns:cod_fiscal"/></DATA></COL> </ROW> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet> Note that the above assumes there will always be at most one record to import. Otherwise you will need to change it to something like: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://tempuri.org/ds.xsd" exclude-result-prefixes="ns"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:template match="/ns:ds"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <METADATA> <FIELD NAME="Cod Fiscal"/> </METADATA> <RESULTSET> <xsl:for-each select="ns:tert"> <ROW> <COL><DATA><xsl:value-of select="ns:cod_fiscal"/></DATA></COL> </ROW> </xsl:for-each> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet> (assuming tert translates to a record).
Marius Posted July 29, 2017 Author Posted July 29, 2017 Wau, works very good ! Thanks very much, for your advice & solution. I have tried also ds/tert/cod_fiscal, but I didn't get I have to put a namespace in it. Thanks a lot, Marius
Recommended Posts
This topic is 2692 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