Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

CSS or CSS2 and XML in Java

Thread view: 
oulan bator - 15 Dec 2005 13:28 GMT
hi,

is there a a way to read a styled (by CSS) XML file, and get it fully
substituted, all in one (or two) step ?
Or have I to do it myself ?

I'm trying to read MathML-presentation documents, that can come with a
css (either embedded, or linked in). I would like to have the file
read, and all styled attribute set following CSS rules.

Is it possible ?

thx
Rhino - 15 Dec 2005 14:40 GMT
> hi,
>
[quoted text clipped - 7 lines]
>
> Is it possible ?

I don't think I really understand your question so I don't know if this will
help.

My memory on this is very hazy but I believe the recommended approach for
controlling the appearance of XML is to use XSL, not CSS. If you want to
apply an XSL stylesheet to XML very easily - once you've actually written
the XSL - you can do this; it's not Java but it works!

=======================================
<html>

<body><script type="text/javascript">// Load XML

var xml = new ActiveXObject("Microsoft.XMLDOM")

xml.async = false

xml.load("Foo.log.xml")

// Load XSL

var xsl = new ActiveXObject("Microsoft.XMLDOM")

xsl.async = false

xsl.load("JavaLogger.xsl")

// Transform

document.write(xml.transformNode(xsl))</script>

</body>

</html>

=======================================

The name of the XML file in this example is 'Foo.log.xml' and the name of
the XSL file is 'JavaLogger.xsl'.

This small script is real code that I wrote myself for a project a while
back.

Rhino
oulan bator - 15 Dec 2005 16:06 GMT
hi,

thanks, but that's not really what I need.

I'm working in a standalone application. I wan't to show a
MathML-presentation (for the moment this standard piece of XML, but I'm
still interested in any kind of XML).
If the MathML XML source is styled (through processing-instruction for
instance), how can I apply CSS rules to this document !  I'd like to
avoid doing-it by myself.

I've heard about SAC, but there are too few implementations.
Oliver Wong - 15 Dec 2005 23:19 GMT
> hi,
>
> is there a a way to read a styled (by CSS) XML file, and get it fully
> substituted, all in one (or two) step ?

   I strongly doubt it. Perhaps in a couple hundred steps.

> Or have I to do it myself ?

   Very likely.

> I'm trying to read MathML-presentation documents, that can come with a
> css (either embedded, or linked in). I would like to have the file
> read, and all styled attribute set following CSS rules.
>
> Is it possible ?

See http://www.w3schools.com/xml/xml_display.asp particularly the part that
says:

<quote>
Note: Formatting XML with CSS is NOT the future of how to style XML
documents. XML document should be styled by using the W3C's XSL standard!
</quote>

   It's possible, but not the recommended way of doing things.
Incidentally, I don't think Java has built in support for XSL either.

   - Oliver
Roedy Green - 16 Dec 2005 04:04 GMT
>I'm trying to read MathML-presentation documents, that can come with a
>css (either embedded, or linked in). I would like to have the file
>read, and all styled attribute set following CSS rules.
>
>Is it possible ?

I would say no simply because you can describe fancy layouts in CSS
for which there is no HTML equivalent.  

You might though be able to roughly express it.  

Another approach might be to see if you can convert your CSS to PDF
which can be viewed without CSS.

If you generate your web pages it may be easier to simply generate two
versions.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

oulan bator - 16 Dec 2005 07:51 GMT
hi,

I don't think CSS is dead, and that XSL stands right for what I need to
do. I know how to handle XSL in java (it is built in since 1.4 IMHO)

I am not generating any web page. I want to get some "raw"
MathML-presentation and and present beautified MathML presentation
(like color attribute for some elements etc...) as described in a CSS
file.

it is possible to mix CSS and MathML-presentation (at least) see
appendix G in w3c MathML 2.0 spec
<http://www.w3.org/TR/2003/REC-MathML2-20031021/appendixg.html>

I was wondering that CSS is a powerfull yet simple way to customize
rendering (in HTML and in MathML presentation too). Is there a generic
library that can parse any XML file, find style data (maybe we can help
parser to find styles), parse style data, AND apply CSS rules.
Oliver Wong - 16 Dec 2005 20:19 GMT
> I don't think CSS is dead, and that XSL stands right for what I need to
> do. I know how to handle XSL in java (it is built in since 1.4 IMHO)

   I'm not saying CSS is dead; in fact, W3C is actively working on CSS3.
I'm just saying that the W3C also recommends that you do NOT use CSS to
format XML data, and that you DO use XSL to format it (as indicated in the
link I made in another post in this thread).

   I went to the javadocs,
http://java.sun.com/j2se/1.5.0/docs/api/index.html, and did a search for
"XSL", and found zero results. Where do you see XSL support built into Java?

> I was wondering that CSS is a powerfull yet simple way to customize
> rendering (in HTML and in MathML presentation too). Is there a generic
> library that can parse any XML file, find style data (maybe we can help
> parser to find styles), parse style data, AND apply CSS rules.

   Applying CSS rules to a document only makes sense in the context where
you want to DISPLAY the document. In other words, it does not make sense to
apply CSS to the in-memory tree-like representation of an XML document. The
CSS language, for example, allows you to place conditionals on the style
rules depending on whether the document should be displayed on screen, or on
paper, something which cannot possibly known before the time comes to
actually print or display the document.

   Once we have a better idea of what you are doing to display your MathML
documents (because I'm pretty sure MathML is not built into Java either), we
might be able to further advise you with regards to CSS, but my initial
claim still stands:

   You'll get more support using XSL to manipulate the presentation of XML
documents than you will with CSS.

   - Oliver
oulan bator - 16 Dec 2005 21:19 GMT
>Where do you see XSL support built into Java?
http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/TransformerFactory.html

>Once we have a better idea of what you are doing to display your MathML
>documents
I do want to display MathML ! I'm building a java MathML viewer ! Thats
why I need CSS
I've been looking a lot around, and didn't find any java implementation
of a CSS parser that I could apply to my MathML tree

I'm starting to think that it does not exist, I'll have to implement
CSS support by myself, but I can't keep thinking that it is possible to
build a generic CSS support !
Dag Sunde - 17 Dec 2005 00:01 GMT
> >Where do you see XSL support built into Java?
> http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/TransformerFactory.html
[quoted text clipped - 5 lines]
> I've been looking a lot around, and didn't find any java implementation
> of a CSS parser that I could apply to my MathML tree

You won't find *any* implementation for *any language of a CSS parser that
you could apply to a MathML tree

MathML is an XML markup-language for mathematics, and not a visual renderer
You use xsl(t) to transform it into something that can be visualy rendered,
and possibly apply a css stylesheet to that.

> I'm starting to think that it does not exist, I'll have to implement
It doesn't
> CSS support by myself, but I can't keep thinking that it is possible to
> build a generic CSS support !

It just doesn't make sense to use css on a mathML document...

Signature

Dag.

caroline.atienza@gmail.com - 17 Dec 2005 00:10 GMT
I don't agree with you, Dag !!
MathML-presentation IS a visual renderer with color tricks and font
size style etc....
as well as HTML !
I know how to "apply" by hand CSS rules to a MathML tree ! There is
absolutely no contradiction. I'm looking for a tool that help me to
process this rules by computer !

>It just doesn't make sense to use css on a mathML document...
It does to me, sorry
Dag Sunde - 17 Dec 2005 03:10 GMT
>I don't agree with you, Dag !!
> MathML-presentation IS a visual renderer with color tricks and font
[quoted text clipped - 6 lines]
>>It just doesn't make sense to use css on a mathML document...
> It does to me, sorry

Can you please post some links or show me how to "apply" those
css-rules to MathML documents by hand?

I'm not trying to be sarcastic here, I'm really interested i
how you do this!

Or maybe I'm just grossly misunderstand what you mean...?

Signature

Dag.

caroline.atienza@gmail.com - 17 Dec 2005 07:43 GMT
look at :

it is possible to mix CSS and MathML-presentation (at least) see
appendix G in w3c MathML 2.0 spec
http://www.w3.org/TR/2003/REC-MathML2-20031021/appendixg.html
Hiran Chaudhuri - 17 Dec 2005 23:41 GMT
>> >Where do you see XSL support built into Java?
>> http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/TransformerFactory.html
[quoted text clipped - 5 lines]
>> I've been looking a lot around, and didn't find any java implementation
>> of a CSS parser that I could apply to my MathML tree

Ever heard of WebEQ?

http://www.webeq.com/en/products/webeq/
oulan bator - 18 Dec 2005 07:50 GMT
yep,
and many others, but they don't fit my requirements :
1- must be a reusable component that I can embbed in my apps
2- the component must edit a constrained subset of mathml (for
instance, sometimes I want to allow a=b+c, but not a+b=c+d )
3- it is destinated to our customers

I thought (I'm evaluating) that it would be easier to have my own
editor ... but I might be wrong

(but you're right, I can see that I've said "viewer", Sorry. But the
target remains to have an editor/viewer, and the first step is to have
a viewer
Oliver Wong - 20 Dec 2005 21:35 GMT
> >Where do you see XSL support built into Java?
> http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/TransformerFactory.html

   Okay, thanks.

>>Once we have a better idea of what you are doing to display your MathML
>>documents
[quoted text clipped - 3 lines]
> I've been looking a lot around, and didn't find any java implementation
> of a CSS parser that I could apply to my MathML tree

   So you're implementing your own viewer from scratch, right? So wouldn't
it be your job to implement applying the styles to your view as well? What
I'm getting at is that it doesn't seem reasonable to try to seperate the
concern of taking an XML document and from that, putting pixels on the
screen with the concern of deciding what set of pixels to put on the screen.
The best you could hope for, I suspect, is a CSS parser; but you still need
to manually interpret the CSS data you've got and apply that to your own
graphical representation of the math formulas.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.