SGMLXML.net A place for SGML and XML application developers.

December 21, 2005

Strange things when you forget the namespace!

Filed under: XSLT — cangione @ 9:49 pm

When your XSLT stylesheet seems to be doing strange things remember to
check the root element for a namespace. I banged my head against the
wall tonight for a good hour trying to figure out why I was getting
such strange results from simple template matches. If I did a match on
a wildcard like * it worked fine but if I did a specific match or xpath
expression nothing was coming back!

Example:

&lt;myroot element xmlns=<a class="moz-txt-link-rfc2396E" href="http://bogus.com/xmlbeans">"http://bogus.com/xmlbeans"</a>&gt;
&lt;some_elements/&gt;
&lt;/myroot&gt; 

Once you remember to check the root for a namespace life is fairly
simple just declare the namespace:

Stylesheet:

&lt;xsl:stylesheet
                        xmlns:bogus="http://bogus.com/xmlbeans"
                        xmlns="http://bogus.com/xmlbeans"&gt;
&lt;/xsl:stylsheet&gt;

Note that I declare the namespace twice. Once so I can address
it in the input file as “bogus:<some_element>” and then as the
default namespace for the resulting file so I don’t have namespaces
declared all over the place.

December 20, 2005

Toggle colors on html span element using Javascript

Filed under: CSS,DOM,XSLT — cangione @ 11:31 pm

Javascript for changeing the color of span elements with a particular class attribute.

<tt>&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text/javascript"</span>&gt;</tt><br />
  <tt>function changecolor() {</tt><br />
  <tt>    for (i=0;i&lt;document.getElementsByTagName("span").length;
i++) {</tt><br />
  <tt>        if
(document.getElementsByTagName("span").item(i).className == "myclass"){</tt><br />
  <tt>           
document.getElementsByTagName("span").item(i).style.color = "green";</tt><br />
  <tt>        }</tt><br />
  <tt>    }</tt><br />
  <tt>}</tt><br />
  <tt>&lt;/<span class="end-tag">script</span>&gt;</tt><br />
  <br />
  <tt>.......</tt><br />
  <br />
  <tt>&lt;<span class="start-tag">a</span><span class="attribute-name">
href</span>=<span class="attribute-value">"#" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"changecolor();"</span>&gt;Change
Color&lt;/<span class="end-tag">a</span>&gt;</tt><br />
  <br />
  <tt>.......</tt><br />
  <br />
  <tt>&lt;span class="myclass"&gt;Hi There&lt;/span&gt;</tt><br />

December 4, 2005

VMware 5.5 Worth the Upgrade for Linux Hosts

Filed under: Linux,Software — cangione @ 9:48 pm

If you are running VMware on a Linux host it is worth the upgrade to
5.5 for the new bridged support for wireless networks. It used
to be the you had to use NAT when running your Virtual Machines under
Linux using a wireless card. This feature had been available for
windows hosts for awhile.

December 2, 2005

Using XSLT Stylesheets with Arbortext E3 for HTML Output

Filed under: Software,XSLT — cangione @ 5:30 pm

“convert” apparently expects to find an ATI processing instruction in
xsl stylesheets before it will execute HTML transformations. Otherwise
it only produces XML.

The PI should take the following form and be inserted as follows:

&lt;?xml version="1.0"?&gt;
&lt;?APT StylesheetID Title="FOOBAR" CompositionTypes="htmlfile"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/XSL/Transform">"http://www.w3.org/1999/XSL/Transform"</a>&gt;

Powered by WordPress