Jump to content

What's wrong with my XSL mark up?


Lutmers
 Share

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

Recommended Posts

Dear friends,

 

Could someone check my XSL. I simply want to achieve following XML:

 

<invoices>

<invoice>

     <inv_id>280587</inv_id>

     <inv_number>274218</inv_number>

     <inv_date>20140401</inv_date>

     <inv_exclbtw>18.50</inv_exclbtw>

     <inv_btw>3.89</inv_btw>

     <inv_inclbtw>22.39</inv_inclbtw>

     <pdf>true</pdf>

     <invoiceprojects>

               <invoiceproject>

                      <project>SOHS35629</project>

                      <projectdescription>Locatie: zzzzz</projectdescription>

                      <orderreference>SOHS35629</orderreference>

                      <ordernumber>925402</ordernumber>

                      <portal_id></portal_id>

               </invoiceproject>

               <invoiceproject>

                      <project>SOHS35628</project>

                      <projectdescription>Locatie:xxxxxx</projectdescription>

                      <orderreference>SOHS35629</orderreference>

                      <ordernumber>925402</ordernumber>

                      <portal_id></portal_id>

             </invoiceproject>

     </invoiceprojects>

</invoice>

</invoices>

 

I currently have following written down. But the Project nodes stay empty...

 

<xsl:template match="/">
<invoices>
     <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
     <invoice>
     <inv_id><xsl:value-of select="fmp:COL[1]/fmp:DATA"/></inv_id>
     <inv_number><xsl:value-of select="fmp:COL[2]/fmp:DATA"/></inv_number>
     <inv_date><xsl:value-of select="fmp:COL[3]/fmp:DATA"/></inv_date>
     <inv_exclbtw><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></inv_exclbtw>
     <inv_btw><xsl:value-of select="fmp:COL[5]/fmp:DATA"/></inv_btw>
     <inv_inclbtw><xsl:value-of select="fmp:COL[6]/fmp:DATA"/></inv_inclbtw>
     <pdf><xsl:value-of select="fmp:COL[7]/fmp:DATA"/></pdf>
     <invoiceprojects>
          <xsl:for-each select="fmp:COL[8]/fmp:DATA">
          <invoiceproject>
               <project><xsl:value-of select="fmp:COL[8]/fmp:DATA"/></project>
               <projectdescription><xsl:value-of select="fmp:COL[9]/fmp:DATA"/></projectdescription>
               <orderreference><xsl:value-of select="fmp:COL[10]/fmp:DATA"/></orderreference>
               <ordernumber><xsl:value-of select="fmp:COL[11]/fmp:DATA"/></ordernumber>
               <portal_id><xsl:value-of select="fmp:COL[12]/fmp:DATA"/></portal_id>
          </invoiceproject>
          </xsl:for-each>
     </invoiceprojects>
     </invoice>
</xsl:for-each>
</invoices>
 
Can anybody help me with this... thanksl!!!
Jeroen
 
Link to comment
Share on other sites

The problem here is that when you do:

<invoiceprojects>
                    <xsl:for-each select="fmp:COL[8]/fmp:DATA">

you move the context to fmp:COL[8]/fmp:DATA. Then, when you try to output:

<project><xsl:value-of select="fmp:COL[8]/fmp:DATA"/></project>

you output an empty project, because the context node fmp:COL[8]/fmp:DATA has no child node fmp:COL[8]/fmp:DATA.

 

What you need to do is this:

...
<invoiceprojects>
    <xsl:for-each select="fmp:COL[8]/fmp:DATA">
        <invoiceproject>
            <xsl:variable name="pos" select="position()"/>
            <project><xsl:value-of select="."/></project>
            <projectdescription><xsl:value-of select="../../fmp:COL[9]/fmp:DATA[$pos]"/></projectdescription>
            <orderreference><xsl:value-of select="../../fmp:COL[10]/fmp:DATA[$pos]"/></orderreference>
            <ordernumber><xsl:value-of select="../../fmp:COL[11]/fmp:DATA[$pos]"/></ordernumber>
            <portal_id><xsl:value-of select="../../fmp:COL[12]/fmp:DATA[$pos]"/></portal_id>
        </invoiceproject>
    </xsl:for-each>
</invoiceprojects>
...

i.e. loop over the DATA elements of COL[8] and for each of these output first itself and then the corresponding DATA elements of the other columns originating in the child table.

Link to comment
Share on other sites

This topic is 2623 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
 Share

  • Similar Content

    • By pfroelicher
      it seems that php and xml publishing will not work on Linux based servers in 19.
      it is my understanding that zulu uses xml... will zulu no longer work if we port our server to linux?
      opinions apreciated.
      pierre
       
    • By DPaquin
      I have been going through the web to look for examples and I have not been successful. 
      Even when looking in Lynda.com.
       
      Over the years, I have been using plist files and now wants to change to xml. I am looking for example on how to export and import data in xml format with filmakers pro . Does anyone have an idea where I could find some information?
      The idea is to create a script which would import a xml file located on a SDHC card. A script is being used to format SDHC cards and at the same time the NX5UCarteNo field will be updated to identify the card with a number from 01 to 10. The information is the being exported as an XML file onto the SDHC card.
      The next time the SDHC card is mounted the script would then import it's content in the NX5U table. The xml file is to identify which SDHC card is being mounted. This would be done with the information saved under the NX5UCarteNo field.
      Thanks for your help!
      With regards!
      Daniel

    • By Laura Griffin Long
      I have an rss feed that returns data like this: 
      2009 LLCs, Corporations, & Business Legal Updates
      2009 Personal Finance Legal Updates
      2010 LLCs, Corporations, & Business Legal Updates
      2010 Personal Finance Legal Updates
      2011 Personal Finance Legal Updates
      2012 Wills, Trusts, and Estates Legal Updates 
      If I click on one of the links I can see the XML.  I need to import all of the XML into my database.  I have done XML/XSL imports before, but it is throwing me off because of the RSS List.  How do I go about this?  Right now I do a copy/paste on view source, put all of that into Notepad++ and then scrub the data.  I use that for an import into a Filemaker table to get the URL.  Then I do an insert by URL to get the XML into the table.  This seems like a lot, I am hoping there is an easier way.... 
    • By eyepro
      I'm very very very newbie on xml.
      What I need to understand is if it's possibile export in this way.
      I use a xsl stylesheet to export from FM.
       
      I was able to use the <xsl:for-each to export details in the way I want:
      <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
              <Details>
                  <Code><xsl:value-of select="fmp:COL[2]/fmp:DATA"/></Code>
                  <WTN><xsl:value-of select="fmp:COL[3]/fmp:DATA"/></WTN>
                  <Date><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></Date>
                  
      result:
      <Details>
      <Code>0280c1</Code>
      <WTN>1</WTN>
      <Date>10/04/2018</Date>
      </Details>
      <Details>
      <Code>0280c2</Code>
      <WTN>2</WTN>
      <Date>10/04/2018</Date>
      </Details>
      <Details>
      <Code>0280c3</Code>
      <WTN>3</WTN>
      <Date>10/04/2018</Date>
      </Details>
      what i need to know is how put the fmp:COL[1] above the <xsl:for-each to get this:
      <CUSTOMER>ABC</CUSTOMER>
      <INVOICE>01</INVOICE>
      <Details>
      <PrimaryKey>0280c1</PrimaryKey>
      <WTN>1</WTN>
      <Date>10/04/2018</Date>
      <Colours/>
      </Details>
      <Details>
      <PrimaryKey>0280c2</PrimaryKey>
      <WTN>2</WTN>
      <Date>10/04/2018</Date>
      <Colours/>
      </Details>
      <Details>
      <PrimaryKey>0280c3</PrimaryKey>
      <WTN>3</WTN>
      <Date>10/04/2018</Date>
      <Colours/>
      </Details>
       
      Thanks in advance.
    • By DarioDN
      Dear all, I've just create a script to export my records in multiple xml file (one xml for each record) applying also an XSL stylesheet.
      So, if I use the style.xsl taking from my computer ("source" button when filemaker ask me to select the file) it works. If I put the same file online, it doesn't work giving me a SAXParseException error: internal error in NetAccess (occurred in an unknown entity, at line 0, column 0).
      In the same folder where I have the style.xsl there are other xsl files that works, but they are used to "import" process (from XML to FILEMAKER, while in this case I'm working to an export process, from FILEMAKER to XML, I don't know if this could be the problem)
      Someone could help me to understand the error? Thank you
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fmp="http://www.filemaker.com/fmpxmlresult" exclude-result-prefixes="fmp" > <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="fmp:FMPXMLRESULT"> <xsl:for-each select="fmp:RESULTSET/fmp:ROW"> <xsl:text>&#xA;</xsl:text> <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text> <xsl:value-of select="fmp:COL[1]/fmp:DATA"/>.<xsl:value-of select="fmp:COL[2]/fmp:DATA"/>.<xsl:value-of select="fmp:COL[3]/fmp:DATA"/><xsl:text disable-output-escaping="yes">--&gt;</xsl:text> <problem display_name="Checkboxes" > <choiceresponse> <label><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></label> <checkboxgroup> <choice correct="{fmp:COL[6]/fmp:DATA}"> <xsl:value-of select="fmp:COL[5]/fmp:DATA"/> <choicehint selected="true"><xsl:value-of select="fmp:COL[7]/fmp:DATA"/> </choicehint> </choice> <choice correct="{fmp:COL[9]/fmp:DATA}"> <xsl:value-of select="fmp:COL[8]/fmp:DATA"/> <choicehint selected="true"><xsl:value-of select="fmp:COL[10]/fmp:DATA"/></choicehint> </choice> <choice correct="{fmp:COL[12]/fmp:DATA}"> <xsl:value-of select="fmp:COL[11]/fmp:DATA"/> <choicehint selected="true"><xsl:value-of select="fmp:COL[13]/fmp:DATA"/></choicehint> </choice> </checkboxgroup> </choiceresponse> </problem> <xsl:text>&#xA;</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>  
×
×
  • Create New...

Important Information

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