Subject: [xsl] Applying XSL transformation to non-xml (but fixed structure) file From: "Christian Schouten" <C.Schouten@xxxxxxxxxx> Date: Wed, 2 Jun 2010 12:32:02 +0200 |
Hi all, I need to apply an XSL transformation to a non-xml file that has a fixed structure. The goal is to read in the file, add/edit/delete a record and write it back. A sample file (start to finish) is as below: === package Endpoints; #generated from Decision Table import bre.Endpoint; rule "Endpoints #1: (Endpoint.urlEndpoint =='\"https://a.b.c/d\"')" salience 0 when endpoint:Endpoint(urlEndpoint== "https://a.b.c/d") then endpoint.setStatus("OK"); end rule "Endpoints #2: (Endpoint.urlEndpoint =='\"https://w.x.y/z\"')" salience 0 when endpoint:Endpoint(urlEndpoint== "https://w.x.y/z") then endpoint.setStatus("OK"); end === How would I best approach this? My thoughts were: * Open file (inside a jar) * Skip three-line header * Use analyze-string/matching-substring to split into records defined as something like "^rule \"Endpoints #[A-Za-z0-9:;/]*end$" * Use string analysis functions to split into fields urlEndpoint and Status * Magically end up with <Endpoints><Endpoint><urlEndpoint>https://a.b.c/d</urlEndpoint><Status>O K</Status></Endpoint><Endpoint><urlEndpoint>https://w.x.y/z</urlEndpoint ><Status>OK</Status></Endpoint></Endpoints> * Perform requested operation (remove item from tree, add item to tree etc.) * Write back changed file (inside the jar) The file header is made up as: package $tableName;\n#generated from Decision Table\nimport bre.$className; Each record is made up as: rule "$tableName #1: ($className.$conditionName =='\"$conditionValue\"')"\n\t\n\tsalience 0\n\twhen\n\t\tendpoint:Endpoint(\n?urlEndpoint== "$conditionValue")\n\tthen\n\t\t$objectName.set$actionName("$actionValue ");\nend\n\n So far, I can come up with the theory up to splitting the file into records that are delimited by the word 'rule' at the start of a line and the word 'end' as its own line and I can come up with a definition for how a record is made up from field. Actually splitting the records into fields within XSL however is too much black magic for me right now. If anybody could share his/her thoughts that'd be most appreciated... Best regards, Christian C. Schouten
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Zvon.org relaunch (includ, Mail Zvon | Thread | Re: [xsl] Applying XSL transformati, Michael Kay |
Re: [xsl] Generating attributes fro, Michael Kay | Date | Re: [xsl] Applying XSL transformati, Michael Kay |
Month |