expand parts of an xml, which is transformed by xslt to html

S

sebastian.langer

Hi!

Certainly somebody had my problem before and could give me just some
hints, how to solve it:

I have an xml file, which contains scientific data in a tree form. The
data should be changed in a JSR168-Portlet and in a Python-Environment
as well, so I want them to be parsed by an xslt to html which then
could be shown in a web browser.

It is quite easy to parse the tree and collapse or expand the whole
tree by parsing the xml against the xslt. What I would like to be able
to do, is to give the xslt an xpath (or whatever path), for example
/layer/projection[@type='mercator']/longitude and the xslt parses the
stylesheet so, that only this path is expanded in the resulting html.

I don't like the idea of expanding the whole tree at once, reading the
whole tree into the browser and make it expanding/collapsing by
javascript, as I would have the whole file in the memory of the client.

Would be great, if somebody could give me hints!

Cheers, Sebastian
 
J

Joe Kesselman

Passing a completely general XPath into XSLT as a string (presumably a
stylesheet parameter) and having it executed as part of the stylesheet's
evaluation requires the use of an extension function, such as the
"dynamic" extensions defined by EXSLT. If your processor doesn't support
such an extension (or if you want a more reliably portable solution) you
could try to write an XPath interpreter in XSLT... ugh.

Another solution would be to take this in stages -- use a stylesheet
which takes the XPath as a parameter and uses it to insert this XPath
into the appropriate place in the the selective-expansion stylesheet,
then use the resulting styled stylesheet to process your actual data
document.
 
S

sebastian.langer

Hey!

I thought a bit about all the stuff and think, one possible solution
could be to pass the xpath of the deepest expanded hierarchy-element to
the stylesheet.

Then I could parse the xml using an ancestor-or-self test for each
element to find out, if it is an ancestor of the last expanded one and
therefore if it should be visibile or not. If it is an ancestor, it
will be treated as visible, otherwise as invisible.

Thank you, Joe!

Cheers, Sebastian
 

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

Members online

No members online now.

Forum statistics

Threads
474,002
Messages
2,570,261
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top