Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

XSL for each question ... I think.

Featured Replies

I just can't quite see this one....

In this instance I have 2 ITEMS and 6 ITEM but sometimes I only have 1 ITEMS.

If I want to import all 6 records <ITEM> ..... and they come in under ITEMS but not the same one... where do I put another for each? Or must I do something else??

XML


<ITEMS>



   <ITEM>1</ITEM>

   <ITEM>2</ITEM>

   <ITEM>3</ITEM>

   <ITEM>4</ITEM>

<ITEMS>

   <ITEM>1</ITEM>

   <ITEM>2</ITEM>

 



 

<xsl:for-each select="Response/ITEMS"> only gives me 2 records.

 

<xsl:for-each select="Response/ITEMS/ITEM"> gives me nothing.

 

 



<RESULTSET>

   			 <xsl:attribute name="FOUND">1</xsl:attribute>

   			 <xsl:for-each select="Response/ITEMS">

                 	<ROW>

   					 <xsl:attribute name="MODID">0</xsl:attribute>

   					 <xsl:attribute name="RECORDID">1</xsl:attribute>

   					 <COL>

   						 <DATA>

   							 <xsl:value-of select="whatever"/>

   						 </DATA>

   					 </COL>

   			 	</ROW>

   			 </xsl:for-each>

</RESULTSET>

<xsl:for-each select="Response/ITEMS"> only gives me 2 records.

I don't see a <Response> element in your XML. It would be best to post a complete example, so we can see the context.

  • Author

It is.

I just don't want to post a bunch of code........ It seems like it's not that hard & I should know how to do this.

I guess to be more exact it should be.......

<Response>  

   <ITEMS>

 	<ITEM>1</ITEM>

      <ITEM>2</ITEM>

      <ITEM>3</ITEM>

      <ITEM>4</ITEM>

   </ITEMS>

   <ITEMS>

      <ITEM>1</ITEM>

      <ITEM>2</ITEM>

   </ITEMS>

</Response>

Try:


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>

<xsl:template match="/">

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">

<ERRORCODE>0</ERRORCODE>

<PRODUCT BUILD="" NAME="" VERSION=""/>

<DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/>

<METADATA>

<FIELD NAME="Item" TYPE="NUMBER" EMPTYOK="YES" MAXREPEAT=""/>

</METADATA>

<RESULTSET FOUND="">

<xsl:for-each select="Response/ITEMS/ITEM">

<ROW MODID="" RECORDID="">

<COL><DATA><xsl:value-of select="."/></DATA></COL>

</ROW>

</xsl:for-each>

</RESULTSET>

</FMPXMLRESULT>

</xsl:template>

</xsl:stylesheet>

  • Author

Thanks.... I didn't want anyone to have to write all that but thank you!

I almost had that.... took it out of another stylesheet I had.

It works fine but I can foresee a possible dilemma later.

What happens if I add objects under ITEM ?

<Response>

	<ITEMS>

      <ITEM>

		<NAME>John Doe</NAME>

		<PHONE>555-555-1212</PHONE>

      </ITEM>

      <ITEM>

		<NAME>John Doe</NAME>

		<PHONE>555-555-1212</PHONE>

      </ITEM>

      <ITEM>

		<NAME>John Doe</NAME>

		<PHONE>555-555-1212</PHONE>

      </ITEM>

      <ITEM>

		<NAME>John Doe</NAME>

		<PHONE>555-555-1212</PHONE>

      </ITEM>

   </ITEMS>

   <ITEMS>

      <ITEM>

		<NAME>John Doe</NAME>

		<PHONE>555-555-1212</PHONE>

      </ITEM>

      <ITEM>

		<NAME>John Doe</NAME>

		<PHONE>555-555-1212</PHONE>

      </ITEM>

   </ITEMS>

</Response>

Now I have multiple ITEMS and also multiple ITEM

??

What happens if I add objects under ITEM ?

You'll need to do two things:

1. Place a FIELD element in the METADATA section for each field you want to import (Name and Phone in your example);

2. Change this:


<ROW MODID="" RECORDID="">

<COL><DATA><xsl:value-of select="."/></DATA></COL>

</ROW>

to:


<ROW MODID="" RECORDID="">

<COL><DATA><xsl:value-of select="NAME"/></DATA></COL>

<COL><DATA><xsl:value-of select="PHONE"/></DATA></COL>

</ROW>

  • Author

BTW - Thanks again .... We just had our first grand-kid so I got busy and didn't get a chance to work on this.

I don't know what I was doing wrong because after all is said and done it looks just like what I had.

Well I take that back !

While writing this I got to wondering and there was a small difference....... I had:

<RESULTSET><xsl:attribute name="FOUND">1</xsl:attribute>

   	         <xsl:for-each select="Response/ITEMS/ITEM">

   		         <ROW>

   			         <xsl:attribute name="MODID">0</xsl:attribute>

   			         <xsl:attribute name="RECORDID">1</xsl:attribute>


 

Instead of:

 


<RESULTSET FOUND="">

   	         <xsl:for-each select="Response/ITEMS/ITEM">

   		         <ROW MODID="" RECORDID="">

So thanks again for the help !!

And I hope you're having a great weekend!

Actually, it shouldn't make a difference.

<RESULTSET>

<xsl:attribute name="FOUND">1</xsl:attribute>

...

is the same as:

<RESULTSET FOUND="1">

...

and Filemaker ignores the actual value when importing anyway.

  • Author

HHhhuuummmmmmm ... Possibly I had something else wrong.

I just know that when I switched it to the later ..

<RESULTSET FOUND="">

....

no 0's or 1's it worked.

Yes, Cabinetman. I always leave this blank. I don't know if it's ignored or not.

See the table at note #2 here:

http://www.filemaker.com/11help/html/import_export.16.34.html#1029660

  • Author

HHHHhhhuuuummmmm again ... LOL

I'm not putting any blame or pointing fingers ... because this could be something I did all by myself .... but way back in the day ( couple of yrs ago) when i was first getting into needing this I had:

<RESULTSET>

<xsl:attribute name="FOUND">1</xsl:attribute>

<xsl:for-each select="amz:ItemLookupResponse/amz:Items/amz:Item">

   	<ROW>

        	<xsl:attribute name="MODID">0</xsl:attribute>

        	<xsl:attribute name="RECORDID">1</xsl:attribute>

in my code.... which I came to I think ... and I say I think ... with the help on Fenton and some others.

Is this consider wrong or poor style?

NOTE: That works fine for my basic imports......

It's not wrong, just unnecessarily verbose. Usually, you'd use xsl:attribute when the value needs to be calculated.

  • 3 months later...

or there is the attribute value template usage <http://www.dpawson.co.uk/xsl/sect2/N1575.html>

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.