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

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

Recommended Posts

Posted

I am attempting to import records from an XML feed formated like this (the sample is showing 2 records based on the <ItemOut> element):

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

<ItemFeedResponse>

<Feed>

<Source type="list">6948232</Source>

<PageSize>50</PageSize>

<Offset>0</Offset>

</Feed>

<FeedResult feedSize="1198">

<ItemOut valid="true">

<ItemId>01661918</ItemId>

<ItemAvailability>

<ItemStatus code="SH" available="true"/>

<ItemStock code="I">

<Description>Alternate</Description>

</ItemStock>

<ItemUom units="EA" per="1">

<QuantityAvailable>0.0</QuantityAvailable>

</ItemUom>

</ItemAvailability>

<ItemDetail>

<Description>CATH IC LTX 18FR 30CC 2W 12EA/CS BARD MEDIC</Description>

<SupplierId>01661918</SupplierId>

<ManufacturerId>0166SI18</ManufacturerId>

<ManufacturerName>BARD MEDIC</ManufacturerName>

<Classification domain="UNSPSC">42000000</Classification>

<Category id="019" type="Major">Urologicals</Category>

<Category id="026" type="Minor">Indwell Cath Specialty</Category>

</ItemDetail>

<ItemExtra>

<ItemDescription>Urethral Catheter The Bardex I.C. 2-Way Foley, Standard Tip 18 Fr. Latex, Silver Alloy Coated</ItemDescription>

<ItemImage>1169_016614_2.jpg</ItemImage>

<ItemAttribute name="Application">Urethral Catheter</ItemAttribute>

<ItemAttribute name="French Size">18 Fr.</ItemAttribute>

<ItemAttribute name="Material">Latex, Silver Alloy Coated</ItemAttribute>

<ItemAttribute name="Securing Method">30 cc Balloon</ItemAttribute>

<ItemAttribute name="Sterility">Sterile</ItemAttribute>

<ItemAttribute name="Style">2-Way Foley, Standard Tip</ItemAttribute>

</ItemExtra>

</ItemOut>

<ItemOut valid="true">

<ItemId>06101900</ItemId>

<ItemAvailability>

<ItemStatus code="SH" available="true"/>

<ItemStock code="I">

<Description>Alternate</Description>

</ItemStock>

<ItemUom units="EA" per="1">

<QuantityAvailable>0.0</QuantityAvailable>

</ItemUom>

</ItemAvailability>

<ItemDetail>

<Description>CATH URETH VNL STP 10FR 100EA/CS KENDALL CO</Description>

<SupplierId>06101900</SupplierId>

<ManufacturerId>400610</ManufacturerId>

<ManufacturerName>KENDALL CO</ManufacturerName>

<Classification domain="UNSPSC">42000000</Classification>

<Category id="019" type="Major">Urologicals</Category>

<Category id="031" type="Minor">Intermit Cath Strght Tip</Category>

</ItemDetail>

<ItemExtra>

<ItemDescription>Intermittent Catheter Robinson, 2 Staggered Eyes Vinyl 10 Fr.</ItemDescription>

<ItemImage>166869_PC.jpg</ItemImage>

<ItemAttribute name="Application">Intermittent Catheter</ItemAttribute>

<ItemAttribute name="French Size">10 Fr.</ItemAttribute>

<ItemAttribute name="Gender">Unisex</ItemAttribute>

<ItemAttribute name="HCPCS">A4351</ItemAttribute>

<ItemAttribute name="Material">Vinyl</ItemAttribute>

<ItemAttribute name="Sterility">Sterile</ItemAttribute>

<ItemAttribute name="Style">Robinson, 2 Staggered Eyes</ItemAttribute>

<ItemAttribute name="Usage">Disposable</ItemAttribute>

<ItemAttribute name="User">Adult</ItemAttribute>

<ItemFeature>This product is required to be reported under California Proposition 65</ItemFeature>

</ItemExtra>

</ItemOut> </FeedResult>

</ItemFeedResponse>

I am using the following XSLT:

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

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

<xsl:output version='1.0' encoding='UTF-8' indent='no' method='xml' />

<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 EMPTYOK="YES" MAXREPEAT="1" NAME="itemID" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="statusCode" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="available" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="stockCode" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="stockDescription" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="uomUnits" TYPE="TEXT"/>

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

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

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="description" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="supplierID" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="manufacturerID" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="manufacturerName" TYPE="TEXT"/>

</METADATA>

<RESULTSET FOUND="">

<xsl:for-each select="ItemFeedResponse/FeedResult/ItemOut">

<ROW MODID="" RECORDID="">

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

<COL><DATA><xsl:value-of select="./ItemAvailability/ItemStatus/@code" /></DATA></COL>

<COL><DATA><xsl:value-of select="./ItemAvailability/ItemStatus/@available" /></DATA></COL>

<COL><DATA><xsl:value-of select="./ItemAvailability/ItemStock/@code" /></DATA></COL>

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

<COL><DATA><xsl:value-of select="./ItemAvailability/ItemUom/@units" /></DATA></COL>

<COL><DATA><xsl:value-of select="./ItemAvailability/ItemUom/@per" /></DATA></COL>

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

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

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

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

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

</ROW>

</xsl:for-each>

</RESULTSET>

</FMPXMLRESULT>

</xsl:template>

</xsl:stylesheet>

When I perform the import I don't get any errors, the field names show up correctly in the import dialogue, but there are no records to be imported. Basically it's importing a found set of "0". My gut is telling me it's because I have the "xsl:for-each select" value formatted incorrectly, but I'm not sure. Any help is appreciated.

Posted

HAH!, ok, techniquely my example worked for me too. And I've discovered why. The original XML that I'm importing makes a "xmlns=" declaration within the first element like this:

<ItemFeedResponse xmlns="http://[url of webservices]">

I had removed that attribute in my post just incase it violated any information agreements. Apparently the removal of that attribute makes everything work. So now my question is, assuming that the attribute will be in there, what would I need to change in my XSL to work with that?

Posted

Let's say it's:

<ItemFeedResponse xmlns="http://yourwebservice.com">

You need to declare the namespace in your stylesheet and assign it a prefix, say "svc":


<xsl:stylesheet version='1.0'

xmlns:xsl='http://www.w3.org/1999/XSL/Transform'

xmlns:svc='http://yourwebservice.com'

exclude-result-prefixes='svc'>





Now you need to use the prefix when you address the elements of the XML documents:





...

<xsl:for-each select="svc:ItemFeedResponse/svc:FeedResult/svc:ItemOut">

<ROW MODID="" RECORDID="">

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

<COL><DATA><xsl:value-of select="svc:ItemAvailability/svc:ItemStatus/@code" /></DATA></COL>

...

Posted

And it works! I actually had to remove the declaration from the individual elements to get it to work. Having just within the namespace works just fine. Thanks

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