How do I filter records from XML doc?

J

jj23

Hi all,

I am really new to XML and have been asked to do a simple task o
filtering out records from an XML source. The source XML however, i
hard to understand and I can't quite figure out how to filter th
records. I have written a script which loads the XML in and I have use
an XML viewer to view the actual XML document in tree structure whic
helps.

I have attached the XML and XSL if anyone would like to take a look a
it. The structure is different from the examples I've seen on the web
Basically, it looks something like this:

If you navigate down through the nodes:

//mi/rit/vw/gr/ly/rt/t

You will see an element (or node not sure) called "Store Region".

Then, if you navigate down through:

//mi/rit/vw/gr/rh/rw/h/fv

You will see a value "10". This is Store region 10.

In this example XML there are two Store Regions. Store Region 10 an
Store Region 25. I need to filter out (either through code or throug
the XSL) all the records for Store Region 10.

Also, I found the conversion table for the node descrptions, they are:

<rit> = report_instance
<rd> = report definition
<ord> = original report definition
<vw> = view
<gr> = grid
<ly> = layout
<rt> = row titles, <cts> = column titles, <pts> = page titles
<t> = title
<rh> = row header, <rw> = row
<h> = header
<fv> = form value
<mv> = metric value
<sv> = subtotal value
<chs> = column headers, <ch> = column header
<phs> = page headers, <ph> = page header
<dp> = drill path, <da> = drill action
<f> = filter
<tm> = template
<rsl> = resolution
<gpp> = graph properties, <gdp> = grid properties
<vws> = view setting

Any help really appreciated

+----------------------------------------------------------------
| Attachment filename: xmlexample.zip
|Download attachment: http://www.forum4designers.com/attachment.php?postid=162312
+----------------------------------------------------------------

jj2
 
P

Patrick TJ McPhee

% I am really new to XML and have been asked to do a simple task of
% filtering out records from an XML source. The source XML however, is
% hard to understand and I can't quite figure out how to filter the
% records. I have written a script which loads the XML in and I have used
% an XML viewer to view the actual XML document in tree structure which
% helps.

Boiling all the details I've removed down, it seems like you have
a document which looks roughly like this

<mi>
<rit><!-- a bunch of stuff --></rit>
<rit><!-- a bunch of stuff, including the value 10 somewhere --></rit>
<rit><!-- a bunch of stuff, including the value 25 somewhere --></rit>
<rit><!-- a bunch of stuff --></rit>
</mi>

and that you want to end up with

<mi>
<rit><!-- a bunch of stuff, including the value 10 somewhere --></rit>
<rit><!-- a bunch of stuff, including the value 25 somewhere --></rit>
</mi>


I haven't looked at your attachment, but you could do this something
like this

<xsl:template match="mi">
<mi>
<xsl:copy-of select='rit[.//fv=10 or .//fv=25]'/>
</mi>
</xsl:template>

The key here is that you put the element you want as the first
thing in the select expression and the criterion on which you
want to filter in the brackets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top