XML Hammer How To

Check a XML document for well-formedness
Validate a XML document against a XML Schema (XSD)
Search a directory using XPath
Validate a XML Schema Document
Transform a XML Document using XSLT
Format XML Documents (Pretty-Print)
Merge a XML Document using XInclude
Validate a XML Stylesheet

Check a XML document for well-formedness

Follow the following steps when you have a XML Document and you want to check wether the document is well-formed.

  1. Create a new XML Parser project, by using the File -> New -> XML Parser menu option.
  2. Select the "Specify specific URIs for input documents" option. (Next)
  3. Type or browse to the location of the XML document. (Next)
  4. Select "SAX (Simple API for XML)" as the XML Parser (Next)
  5. Use default values (namespace enabled, XInclude disabled) on the Parser Properties Page. (Next)
  6. Select "Checking for wellformed-ness" (Finish)
  7. A new project "New Project 1" is created, 'execute' or 'run' the project by pressing the Execute button.

After the project has been executed, the parsed XML Document with potential errors or warnings can be found on the Result tab.

Validate a XML document against a XML Schema (XSD)

Follow the following steps when you have a XML Document and you want to validate it against a specific XML Schema document.

  1. Create a new XML Parser project, by using the File -> New -> XML Parser menu option.
  2. Select the "Specify specific URIs for input documents" option. (Next)
  3. Type or browse to the location of the XML document. (Next)
  4. Select "SAX (Simple API for XML)" as the XML Parser (Next)
  5. Use default values (namespace enabled, XInclude disabled) on the Parser Properties Page. (Next)
  6. Select "Validate using specified schema(s)" (Next)
  7. Specify "http://www.w3.org/2001/XMLSchema" as the schemaLanguage.
    Type or browse to the location of the XML Schema (XSD) document. (Finish)
  8. A new project "New Project 1" is created, 'execute' or 'run' the project by pressing the Execute button.

After the project has been executed, the validated XML Document with potential errors or warnings can be found on the Result tab.

Search a directory using XPath

Follow the following steps when you have a number of xml documents in a directory and you want to find information in these documents by performing a XPath search.

  1. Create a new XPath Search project, by using the File -> New -> XPath Search menu option.
  2. Select the "Specify the input documents using a Filter" option. (Next)
  3. Specify the directory location in the "Look In" field by typing or by using the browse button.
    In the pattern field type "*". (Next)
  4. Use default values (namespace enabled, XInclude disabled) on the Parser Properties Page. (Next)
  5. Select "Checking for wellformed-ness" (Next)
  6. Specify the XPath expression "*" in the Expression field.
    Make sure the Return Type field is set to NODESET. (Finish)
  7. A new project "New Project 1" is created, 'execute' or 'run' the project by pressing the Execute button.

After the XPath expression has been executed and all XML documents in the Look In directory have been searched, the XML documents with matching nodes can be found on the Result tab.

Validate a XML Schema Document

Follow the following steps when you have a XML Schema document (XSD) and you want to make sure this schema document is valid.

  1. Create a new Schema Validator project, by using the File -> New -> Schema Validator menu option.
  2. Select the "Specify specific URIs for input documents" option. (Next)
  3. Type or browse to the location of the XML Schema document. (Next)
  4. Specify "http://www.w3.org/2001/XMLSchema" as the schemaLanguage. (Finish)
  5. A new project "New Project 1" is created, 'execute' or 'run' the project by pressing the Execute button.

After the project has been executed, the validated XML Schema Document with potential errors or warnings can be found on the Result tab.

Transform a XML Document using XSLT

Follow the following steps when you have a XML document and you want to transform the document using a XML Stylesheet.

  1. Create a new XSL Transform project, by using the File -> New -> XSL Transform menu option.
  2. Select the "Specify specific URIs for input documents" option. (Next)
  3. Use the "Source" field to specify the location of the XML document.
    Use the "Result" field to specify the location of the resulting document. (Next)
  4. Select "SAX (Simple API for XML)" as the XML Parser (Next)
  5. Make sure the Namespace option and the XInclude option are both selected. (Next)
  6. Select "Checking for wellformed-ness". (Next)
  7. Select "Specify individual Stylesheet URIs". (Next)
  8. Type or browse to the location of the XML Stylesheet. (Next)
  9. Select "Use default output properties". (Finish)
  10. A new project "New Project 1" is created, 'execute' or 'run' the project by pressing the Execute button.

After the XSL Transform project has been executed and the "Source" document has been processed, information about processing the document can be found on the Result tab and the transformed output document can be found in the place where it was specified by the "Result" field.

Format XML Documents (Pretty-Print)

Follow the following steps when you have a number of XML documents in a directory and you want to format the contents of the XML documents, adding indentations and new-lines.

  1. Create a new XSL Transform project, by using the File -> New -> XSL Transform menu option.
  2. Select the "Specify the input documents using a Filter" option. (Next)
  3. Specify the directory location in the "Look In" field by typing or by using the browse button.
    In the pattern field type "*".
    Specify the directory location for the output documents in the "Store In" field by typing or by using the browse button.
    In the extensions field type "out". (Next)
  4. Select "SAX (Simple API for XML)" as the XML Parser (Next)
  5. Use default values (namespace enabled, XInclude disabled) on the Parser Properties Page. (Next)
  6. Select "Checking for wellformed-ness". (Next)
  7. Select "Use the default Stylesheet". (Next)
  8. Select "Specify XML output properties". (Next)
  9. Use the default values for all options, except make sure to select the "Indent" option. (Finish)
  10. A new project "New Project 1" is created, 'execute' or 'run' the project by pressing the Execute button.

After the XSL Transform project has been executed and all XML documents in the "Look In" directory have been processed, information about the processed documents can be found on the Result tab and the formatted output documents can be found in the directory specified by the "Store In" field.

Merge a XML Document using XInclude

Follow the following steps when you have a XML document which uses XIncludes to include fragments from other documents, to merge and format the XIncluded fragments into a resulting XML document.

  1. Create a new XSL Transform project, by using the File -> New -> XSL Transform menu option.
  2. Select the "Specify specific URIs for input documents" option. (Next)
  3. Use the "Source" field to specify the location of the XML document with the XIncludes.
    Use the "Result" field to specify the location of the resulting merged document. (Next)
  4. Select "SAX (Simple API for XML)" as the XML Parser (Next)
  5. Make sure the Namespace option and the XInclude option are both selected. (Next)
  6. Select "Checking for wellformed-ness". (Next)
  7. Select "Use the default Stylesheet". (Next)
  8. Select "Specify XML output properties". (Next)
  9. Use the default values for all options, except make sure to select the "Indent" option. (Finish)
  10. A new project "New Project 1" is created, 'execute' or 'run' the project by pressing the Execute button.

After the XSL Transform project has been executed and the "Source" document has been processed, information about processing the document can be found on the Result tab and the merged and formatted output document can be found in the place where it was specified by the "Result" field.

Validate a XML Stylesheet

Follow the following steps when you have a XML Stylesheet and you want to make sure the document is valid.

  1. Create a new Stylesheet Validator project, by using the File -> New -> Stylesheet Validator menu option.
  2. Select the "Specify specific URIs for input documents" option. (Next)
  3. Type or browse to the location of the XML Stylesheet. (Finish)
    A new project "New Project 1" is created.
  4. Press the Execute button.

After the project has been executed, the validated XML Stylesheet with potential errors or warnings can be found on the Result tab.