vanguns
07-28-2007, 11:13 AM
Is there a way to associate a stylesheet with an XML document, but define the style of the elements in the XML such that the attributes are arbitrary and interpreted by code rather than by a web browser?
For example, what if I were to create an XML document that was used to create a real-world object. For example, if I were to have something like:
<car>
<seat class="driver" id="0" />
<seat class="passenger" id="1" />
</car>
And I wanted to create an arbitrary stylesheet to associate with this. For example,
car {
color: #C1C1C1;
type: "convertible";
}
seat.driver {
fabric: "leather";
pattern: "polka-dot";
}
seat.passenger {
fabric: "polyester";
pattern: "plaid";
}
I understand that one way to do this would be to list lots of attributes inside each tag, but what if there are lots of attributes, say 20 or more? This would be a major pain and doesn't seem like the proper way to do this, anyways.
By the way, assume that the interpreter of the XML and associated stylesheet is written in JavaScript.
For example, what if I were to create an XML document that was used to create a real-world object. For example, if I were to have something like:
<car>
<seat class="driver" id="0" />
<seat class="passenger" id="1" />
</car>
And I wanted to create an arbitrary stylesheet to associate with this. For example,
car {
color: #C1C1C1;
type: "convertible";
}
seat.driver {
fabric: "leather";
pattern: "polka-dot";
}
seat.passenger {
fabric: "polyester";
pattern: "plaid";
}
I understand that one way to do this would be to list lots of attributes inside each tag, but what if there are lots of attributes, say 20 or more? This would be a major pain and doesn't seem like the proper way to do this, anyways.
By the way, assume that the interpreter of the XML and associated stylesheet is written in JavaScript.