Question about CSS and XML

K

kdjansen

I've been using XML to define 3d map geometry for a game engine, like
this:

<wall x1="-1000" y1="300" x2="1000" y2="300" z="0" height="100"
texture="nature/wood001" />

However, I would like specify the texture not by a filename, but by a
CSS style, like this:

<wall x1="-1000" y1="300" x2="1000" y2="300" z="0" height="100"
style="texture-group: nature; texture-resolution: xx-high; texture-
family: wood; target: wall;" />

because textures could then be defined with external stylesheets and
allow reuse with class attributes.

However, there are no CSS specifiers for things like textures or image
resolution.

I have looked into other things like XSLT, but those are not what I'm
looking for (although I did use XSLT to make SVG overview maps)

Is there any way to create custom CSS attributes and apply it to an
XML document? Or at least a library that will store non-standard
attributes?
 
J

Joseph J. Kesselman

However, there are no CSS specifiers for things like textures or image
> resolution.

So you first need to invent the markup conventions for those properties.
I'd suggest separate attributes rather than CSS strings, since distinct
properties are easier for software to manipulate than a string which has
to be re-parsed every time.

I suspect XSLT is, in fact, the simplest way to apply non-CSS styling to
a document.

CSS really is HTML-oriented. XSLT is a more general tool.
 
K

kdjansen

 > However, there are no CSS specifiers for things like textures or image
 > resolution.

So you first need to invent the markup conventions for those properties.
I'd suggest separate attributes rather than CSS strings, since distinct
properties are easier for software to manipulate than a string which has
to be re-parsed every time.

I suspect XSLT is, in fact, the simplest way to apply non-CSS styling to
a document.

CSS really is HTML-oriented. XSLT is a more general tool.

I have tried using separate attributes, but they are not as reusable
and do not cascade.

CSS (or something similar) strings are the best way I can think of.

I am looking into SAC to parse this. I may have to modify it to accept
non-HTML-CSS, but it beats writing my own parser from scratch.

Speed is not a significant issue, since I am converting it into a
series of C arrays and structures at load time.
 

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
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top