other register

Monday, April 28, 2008

Escape <?xml version="1.0" encoding="UTF-8"?> in XML / XSLT

If an xml file is embeded in another xml file like below:

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

And you want to extract the embedded xml file and remove its xml declaration tag, then do the following:

<!-- Disable xml declaration by xslt -->
<xsl:output method="xml" omit-xml-declaration="yes" />

<!-- Define the string you want to remove -->
<xsl:variable name="declare">
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]>

<!-- Get the embedded xml file -->
<xsl:variable name="prepared">
<xsl:value-of select="value" />

<!-- Remove the xml declaration and escape special characters -->
<xsl:value-of select="substring-after($prepared, $declare)"
disable-output-escaping="yes" />

Define variable using xsl:choose in XSLT

<xsl:variable name="doctype">
<xsl:when test="condition1">value1</xsl:when>
<xsl:when test="condition2">value1</xsl:when>

Get filename using XSLT

<!-- Get the filename -->
<xsl:variable name="filename" select="tokenize(base-uri(.), '/')[last()]">

<!-- Split the filename using '\.' -->
<xsl:variable name="filenamepart" select="tokenize($filename, '\.')">

<!-- Remove the file extension -->
<xsl:value-of select="$filenamepart[1]"/>

Friday, April 11, 2008

How To Make A Web Site On The Local Machine Available To Other Computer Users If you deployed a web site on apache, tomcat, or IIS on port 80, then do the following: 1. Control Panel / Network Connections / Local Area Connection (right click) / Properties 2. Advanced tab / Windows Firewall (click Settings button) / Exception tab / click Add Port button 3. Enter Name (i.e. blackboard), Port number: 80 (TCP). 4. Then click "Change scope" button, select the relevant option.

Tuesday, April 08, 2008

How to Set JAVA_HOME in Linux

Set JAVA_HOME for One User

1. Make sure you are in bash mode by typing bash

2. Edit your .bashrc file vi ~/.bashrc

3. Add the following lines

export JAVA_HOME export PATH=$JAVA_HOME/bin:$PATH

Make sure put $JAVA_HOME/bin in front of $PATH, so that the system will look for javac and java first in the $JAVA_HOME/bin, and then $PATH.

4. Refresh the user profile using the following command.

source ~/.bashrc

Note: You have to make sure you are in the bash mode by typing: bash, otherwise the user profile won't be refreshed by the above source command.

5. Check your variables:

echo $PATH
which java
which javac

Set JAVA_HOME for All Users

1. Login as root.

2. Change it to bash shell by typing bash bash

3. Edit /etc/bashrc file vi /etc/bashrc

4. 5. 6 are the same as Set JAVA_Home for One User.