473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Defining my own new attributes?


I would like to define additional attributes on some XHTML elements. The
purpose is to use them as parameters for scripts. So far, I have no
good grasp on how to add attributes *cleanly*. Of course, I can just
put them in, like this,

<input type="text" myns:maxlength="10" />

However, that's not valid XHTML. If possible, what I'd like to achieve
is this: I want to live in peace with XHTML validators by telling them
that they should just check the XHTML as they know it and when they
encounter an attribute with a specific prefix they should not complain
about it, but instead accepts that it is my business to look after the
attribute.

Michael

--
Michael Schuerig Airtight arguments have
mailto:mi*****@schuerig.de vacuous conclusions.
http://www.schuerig.de/michael/ --A.O. Rorty, Explaining Emotions

Aug 20 '05 #1
10 2054
Michael Schuerig wrote:
I would like to define additional attributes on some XHTML elements. The
purpose is to use them as parameters for scripts. So far, I have no
good grasp on how to add attributes *cleanly*. Of course, I can just
put them in, like this,

<input type="text" myns:maxlength="10" />

However, that's not valid XHTML. If possible, what I'd like to achieve
is this: I want to live in peace with XHTML validators by telling them
that they should just check the XHTML as they know it and when they
encounter an attribute with a specific prefix they should not complain
about it, but instead accepts that it is my business to look after the
attribute.


You can't if you serve up pages like that. Serve them as XML rather
(x)html.

However, if you're serving them on the Web, you can deal with it
by negotiating with user agents. Strip out your extra attributes
(using the Apache namespace framework, or your server's equivalent)
when serving to a 'normal' client. Have clients that want your
namespace say so in an Accept: header, and negotiate based on that.

--
Nick Kew
Aug 20 '05 #2
Nick Kew wrote:
Michael Schuerig wrote:
I would like to define additional attributes on some XHTML elements.
The purpose is to use them as parameters for scripts. So far, I have
no good grasp on how to add attributes *cleanly*. Of course, I can
just put them in, like this,

<input type="text" myns:maxlength="10" />

However, that's not valid XHTML. If possible, what I'd like to
achieve is this: I want to live in peace with XHTML validators by
telling them that they should just check the XHTML as they know it
and when they encounter an attribute with a specific prefix they
should not complain about it, but instead accepts that it is my
business to look after the attribute.
You can't if you serve up pages like that. Serve them as XML rather
(x)html.


What exactly do you mean by "can't"? That it is not possible to achieve
valid XHTML in this way? Or that browsers won't be able to deal with
what they get?
However, if you're serving them on the Web, you can deal with it
by negotiating with user agents. Strip out your extra attributes
(using the Apache namespace framework, or your server's equivalent)
when serving to a 'normal' client. Have clients that want your
namespace say so in an Accept: header, and negotiate based on that.


My clients are ordinary current web browsers. Ideally they just ignore
attributes they don't know about. I'll handle them with JavaScript.

Michael

--
Michael Schuerig Thinking is trying to make up
mailto:mi*****@schuerig.de for a gap in one's education.
http://www.schuerig.de/michael/ --Gilbert Ryle

Aug 20 '05 #3
In article <de**********@newsreader3.netcologne.de>,
Michael Schuerig <mi*****@schuerig.de> wrote:
You can't if you serve up pages like that. Serve them as XML rather
(x)html.
What exactly do you mean by "can't"? That it is not possible to achieve
valid XHTML in this way?


If you add stuff that is not valid according to XHTML 1.0, XHTML 1.1 or
XHTML Basic, your document obviously won't be valid XHTML 1.0, XHTML 1.1
or XHTML Basic.

However, if you write your own schema, your document can be valid
according to that schema. You may be able to truthfully claim that your
language belongs in the "XHTML family".
Or that browsers won't be able to deal with
what they get?


They'll deal by parsing the attribute into the DOM and not acting on the
attribute in any particular way.

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Aug 20 '05 #4
Michael Schuerig wrote:
Nick Kew wrote:

Michael Schuerig wrote:
I would like to define additional attributes on some XHTML elements.
The purpose is to use them as parameters for scripts. So far, I have
no good grasp on how to add attributes *cleanly*. Of course, I can
just put them in, like this,

<input type="text" myns:maxlength="10" />

However, that's not valid XHTML. If possible, what I'd like to
achieve is this: I want to live in peace with XHTML validators by
telling them that they should just check the XHTML as they know it
and when they encounter an attribute with a specific prefix they
should not complain about it, but instead accepts that it is my
business to look after the attribute.
You can't if you serve up pages like that. Serve them as XML rather
(x)html.


He didn't give any indication about how they were being served, so how
can you assume that he isn't serving them as XML?
What exactly do you mean by "can't"?
I believe he meant that you can't serve it as text/html, you need to use
an XML MIME type like application/xhtml+xml or application/xml.
That it is not possible to achieve valid XHTML in this way?
Well, it is possible, but you have to write your own DOCTYPE or schema
to validate against. However, you should understand that validity is
different from conformance and even though the document may pass
validation, it may not be conformant.

You should look into XHTML Modularisation, which allows you to extend
the langauge with your own modules.
My clients are ordinary current web browsers.
If that includes "current browsers" (read: obsolete) like IE, then you
can't do what you want because IE will not accept XHTML served with the
correct MIME type. If includes other browsers, such as Firefox, Opera
or nearly every other modern browser, then XHTML modularisation may be
suitable for your needs.

Ideally they just ignore attributes they don't know about. I'll
handle them with JavaScript.


Your extensions (incluing, among other things, any elements or
attributes you add) will appear in the DOM, but browsers will not do
anything useful with them. Scripts and/or stylesheets will be able to
work with them like any other element or attribute.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Aug 20 '05 #5
Lachlan Hunt wrote:
Michael Schuerig wrote: I believe he meant that you can't serve it as text/html, you need to
use an XML MIME type like application/xhtml+xml or application/xml.
What happens if I serve such a document as text/html nevertheless?
Presumably the browser won't burst into flames.
You should look into XHTML Modularisation, which allows you to extend
the langauge with your own modules.


Yes, that's what I guessed, but my knowledge of modularization is less
than superficial. Are there any more approachable documents on the
topic than the W3C recommendations?

Apparently I need to write my own schema as an extension of a suitable
existing XHTML schema. I can't remember seeing any information on how
to do this, unfortunately.
My clients are ordinary current web browsers.


If that includes "current browsers" (read: obsolete) like IE, then you
can't do what you want because IE will not accept XHTML served with
the
correct MIME type.


As much as I like it, I can't ignore IE. But again the question, what
bad things happen if I do serve a document with a technically incorrect
MIME type?

Michael

--
Michael Schuerig The more it stays the same,
mailto:mi*****@schuerig.de The less it changes!
http://www.schuerig.de/michael/ --Spinal Tap, The Majesty of Rock

Aug 20 '05 #6
Michael Schuerig wrote:
As much as I like it, I can't ignore IE. But again the question, what
bad things happen if I do serve a document with a technically incorrect
MIME type?


If you serve XHTML 1.0 as (Markup validated) text/html your document
should render and display the same as a (Markup validated) HTML 4.01
document; it will not have XML functionality -- you need to serve XHTML
1.0 as application/xhtml+xml for that.

XHTML 1.1 and XHTML Basic documents should only be served as
application/xhtml+xml.

--
James Pickering
http://www.jp20.org/

Aug 20 '05 #7

Previously I wrote:
If you serve XHTML 1.0 as (Markup validated) text/html your document
should render and display the same as a (Markup validated) HTML 4.01
document; it will not have XML functionality -- you need to serve XHTML
1.0 as application/xhtml+xml for that.

XHTML 1.1 and XHTML Basic documents should only be served as
application/xhtml+xml.


Of course, MSIE browsers do not recognize MIME type
application/xhtml+xml and will display a download window when served
such documents -- this is the old dilemna -- you are really better off
creating valid HTML 4.01 documents.

James Pickering
http://www.jp29.org/ (corrected)

Aug 20 '05 #8
James Pickering wrote:

Previously I wrote:
If you serve XHTML 1.0 as (Markup validated) text/html your document
should render and display the same as a (Markup validated) HTML 4.01
document; it will not have XML functionality -- you need to serve
XHTML 1.0 as application/xhtml+xml for that.

XHTML 1.1 and XHTML Basic documents should only be served as
application/xhtml+xml.


Of course, MSIE browsers do not recognize MIME type
application/xhtml+xml and will display a download window when served
such documents -- this is the old dilemna -- you are really better off
creating valid HTML 4.01 documents.


Yes, but that doesn't help me with my original problem. I'm looking for
a way to attach additional payload to my markup. What I'm currently
doing is that I'm abusing the class attribute, where I add classes of
the form <key>:<url-encoded-value>. It works, it's conformant, as the
class attribute is defined as a cdata-list. But it is ugly and doesn't
feel right.

Michael

--
Michael Schuerig Thinking is trying to make up
mailto:mi*****@schuerig.de for a gap in one's education.
http://www.schuerig.de/michael/ --Gilbert Ryle

Aug 20 '05 #9
In article <de**********@newsreader3.netcologne.de>,
Michael Schuerig <mi*****@schuerig.de> wrote:
Lachlan Hunt wrote:
Michael Schuerig wrote:
I believe he meant that you can't serve it as text/html, you need to
use an XML MIME type like application/xhtml+xml or application/xml.


What happens if I serve such a document as text/html nevertheless?
Presumably the browser won't burst into flames.


At worst your choice of doctype might lead to the quirks layout mode
(assuming "such document" means a document which is like an Appendix C
XHTML 1.0 doc except it has a home-grown attribute somewhere).
Apparently I need to write my own schema as an extension of a suitable
existing XHTML schema. I can't remember seeing any information on how
to do this, unfortunately.


Instead of DTDs, you may prefer to use RELAX NG. Either way, your result
will be unofficial.

The easiest way is to grab a full copy of an existing schema and edit
the parts you need changed.

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Aug 20 '05 #10
James Pickering <jp**@cox.net> wrote:
If you serve XHTML 1.0 as (Markup validated) text/html your
document should render and display the same as a (Markup
validated) HTML 4.01 document


In your favorite browser maybe.

--
David Håsäther
Aug 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anna | last post by:
Hi all. I have a text box: <input type="text" size="36"/> and a textarea: <textarea rows="3" cols="26"></texarea> and I use these in several pages. Is there a way to define the sizing of the...
38
by: Ted | last post by:
Is there a way to define a constant value for a color in a CSS declaration? I have numerous colors in different CSS elements, and if I make a change in color, I have to change all the reference...
3
by: LeRoy Lee | last post by:
I have been searching for the answer to this as it will determine how I use classes. Here are two bits of code. class foo1: def __init__(self, i): self.r = i self.j = 5 >>h = foo1(1) >>h.r
5
by: Sadeq | last post by:
Is it possible to define custom attributes for arrays? And if so, how can I retrieve them? I mean I want to define sth like: int MyArray; and then retrieve the value of the custom...
4
by: Hans | last post by:
Hi, I want to define a couple of constant strings, like in C: #define mystring "This is my string" or using a const char construction. Is this really not possible in Python? Hans
5
by: Cmtk Software | last post by:
The following code: public __gc class MyClass { public: void MyFunc (int __gc* number); }; Generates the following metadata for C# when compiled in VC 2005 with the /clr:oldsyntax switch...
5
by: chapeau_melon | last post by:
Hello, I'm basicly not a programmer... I found some C++ codes on the net that almost satisfy me needs, wich is to communicate with an other device that sends data to me, wich I have to receive...
3
by: fussellja | last post by:
Is there a way of defining the maximum length of a string parameter to a web service in .Net? I assumed that there would be an Xml... attribute that I could apply to a string definition in the...
2
by: ismailc | last post by:
Hi, I don't know xml. The stylesheet identifies all the objects from DB & as it reads through the DB, it checks the next object "for-each", I need to check the third object as well & define within...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.