Proposal for small enhancement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Proposal for small enhancement

Sorin Schwimmer

Hello everybody,

I'm not exactly a specialist in web development, and am writing HTML code (manually, btw) only now and then. Doing it, I felt that I'm missing a certain functionality (or is it there and I don't know about it?): when it's about style, we have the very powerful CSS, allowing one definition to be used again and again. When it's about content, I couldn't find anything like inlining (a feature found for instance in wikis).

So, here is my suggestion: lets add a tag in one of the following forms:
<r id=ID/>
<r src=URL/>
"r" stands from "replace", and the idea is to use a substitution in the text the same way #define does it in C.

The first form is introducing an ad-hoc definition, the second one is refering another resource to be inlined (can I use such a verb?).
For the first situation, ad-hoc definitions can be grouped in an external file, with the prefered CCS extension (from cascading content sheet), and it is introduced similar with a CSS file, in the <head> section:
<link href="myfile.ccs" rel="contentsheet" type="text/ccs" />

Let's look at an example:

myfile.css:

i1 {</td></tr><tr><td><img src="icon1.jpg" valign="top"/></td><td>}
i2 {</td></tr><tr><td><img src="icon2.jpg" valign="top"/></td><td>}
e {<r src="otherfile.html"/>}

myfile.html:

<head>
<link href="myfile.ccs" rel="contentsheet" type="text/ccs" />
</head>
<body>
<table border=0><tr><td><img src="icon1.jpg" valign="top"/></td><td>
Content of this cell
<hr/><r id="i1"/>
Content of that cell
<hr/><r id="i1"/>
Content of this cell
<hr/><r id="i2"/>
Content of that cell
<hr/><r id="i1"/>
Last cell
</td></tr></table>
<p>this is a paragraph, stating that <r id="e"/>, and <r src="file2.html"/>
</body>

Comments: this approach allows the gradual adoption of the new tag. Old browser, oblivious to the <r> tag, will ignore it, but the respective content is not retrieved. The onus is on the server side to detect that the user agent has the ability to work with <r> and, if not, to serve alternative content (defined by the same authors). In plain English, until <r> becomes generaly accepted, there will have to be two versions of the same file, one with <r>'s, one with <r>'s already replaced, and the server will send the appropriate one.

Plugins can be the first solution to allow <r>, then newer versions of the user agents can simply implement <r>.

If accepted and implemented, for authors, it simplifies a lot the work: if there is a need to change a certain thing in the replaced paragraph, it is done only once, in the definition. Not having this feature means going through all the affected files and operating the change. It also can work as a shortcut for the lazy ones (I subscribe here).
For user agents aware of <r> it reduces traffic, as there is no need to GET the same fragment again and again.

>From a DOM prospective, this is a non-issue, as <r> is eventualy replaced, and dissapears.

Regarding the second form, to avoid circular referencing, as the user agent is processing the substitutions, it needs to maintain a list of URLs invoked for a particular substitution. If an URL repeats itself, then the user agent should stop expanding, and signal an error.

Regards,
Sorin Schwimmer


     


Reply | Threaded
Open this post in threaded view
|

Replaceable element for parameterising pages (was: Proposal for small enhancement)

David Woolley (E.L)

Sorin Schwimmer wrote:

First point, when choosing a subject try to summarise the proposal.

>
> So, here is my suggestion: lets add a tag in one of the following forms:
> <r id=ID/>
> <r src=URL/>
> "r" stands from "replace", and the idea is to use a substitution in the text the same way #define does it in C.

This capability has always existed in HTML, as specified (probably
dropped in HTML5).  However, browser developers have never considered it
worth implementing.

Most web pages actually make use of the capability, e.g. when they write
&nbsp; they really asking for the browser to substitute the definition
of nbsp, which is, I believe, actually &#xa0;.  In practice, though the
browsers have things like &nbsp; hard coded, rather than parsing the
list of definitions at run time, and most do not have the code to
support that parsing.

Your second case is handled by redirection.  If I remember correctly, an
entity can be defined to be external.  Again, normal browsers don't have
the code to support this.

Also, I don't think you can use the id attribute, as you may want to
substitute the same text in multiple places, and id uniquely identifies
the element in which it occurs.  (You make the common mistake of
referring to elements as tags.)
--
David Woolley
Emails are not formal business letters, whatever businesses may want.
RFC1855 says there should be an address here, but, in a world of spam,
that is no longer good advice, as archive address hiding may not work.

Reply | Threaded
Open this post in threaded view
|

Re: Proposal for small enhancement

Andrei Eftimie
In reply to this post by Sorin Schwimmer

> myfile.css:
>
> i1 {</td></tr><tr><td><img src="icon1.jpg" valign="top"/></td><td>}
> i2 {</td></tr><tr><td><img src="icon2.jpg" valign="top"/></td><td>}
> e {<r src="otherfile.html"/>}

You are mixing Structure with Style by adding markup into CSS. You can
add content from CSS right now (altough it does not work in every UA)
with
p { content: 'here goes your content that replaces the actual content"; }

CSS should not be allowed to manipulate the DOM. You have Javascript for that.


> If accepted and implemented, for authors, it simplifies a lot the work: if there is a need to change a certain thing in the replaced paragraph, it is done only once, in the definition. Not having this feature
> means going through all the affected files and operating the change

You could use a database and don't repeat the same information there,
and retrieve it where you need it

I't not sure how much bandwidth this could reduce. My guess is
insignificant. In your example you have an image. The actual image is
retrieved only once. The reference to that image is tiny.

--
Andrei Eftimie

+40 766 745 235

Web Developer
http://www.designpunct.ro

http://www.eftimie.com

Reply | Threaded
Open this post in threaded view
|

Re: Replaceable element for parameterising pages (was: Proposal for small enhancement)

Sorin Schwimmer
In reply to this post by David Woolley (E.L)

Thanks for your answers.

Because of a typo (old habits die hard), the example file myfile.css should have been myfile.ccs, although the actual name should be irrelevant.

David:
1. &nbsp; is replacing one character; I'm talking about more then one, including html code that need to be inserted before it is interpreted by the browser
2. I'm not sure what you mean by "redirection" - is it loading another page instead of this one? If so, it does not serve my purpose. I want to add some on-the-fly generated code (be it text content, HTML code, JS code, even SVG code if embedded in HTML), not to replace the whole page.
3. The id attribute has nothing to do with the usual semantic for an id attribute. Remember that the <r> element dissapears, by being replaced with the invoked content, and so will dissapear it's id attribute. It is the same like using #define in C/C++ - whatever name was used there is replaced with the actual value by the preprocessor, and the compiler never sees it.
4. "tag", "element" - yeah, you're right, I'm a bit loose here.

Andrei:
1. CSS has indeed "content". Many voices are against it, and I subscribe to that, as CSS is about style (presentation), and not content
2. Even so, "content" is related to an HTML element (p, div, span...) and won't allow parsing and interpreting HTML code.

The aim of my proposal is to have a mechanism (under UA management) in which the <r>'s are searched, if found, replaced, and afterward the new text is processed normaly.

Try to accomplish what I'm describing with existing tools (see example in my first posting). At client side there is only JS, not an easy approach for my stated goal.

Regards,
Sorin Schwimmer


     

Reply | Threaded
Open this post in threaded view
|

Re: Replaceable element for parameterising pages (was: Proposal for small enhancement)

David Woolley (E.L)

Sorin Schwimmer wrote:

> 1. &nbsp; is replacing one character; I'm talking about more then

&nbsp; is a degenerate case of the entity mechanism, the actual SGML and
XML entity mechanisms allow arbitrary numbers of characters to be replaced.

> one, including html code that need to be inserted before it is
> interpreted by the browser

I'm not sure about whether markup is allowed in entities.  One problem
with markup is that you cannot validate the file without expanding the
entities.

Note that quite a lot of the XML specification is about the problem of
external entities that cannot be processed because the viewer is a
non-validating one.


> 2. I'm not sure what you mean by "redirection" - is it loading

I hope I wrote indirection.  I.E., inline you have &entity; and in the
internal subset of the DTD you define entity to refer to an external file.

> another page instead of this one? If so, it does not serve my
> purpose. I want to add some on-the-fly generated code (be it text
> content, HTML code, JS code, even SVG code if embedded in HTML), not

I think inlining JS is generally discouraged.

The only legitimate way of changing the DOM at run time is by explicitly
  manipulating it.

> to replace the whole page.

> 3. The id attribute has nothing to do with the usual semantic for an
> id attribute. Remember that the <r> element dissapears, by being

id is still a reserved attribute.

> replaced with the invoked content, and so will dissapear it's id
> attribute. It is the same like using #define in C/C++ - whatever name
> was used there is replaced with the actual value by the preprocessor,
> and the compiler never sees it.
--
David Woolley
Emails are not formal business letters, whatever businesses may want.
RFC1855 says there should be an address here, but, in a world of spam,
that is no longer good advice, as archive address hiding may not work.

Reply | Threaded
Open this post in threaded view
|

Re: Replaceable element for parameterising pages (was: Proposal for small enhancement)

Sorin Schwimmer
In reply to this post by David Woolley (E.L)

First, I have to admit that I wasn't aware of the extent of the functionality of the XML entities. After reading the reply, I yahooed (I'm not googling :-) ) and found details.
But, HTML is not XML, so can I count on the same functionality in HTML? Do you have an example?

Thanks,
Sorin Schwimmer


     

Reply | Threaded
Open this post in threaded view
|

Re: Replaceable element for parameterising pages (was: Proposal for small enhancement)

Andrei Eftimie
In reply to this post by Sorin Schwimmer

> The aim of my proposal is to have a mechanism (under UA management) in which the <r>'s are searched, if found, replaced, and afterward the new text is processed normaly.
>
> Try to accomplish what I'm describing with existing tools (see example in my first posting). At client side there is only JS, not an easy approach for my stated goal.


I do see some benefits here, although small. Maybe i am not realising
what you had in mind.

1. If you want to replace big chunks of information, i dare ask *why*
would you want to display it twice (or more times) on the same page?
If its not on the same page, i dare ask why you would want it replaced.

2. If its a small amount of information, i don't see any benefits
regarding bandwith, and not really regarding writing it /
maintenancing it.

Would you provide a more concrete example of what you had in mind?
Maybe we can find some better solutions.

****
As a side note. I'm not trying to ditch your ideea, there *may* be
some valid cicumstances in using it, but i fail to see where and why.
It sort of reminds me of the ideea of using variables into CSS,
something along these lines
http://meiert.com/en/blog/20080207/selector-variables/


--
Andrei Eftimie

+40 766 745 235

Web Developer
http://www.designpunct.ro

http://www.eftimie.com

Reply | Threaded
Open this post in threaded view
|

Re: Replaceable element for parameterising pages (was: Proposal for small enhancement)

David Woolley (E.L)
In reply to this post by Sorin Schwimmer

Sorin Schwimmer wrote:
> First, I have to admit that I wasn't aware of the extent of the functionality of the XML entities. After reading the reply, I yahooed (I'm not googling :-) ) and found details.
> But, HTML is not XML, so can I count on the same functionality in HTML? Do you have an example?

HTML is, theoretically, based on SGML, and therefore inherits various
capabilities from SGML.  In practice, browser developers have ignored
this SGML heritage and its implications.

XML was originally intended to be a cut down version of SGML, and its
entity constructs come from SGML.
>      
>


--
David Woolley
Emails are not formal business letters, whatever businesses may want.
RFC1855 says there should be an address here, but, in a world of spam,
that is no longer good advice, as archive address hiding may not work.

Reply | Threaded
Open this post in threaded view
|

Re: Replaceable element for parameterising pages (was: Proposal for small enhancement)

Sorin Schwimmer
In reply to this post by David Woolley (E.L)

I am documenting a project of mine. I found that a web-page like documentation will serve the purpose better than a flat manual.

There are paragraphs that repeat themselves in various pages. It will be kind of unnatural to break the text flow with a link to the common text and expect a mouse action from the reader, that's why I want the paragraphs to be shown in each individual file. For now, I used the copy-paste method - time consuming and I hesitate to change something there. Here I would enjoy a functionality similar with my <r src=URL>

I am also using in many of my files tables with two columns: in the left column of the row there is a symbol associated with the nature of the action described, in the right column there is a narrative regarding the action. The general structure of a delimiter between two rows looks like this:
<hr></td></tr><tr><td valign=top><abbr title="Uses SmartChip technology"><img src="smartchip.jpg"></abbr></td><td>

Different images will have different titles in abbr, but there are three kinds for many, many times in almost all my files.

Here I would use the <r id=ID>, or whatever attribute name should be there (wink).

There is another area where I would have liked such a feature: the name of my project (uniQ/Card) is written in a certain way, to serve as a logo. It could have been accomplished using CSS, but would have been too much to write for each and every reference to that name/logo. Instead I made some png's and am using them. This solution works, but the cost is in the size of the carried information: the png is 305 bytes (an animated gif version goes up to 321 bytes) + the reference to it (<img style="vertical-align:middle" src="uc0.gif">), while the CSS enhanced version would have been 20-something bytes, and the plain text version is uniQ/Card -> 9 bytes. The other disadvantage with the graphic version is that it is frozen: the font does not correlate with the font used in the text. On my machine they do, just because I made the graphics to correlate, but that's not for my reading. I had to make three verions of that logo, one normal size (assuming it to be
 12 points), one for <h2> and one for <h3>. On someone's else screen things may not look so well, and a text-oriented, but CSS-enhanced version would have been better - if it weren't too much work for me for every occurence of my logo.
Here, again, I'll use <r id=ID>

Finally, Andrei, I am not worried about resistance to my idea, criticism to it or even outright rejection (nor acceptance or enthusiasm will scarry me). I came with a suggestion which may or may not find an audience; I'm more worried of not being able to express myself properly in English, at least not the same way I would do it in Romanian.

If my experience is unique in my need is very particular, not many people will rally behind such a change; if, on the other hand, it is a widespread situation, then we may end up with a quorum interested in implementing such a change, and something may happen. I am grateful for learning from people better prepared than me.

Regards,
Sorin Schwimmer


     

Reply | Threaded
Open this post in threaded view
|

Re: Replaceable element for parameterising pages (was: Proposal for small enhancement)

Sorin Schwimmer
In reply to this post by David Woolley (E.L)

Jim,

I'm not making a website, but a documentation. I am using (or abusing) the web page concept just because it fits better to my purpose. I know my audience and am addressing only it, so I don't try to respect standards, assure accessibility etc. That's why I (clearly) abuse the abbr element - it doesn't clarify an abbreviation, it rather shows a text when the mouse hover over the image.

My table is defined with border=0 and the <hr> is left only on the right cell on purpose - that's the look that I want.

Having said that, I don't have a "server-side" solution (I would know how to do that). I am delivering all the files in a zip, the user unpacks it and starts index.html. Of course, I can use JavaScript, but I found to be too much work vs the benefit.

I solved my problem by typing and copying-and-pasting, but my suggestion came as a way to solve the more general problem of repetitive content. If it will be implemented, for my documentation it will be too late anyway.

So, that's what and why am I proposing, and looking for your feedback.

Btw, with every answer I learned a bit more, so thank you all, and am looking forward for more reactions. If the conclusion is that such a preprocessor + substitution makes sense, we may end up with a better development environment. If, on the other hand, there is not much enthusiasm for such a thing, there was still a healthy debate with learning opportunities for all of us.

Regards,
Sorin Schwimmer