Best way to display a large XML

R

rudigarude

Hi,

I have a reasonably large XML file created for an image processing
experiment, and have been displaying them using XSL. However since
there are quite a few of them, what I want to be able to do is show a
few of these objects at a time, e.g. 10 at a time.

Below is an example of the XML sheet;

<Objects>
<object>

<index>4</index>

<picture>Object4.jpg</picture>

<pixels>99</pixels>

<bottom>83 337</bottom>

<top>88 354</top>

</object>

<object>

<index>5</index>

<picture>Object5.jpg</picture>

<pixels>621</pixels>

<bottom>100 424</bottom>

<top>154 472</top>

</object>

<object>

<index>7</index>

<picture>Object7.jpg</picture>

<pixels>1344</pixels>

<bottom>104 429</bottom>

<top>149 468</top>

</object>

<object>

<index>15</index>

<picture>Object15.jpg</picture>

<pixels>251</pixels>

<bottom>112 348</bottom>

<top>128 367</top>

</object>

<object>

<index>18</index>

<picture>Object18.jpg</picture>

<pixels>1146</pixels>

<bottom>121 280</bottom>

<top>159 318</top>

</object>
</Objects>

As you can see, the index isn't sequential in the XML, this is since
the code that generates XML pages stores all the 'objects', but only
some of them are relevant to the display, so those are displayed in
the XML.

I am not looking for anything pretty, but it needs to be simple since
I don't have time to start implementing anything major. Is this
possible in XSL? If anyone knows a suitable tutorial that shows
someone doing something similar then that might help.

Thank you

Martin
 
M

Martin Honnen

I have a reasonably large XML file created for an image processing
experiment, and have been displaying them using XSL. However since
there are quite a few of them, what I want to be able to do is show a
few of these objects at a time, e.g. 10 at a time.

I am not looking for anything pretty, but it needs to be simple since
I don't have time to start implementing anything major. Is this
possible in XSL? If anyone knows a suitable tutorial that shows
someone doing something similar then that might help.

Well XSLT does not display anything, it is a transformation language
that transforms XML to XML or HTML or plain text.
Do you use XSLT to transform XML to HTML to display HTML in a browser?
Where do you use XSLT, on the server (e.g. with JSP or ASP) or in the
browser (e.g. with Mozilla or IE)?
 
R

rudigarude

Well XSLT does not display anything, it is a transformation language
that transforms XML to XML or HTML or plain text.
Do you use XSLT to transform XML to HTML to display HTML in a browser?
Where do you use XSLT, on the server (e.g. with JSP or ASP) or in the
browser (e.g. with Mozilla or IE)?

Yes, I am using XSLT to transform the XML to HTML in the browser. Just
a simple

<xsl:for-each select="Objects/object"></xsl:for-each>

type thing in a *.xsl file.

What I imagined was that I could have a page that displays 10 (or so)
objects at a time, much like an email inbox. Since both the XML and
XSL code is generated by the output of my C++ code I want something
simple, since it needs to be automatically generated for various
experiments.
 
M

Martin Honnen

Yes, I am using XSLT to transform the XML to HTML in the browser. Just
a simple

<xsl:for-each select="Objects/object"></xsl:for-each>

type thing in a *.xsl file.

What I imagined was that I could have a page that displays 10 (or so)
objects at a time, much like an email inbox. Since both the XML and
XSL code is generated by the output of my C++ code I want something
simple, since it needs to be automatically generated for various
experiments.

Well as you use XSLT to transform XML to HTML client-side there is not
much you can do with XSLT itself, you would need to apply client-side
scripting in the result HTML document of your transformation to hide
some elements and to provide button with the functionality to show elements.
 
R

rudigarude

Well as you use XSLT to transform XML to HTML client-side there is not
much you can do with XSLT itself, you would need to apply client-side
scripting in the result HTML document of your transformation to hide
some elements and to provide button with the functionality to show elements.

How might I go about doing this? Are there any tutorials or examples
that might help?
 
M

Martin Honnen

How might I go about doing this? Are there any tutorials or examples
that might help?

Here is an example:
http://home.arcor.de/martin.honnen/xslt/test2009010701.xml
The stylesheet used is
http://home.arcor.de/martin.honnen/xslt/test2009010701Xsl.xml
the script used is
http://home.arcor.de/martin.honnen/xslt/test2009010701.js

So in that sample the XSLT stylesheet generates a HTML table with a
tbody section for each "page" to be displayed, then the provided script
kicks in and hides all but the first tbody and sets up buttons to show
the next tbody ("tbody") respectively the previous tbody ("page").
 
R

rudigarude

Here is an example:
   http://home.arcor.de/martin.honnen/xslt/test2009010701.xml
The stylesheet used is
   http://home.arcor.de/martin.honnen/xslt/test2009010701Xsl.xml
the script used is
   http://home.arcor.de/martin.honnen/xslt/test2009010701.js

So in that sample the XSLT stylesheet generates a HTML table with a
tbody section for each "page" to be displayed, then the provided script
kicks in and hides all but the first tbody and sets up buttons to show
the next tbody ("tbody") respectively the previous tbody ("page").

That's fantastic, exactly what I am looking for, thank you very much.
 
R

rudigarude

Hi I was just wondering if there is a way to sort this, e.g <xsl:sort
select="bar"/> ?

I have tried playing this into the xsl code and it doesnt work.

Thank you

Martin
 
M

Martin Honnen

Hi I was just wondering if there is a way to sort this, e.g <xsl:sort
select="bar"/> ?

I have tried playing this into the xsl code and it doesnt work.

You could sort first and then use the existing algorithm on the sorted
nodes. However that does only work with XSLT 1.0 if the processor
supports an extension function to convert a result tree fragment into a
node-set. Firefox 3.0, Opera 9, IE 6 and later can do that, earlier
version not I think. Does that help for your application?

Here is an adapted example:
http://home.arcor.de/martin.honnen/xslt/test2009011502.xml
http://home.arcor.de/martin.honnen/xslt/test2009011502Xsl.xml
the stylesheet checks whether a node-set extension function is supported
and if so sorts on the 'bar' element number value, then applies the
other templates after using the extension function.

I tested that the sorting works on Windows with Firefox 3.0, IE 7, Opera
9.6 and Safari 3.2.
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top