tags: XML

Action executed in 0.000

Each Tag


Common tags - number of posts

TrickleUp (3), Atom (2), IT (1), USPS (1), truncate (1), web (1), XmlDoc Substring (1), joke (1), falling asleep (1), guitar (1), humor (1), RSS (1), sleep (1), Marc (1), articles (1), Xerces (1), well formed (1), substring (1), search (1), Moss (1), validate (1), GP (1), address (1),

2 way join

Atom, XML, TrickleUp, XML


tags: Atom, RSS, XML
Fixed Atom feed. Thanks to Katie for asking me to fix it.


tags: IT, search, web, XML
a collection of simple formats for the sharing of search results

url: http://www.opensearch.org/

type: unknown, format: unknown

Brian versus Sleep

Last night i was working on GP as usual. For the last few nights this week me and Sleep have been battling each other. After a late dinner i'll get to work programming. Around 9pm Sleep hits me hard. I'll crash on the couch until midnight or 3am, then return to work. Two nights ago i thought i could work out an idea as i laid down...

Nope! Sleep knocked me out.

But last night, i made a strong come back. I laid down to figure something out and i got the solution before Sleep hit me.

Tonight i look forward to implementing it.


Previously, i've written a function to take the substring of an XML string, while preserving well-formedness. E.g. xml_substring( "<p>The brown <span class='light'>cow jumped over the lazy</span> moon</p>", 50 ) produces <p>The brown <span class='light'>cow jump</span></p>. What i need now is the rest of the string, i.e <p><span class='light'>ed over the lazy</span> moon.</p>. And i figured a way to build this into my recursive algorithm. So far i see only one problem with this, viz. an element with an id attribute can't be split into two.

XML Joke

tags: joke, humor, validate, XML, Moss
[14:12:32] <dero><there>is<nothing/>wrong with <xml/></there>
[14:13:20] <moss>please wait while I validate

XmlDoc Substring

I wrote a useful PHP class i'd like to share. The whole purpose to to take a substring of an XML document while preserving well-formedness. I created this function because i incorporate other people's articles into my blog, but need to limit the size of summaries. Examples and source code are included below.

I wanted to create a class "myXmlDoc" as an extension of xmldoc in PHP, but apparently xmldoc is not a class, just a collection of functions.

This is how xmlDoc is used.

$str_Doc = "<person><name>Brian</name><hobby>writing code</hobby>";
$XmlDoc = new xmlDoc( $str_Doc );
if ($XmlDoc->isWellFormed())
   $SS = $XmlDoc->substring( 30 );

Here's a larger example.

Here's the source code licensed under GPL.

One thing this code doesn't do is maintain validity. Consider that an address element is composed of mandatory street, city, and state elements. This function would cut the state element first, then city, and finally street if you wanted a short enough substring.

Tangentially, i would represent a postal address like i represent time in a hierachial structure, like this.

  <country value='USA'>
    <state value='MD'>
      <city value='Rockville'>
        <zip value='20742'>
          <street value='Ruth Lane'>
            <number value='169' />

Each sub element is optional. This allows you to have arbitrary precision. Using this method, a substring will maintain validity in addition to well-formedness. If you are forced to omit data, the first to go are the finest details. Saying you live in USA has more meaning than saying you live at 169.


tags: TrickleUp, Atom, XML

An Atom feed of this site is now available. Here's the URL: http://brian.derocher.org/atomSearch.php Atom is the new RSS.

Atom uses a well defined XML schema, XML namespaces, HTTP (GET, POST, PUT, DELETE), avoids, RPC, and passwords are sent securely (granted i'm not controlling access to my feed.

With Atom, it's possible to embed images using base64 encoding.

Will i provide RSS version x.xx? Probably not.

Guitar Test, Truncated XML

After a short workout, i went with Marc directly from work to Guitar Center. We went to the back room were we tested a varied selection of Martins and Taylors.

The Taylors have a tinny and bright sound whereas the Martins have a mellow and full bodied sound. After hearing it, i'm now thinking about the D-28; after all this guitar will last me a lifetime.

I didn't work on the comment feature on account of this dilemma. I want to provide truncated versions of articles on the top page, but don't know how to truncate XML without invalidating it. I do have one idea. Basically read and parse the content maintaining a stack of open tags. Count the number of characters printed. When you hit the limit, close all the open tags in reverse order.

PHP and Java have nice libraries to parse XML. I just prefer Xerces.