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

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

Recommended Posts

Posted
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).

 

 

Posted

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

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 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.