how to us for-each here ??

Here should go questions about transforming XML with XSLT and FOP.
heldopslippers
Posts: 10
Joined: Thu Dec 07, 2006 12:08 pm

how to us for-each here ??

Post by heldopslippers » Fri Jan 12, 2007 11:19 am

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>

george
Site Admin
Posts: 2100
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Fri Jan 12, 2007 11:40 am

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
George Cristian Bina

heldopslippers
Posts: 10
Joined: Thu Dec 07, 2006 12:08 pm

Post by heldopslippers » Fri Jan 12, 2007 11:52 am

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:

Post Reply