Subject: RE: [xsl] Filtering XML elements based on tokenized external parameters? From: "Aron Bock" <aronbock@xxxxxxxxxxx> Date: Fri, 17 Jun 2005 16:59:40 +0000 |
From: "Ramon Felciano" <felciano@xxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: [xsl] 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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Filtering XML elements based , Ramon Felciano | Thread | Re: [xsl] Filtering XML elements ba, Sam D. Chuparkoff |
RE: [xsl] Anybody know when "transf, Aron Bock | Date | [xsl] Removing entity in specific e, Joe Stump |
Month |