The processing instruction target matching “[xX][mM][lL]” is not allowed

┬áThe processing instruction target matching “[xX][mM][lL]” is not allowed

This exception reminds me of quote “Much ado about nothing”.

I experienced this exception while parsing an XML using SAXParser. I searched over the web and found many questions on this and there were several others who experienced the same issue. So thought of putting a solution over here, so that it might help someone if they safe something similar.

Well, the solution is pretty simple. The problem is somewhere with the first line of you XML i.e.

<?xml version=”1.0″ encoding=”utf-8″?

In my case there was a whitespace before the start tag <. I trimmed the XML string and that’s all!

Advertisements

How to identify endianness of a system

Though Java is platform independent, there are times when we need to identify the endianness of a system.

In this short blog, we will see how can this be achieved.

1. Using System.Properties()

System.getProperty(“sun.cpu.endian”);

Ex:

System.out.println(“Endianness: ” + System.getProperty(“sun.cpu.endian”));

Output:

Endianness: little

2. Using ByteOrder.nativeOrder()

System.out.println(“ByteOrder: ” + ByteOrder.nativeOrder());
if(ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
System.out.println(“Little Indian”);
}

Output:

ByteOrder: LITTLE_ENDIAN
Little India

3. Using BitShift

int right = 0;
int left = 1;
int combine = (left<<16) | right;
if(combine == 65536) {
System.out.println(“Little Indian”);
}

Output:

Little Indian


Build Mavan project without TestCase

If you want to build a maven project without running the test cases, it can be done in several ways:

  1. If the build is being invoked from terminal, build needs to be done with additional argument:
    • mvn -Dmaven.test.skip=true
  2. If the build is being done from Netbeans IDE, below is the step:
    1. Right click on the maven project and select Custom -> Goals
    2. Type Install in the Goals field
    3. Select the check box ‘Skip Tests’
    4. If you want to build project even in future with testcases, select the check box ‘Remember as’ and give a name
    5. Click Ok

      Netbeans maven build without test cases

      Snapshot for maven build without testcases in Netbeans

If you want to start the Netbeans Profiler without running the testcases, you need to add the following tag in pom.xml within <profiles><profile><profile><profiles> tag:

<properties>
<maven.test.skip>true</maven.test.skip></properties>