Esoteric XHTML question about href

G

Grant Robertson

I don't know much about XHTML. I am trying to design an XML standard
where content authors can use HTML or XHTML for the content within an
element. I already know how to use the import element in XML. My question
is even more esoteric than that.

Within the above mentioned XHTML content I want authors to be able to
insert an href to refer to a graphic without knowing what file type that
graphic will be. I want them to be able to point instead to a separate
list of alternative files and the first file in the list will be
displayed if possible. If the browser can't display that first file then
it will try the next until it finds one it can display.

What I want is similar to alternate text except for two things: 1) The
alternative could be a different graphic or even a snipit of MATHML or
INKML. 2)The alternatives aren't listed in the original content. They are
listed in a separate file that can be modified without changing the
original content at all.

Can this be done in XHTML at all?

Can it be done with no server-side code?

If so, what is it called and how do I learn about it?

Thanks in advance.

P.S. This is for a standard for marking up educational material. So any
help you give will benefit all of mankind.
 
D

David Dorward

Grant said:
I don't know much about XHTML. I am trying to design an XML standard
where content authors can use HTML or XHTML for the content within an
element.

That isn't possible - unless the HTML is going to be entered in CDATA
sections or encoding with character references.
Within the above mentioned XHTML content I want authors to be able to
insert an href to refer to a graphic without knowing what file type that
graphic will be.

href="http://www.example.com/foo/someImage"

.... and then the server can deliver up whatever you like.
I want them to be able to point instead to a separate
list of alternative files and the first file in the list will be
displayed if possible. If the browser can't display that first file then
it will try the next until it finds one it can display.

<object data="foo.gif" type="image/gif">
<object data="foo.jpeg" type="image/jpeg">
<object data="foo.png" type="image/png">
<object data="foo.svg" type="image/svg+xml">
<p>Alternative content.</p>
</object>
</object>
</object>
</object>

.... has been fine since HTML 4.0 ... shame about the browser support though.
2)The alternatives aren't listed in the original content. They are
listed in a separate file that can be modified without changing the
original content at all.

Can this be done in XHTML at all?

Not with pure HTML.
Can it be done with no server-side code?

Possibly with some JavaScript voodoo, but I wouldn't like to go down that
route.
 
T

Toby A Inkster

David said:
Grant Robertson wrote:

<object data="foo.gif" type="image/gif">
<object data="foo.jpeg" type="image/jpeg">
<object data="foo.png" type="image/png">
<object data="foo.svg" type="image/svg+xml">
<p>Alternative content.</p>
</object>
</object>
</object>
</object>

... has been fine since HTML 4.0 ... shame about the browser support though.


Not with pure HTML.

You could use something along these lines:

<object data="foo">
<p>Alternative content</p>
</object>

Then allow the HTTP server and the browser to automatically negotiate the
best choice of content from foo.gif, foo.jpeg, foo.png and foo.svg using
standard HTTP content negotiation (which is well supported by Apache).

How well that all works in practise on today's user agents is another
matter entirely.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
 
D

David Dorward

Toby said:
You could use something along these lines:

<object data="foo">
<p>Alternative content</p>
</object>

Then allow the HTTP server and the browser to automatically negotiate the
best choice of content from foo.gif, foo.jpeg, foo.png and foo.svg using
standard HTTP content negotiation (which is well supported by Apache).

You mean as I suggested when I said:
"""
href="http://www.example.com/foo/someImage"

.... and then the server can deliver up whatever you like.
"""
? ;)
How well that all works in practise on today's user agents is another
matter entirely.

The user agent doesn't matter if you're making the decision based on what
images are available on the server. Apache MultiViews to the rescue!
 
T

Toby A Inkster

David said:
You mean as I suggested when I said:
"""
href="http://www.example.com/foo/someImage"

... and then the server can deliver up whatever you like.
"""
?

What I meant was a combination of two of your suggestions.
The user agent doesn't matter if you're making the decision based on what
images are available on the server. Apache MultiViews to the rescue!

What I was a little unsure of was how browsers would react to an OBJECT
element without a TYPE attribute. The TYPE attribute is technically
optional, but it's recommended when a data attribute is present.

If the TYPE attribute is absent, then the user agent is not aware of what's
at the other end. Unsure of whether it can handle it or not, it may decide
not to request the resource at all, and simply display the alternative
content.

I'm not sure what current user agents actually do in such a situation.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
 
D

David Dorward

Toby said:
What I was a little unsure of was how browsers would react to an OBJECT
element without a TYPE attribute. The TYPE attribute is technically
optional, but it's recommended when a data attribute is present.

Doesn't Internet Explorer still have serious issues with object elements
(hence my comment about browser support)?

Time to test ...

IE7 says ... "This website wants to run the following add-on: 'Microsoft (R)
HTML Viewer' from 'Microsoft Corporation'. If you trust the website and the
add-on and want to allow it to run, click here..."

Clicking there gives me a menu and lets me pick "Run ActiveX control",
selecting that ...

.... and I get a dialog box. "Do you want to run this ActiveX control?"

I say "Run" and ...

The alternative text vanishes to be replaced by nothing at all.

If I try it with explicit height and width specified then ... it draws a box
of the right dimensions, slaps an inset border on the edge, then scales the
image down to fit in the space left, and gives the image a black
background.

hmm, and if I refresh I see a brief flash of the Quicktime logo.

Hang on. Quicktime? That isn't "Microsoft (R) HTML Viewer"

Oh boy. Internet Explorer truly is a world class piece of software.

The good news is that the lack of a type attribute doesn't seem to make any
difference for IE.
 
G

Grant Robertson

I should give some more details about my system. I am working on a
standard for marking up educational material, as I mentioned in my
original post. This material will be designed to be distributed or
downloaded to an individual student's hard drive. It will then be "served
up" and displayed by software on the user's computer. I want the desktop
software to be able to use unmodified browser code to display the
content. This is why it will be XML files with XHTML for the content to
be displayed. The software will look through the XML file for the
particular XHTML content it wants to display. Granted, I could use any
darn file format I want. However, I want to encourage lots of people to
contribute content so I want it to be in standard XHTML so people don't
have to learn anything new.

This content will be very, very modularized and I want to be able to
replace an image in the content with another image or even a snipit of
MathML or a flash applet or whatever without ever having to modify the
original content that refers to it. This way people can submit content
with lame scanned sketches for pictures and others who are more
graphically inclined can submit improved versions of these pictures. Or
someone with no software for entering equations as MathML can submit a
scan of an equation and someone else can enter that as MathML so it will
look better.

Therefore, I can't rely on ANY features of any web server software.
Though it would be OK to require the desktop software to emulate those
features if necessary. All I am concerned with at this time is: Is there
a way to indicate a generically named resource within XHTML code and have
that code still be legal. If someone were using any standard, modern web
design software to design this small hunk of XHTML content would it let
them do it at all? Would it fail to display anything, or would it give an
error?

I know these are very nonstandard questions but this is a very
nonstandard situation where I am trying to use as many existing standards
as possible. I also know I could probably answer these questions myself
if I had time to teach myself web design but I am a little pressed for
time these days with school and this standard that I am trying to work
out.

I do appreciate any help you all can give.


That isn't possible - unless the HTML is going to be entered in CDATA
sections or encoding with character references.

I know that XHTML can be used as content within an XML file. I have no
problem requiring that HTML be enclosed within CDATA tags. XML and HTML
developers are used to this already.


href="http://www.example.com/foo/someImage"

... and then the server can deliver up whatever you like.

Would "someimage" be a folder name? Or is it legal within XHTML to refer
to a resource without specifying a full, specific file name.

<object data="foo.gif" type="image/gif">
<object data="foo.jpeg" type="image/jpeg">
<object data="foo.png" type="image/png">
<object data="foo.svg" type="image/svg+xml">
<p>Alternative content.</p>
</object>
</object>
</object>
</object>

... has been fine since HTML 4.0 ... shame about the browser support though.

Where would I put this snipit of code? Would this go in the separate file
I was referring to? What would the whole file look like? How, then, would
I refer to this file within the original XHTML content? What is this
technique called so I can look it up on my own?

It doesn't matter about the browser support. I can require that the
desktop software perform a transformation of sorts to dynamically modify
the href attribute just before it sends it to the browser part of their
program. The dynamically modified XHTML content would then merely refer
to a specific file and the browser part would be none the wiser. I just
want to make sure that the XHTML code, as it sits in the original
content, is legal.

If I had to, I guess I could make up my own standard for the way the
separate list is formatted since the only software reading it is the same
software that is reading my XML file. However, I want to use as many
existing standard methods as possible so developers will be able to use
as much existing code as possible. By making it easy to design software
to my standard, I hope to encourage lots of competition in creating
software that works with the standard.

Again, I really appreciate any help anyone can give me.
 

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,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top