Newbies eyepro Posted November 6, 2018 Newbies Posted November 6, 2018 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.
comment Posted November 6, 2018 Posted November 6, 2018 Your question is not entirely clear (mostly because you have omitted the parts that would enable to see the context). I suspect you simply want to put: <CUSTOMER> <xsl:value-of select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW[1]/fmp:COL[1]/fmp:DATA"/> </CUSTOMER> right before: <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW"> This will take the data from the first field in the first record and place it inside the CUSTOMER element (I take it that the customer is the same for all records being exported, as is the invoice). I don't know where the invoice number is, but the process should be the same.
Newbies eyepro Posted November 6, 2018 Author Newbies Posted November 6, 2018 (edited) Yes it is and works like a charm!!! Thanks for your prompt reply. Edited November 6, 2018 by eyepro
Newbies eyepro Posted November 8, 2018 Author Newbies Posted November 8, 2018 I have a issue: not all fields above xsl:for each are exported, some rows stays blank. If I export without stylesheet (using just FMPXMLRESULT) every row is exported correctly, but in wrong format. Where I'm wrong? I have discovered that the export changes according to the form where I am. If I'm on invoices some field are exported and some not, if I'm on Invoice details some exported and some not...possible? Thanks
comment Posted November 8, 2018 Posted November 8, 2018 I am afraid you're not being entirely clear. You determine which fields are exported, by selecting them in the export dialog. You can also select fields from a related table. However, you must pay attention which layout you are on when exporting, because that will affect the structure of your export - and your stylesheet would normally be designed for a specific structure. For example, if you export from Invoices, then each ROW will be an invoice. If you export from Lineitems, then each ROW will be a line item - and if your stylesheet was designed to create an invoice for each ROW, it will no longer work as expected. If that's your issue (and even if it's not), I would suggest you script your export, and start the script by going to a layout of the table from which you want to export.
Newbies eyepro Posted November 8, 2018 Author Newbies Posted November 8, 2018 Thanks. You mean that can't export from different related tables? What can't understand is why exporting without stylesheet works fine and with stylesheet no, exporting fields are the same. There is something wrong in stylesheet (attached)? Concerning the script is possible going from layout to layout and then append data to the xml? stylesheet.xsl
comment Posted November 8, 2018 Posted November 8, 2018 1 hour ago, eyepro said: You mean that can't export from different related tables? No, I mean that the XML exported from the parent table is structured differently from XML exported from the child table. They contain the same information - but a stylesheet written to process one cannot be used to process the other. 1 hour ago, eyepro said: There is something wrong in stylesheet (attached)? I don't see the source XML, and I don't know what your expected result is, so it's hard for me to say. What I do see is that your stylesheet creates a DettaglioLinee for each ROW. That means it is written for XML exported from a table where each detail line is an individual record. It will not work as expected if you export from Invoices or from Clients - even if you export exactly the same combination of fields from these tables. 1 hour ago, eyepro said: Concerning the script is possible going from layout to layout and then append data to the xml? I see no reason why you should ever need to do such thing.
comment Posted November 8, 2018 Posted November 8, 2018 (edited) BTW, this caught my eye at the last moment before closing your file. You have: <CodiceDestinatario><xsl:value-of select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW[2]/fmp:COL[2]/fmp:DATA"/></CodiceDestinatario> <PECDestinatario><xsl:value-of select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW[3]/fmp:COL[3]/fmp:DATA"/></PECDestinatario> I think this should be: <CodiceDestinatario><xsl:value-of select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW[1]/fmp:COL[2]/fmp:DATA"/></CodiceDestinatario> <PECDestinatario><xsl:value-of select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW[1]/fmp:COL[3]/fmp:DATA"/></PECDestinatario> i.e. ROW[1] instead of ROW[2] and ROW[3]. And the same goes for the rest of your header fields - they should all be getting their values from the first ROW - otherwise they will be empty if you ever export an invoice with fewer items. Edited November 8, 2018 by comment
Newbies eyepro Posted November 8, 2018 Author Newbies Posted November 8, 2018 3 hours ago, comment said: i.e. ROW[1] instead of ROW[2] and ROW[3]. it's working By the way do you know ho to remove spaces between lines. When open the xml with notepad++ i get this: ....sorry for dumb questions
comment Posted November 8, 2018 Posted November 8, 2018 It could be Notepad interpreting CRLF as two line breaks. Or it could be the bug mentioned here: https://fmforums.com/topic/100296-getting-on-xml-export-from-windows-server/ 1
Recommended Posts
This topic is 2473 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 accountSign in
Already have an account? Sign in here.
Sign In Now