[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Applying XSL transformation to non-xml (but fixed str

Subject: 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
 Applying XSL transformation to non-xml (but fixed  str
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.