Family & FriendsMy Family's Home Page
|
Technology LinksMicrosoft MSXSL Command-line Transformation Tool Microsoft Video Control in VB Form Microsoft TCP/IP on Windows 2000 - White Paper ECMAScript (JavaScript) Documentation |
My Code Samples and other stuff I didXML Data Islands (Matthew's Damage Calculator) |
SecurityMicrosoft's Federated Security and Identity Roadmap Microsoft Security Tools and Checklists Microsoft Baseline Security Analyzer Windows IT Library: How to protect your system
|
||||||||||||||||
|
Fun Stuff |
Interesting ArticlesEdward Dijkstra: Goto considered joyful - About pondering as a science |
Interesting Downloads |
||||||||||||||||
NotesRegedit/s will surpress confirmation boxes and the removal of a
key is as simple as putting a minus sign in front of the key in the reg
file. e.g.:
|
More Tech LinksBusiness Process Markup Language (BPML) |
NoClick JavaScript | |||||||||||||||||
Notes About XML SchemaWildcardsThere are 3 kinds of "any"s (wildcards): strict, lax, and skip. If you specify "skip", then for sure there won't be validation errors inside the element that matches this "any". If you specify "lax", then you might get some error (if there happen to exist an element declaration that matches one of the elements to be hidden, or if there is an xsi:type on one of those elements). If you specify "strict" (the default), then 99% you'll get some error. So use <any processContents="skip" ...> and you are set. Validate Against a SchemaSet "http://apache.org/xml/features/validation/schema" to true. It means validate against a schema, not validate a schema. Validating With DOMJAXP 1.2 also defines schema support for the DOM parser, as shown in Listing 4. The procedure is very similar to that of a SAX parser, the only difference being that you set attributes on the factory object instead of properties on the parser object. The detailed procedure is: 1. Create a DOMBuilderFactory object. 2. Set the namespace-aware and validating properties to true. 3. Set the attributes for the schema language and schema source. If your parser is not JAXP 1.2-compliant, it will throw an IllegalArgumentException exception. 4. Obtain a DocumentBuilder object (the parser). 5. Register an ErrorHandler object with the parser. 6. Parse the document. This example only demonstrates validation. Your application could do more interesting things with the parse tree. |
package org.ananas.tips;
import java.io.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
public class ValidateDOM
{
public static String SCHEMA_LANGUAGE ="http://java.sun.com/xml/jaxp/properties/schemaLanguage",
XML_SCHEMA ="http://www.w3.org/2001/XMLSchema",
SCHEMA_SOURCE ="http://java.sun.com/xml/jaxp/properties/schemaSource";
public final static void main(String[] args)
throws IOException, SAXException,
ParserConfigurationException
{
if(args.length < 2)
{
System.err.println("usage is:");
System.err.println(" java -jar
tips.jar -validatedom " + "input.xml schema.xsd");
return;
}
File input = new File(args[0]),
schema = new File(args[1]);
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
try
{
factory.setAttribute(SCHEMA_LANGUAGE,XML_SCHEMA);
factory.setAttribute(SCHEMA_SOURCE,schema);
}
catch(IllegalArgumentException x)
{
System.err.println("Your DOM parser
is not" + "JAXP 1.2 compliant.");
}
DocumentBuilder parser =
factory.newDocumentBuilder();
parser.setErrorHandler(new ErrorPrinter());
parser.parse(input);
}
}
<script language="JavaScript">
// The \n is a newline character. Change this to whatever suits you!
var message="Thank you for visiting :)\n\nCopyright 2003 ? Loretta Houben";
// This gets called when you click either mouse button.
function click(e)
{
if (document.all)
{
// for event.button 1 is left mouse button, 2 is right mouse button
if (event.button == 2)
{
alert(message);
return false;
}
}
}
// This tells the browser to call our function when the mouse button is
pressed.
document.onmousedown=click;
</script>