XHTML space slash

XHTML tags in the format <tag />.

<br />, <hr />, <img />, <input />, <base />, <link />

The space before closing slash was primarily done for legacy browsers that did not properly parse the value without an attribute or space, but does have some value in improving readability of XHTML markup. (In my experience this is NN4.x and earlier.)

Per http://www.w3.org/TR/xhtml1/#C_2:

C.2. Empty Elements

Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br /> allowed by XML gives uncertain results in many existing user agents.

REFERENCE:

Disable Cisco NAC Agent logging

I recently had to use a Windows computer with Cisco NAC installed, and found that there was a lot of disk activity for logging.

These files would grow to approximately 5MB before rotation.

C:\Documents and Settings\All Users\Application Data\Cisco\Cisco NAC Agent\logs\NACAgentLogCurrent.log
C:\Documents and Settings\All Users\Application Data\Cisco\Cisco NAC Agent\logs\NACAgentLogOld.log

To reduce this overhead (when no problems exist), the config file is exposed in XML.

  1. Open C:\Program Files\Cisco\Cisco NAC Agent\NACAgentCFG.xml
  2. Add/modify the LogFileSize attribute to 0 (zero) as shown below:

    <?xml version="1.0" ?>
    <cfg>
    <DiscoveryHost></DiscoveryHost>
    <LogFileSize>0</LogFileSize><!-- default 5 -->
    </cfg>
  3. Reboot
  4. Remove the old .log files

NOTE: if you ever have networking issues and require support, you will need to restore the default value to ‘5’.

REFERENCES:

CDATA markup of XHTML script and style tags

Ideally all JavaScript and CSS definitions should be external to the content of an HTML page, in some cases it’s simply not practical. If you’ve migrated to XHTML markup of your page, this can often lead to XML validation errors. The use of a CDATA escape can fix most issues, though you may have to cleanup some of the actual code to resolve other issues, particularly with some special characters that are expected to be encoded.

Here are a few examples of CDATA implementation in HTML tags:

<script type="text/javascript">
/* <![CDATA[ */
...
/* ]]> */
</script>

<script type="text/javascript">// <![CDATA[
...
// ]]>
</script>

<style type="text/css">
/* <![CDATA[ */
...
/* ]]> */
</style>

XML formatted JSP source code

I’ve found that many developers still use the classic coding style on JSP’s, unfortunately this makes it difficult to use some common tools for validation and complicates matters when looking for improperly nested tags in the markup. Migrating the XML formatted JSP markup simplifies matters and makes it possible for developers to quickly identify many problem areas of code within the IDE.

<%@ page language="java" %> = <jsp:page.directive language="java" />

<%@ page contentType="text/html; charset=utf-8" %> = <jsp:page.directive contentType="text/html; charset=utf-8" />

<%@ page import="" %> = <jsp:page.directive import="" />

NOTE: you can combine page.directive’s to a single tag with all attributes.

<% //some scriptlet %> = <jsp:scriptlet>//some scriptlet</jsp:scriptlet>

<%! String somevalue="1"; %> = <jsp:declaration>String somevalue="1";</jsp:declaration>

<%= somevalue %> = <jsp:expression>somevalue</jsp:expression>

<jsp:include page="" />
<jsp:directive.include file="" />

<jsp:useBean id="" scope="" type="" />

<jsp:setProperty name="" />

Unfortunately, there’s one common type of tag that does not have an XML equivalent:

<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld" %>

REFERENCES:

Happy coding

JSON – JavaScript Object Notation

Here’s another simple way to optimize code and network traffic. XML… by it’s very definition is wasteful as it exchanges size for readability. JSON is a different approach that maintains readability as well as reduces the size to a minimum. This method can be used in any client-server environment, not just between a browser and server.

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to and machines to read/parse and write/generate. JSON is a text format that is completely language independent but uses conventions that are familiar to most programmers familiar with OO languages.

JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

Key Concepts:

  • An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
  • An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).
  • A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.
  • A string is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
  • A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.

REFERENCES:

Cheers!

RSS Implementation Guide (Part 1 of ‘many’)

First off… the abbreviation RSS has two conflicting (but similar) meanings, both of which are XML file formats for web syndication:

  • RDF Site Summary
  • Really Simple Syndication

If you are already running a Blog or other web application that provides support for RSS, most of the work is already done for you. Here we will cover the integration of the “Feed” into your other websites.

If you take a look at the HTML source of this page, it should closely resemble what is shown below…


<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.giantgeek.com/blog/?feed=rss2" />
<link rel="alternate" type="text/xml" title="RSS .92" href="http://www.giantgeek.com/blog/?feed=rss" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://www.giantgeek.com/blog/?feed=atom" />

There's not a whole lot of difference in the actual content of these different feeds, they all contain the same 'core'
content, but apply it to different standards (each of which has it's own strengths and weaknesses).

To add the feed link to your site, it's recommended to use one or more of the 'feed' types and place the appropriate <link> into the <head> section of your website.

A 'standard' icon for RSS was recently agreed upon by Microsoft (for MSIE 7.0) and the Mozilla Organization - it is the orange colored icon that is shown here (RSS Feed Icon). Many websites that support RSS subscriptions have opted to place this in the footer of their pages.

In upcoming articles we'll show you how the RSS feed itself is created and discuss the differences in each format.