Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2013, 11:15 AM
Authorized User
 
Join Date: Feb 2013
Posts: 19
Thanks: 2
Thanked 0 Times in 0 Posts
Default Can you use XSLT to extract information form .DRL

Posted this in java but im thinking its mroe likely to by an XML/Xpath/XSLT issue..

I have 1000's of drule/drool files and i am looking for a script i can run that will extract the name of each rule (will be multiple per file) within the file and extract its logger.info line so that i get a text or xml file with

Rule "blah blah1"
logger.info ("declined because you smell");
Rule "blah blah2"
logger.info ("declined because you don't smell");

etc etc, id run the script on each file individually so that i can keep the data seperate for each file.
The rules are built using an ANT built on a satbuild.xml that compiles the .drl file, and various XML viles into a Jar file if that helps at all the .drl is used to filter information from being output and the xml's are Morphs for the data being output
 
Old February 15th, 2013, 12:02 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Is a Drools file an XML file? Assume we have never heard of Drool before.

If so you'd have to show us a sample of the XML and highlight what you want to output to look like.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 15th, 2013, 12:10 PM
Authorized User
 
Join Date: Feb 2013
Posts: 19
Thanks: 2
Thanked 0 Times in 0 Posts
Default

It is a Java/Joda language file that is used to read and apply restrictions to XML.
For example inside a Drule/drool (not actually sure on the spelling they are .drl files you will have various sections like
Code:
rule "EX Modified"
salience 600
when
	AbstractRulesEngineRequest(aggregatorName == "#####")
	$broker : Broker(brokerName == broker)
	Vehicle(modified == true)	
then
	logger.info("**** Rejecting due to modifications ****");
	$broker.setInclude(false);
	retract($broker);	
end
The Aggname will only move to enxt line if AggName was #####, then broker is assigned to a variable $broker and only moves on if the broker is in the "broker" global (an xml file as follows)
Code:
<globals>
  <global name="broker">
    <string>whoever</string>
    <string>whoever2</string>
  </global>
</globals>
this then looks up some information retracted from XML and stored into transformers and if the value of this XML tag is true, moves to the THEN.
this removes the broker form the quote, removes the broker from the list of activer brokers amd Prints out an error/decline message. if there was 10 of these rules in 1 file, i would want something maybe XLST or maybe it would have to be Java/Joda to take the rule"" line and logger.info line. The drl file (built into a jar file) outputs into xml ready to be passed around and passed through more Drule/drool files
 
Old February 15th, 2013, 12:15 PM
Authorized User
 
Join Date: Feb 2013
Posts: 19
Thanks: 2
Thanked 0 Times in 0 Posts
Default

i guess in short.... .drl is compiled into a jar file with XSLT/XPATH and the job of the drl job is to stop the XML being proccessed any further and present an error line
 
Old February 15th, 2013, 12:26 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Do you have a grammar for this language? If so you could parse it using for example Gunther Rademacher's REX parser which would produce output suitable for processing by XSLT.

Alternatively you might be able to extract what you need without complete parsing, but that would depend on the grammar and on what you actually need.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old February 15th, 2013, 12:26 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Doesn't look like the DRL file is an XML file to me. XSLT is perhaps not your best bet.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you extract information from Active Directory Phaedrus23 BOOK: Professional Microsoft SQL Server 2008 Integration Services ISBN: 978-0-470-24795-2 0 October 23rd, 2011 11:15 AM
Extract details from another xml file in XSLT tombliboo XSLT 3 February 9th, 2011 07:53 PM
Extract information from MS Word by VC++ avinashss VB How-To 1 November 28th, 2007 08:41 AM
emailing form information mark jonas Beginning PHP 2 November 16th, 2006 05:54 AM
Obtaining information from a form Ashleek007 PHP How-To 1 March 1st, 2004 09:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.