Hi all,
I am looking for a generic XML import & export functionality in OFBiz, but have a hard time finding it. Can you point me towards the right direction? Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com |
Maybe kettle.
http://community.pentaho.com/projects/data-integration/ On Fri, Jun 27, 2014 at 2:17 AM, Pierre Smits <[hidden email]> wrote: > Hi all, > > I am looking for a generic XML import & export functionality in OFBiz, but > have a hard time finding it. > > Can you point me towards the right direction? > > Regards, > > Pierre Smits > > *ORRTIZ.COM <http://www.orrtiz.com>* > Services & Solutions for Cloud- > Based Manufacturing, Professional > Services and Retail & Trade > http://www.orrtiz.com > |
Entity Import and Entity Import Dir are two great tools in Ofbiz to achieve
that. *Entity Import: *To import XML text http://demo-stable-ofbiz.apache.org/webtools/control/EntityImport *Entity Import Dir: *To import entity XML files loaded with data kept in a directory relative to Ofbiz home directory http://demo-stable-ofbiz.apache.org/webtools/control/EntityImportDir Seed writer utilities are also available in the base framework to generate Seed XML using GenericValue or Maps. On Fri, Jun 27, 2014 at 2:14 PM, Mike <[hidden email]> wrote: > Maybe kettle. > > http://community.pentaho.com/projects/data-integration/ > > > > > On Fri, Jun 27, 2014 at 2:17 AM, Pierre Smits <[hidden email]> > wrote: > > > Hi all, > > > > I am looking for a generic XML import & export functionality in OFBiz, > but > > have a hard time finding it. > > > > Can you point me towards the right direction? > > > > Regards, > > > > Pierre Smits > > > > *ORRTIZ.COM <http://www.orrtiz.com>* > > Services & Solutions for Cloud- > > Based Manufacturing, Professional > > Services and Retail & Trade > > http://www.orrtiz.com > > > |
In reply to this post by Mike Z
Hi Mike,
Thank you for you input, but scaffolding another toolset to just import standardized XML data, seems a bit like overkill to me. Regards, Pierre Verstuurd vanaf mijn iPad > Op 27 jun. 2014 om 23:14 heeft Mike <[hidden email]> het volgende geschreven: > > Maybe kettle. > > http://community.pentaho.com/projects/data-integration/ > > > > > On Fri, Jun 27, 2014 at 2:17 AM, Pierre Smits <[hidden email]> > wrote: > >> Hi all, >> >> I am looking for a generic XML import & export functionality in OFBiz, but >> have a hard time finding it. >> >> Can you point me towards the right direction? >> >> Regards, >> >> Pierre Smits >> >> *ORRTIZ.COM <http://www.orrtiz.com>* >> Services & Solutions for Cloud- >> Based Manufacturing, Professional >> Services and Retail & Trade >> http://www.orrtiz.com >> |
In reply to this post by Mandeep Sidhu
Hi Mandeep,
Thank you for your feedback. The thing with your suggestion is that the tools require a predefined format of the XML, namely recognizable as entity data. My XML data is not in that format, so it must be converted. Regards, Pierre Verstuurd vanaf mijn iPad > Op 28 jun. 2014 om 06:46 heeft Mandeep Sidhu <[hidden email]> het volgende geschreven: > > Entity Import and Entity Import Dir are two great tools in Ofbiz to achieve > that. > > *Entity Import: *To import XML text > http://demo-stable-ofbiz.apache.org/webtools/control/EntityImport > *Entity Import Dir: *To import entity XML files loaded with data kept in a > directory relative to Ofbiz home directory > http://demo-stable-ofbiz.apache.org/webtools/control/EntityImportDir > > Seed writer utilities are also available in the base framework to generate > Seed XML using GenericValue or Maps. > > >> On Fri, Jun 27, 2014 at 2:14 PM, Mike <[hidden email]> wrote: >> >> Maybe kettle. >> >> http://community.pentaho.com/projects/data-integration/ >> >> >> >> >> On Fri, Jun 27, 2014 at 2:17 AM, Pierre Smits <[hidden email]> >> wrote: >> >>> Hi all, >>> >>> I am looking for a generic XML import & export functionality in OFBiz, >> but >>> have a hard time finding it. >>> >>> Can you point me towards the right direction? >>> >>> Regards, >>> >>> Pierre Smits >>> >>> *ORRTIZ.COM <http://www.orrtiz.com>* >>> Services & Solutions for Cloud- >>> Based Manufacturing, Professional >>> Services and Retail & Trade >>> http://www.orrtiz.com >> |
Hi Pierre,
It seems like what you need is not related to ofbiz and you should instead use standard tools. XQuery seems to be what you need unless you can be specific on what needs conversion. Taher Alkhateeb On Jun 28, 2014 9:48 PM, "Pierre Smits" <[hidden email]> wrote: > Hi Mandeep, > > Thank you for your feedback. The thing with your suggestion is that the > tools require a predefined format of the XML, namely recognizable as entity > data. > > My XML data is not in that format, so it must be converted. > > Regards, > > Pierre > > Verstuurd vanaf mijn iPad > > > Op 28 jun. 2014 om 06:46 heeft Mandeep Sidhu <[hidden email]> > het volgende geschreven: > > > > Entity Import and Entity Import Dir are two great tools in Ofbiz to > achieve > > that. > > > > *Entity Import: *To import XML text > > http://demo-stable-ofbiz.apache.org/webtools/control/EntityImport > > *Entity Import Dir: *To import entity XML files loaded with data kept in > a > > directory relative to Ofbiz home directory > > http://demo-stable-ofbiz.apache.org/webtools/control/EntityImportDir > > > > Seed writer utilities are also available in the base framework to > generate > > Seed XML using GenericValue or Maps. > > > > > >> On Fri, Jun 27, 2014 at 2:14 PM, Mike <[hidden email]> wrote: > >> > >> Maybe kettle. > >> > >> http://community.pentaho.com/projects/data-integration/ > >> > >> > >> > >> > >> On Fri, Jun 27, 2014 at 2:17 AM, Pierre Smits <[hidden email]> > >> wrote: > >> > >>> Hi all, > >>> > >>> I am looking for a generic XML import & export functionality in OFBiz, > >> but > >>> have a hard time finding it. > >>> > >>> Can you point me towards the right direction? > >>> > >>> Regards, > >>> > >>> Pierre Smits > >>> > >>> *ORRTIZ.COM <http://www.orrtiz.com>* > >>> Services & Solutions for Cloud- > >>> Based Manufacturing, Professional > >>> Services and Retail & Trade > >>> http://www.orrtiz.com > >> > |
Hi Taher (I trust that is your first name),
It is related to OFBiz as the elements in the XML file need to be processed in OFBiz and lead to the creation of new entities. The process for the majority of our customers is uploading this XML file. For the minority of other customers other means are available. In the scenario of uploading, the uploaded file itself must be processed but not stored in the (file system) of the OFBiz setup. Basically, the XML file consists of: - <?xml version="1.0" encoding="UTF-8" standalone="yes"?> - followed by a document tag pointing to a standardized urn (<Document xmlns="urn:iso:std:iso:12345:etc:etc"> - subsequently the actual content (to be processed by OFBiz) of the document is presented. This content consists of tags (and some tags have sub tags) that need to be verified against data already in OFBiz and in predetermined cases lead to the creation of new entity records. Some of the sub tags are data elements of the parent tags, but other sub tags are new (other, but related) entity records. Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com |
Hi Pierre,
Yes my first name is Taher. So essentially you need to do the following: - upload an XML file - validate it (assuming you need to) - do some custom business logic However, this can go a hundred different directions depending on the complexity of the logic you mentioned below. You might only get partial implementation from OFBiz such as uploading and parsing. I think you still have to do all the logic yourself! Also, I am not sure how big/small are these files, and whether you need to parse into DOM or SAX (if performance matters) such as the implementation for the entity engine in org.ofbiz.entity.util.EntitySaxReader.java Sorry if this is not a lot of help but I doubt you can find anything in the framework to satisfy your needs as you are not repeating any functionality that already exists. Regards, Taher Alkhateeb ----- Original Message ----- From: "Pierre Smits" <[hidden email]> To: [hidden email] Sent: Saturday, June 28, 2014 10:50:23 PM Subject: Re: Generic xml import & export functionality Hi Taher (I trust that is your first name), It is related to OFBiz as the elements in the XML file need to be processed in OFBiz and lead to the creation of new entities. The process for the majority of our customers is uploading this XML file. For the minority of other customers other means are available. In the scenario of uploading, the uploaded file itself must be processed but not stored in the (file system) of the OFBiz setup. Basically, the XML file consists of: - <?xml version="1.0" encoding="UTF-8" standalone="yes"?> - followed by a document tag pointing to a standardized urn (<Document xmlns="urn:iso:std:iso:12345:etc:etc"> - subsequently the actual content (to be processed by OFBiz) of the document is presented. This content consists of tags (and some tags have sub tags) that need to be verified against data already in OFBiz and in predetermined cases lead to the creation of new entity records. Some of the sub tags are data elements of the parent tags, but other sub tags are new (other, but related) entity records. Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com |
Taher,
Any hint towards a direction is help. So, thank you. Yes, validating is essential. Thus, having to do custom business logic is expected. On average, based on the example XML files I have received the majority of those files are below 100 kB. But, exceptions will always exist. Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com > > |
Pierre,
I would suggest you to create XML schema for your XML. Schema can do some validation beyond well formed document. Write your business rules validator for validation which are not handled by schema. Use XSLT to transform your document to entity-engine XML. From there on OFBiz can take care of importing the data into database using entity-engine XML. Regards, Raj On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: > Taher, > > Any hint towards a direction is help. So, thank you. > > Yes, validating is essential. Thus, having to do custom business logic is > expected. > > On average, based on the example XML files I have received the majority of > those files are below 100 kB. But, exceptions will always exist. > > Regards, > > > Pierre Smits > > *ORRTIZ.COM <http://www.orrtiz.com>* > Services & Solutions for Cloud- > Based Manufacturing, Professional > Services and Retail & Trade > http://www.orrtiz.com > >> |
I agree. Using a transformer seems the way to go.
Adrian Crum Sandglass Software www.sandglass-software.com On 6/28/2014 6:41 PM, Rajbir Saini wrote: > Pierre, > > I would suggest you to create XML schema for your XML. Schema can do > some validation beyond well formed document. Write your business rules > validator for validation which are not handled by schema. Use XSLT to > transform your document to entity-engine XML. From there on OFBiz can > take care of importing the data into database using entity-engine XML. > > Regards, > > Raj > On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: >> Taher, >> >> Any hint towards a direction is help. So, thank you. >> >> Yes, validating is essential. Thus, having to do custom business logic is >> expected. >> >> On average, based on the example XML files I have received the >> majority of >> those files are below 100 kB. But, exceptions will always exist. >> >> Regards, >> >> >> Pierre Smits >> >> *ORRTIZ.COM <http://www.orrtiz.com>* >> Services & Solutions for Cloud- >> Based Manufacturing, Professional >> Services and Retail & Trade >> http://www.orrtiz.com >> >>> > |
Hi All,
Thanks for your contributions. So I found that there is a set of services related to handling XML in UtilXml.java. It looks like that file contains (parts of) the solution needed for my requirements. Question is: do you know of an example in OFBiz applying some of the functions to process an external XML file? Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com On Sun, Jun 29, 2014 at 10:11 PM, Adrian Crum < [hidden email]> wrote: > I agree. Using a transformer seems the way to go. > > Adrian Crum > Sandglass Software > www.sandglass-software.com > > > On 6/28/2014 6:41 PM, Rajbir Saini wrote: > >> Pierre, >> >> I would suggest you to create XML schema for your XML. Schema can do >> some validation beyond well formed document. Write your business rules >> validator for validation which are not handled by schema. Use XSLT to >> transform your document to entity-engine XML. From there on OFBiz can >> take care of importing the data into database using entity-engine XML. >> >> Regards, >> >> Raj >> On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: >> >>> Taher, >>> >>> Any hint towards a direction is help. So, thank you. >>> >>> Yes, validating is essential. Thus, having to do custom business logic is >>> expected. >>> >>> On average, based on the example XML files I have received the >>> majority of >>> those files are below 100 kB. But, exceptions will always exist. >>> >>> Regards, >>> >>> >>> Pierre Smits >>> >>> *ORRTIZ.COM <http://www.orrtiz.com>* >>> Services & Solutions for Cloud- >>> Based Manufacturing, Professional >>> Services and Retail & Trade >>> http://www.orrtiz.com >>> >>> >>>> >> |
Have a good look at XSLT before starting to write code.
http://www.w3schools.com/xsl/xsl_transformation.asp http://www.cs.toronto.edu/~ryanjohn/teaching/cscc43-s12/lectures/c43-xslt-v02.pdf A couple of good books from O'Reilly: XSLT Cookbook Solutions and Examples for XML and XSLT Developers http://shop.oreilly.com/product/9780596003722.do XSLT, 2nd Edition Mastering XML Transformations Ron On 01/07/2014 5:37 AM, Pierre Smits wrote: > Hi All, > > Thanks for your contributions. So I found that there is a set of services > related to handling XML in UtilXml.java. It looks like that file contains > (parts of) the solution needed for my requirements. > > Question is: do you know of an example in OFBiz applying some of the > functions to process an external XML file? > > Regards, > > Pierre Smits > > *ORRTIZ.COM <http://www.orrtiz.com>* > Services & Solutions for Cloud- > Based Manufacturing, Professional > Services and Retail & Trade > http://www.orrtiz.com > > > On Sun, Jun 29, 2014 at 10:11 PM, Adrian Crum < > [hidden email]> wrote: > >> I agree. Using a transformer seems the way to go. >> >> Adrian Crum >> Sandglass Software >> www.sandglass-software.com >> >> >> On 6/28/2014 6:41 PM, Rajbir Saini wrote: >> >>> Pierre, >>> >>> I would suggest you to create XML schema for your XML. Schema can do >>> some validation beyond well formed document. Write your business rules >>> validator for validation which are not handled by schema. Use XSLT to >>> transform your document to entity-engine XML. From there on OFBiz can >>> take care of importing the data into database using entity-engine XML. >>> >>> Regards, >>> >>> Raj >>> On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: >>> >>>> Taher, >>>> >>>> Any hint towards a direction is help. So, thank you. >>>> >>>> Yes, validating is essential. Thus, having to do custom business logic is >>>> expected. >>>> >>>> On average, based on the example XML files I have received the >>>> majority of >>>> those files are below 100 kB. But, exceptions will always exist. >>>> >>>> Regards, >>>> >>>> >>>> Pierre Smits >>>> >>>> *ORRTIZ.COM <http://www.orrtiz.com>* >>>> Services & Solutions for Cloud- >>>> Based Manufacturing, Professional >>>> Services and Retail & Trade >>>> http://www.orrtiz.com >>>> >>>> -- Ron Wheeler President Artifact Software Inc email: [hidden email] skype: ronaldmwheeler phone: 866-970-2435, ext 102 |
Ron,
Thans! Regards, Pierre Sent from my iPhone > On 1 jul. 2014, at 17:06, Ron Wheeler <[hidden email]> wrote: > > Have a good look at XSLT before starting to write code. > > http://www.w3schools.com/xsl/xsl_transformation.asp > http://www.cs.toronto.edu/~ryanjohn/teaching/cscc43-s12/lectures/c43-xslt-v02.pdf > > A couple of good books from O'Reilly: > XSLT Cookbook Solutions and Examples for XML and XSLT Developers > http://shop.oreilly.com/product/9780596003722.do > > XSLT, 2nd Edition > Mastering XML Transformations > > Ron > >> On 01/07/2014 5:37 AM, Pierre Smits wrote: >> Hi All, >> >> Thanks for your contributions. So I found that there is a set of services >> related to handling XML in UtilXml.java. It looks like that file contains >> (parts of) the solution needed for my requirements. >> >> Question is: do you know of an example in OFBiz applying some of the >> functions to process an external XML file? >> >> Regards, >> >> Pierre Smits >> >> *ORRTIZ.COM <http://www.orrtiz.com>* >> Services & Solutions for Cloud- >> Based Manufacturing, Professional >> Services and Retail & Trade >> http://www.orrtiz.com >> >> >> On Sun, Jun 29, 2014 at 10:11 PM, Adrian Crum < >> [hidden email]> wrote: >> >>> I agree. Using a transformer seems the way to go. >>> >>> Adrian Crum >>> Sandglass Software >>> www.sandglass-software.com >>> >>> >>>> On 6/28/2014 6:41 PM, Rajbir Saini wrote: >>>> >>>> Pierre, >>>> >>>> I would suggest you to create XML schema for your XML. Schema can do >>>> some validation beyond well formed document. Write your business rules >>>> validator for validation which are not handled by schema. Use XSLT to >>>> transform your document to entity-engine XML. From there on OFBiz can >>>> take care of importing the data into database using entity-engine XML. >>>> >>>> Regards, >>>> >>>> Raj >>>>> On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: >>>>> >>>>> Taher, >>>>> >>>>> Any hint towards a direction is help. So, thank you. >>>>> >>>>> Yes, validating is essential. Thus, having to do custom business logic is >>>>> expected. >>>>> >>>>> On average, based on the example XML files I have received the >>>>> majority of >>>>> those files are below 100 kB. But, exceptions will always exist. >>>>> >>>>> Regards, >>>>> >>>>> >>>>> Pierre Smits >>>>> >>>>> *ORRTIZ.COM <http://www.orrtiz.com>* >>>>> Services & Solutions for Cloud- >>>>> Based Manufacturing, Professional >>>>> Services and Retail & Trade >>>>> http://www.orrtiz.com > > > -- > Ron Wheeler > President > Artifact Software Inc > email: [hidden email] > skype: ronaldmwheeler > phone: 866-970-2435, ext 102 > |
Hi pierre
I am not sure if XSLT alone is enough. Are you only converting xml to xml? If no then you must parse into DOM and apply some business logic. Also UtilXml has alot of examples. Just follow the code from the controller and you will see it pop up all over the place as the screens and forms are parsed into DOM. There is more than enough code in the framework itself. Taher Alkhateeb On Jul 1, 2014 5:13 PM, "Pierre @GMail" <[hidden email]> wrote: > Ron, > > Thans! > > Regards, > > Pierre > > Sent from my iPhone > > > On 1 jul. 2014, at 17:06, Ron Wheeler <[hidden email]> > wrote: > > > > Have a good look at XSLT before starting to write code. > > > > http://www.w3schools.com/xsl/xsl_transformation.asp > > > http://www.cs.toronto.edu/~ryanjohn/teaching/cscc43-s12/lectures/c43-xslt-v02.pdf > > > > A couple of good books from O'Reilly: > > XSLT Cookbook Solutions and Examples for XML and XSLT Developers > > http://shop.oreilly.com/product/9780596003722.do > > > > XSLT, 2nd Edition > > Mastering XML Transformations > > > > Ron > > > >> On 01/07/2014 5:37 AM, Pierre Smits wrote: > >> Hi All, > >> > >> Thanks for your contributions. So I found that there is a set of > services > >> related to handling XML in UtilXml.java. It looks like that file > contains > >> (parts of) the solution needed for my requirements. > >> > >> Question is: do you know of an example in OFBiz applying some of the > >> functions to process an external XML file? > >> > >> Regards, > >> > >> Pierre Smits > >> > >> *ORRTIZ.COM <http://www.orrtiz.com>* > >> Services & Solutions for Cloud- > >> Based Manufacturing, Professional > >> Services and Retail & Trade > >> http://www.orrtiz.com > >> > >> > >> On Sun, Jun 29, 2014 at 10:11 PM, Adrian Crum < > >> [hidden email]> wrote: > >> > >>> I agree. Using a transformer seems the way to go. > >>> > >>> Adrian Crum > >>> Sandglass Software > >>> www.sandglass-software.com > >>> > >>> > >>>> On 6/28/2014 6:41 PM, Rajbir Saini wrote: > >>>> > >>>> Pierre, > >>>> > >>>> I would suggest you to create XML schema for your XML. Schema can do > >>>> some validation beyond well formed document. Write your business rules > >>>> validator for validation which are not handled by schema. Use XSLT to > >>>> transform your document to entity-engine XML. From there on OFBiz can > >>>> take care of importing the data into database using entity-engine XML. > >>>> > >>>> Regards, > >>>> > >>>> Raj > >>>>> On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: > >>>>> > >>>>> Taher, > >>>>> > >>>>> Any hint towards a direction is help. So, thank you. > >>>>> > >>>>> Yes, validating is essential. Thus, having to do custom business > logic is > >>>>> expected. > >>>>> > >>>>> On average, based on the example XML files I have received the > >>>>> majority of > >>>>> those files are below 100 kB. But, exceptions will always exist. > >>>>> > >>>>> Regards, > >>>>> > >>>>> > >>>>> Pierre Smits > >>>>> > >>>>> *ORRTIZ.COM <http://www.orrtiz.com>* > >>>>> Services & Solutions for Cloud- > >>>>> Based Manufacturing, Professional > >>>>> Services and Retail & Trade > >>>>> http://www.orrtiz.com > > > > > > -- > > Ron Wheeler > > President > > Artifact Software Inc > > email: [hidden email] > > skype: ronaldmwheeler > > phone: 866-970-2435, ext 102 > > > |
Administrator
|
Also Freemarker can be used for this kind of tasks..
Jacques Le 01/07/2014 16:43, Taher Alkhateeb a écrit : > Hi pierre > > I am not sure if XSLT alone is enough. Are you only converting xml to xml? > If no then you must parse into DOM and apply some business logic. > > Also UtilXml has alot of examples. Just follow the code from the controller > and you will see it pop up all over the place as the screens and forms are > parsed into DOM. There is more than enough code in the framework itself. > > Taher Alkhateeb > On Jul 1, 2014 5:13 PM, "Pierre @GMail" <[hidden email]> wrote: > >> Ron, >> >> Thans! >> >> Regards, >> >> Pierre >> >> Sent from my iPhone >> >>> On 1 jul. 2014, at 17:06, Ron Wheeler <[hidden email]> >> wrote: >>> Have a good look at XSLT before starting to write code. >>> >>> http://www.w3schools.com/xsl/xsl_transformation.asp >>> >> http://www.cs.toronto.edu/~ryanjohn/teaching/cscc43-s12/lectures/c43-xslt-v02.pdf >>> A couple of good books from O'Reilly: >>> XSLT Cookbook Solutions and Examples for XML and XSLT Developers >>> http://shop.oreilly.com/product/9780596003722.do >>> >>> XSLT, 2nd Edition >>> Mastering XML Transformations >>> >>> Ron >>> >>>> On 01/07/2014 5:37 AM, Pierre Smits wrote: >>>> Hi All, >>>> >>>> Thanks for your contributions. So I found that there is a set of >> services >>>> related to handling XML in UtilXml.java. It looks like that file >> contains >>>> (parts of) the solution needed for my requirements. >>>> >>>> Question is: do you know of an example in OFBiz applying some of the >>>> functions to process an external XML file? >>>> >>>> Regards, >>>> >>>> Pierre Smits >>>> >>>> *ORRTIZ.COM <http://www.orrtiz.com>* >>>> Services & Solutions for Cloud- >>>> Based Manufacturing, Professional >>>> Services and Retail & Trade >>>> http://www.orrtiz.com >>>> >>>> >>>> On Sun, Jun 29, 2014 at 10:11 PM, Adrian Crum < >>>> [hidden email]> wrote: >>>> >>>>> I agree. Using a transformer seems the way to go. >>>>> >>>>> Adrian Crum >>>>> Sandglass Software >>>>> www.sandglass-software.com >>>>> >>>>> >>>>>> On 6/28/2014 6:41 PM, Rajbir Saini wrote: >>>>>> >>>>>> Pierre, >>>>>> >>>>>> I would suggest you to create XML schema for your XML. Schema can do >>>>>> some validation beyond well formed document. Write your business rules >>>>>> validator for validation which are not handled by schema. Use XSLT to >>>>>> transform your document to entity-engine XML. From there on OFBiz can >>>>>> take care of importing the data into database using entity-engine XML. >>>>>> >>>>>> Regards, >>>>>> >>>>>> Raj >>>>>>> On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: >>>>>>> >>>>>>> Taher, >>>>>>> >>>>>>> Any hint towards a direction is help. So, thank you. >>>>>>> >>>>>>> Yes, validating is essential. Thus, having to do custom business >> logic is >>>>>>> expected. >>>>>>> >>>>>>> On average, based on the example XML files I have received the >>>>>>> majority of >>>>>>> those files are below 100 kB. But, exceptions will always exist. >>>>>>> >>>>>>> Regards, >>>>>>> >>>>>>> >>>>>>> Pierre Smits >>>>>>> >>>>>>> *ORRTIZ.COM <http://www.orrtiz.com>* >>>>>>> Services & Solutions for Cloud- >>>>>>> Based Manufacturing, Professional >>>>>>> Services and Retail & Trade >>>>>>> http://www.orrtiz.com >>> >>> -- >>> Ron Wheeler >>> President >>> Artifact Software Inc >>> email: [hidden email] >>> skype: ronaldmwheeler >>> phone: 866-970-2435, ext 102 >>> -- |
In reply to this post by taher
Taher,
Thank you. No, the conversion of the XML file is necessary to create entity records. Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com |
Administrator
|
In reply to this post by Jacques Le Roux
It's old but still relevant... http://markmail.org/message/bbvz5jtt2yq7lotj
Jacques Le 01/07/2014 20:26, Jacques Le Roux a écrit : > Also Freemarker can be used for this kind of tasks.. > > Jacques > > Le 01/07/2014 16:43, Taher Alkhateeb a écrit : >> Hi pierre >> >> I am not sure if XSLT alone is enough. Are you only converting xml to xml? >> If no then you must parse into DOM and apply some business logic. >> >> Also UtilXml has alot of examples. Just follow the code from the controller >> and you will see it pop up all over the place as the screens and forms are >> parsed into DOM. There is more than enough code in the framework itself. >> >> Taher Alkhateeb >> On Jul 1, 2014 5:13 PM, "Pierre @GMail" <[hidden email]> wrote: >> >>> Ron, >>> >>> Thans! >>> >>> Regards, >>> >>> Pierre >>> >>> Sent from my iPhone >>> >>>> On 1 jul. 2014, at 17:06, Ron Wheeler <[hidden email]> >>> wrote: >>>> Have a good look at XSLT before starting to write code. >>>> >>>> http://www.w3schools.com/xsl/xsl_transformation.asp >>>> >>> http://www.cs.toronto.edu/~ryanjohn/teaching/cscc43-s12/lectures/c43-xslt-v02.pdf >>>> A couple of good books from O'Reilly: >>>> XSLT Cookbook Solutions and Examples for XML and XSLT Developers >>>> http://shop.oreilly.com/product/9780596003722.do >>>> >>>> XSLT, 2nd Edition >>>> Mastering XML Transformations >>>> >>>> Ron >>>> >>>>> On 01/07/2014 5:37 AM, Pierre Smits wrote: >>>>> Hi All, >>>>> >>>>> Thanks for your contributions. So I found that there is a set of >>> services >>>>> related to handling XML in UtilXml.java. It looks like that file >>> contains >>>>> (parts of) the solution needed for my requirements. >>>>> >>>>> Question is: do you know of an example in OFBiz applying some of the >>>>> functions to process an external XML file? >>>>> >>>>> Regards, >>>>> >>>>> Pierre Smits >>>>> >>>>> *ORRTIZ.COM <http://www.orrtiz.com>* >>>>> Services & Solutions for Cloud- >>>>> Based Manufacturing, Professional >>>>> Services and Retail & Trade >>>>> http://www.orrtiz.com >>>>> >>>>> >>>>> On Sun, Jun 29, 2014 at 10:11 PM, Adrian Crum < >>>>> [hidden email]> wrote: >>>>> >>>>>> I agree. Using a transformer seems the way to go. >>>>>> >>>>>> Adrian Crum >>>>>> Sandglass Software >>>>>> www.sandglass-software.com >>>>>> >>>>>> >>>>>>> On 6/28/2014 6:41 PM, Rajbir Saini wrote: >>>>>>> >>>>>>> Pierre, >>>>>>> >>>>>>> I would suggest you to create XML schema for your XML. Schema can do >>>>>>> some validation beyond well formed document. Write your business rules >>>>>>> validator for validation which are not handled by schema. Use XSLT to >>>>>>> transform your document to entity-engine XML. From there on OFBiz can >>>>>>> take care of importing the data into database using entity-engine XML. >>>>>>> >>>>>>> Regards, >>>>>>> >>>>>>> Raj >>>>>>>> On Sunday 29 June 2014 02:41 AM, Pierre Smits wrote: >>>>>>>> >>>>>>>> Taher, >>>>>>>> >>>>>>>> Any hint towards a direction is help. So, thank you. >>>>>>>> >>>>>>>> Yes, validating is essential. Thus, having to do custom business >>> logic is >>>>>>>> expected. >>>>>>>> >>>>>>>> On average, based on the example XML files I have received the >>>>>>>> majority of >>>>>>>> those files are below 100 kB. But, exceptions will always exist. >>>>>>>> >>>>>>>> Regards, >>>>>>>> >>>>>>>> >>>>>>>> Pierre Smits >>>>>>>> >>>>>>>> *ORRTIZ.COM <http://www.orrtiz.com>* >>>>>>>> Services & Solutions for Cloud- >>>>>>>> Based Manufacturing, Professional >>>>>>>> Services and Retail & Trade >>>>>>>> http://www.orrtiz.com >>>> >>>> -- >>>> Ron Wheeler >>>> President >>>> Artifact Software Inc >>>> email: [hidden email] >>>> skype: ronaldmwheeler >>>> phone: 866-970-2435, ext 102 >>>> > -- |
Hi all,
Based on some code in OFBiz, I came up with the following to enable upload and (partly) process the XML file to create entity records: public static Map<String, Object> importCamt053(DispatchContext dctx, Map<String, Object> context) { Debug.logInfo("in MyXmlImportService.java : starting ", module); Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile"); if (fileBytes == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "UploadedFileNotValid", locale)); } String encoding = System.getProperty("file.encoding"); String xmlFile = Charset.forName(encoding).decode(fileBytes).toString(); if (xmlFile != null) { Debug.logInfo("in MyXmlImportService.java : xmlFile = " + xmlFile, module); Document myImportXmlMessage = null; try { myImportXmlMessage = UtilXml.readXmlDocument(xmlFile, false); Debug.logInfo("in MyXmlImportService.java : myImportXmlMessage = " + myImportXmlMessage, module); Element myXmlDocument = myImportXmlMessage.getDocumentElement(); Debug.logInfo("in MyXmlImportService.java : myXmlDocument = " + myXmlDocument, module); Element HeaderElement = UtilXml.firstChildElement(myXmlDocument, “header"); String Header = UtilXml.elementValue(HeaderElement); Debug.logInfo("in MyXmlImportService.java : Header = " + Header, module); Element TransactionElement = UtilXml.firstChildElement(myXmlDocument, “transaction"); String Transaction = UtilXml.elementValue(TransactionElement); Debug.logInfo("in MyXmlImportService.java : Transaction = " + Transaction, module); As you can see there are some debug statements to see if it processing correctly. The process in broad strokes is as follows: 1. I execute opening a new screen and form in my component to upload the XML file 2. I attach the intended file and execute the process to upload. In the log I subsequently see that the XML is uploaded and the content of the file is shown in the log (as string) through code line: Debug.logInfo("in MyXmlImportService.java : xmlFile = " + xmlFile, module); There it stops doing what is intended. I don't see the result of getting the XML or the document element of the XML getting logged with Debug.logInfo("in MyXmlImportService.java : myImportXmlMessage = " + myImportXmlMessage, module); or Debug.logInfo("in MyXmlImportService.java : myXmlDocument = " + myXmlDocument, module); Nor am I getting any log moments of child elements in the document elements. Apparently I am missing something in code. Can you help me out by pointing out the right direction with a code example? Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com |
Administrator
|
If you could share your code in another way it would be easier to read ;)
Jacques Le 03/07/2014 15:38, Pierre Smits a écrit : > Hi all, > > Based on some code in OFBiz, I came up with the following to enable upload > and (partly) process the XML file to create entity records: > > public static Map<String, Object> importCamt053(DispatchContext dctx, > Map<String, Object> context) { > Debug.logInfo("in MyXmlImportService.java : starting ", > module); > Delegator delegator = dctx.getDelegator(); > LocalDispatcher dispatcher = dctx.getDispatcher(); > Locale locale = (Locale) context.get("locale"); > > GenericValue userLogin = (GenericValue) context.get("userLogin"); > > ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile"); > if (fileBytes == null) { > return > ServiceUtil.returnError(UtilProperties.getMessage(resource, > "UploadedFileNotValid", locale)); > } > String encoding = System.getProperty("file.encoding"); > String xmlFile = > Charset.forName(encoding).decode(fileBytes).toString(); > > > if (xmlFile != null) { > > Debug.logInfo("in MyXmlImportService.java : xmlFile = " > + xmlFile, module); > > Document myImportXmlMessage = null; > try { > myImportXmlMessage = UtilXml.readXmlDocument(xmlFile, > false); > > Debug.logInfo("in MyXmlImportService.java : > myImportXmlMessage = " + myImportXmlMessage, module); > > Element myXmlDocument = > myImportXmlMessage.getDocumentElement(); > > Debug.logInfo("in MyXmlImportService.java : > myXmlDocument = " + myXmlDocument, module); > > Element HeaderElement = > UtilXml.firstChildElement(myXmlDocument, “header"); > String Header = UtilXml.elementValue(HeaderElement); > Debug.logInfo("in MyXmlImportService.java : Header > = " + Header, module); > > Element TransactionElement = > UtilXml.firstChildElement(myXmlDocument, “transaction"); > String Transaction = > UtilXml.elementValue(TransactionElement); > Debug.logInfo("in MyXmlImportService.java : > Transaction = " + Transaction, module); > > > As you can see there are some debug statements to see if it processing > correctly. > > The process in broad strokes is as follows: > > 1. I execute opening a new screen and form in my component to upload the > XML file > 2. I attach the intended file and execute the process to upload. > > In the log I subsequently see that the XML is uploaded and the content of > the file is shown in the log (as string) through code line: > > Debug.logInfo("in MyXmlImportService.java : xmlFile = " + xmlFile, > module); > > > There it stops doing what is intended. I don't see the result of getting > the XML or the document element of the XML getting logged with > > Debug.logInfo("in MyXmlImportService.java : myImportXmlMessage = " > + myImportXmlMessage, module); > > or > > Debug.logInfo("in MyXmlImportService.java : myXmlDocument = " + > myXmlDocument, module); > > > Nor am I getting any log moments of child elements in the document elements. > > Apparently I am missing something in code. > > Can you help me out by pointing out the right direction with a code example? > > Regards, > > > Pierre Smits > > *ORRTIZ.COM <http://www.orrtiz.com>* > Services & Solutions for Cloud- > Based Manufacturing, Professional > Services and Retail & Trade > http://www.orrtiz.com > -- |
Free forum by Nabble | Edit this page |