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

Filtering XML elements based on tokenized external pa

Subject: Filtering XML elements based on tokenized external parameters?
From: "Ramon Felciano" <felciano@xxxxxxxxxxxxx>
Date: Fri, 17 Jun 2005 09:44:00 -0700
ramon felciano
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.

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.