Jump to content

XSLT/XML Export Problem?


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

Recommended Posts

Hi,

 

I have optical store and I made Filemaker database to manage inventory of optical frames and lenses. Now I want to implement fiscal printer into same database so I can print receipts directly. Fiscal printer read xml files but files needs to be in some particular format, Filemaker does not export it that way.

So I will attach two files, One is example of what it should look like to be readable by printer and the other one is example of how file maker export it from my database.

This is sample what is what:

DATA BCR= Sifra Proizvoda

VAT= PDV stopa

PRC= MPC

AMN= Kolicina

 

Could someone help me write xslt file so I can export it the right way??? 

Thank you

RCP_104300.XMLUntitled.xml

Link to comment
Share on other sites

Try:

<?xml version="1.0" encoding="UTF-8"?>
<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 method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<RECEIPT>
    <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
        <DATA BCR='{fmp:COL[1]/fmp:DATA}' VAT='{fmp:COL[2]/fmp:DATA}' PRC='{fmp:COL[3]/fmp:DATA}' AMN='{fmp:COL[4]/fmp:DATA}'/>
    </xsl:for-each>
</RECEIPT>
</xsl:template>
</xsl:stylesheet>
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

I have tested it and it works excellent.

But now I have other issue by default printer total amount as cash. Sometimes I need to use money transfer or Credit Card. I made three fields for amounts of Credit Card, Money transfer and cash which is different table from my products table from above. Below is how final example should looks like. DATA AMN after products is amount of money and PAY= 0 or 1 or 2 is code for cash, money transfer or credit card.  If you could help me it will be appreciated?  

 

Thank you 

 

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

<RECEIPT>

<DATA BCR="315" VAT="1" MES="0" DEP="0" DSC="CR" PRC="7.50" AMN="2"/>

<DATA BCR="316" VAT="1" MES="0" DEP="0" DSC="CR" PRC="77.50" AMN="2"/>
<DATA BCR="317" VAT="1" MES="0" DEP="0" DSC="CR" PRC="777.50" AMN="2"/>
<DATA AMN="30.50" PAY="0"/>
<DATA AMN="10" PAY="1"/>
<DATA AMN="5000" PAY="2"/>
</RECEIPT>

Link to comment
Share on other sites

I made three fields for amounts of Credit Card, Money transfer and cash which is different table from my products table from above.

I am afraid that's not clear enough. Is the data required to populate the three <DATA AMN="@@@" PAY="X"/> elements present in the export? If so, where is it?

Link to comment
Share on other sites

DATA BCR="317" VAT="1" MES="0" DEP="0" DSC="CR" PRC="777.50" AMN="2"

this is exported from one table, and this is working good

I want to add DATA AMN="@@@" PAY="X"/ elements from other table at the end of as shown in example above. This is part where I need help. It should export amount of cash instead od "@@@" and 1 instead of "X" , Amount for Credit Card in next row instead of "@@@" and 2 instead of "X" etc etc

Link to comment
Share on other sites

1. You're not answering my question. I don't know how you can get the result you're looking for, because I don't understand what you're starting with.

2. I suspect you are making this more complicated than it needs to be. If you are exporting records that have an amount and a type, you can tell the stylesheet to summarize the amounts by type at the end (this is assuming you want to summarize the amounts by type - in your example above the totals do not add up).

Link to comment
Share on other sites

Table A conatins:

1.Patient details(name, birth date, phone etc...)

2. Portal related to Table B (which contains products like : lens, optical frame...)

3. Thee fields Called: 1.Cash, 2.Money Transfer, 3. Credit Card

with first stylesheet you helped me to export product details like this(<DATA BCR="315" VAT="1" MES="0" DEP="0" DSC="CR" PRC="7.50" AMN="2"/>) when it is exported to specific folder fiscal printer print receipt, by default receipt is always payed in cash. If I add DATA AMN="@@@" PAY="X" after list of products I can specify type of payment this is everything should be exported as one XML file from Filemaker.

So if I have patient who spent $100 (for frame $60 and for lens $20x2=$40)and he want to pay in cash=$20, Credit card=$50 and money transfer=$30 this is how xml file should look like:

 

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

<RECEIPT>

<DATA BCR="315" VAT="1" MES="0" DEP="0" DSC="LENS" PRC="20.00" AMN="2"/>

<DATA BCR="316" VAT="1" MES="0" DEP="0" DSC="FRAME" PRC="60.00" AMN="1"/>
<DATA AMN="20" PAY="0"/>
<DATA AMN="50" PAY="1"/>
<DATA AMN="30" PAY="2"/>
</RECEIPT>

 
 
Link to comment
Share on other sites

:)  Records from both table should be included in one xml file.

This is what I get from Table B

<DATA BCR="315" VAT="1" MES="0" DEP="0" DSC="LENS" PRC="20.00" AMN="2"/>

<DATA BCR="316" VAT="1" MES="0" DEP="0" DSC="FRAME" PRC="60.00" AMN="1"/>

and this from Table A (should get)

<DATA AMN="20" PAY="0"/>
<DATA AMN="50" PAY="1"/>
<DATA AMN="30" PAY="2"/>

 

Link to comment
Share on other sites

:)  Records from both table should be included in one xml file.

​Yes, I understand that - but you can export from only one table. You can include fields from related tables, but exporting from the parent table with child fields included is not the same thing as exporting from the child table with the parent fields included.

So, assuming you are exporting from a layout of the child table, and your export field order looks something like this:

exp.thumb.png.5a6c3c8413d70867a8ff94fe33

Note there are 4 child fields and 3 parent fields exported. Their order matters. If you export in this manner, you can use the following stylesheet to format the export:

<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 method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
	<RECEIPT>
		<xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
			<DATA BCR="{fmp:COL[1]/fmp:DATA}" VAT="1" MES="0" DEP="0" DSC="{fmp:COL[2]/fmp:DATA}" PRC="{fmp:COL[3]/fmp:DATA}" AMN="{fmp:COL[4]/fmp:DATA}"/>
		</xsl:for-each>
		<xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW[1]">
			<DATA AMN="{fmp:COL[5]/fmp:DATA}" PAY="0"/>
			<DATA AMN="{fmp:COL[6]/fmp:DATA}" PAY="1"/>
			<DATA AMN="{fmp:COL[7]/fmp:DATA}" PAY="2"/>
		</xsl:for-each>
	</RECEIPT>
</xsl:template>

</xsl:stylesheet>

 

  • Like 1
Link to comment
Share on other sites

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