bkaisin

Parsing into FM - XML-XSLT

Discussion created by bkaisin on Apr 17, 2018
Latest reply on May 23, 2018 by beverly

Helo,

 

I have no experience importing XML into Filemaker and creation of XSL file; I spent the last days learning XML, XSLT and XPATH.

I have to parse a XML file but my XSLT seems not correct and I don't understand why no record are imported.

 

The XML file is not an easy one but I need only a couple of data per record.

Hereunder you will find the XML and XSL file, I need 5 fields (-> in my XSLT) and also 1 url (the 4th link -> href) which I have no idea yet how to get it.

I will appreciate if someone can help me.

 

Thanks

Regards

Ben

 

XML

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    
<title>UCD search</title>
    
<link rel="self" type="application/atom+xml" href="/rest/api/ucds?q=DAFALGAN&amp;status=AVAILABLE&amp;start-page=1&amp;page-size=25" title="Current page"/>
    
<id>vidal://ucds/</id>
    
<updated>2018-03-20T00:00:00Z</updated>
    
<opensearch:itemsPerPage xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">25</opensearch:itemsPerPage>
    
<opensearch:totalResults xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">10</opensearch:totalResults>
    
<opensearch:startIndex xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1</opensearch:startIndex>
    
<entry xmlns:vidal="http://api.vidal.net/-/spec/vidal-api/1.0/" vidal:categories="UCD">
        
<title>DAFALGAN 1000MG CPR EFFV</title>
        
<link rel="alternate" type="application/atom+xml" href="/rest/api/ucd/17175" title="UCD"/>
        
<link rel="related" type="application/atom+xml" href="/rest/api/ucd/17175/units" title="UNITS"/>
        
<link rel="related" type="application/atom+xml" href="/rest/api/ucd/17175/routes" title="ROUTES"/>
        
<link rel="related" type="application/atom+xml" href="/rest/api/ucd/17175/indicators" title="INDICATORS"/>
        
<link rel="related" type="application/atom+xml" href="/rest/api/ucd/17175/packages" title="PACKAGES"/>
        
<link rel="related" type="application/atom+xml" href="/rest/api/ucd/17175/products" title="PRODUCTS"/>
        
<link rel="related" type="application/atom+xml" href="/rest/api/product/4742" title="PRODUCT"/>
        
<link rel="related" type="application/atom+xml" href="/rest/api/vmp/3450" title="VMP"/>
        
<category term="UCD"/>
        
<author><name>VIDAL</name></author>
        
<id>vidal://ucd/17175</id>
        
<updated>2018-03-20T00:00:00Z</updated>
        
<summary type="text">PARACETAMOL 1 g cp efferv (DAFALGAN 1000MG CPR EFFV)</summary>
        
<content/>
        
<vidal:id>17175</vidal:id>
        
<vidal:name>DAFALGAN 1000MG CPR EFFV</vidal:name>
        
<vidal:marketStatus name="AVAILABLE">Commercialisé</vidal:marketStatus>
        
<vidal:horsGHS>false</vidal:horsGHS>
        
<vidal:ucd>9354573</vidal:ucd>
        
<vidal:ucd13>3400893545737</vidal:ucd13>
        
<vidal:minUcdRangePrice>0.145</vidal:minUcdRangePrice>
        
<vidal:maxUcdRangePrice>0.145</vidal:maxUcdRangePrice>
        
<vidal:safetyAlert>true</vidal:safetyAlert>
        
<vidal:vmp vidalId="3450">paracétamol * 1 g ; voie orale ; cp efferv</vidal:vmp>
    
</entry>
    
<entry xmlns:vidal="http://api.vidal.net/-/spec/vidal-api/1.0/" vidal:categories="UCD">

   I could have many entries like this above…

    </entry>
</feed>

 

 

MY XSLT

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/2005/Atom" xmlns:ns2="http://www.w3.org/1999/xlink">
    
<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="17/04/2018" NAME="FileMaker" VERSION="ProAdvanced 16.0.5"/>
            
<DATABASE DATEFORMAT="m.d.yyyy" LAYOUT="" NAME="" RECORDS="{count(/*/*)}"
                TIMEFORMAT="k:mm:ss "/>
            
<METADATA>
                
<!--  <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="link4" TYPE="TEXT"/>    -->
                
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="title" TYPE="TEXT"/>
                
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="vidal_id" TYPE="NUMBER"/>
                
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="vidal_marketStatus" TYPE="TEXT"/>
                
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="vidal_UCD" TYPE="NUMBER"/>
                
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="vidal_vmp" TYPE="TEXT"/>
            
</METADATA>
            
<RESULTSET FOUND="">
                
<xsl:for-each select="entry">
                    
<!--  <Row MODID="0" xmlns="http://www.filemaker.com/fmpxmlresult">  -->
                    
<!--      <col><DATA><xsl:value-of select="link4"/></DATA></col>  -->
                    
<!--  </Row>  -->
                    
<Row MODID="0" xmlns="http://www.filemaker.com/fmpxmlresult">
                        
<col><DATA><xsl:value-of select="//Field[@name='title']"/></DATA></col>
                    
</Row>
                    
<Row MODID="" xmlns="http://www.filemaker.com/fmpxmlresult">
                        
<col><DATA><xsl:value-of select="//Field[@name='vidal_id']"/></DATA></col>
                    
</Row>
                    
<Row MODID="" xmlns="http://www.filemaker.com/fmpxmlresult">
                        
<col><DATA><xsl:value-of select="//Field[@name='vidal_marketStatus']"/></DATA></col>
                    
</Row>
                    
<Row MODID="" xmlns="http://www.filemaker.com/fmpxmlresult">
                        
<col><DATA><xsl:value-of select="//Field[@name='vidal_UCD']"/></DATA></col>
                    
</Row>
                    
<Row MODID="" xmlns="http://www.filemaker.com/fmpxmlresult">
                        
<col><DATA><xsl:value-of select="//Field[@name='vidal_vmp']"/></DATA></col>
                    
</Row>
                
</xsl:for-each>
            
</RESULTSET>
        
</FMPXMLRESULT>
    
</xsl:template>
</xsl:stylesheet>

 

Outcomes