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

April 26, 2006

DTD vs Schema

Filed under: XML — cangione @ 5:57 pm







Get the question "should I use a DTD or a Schema" all the time. Found an interesting article on XML.com that said in a sample of over 800 XSD schemas it found that few actually use anything more than DTDs could have provided.

One thing that I've found schema's good for is when you want to have some rules enforcement for authoring but you are using the actual XML source files direct on the Web with CSS. Firefox does not complain if it finds an XML file with a doctype declaration and proceeds to render the XML document via CSS. Internet Explorer of course will not render an XML document that contains a doctype declaration.

CA

April 6, 2006

Quick tour of XPath

Filed under: XSLT — cangione @ 3:43 pm







Getting lots of questions about XPath on the #XML IRC channel so figured I'd write a quick cheat sheet. Sometimes the hardest part of learning something is knowing what it's called.

There are 7 Types of Nodes:

  1. Root Node
    /
  2. Element Node
  3. Text Node text
    ()
  4. Attribute Node
    @
  5. Comment Node
    comment()
  6. Processing Instruction
    processing-instruction()
  7. Namespace Node

There are 13 AXIS Specifiers from your current node:

  1. ancestor::
  2. ancestor-or-self::
  3. attribute::(or @)
  4. child::(or nothing)
  5. descendant::
  6. descendant-or-self::
  7. following::
  8. following-sibling::
  9. namespace::
  10. parent::or (or ..)
  11. preceding::
  12. preceding-sibling::
  13. self:: or (.)

Note that the double colon "::" immediately follows the use of an axis name.

Predicates:

Predicates are used to qualify expressions (i.e filter nodes). Predicates are specifiable on any node set and appear in sqare brackets after the node test.

Example:

version[3]

Functions:

  • last()

    - When processing a list of nodes, if the nodes are numbered from one, last() returns the last number.

  • position()

    - returns the value of the context position

  • name()

    - returns the name of a node. Good for getting things like the element name for tests.

  • concat() 

    - take two or more arguments and joins the results together end-to-end.

  • count()

    - returns the number of nodes present in the node-set

  • not()

    - returns the negation of its argument.

Examples:

Actually reading the XPath Expressions is probably the easiest way to learn them. Keep in mind that from any position in the document you can write an XPath expression to get to any other node in that document.

para
matches all para children in the current context
para/emphasis
matches all emphasis elements that have a parent of para
//title
matches all title elements anywhere in the document
.//title 
matches all title elements that are descendants of the current context
item[1]
matches the "first" item
item[position()=last()]
matches the last item (in a given list)
topic[@level='basic']
matches topic elements with level attributes whose value is basic
//chapter[2]/title
The title of the second chapter
preceding::partNumber
all preceding partNumber elements


Way to remember format for crontab

Filed under: Linux — cangione @ 2:59 pm







The crontab file is used to schedule commands. To use it you must remember the format it expects. It is not how shall we say mnemonic. In trying to remember the format, I came across a good linuxjournal article that had an easy way to remember it.

Add a header comment that provides the proper sequence:

$ crontab -e
# ****************Roots crontab***********************

# minute (0-59),
#    hour (0-23),
#       day of the month (1-31),
#          month of the year (1-12),
#             day of the week (0-6, 0=Sunday),
#                command


April 4, 2006

meebo instant messenger clients via AJAX

Filed under: Software — cangione @ 10:24 pm







http://www23.meebo.com/

Very cool AJAX IM implementation for AIM, ICQ, Yahoo, MSN, Jabber and GTalk

Great for when your away from your computer.

April 3, 2006

Create an Exact Copy of a Document using XSLT

Filed under: XSLT — cangione @ 1:59 pm







I get this request all the time so here is an example. It also shows you how to handle cases where you want to do something specific to certain elements while doing the copy.

<?xml version="1.0" encoding="UTF-8" ?>

<!--
    Document   : Create Copy of Document
    Created on : April 3, 2006
    Author     : sgmlxmldotnet
    Comment
       Demo file for Creating an Exact Copy of the document.
-->

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- template rule matching source root element -->
    <xsl:template match="/|*|comment()">
       <xsl:call-template name="do_copy"/>
    </xsl:template>

<!-- Add additional template matches here -->

<!-- Named Templates -->
	<!-- Copy current element and attribute nodes -->
	<xsl:template name="do_copy">
	    <xsl:copy>
        	<xsl:for-each select="@*">
				<xsl:copy/>
			</xsl:for-each>
			<xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>


March 23, 2006

oXygen Development Enviornment for XML a multi platform alternative to Altova XML Spy

Filed under: Eclipse,Software,XML,XSL,XSLT — cangione @ 9:44 pm







Downloaded the latest version of the <oXygen> XML IDE last night and was impressed with what I saw. <oXygen> is cross platform and supports both Linux and Windows as well as the Eclipse IDE. One things that I have always like about the Altova XML Spy suite (that they remove from their community edition) is the ability to collapse an element in the edit interface. This comes in really handy when working with complex documents. <oXygen> also has a nice Schema interface, XPATH 2.0 interface and diffing tool.

Altova charges big bucks for all of this functionality. The equivalent functionality in <oXygen> for 1/4 the price, cross platform to boot? Summary good deal!

NOTE: If you are running <oXygen> under Linux you do need a Sun JVM. The JVM that comes with the Fedora Core 4 & 5 distributions is not supported. To make it work in Fedora Core, rename the supplied /usr/bin/java binary to java.old and then include a link called java to the SUN JVM.

How can hiding menu items be a good thing?

Filed under: Rants/Musings — cangione @ 8:40 pm







I have long cursed the day that Microsoft introduced the concept of infrequently used menu items which they hide for you.... unless you request all the menu items by another mouse click. Like I might not want the REDO function. Supposedly this makes the menu interface "cleaner". To any advanced user this is the most annoying freakin invention ever! To make it even worse, the Microsoft interface experts provide no way (that I know of) to turn the "feature" off!

I will be curious to see if this "improvement" was kept in Vista.

March 22, 2006

The Underscore Hack

Filed under: CSS — cangione @ 6:36 pm







We all know that IE is not the best at supporting the web standards. This leads properly coded web pages to look awful at times including this site! My typical web browser is Firefox where the pages on sgmlxml.net look great. I still have some wayward friends that use IE so I was experimenting with making the pages look better in IE.

There are a couple of different techniques talked about on the web for this problem. The one that I prefer after some experimentation is the Underscore Hack. The hack works because IE is not the brightest browser in the world. An underscore in CSS is designed to act as a comment for that attribute only, and all browsers but IE honor this.

.text {
       margin: 10px;
       _margin: 15px;
}

NOTE: You have to place the underscore rule after the real attribute since IE sees both but uses the last one it sees.


Firebug Plugin for Firefox

Filed under: Software — @ 2:30 pm







FireBug is a new tool that aids with debugging Javascript, DHTML, and Ajax. Combination Javascript Console, DOM Inspector, and a command line Javascript interpreter.






February 26, 2006

Pastebin for online collaboration on source code

Filed under: Software — cangione @ 3:09 pm







Stumbled across a neat site the other day while in an IRC chat called Pastebin. A contributor wanted people to review his source code so he put it out on a site called http://pastebin.ca

The site is designed so that you can post, comment and retrieve someone's source code for review. The site also offers a way to comment and highlight the code. There are various levels of control from a completely public area to a username/password option to view a post. Pastebin also offers to expire the post based on a time period of your choosing.

In short, a easy quick online collaboration tool.


February 23, 2006

Add Your Own Search Engine in Firefox

Filed under: Software — @ 11:12 pm







Firefox comes with multiple search sites in the Search Bar in the upper-right corner. The only one that I use on a regular basis is the default google one. I had other search engines that I wanted to add and I wanted to remove the ones that I didn't use. The process of removing search engines will be an exercise left to the reader.



The process of adding your own search engine is fairly straight forward. The following example shows you how to connect the sgmlxml.net blog search engine to the google Search Bar in Firefox.




  1. Navigate to the firefox/searchplugins directory
  2. Create a file named sgmlxml.src
  3. Edit the sgmlxml.src file as follows


sgmlxml.src File Example








<search
name="SGMLXML Blog Search"
description="SGMLXML Blog Search"
method="GET"
action="http://sgmlxml.net/sgmlxmlblogs/index.php"
queryCharset="utf-8"
>

<input name="s" user>
<inputnext name="start" factor="10">
<inputprev>
<input name="ie" value="utf-8">
<input name="oe" value="utf-8">

<interpret
browserResultType="result"
charset = "UTF-8"
resultListStart="<!--a-->"
resultListEnd="<!--z-->"
resultItemStart="<!--m-->"
resultItemEnd="<!--n-->"
>
</search>



















Firefox FireFTP

Filed under: Software — @ 9:49 pm







FireFTP is a free, secure, cross-platform FTP client plugin for Mozilla Firefox which provides easy and intuitive access to FTP servers.



http://fireftp.mozdev.org/

« Newer PostsOlder Posts »

Powered by WordPress