how to us for-each here ??

Here should go questions about transforming XML with XSLT and FOP.
heldopslippers
Posts: 10

how to us for-each here ??

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

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

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:

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest