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

RE: Filtering XML elements based on tokenized external

Subject: RE: Filtering XML elements based on tokenized external parameters?
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Fri, 17 Jun 2005 16:59:40 +0000
xml shell script
Ramon,

You'll probably get many suggestions on approaching this as you describe -- pass in XSL parameters, and have the main stylesheet figure out what to emit.

I'm writing to propose an alternative -- especially since you may use a script to glue together things, the school of thought that has programs writing programs would have you consider writing a script or transform that, given your input "parameters", would then automatedly and dynamically construct a special-purpose XSL stylesheet that, applied against your original input XML, would output the nodes you want.

Regards,

--A

From: "Ramon Felciano" <felciano@xxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Filtering XML elements based on tokenized external parameters?
Date: Fri, 17 Jun 2005 09:44:00 -0700



Hello --


I'm trying to do parameterized XSLT-based filtering to strip out
unwanted structure from an XML file. The XML file represents a graph
data structure along with some other metadata. Conceptually I want to
extract a subgraph from this data structure, but want to do so in an
upwards-compatible way such that any additional tags in the XML are
carried over to the resulting document. For example, given this XML
file:

<graph>
    <node id="alpha"/>
    <node id="beta"/>
    <node id="delta"/>
    <node id="gamma"/>
    <edge from="alpha" to="delta"/>
    <edge from="alpha" to="beta"/>
    <edge from="alpha" to="gamma"/>
    <edge from="beta" to="beta"/>
    <mymetadata id="123"/>
</graph>

Given the above simple graph data structure, I want to produce a
filtered version that only includes node elements (ideally both node and
edge elements) that match a given set of input parameters, as well as
any other tags that might be included (e.g. the mymetadata tag). I'd
ideally like to issue a call like this so that I integrate this w shell
scripts:

xsltproc mytransform.xslt myfile.xml --param nodelist "alpha,beta"

And get this back:

<graph>
    <node id="alpha"/>
    <node id="beta"/>
    <edge from="alpha" to="beta"/>
    <edge from="beta" to="beta"/>
    <mymetadata id="123"/>
</graph>

I have two questions:

1. What is the best way to create a pattern match that is parameterized
based on the incoming nodelist? I'd like to flexible about delimeters
(e.g. have both "alpha,beta" and "alpha   ,   beta" work). I've tried
playing with tokenize from EXSLT but can't figure how to use the
resulting tokens to implement the filtering in a single-pass.

2. Is there a way to implement this to also include the alpha-gamma edge
and the gamma node, based on the partial edge match to "alpha"? I know
how to do this w multiple passes (e.g. by marking the edges, then the
nodes, then filtering) but was wondering if there was a nice one-pass
functional approach I've missed.

Thank you in advance for your time.

Ramon

_________________________________

Ramon M. Felciano
INGENUITY Systems, Inc.


_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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.