Page 1 of 1

how to us for-each here ??

Posted: Fri Jan 12, 2007 11:19 am
by heldopslippers
I have this XML file:

Code: Select all


<?xml version="1.0" encoding="UTF-8" ?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"/>
<METADATA>
<FIELD id="1" NAME="tekstvak">
<FIELD id="12" NAME="tekstvak1">
</METADATA>
</FMPXMLRESULT>
My XSL file needs to look for each FIELD. I tryed lots of things but doesn't work. The following code (I think) should work but doesn't. I hope someone can tell me what I do wrong.. :?

Code: Select all


<xsl:template match="/">
<xsl:element name="a">
<for-each select="/FS:FMPXMLRESULT/FS:METADATA/FS:FIELD" xmlns:FS="http://filemaker.com/fmpxmlresult" >
<xsl:element name="b">
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>

Posted: Fri Jan 12, 2007 11:40 am
by george
There are many problems.

1. The XML file is not wellformed, the FMPXMLRESULT is empty, FIELD tags are not closed. The wellformed example after corrections is

Code: Select all


<?xml version="1.0" encoding="UTF-8" ?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<METADATA>
<FIELD id="1" NAME="tekstvak"/>
<FIELD id="12" NAME="tekstvak1"/>
</METADATA>
</FMPXMLRESULT>
The xsl file contains for-each instead of xsl:for-each and the namespace for the source elements is wrong, in stylesheet it is declared without www, compare http://filemaker.com/fmpxmlresult with http://www.filemaker.com/fmpxmlresult.

Correcting also the stylesheet gives

Code: Select all


<xsl:template match="/">
<xsl:element name="a">
<xsl:for-each select="/FS:FMPXMLRESULT/FS:METADATA/FS:FIELD"
xmlns:FS="http://www.filemaker.com/fmpxmlresult">
<xsl:element name="b"> </xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
which works ok.

Regards,
George

Posted: Fri Jan 12, 2007 11:52 am
by heldopslippers
Thanxs for the fast replay.
and wel ...ehm sorry but I typed it over mist some things and had to sort out the things the aren't relevand


gr "heldop" :wink: