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

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

Recommended Posts

Posted

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>

Posted

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

Posted

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>

Posted

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>

Posted

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

??

Posted

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>

Posted

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!

Posted

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.

Posted

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.

Posted

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

Posted

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

  • 3 months later...
Posted

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

This topic is 4770 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.