I am 开发者_高级运维writing a Page with XML Only. No XSL is being. everything is going well with XML and CSS. But how can I make Input fields with XML and CSS Only ?? is it really possible ??
Xml is for data transformation, porting, trasportation, etc - things related to data.
CSS is for styling.
You will need something for instance, html(or XForms?), to provide/render controls.
Or probably, if you plan to render the control yourself, then you can, for instance, add an element, and render the control by parsing it yourself.
<MyControl type="Text">This is a test value</MyControl>
When you see MyControl having a Text type then add a Text control.
--EDIT--
This is in response to your comment.
I understand what you are saying; to be clear, I believe CSS by nature/actually is for styling - therefore CSS is applied "on" the controls, CSS aren't the controls; so we come up with certain classes, ids, selectors and apply them over the controls.
This may be, yet again, a fat example, but its like telling a "Paint" to build a "House".
Probably you already know this, but this is just to add: Following is how CSS is applied to a html button control. Example taken from here:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS Button</title>
<style type="text/css">
body {
font: 140%/1.6 "Gill Sans", Futura, "Lucida Grande", Geneva, sans-serif;
color: #666;
background: #fff;
}
a:link, a:visited {
display: block;
width: 6em;
padding: 0.2em;
line-height: 1.4;
background-color: #94B8E9;
border: 1px solid black;
color: #000;
text-decoration: none;
text-align: center;
}
a:hover {
background-color: #369;
color: #fff;
}
</style>
</head>
<body>
<p><a href="#">Button</a></p>
</body>
</html>
The above code is going to render a button with css applied like following: alt text http://img689.imageshack.us/img689/4615/72060104.jpg
So to answer your question directly, I believe it is not possible to render a control with CSS.
Now based upon your requirements, I understand that: 1. You want to render the control yourself. 2. You want to apply CSS to that control.
Solution 1: 1. Add, parse and render your custom control xml tags, as discussed earlier. 2. And add the CSS style within xml, see example
Solution 2:
1. Add, parse and render your custom control xml tags, as discussed earlier.
2. Add css in xml CDATA
; while xml parse, grab the CSS from CDATA, and apply to the control.
I don't believe you can use just CSS to create controls.
However..
If you don't mind expanding to use something else, I would suggest using XForms. It works very well with XML, and it uses CSS for styling.
The following are links to some guides, tutorials, and articles to get you started:
http://en.wikibooks.org/wiki/XForms
http://w3schools.com/xforms/default.asp
http://www.ibm.com/developerworks/xml/library/x-xformsfirefox/
http://www.ibm.com/developerworks/library/x-xformswhy.html
Hope this helps!
CSS can style XML, but browsers are inconsistent concerning semantics.
For example, something like:
<Link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="..." />
Will make a working link in Firefox, but doesn't work in Safari.
( I think it also worked in IE, but I tried it a long time ago, so I could be wrong. I also tried using <xhtml:a ...>
, which I think also worked in some but not other browsers. Perhaps there's a way to do this in javascript. )
So: there's not even a portable way to get link behavior in CSS styled XML. I don't think input fields are possible at all. Doing xslt transforms to html in the browser is much more portable. You might also look at XForms -- although no browsers support that natively either.
精彩评论