Search code examples
guidewire

Convert xml document (Guidewire Product Model file) to comma delimited csv file


Need some assistance converting an xml document to a CSV file using an xslt stylesheet. Basically I'm looking forward to something like this at bare minimum to be the output:

Coverage Name 1, Coverage Pattern Code 1

Coverage Name 2, Coverage Pattern Code 2

The xml file would be like this:

                <ns0:Entry>
                                    <ns1:Code>PALiabCond</ns1:Code>
                                    <ns1:Names>
                                        <ns1:Entry>
                                            <ns1:Locale>en_CA</ns1:Locale>
                                            <ns1:Value>Personal Auto Liability Conditions</ns1:Value>
                                        </ns1:Entry>
                                        <ns1:Entry>
                                            <ns1:Locale>fr_CA</ns1:Locale>
                                            <ns1:Value>Responsabilité auto personnelle - Conditions</ns1:Value>
                                        </ns1:Entry>
                                        <ns1:Entry>
                                            <ns1:Locale>en_US</ns1:Locale>
                                            <ns1:Value>Personal Auto Liability Conditions</ns1:Value>
                                        </ns1:Entry>
                                    </ns1:Names>
                                    <ns1:Priority>1</ns1:Priority>
                                </ns0:Entry>

Where 'Coverage Name' would be the node 'ns1:Value' and 'Coverage Pattern Code' would be 'ns1:Code'. Is there some easy way to get this done by using XLST?

Regards, Matías


Solution

  • You could use any number of tools to do this not just XSLT.

    e.g. a very quick Groovy script using XMLSlurper will also do it

    But I am wondering why you are wanting to do it. If it's for importing then I don't believe that you can easily import these items anyway as they are key to the product model and underlying architecture that the system relies upon.