Java, C#, Python, and Perl

None of the common schema languages are Turing complete. Thus none of them can state and verify every possible constraint on an XML document. For example, none of them can verify that the content of a Prime element is in fact a prime number. However, this verification is straightforward in any reasonably powerful programming language. For example, here's a very naïve algorithm implemented in Java that accomplishes this task by dividing the number by every integer between 2 and its square root until it finds a divisor.

 public void isPrime(String text) { int test; try { test = Integer.parseInt(text); } catch (NumberFormatException ex) { return false; } if (test < 2) return false; for (int i = 2; i < Math.sqrt(test); ...

Get Effective XML: 50 Specific Ways to Improve Your XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.