Promethe’s Blog Web, RIAs and chocolate spaghettis…

13Jun/090

Edit XML Namespaces with sed

Even if you are a high level programing language user, you sometimes have to use some good old tools to gain some productivity. Sed is one of those tools that might come to be handy.

I recently needed to change the xmlns attribute of a lot of XML/XSL files and doing it file by file would have been a real mess. So I wrote this little piece of script shell:

#! /bin/sh
 
NAMESPACE_NAME=$1
NAMESPACE_URI=$(echo $2 | sed -e 's/\//\\\//g')
FILE=$3
 
if [ x${NAMESPACE_NAME} = 'x' -o x${NAMESPACE_URI} = 'x' -o ! -f ${FILE} ]; then
    echo 'Usage:' ${0} 'NAMESPACE_NAME NAMESPACE_URI FILE'
    exit 42
fi
 
cat $FILE | sed -e s/xmlns:${NAMESPACE_NAME}=\".*\"/xmlns:${NAMESPACE_NAME}'="'${NAMESPACE_URI}\"/g > $FILE

You can run the script with the following command line:

./change_namespace.sh myns http://my.namespace.uri my_file.xml

Where :

  • myns is the namespace name (html, xsl, xhtml, etc...)
  • http://my.namespace.uri is the URI of the namespace
  • my_file.xml is the file to edit
12Jun/090

New DirectFlex experiments: ‘FPS’ and ‘Earth’

I just posted and blogged about a few new experiments built using DirectFlex on Direct Flex Labs:

  • FPS: is it possible to display Half Life 1 graphics in Flash ? I don't know yet... but this experiment is an improvement of the one I posted a while back
  • Earth: I always wanted to implement the famous Google Earth in Flash. This might be a good first step! I made this experiment in approximately 1 hour to test out a few new features

Please let me know what you think about those new experiments. Any feedback will be greatly appreciated!