Other Microsoft XML Tools

only for RuBoard

Now that you're comfortable with most .NET tools for XML, let's complete the discussion with a brief overview of a few non .NET XML tools available from Microsoft.

XML Notepad

Microsoft XML Notepad application enables you to create and edit XML documents quickly and easily. The tool displays the structure of your XML data in an intuitive and simple user interface that graphically represents it in a tree structure. The interface presents two panes: The one on the left represents the structure with a tree control; the one on the right displays the values. You can add elements, attributes, comments, and text to the XML document by creating the tree structure in the left pane and entering values in the right pane's corresponding text boxes.

Figure 4.39 shows XML Notepad with an XML document loaded into it.

Figure 4.39. An XML document loaded into the XML Notepad.
graphics/04fig39.gif

The following features can be useful when you create and edit your documents with XML Notepad:

  • New, open , save and exit ” The File menu option provides these standard options that are common to text editors, such as creating new documents, opening existing documents, saving documents, and exiting the XML Notepad application.

  • Inserting an XML node ” To insert a new XML node, you can highlight the node relative to which you want to insert the new node. Then select the appropriate node type that you want to insert. Figure 4.40 shows a new child element being added to the Customer node.

    Figure 4.40. Inserting an XML node.
    graphics/04fig40.gif
  • View the source ” Selecting Source from the View menu displays a non-editable view of the XML source.

  • Validating XML ” If you have IE 5. x installed on your computer, you can perform DTD or XML Schema validation on your files by enabling the validation option from the options.

  • Creating a schema ” You can create an XML schema because schemas are expressed in XML syntax. You cannot, however, create a DTD.

  • Searching the XML document ” Clicking Find from the Edit menu makes the Find dialog box appear. From here, you can provide your criteria to search the document.

  • Options ” Selecting Options from the Tools menu allows you to enable or disable the XML Notepad options.

  • Converting a node's type ” To change the type of a leaf node, you can highlight the node to change and then select Change To from the Tools menu.

Apart from the preceding list, you might also find some interesting features, such as Dragging and Dropping Nodes, Duplicating a Subtree, and so on.

Downloading the XML Notepad Tool

You can download the XML Notepad tool from this URL on Microsoft's MSDN site: http://msdn.microsoft.com/xml/notepad/intro.asp.

Command-Line Transformation Utility ( MSXSL .EXE )

Imagine that, in a staging environment, you want to merge two XML documents into one before you push it to the production environment, or say that you want to filter out a large XML document into a smaller one. You would surely choose to write an XSL stylesheet because the declarative nature of XSL saves you from having to write code using any specific language or an XML parser implementation. But, if you want to perform the transformation using the Microsoft XSL processor, you must write code to load the source document and the stylesheet, followed by the calls to the methods that perform the transformation. But what if you want to perform all the transformation in an off-the-shelf manner? One workaround is to use the IE 5. x browser to perform a transformation and copy the results from the browser and paste it to a new file.

MSXSL command-line utility lets you perform off-the-shelf XSL transformations by invoking MSXML3.DLL or MSXML4.DLL . To use this tool, you must install MSXML 2.6 or later on your computer. The following is the syntax for running the tool from the command prompt:

 MSXSL source stylesheet [options] [param=value...] [xmlns:prefix=uri...] 

Here, param indicates the XSL Transformations (XSLT) parameters that conform to the XML QName syntax. There can be any number of parameters ”a white space needs to separate a parameter value from the next parameter name .

xmlns:prefix=uri indicates the prefix part that the parameter names and the start mode name can contain. This prefix is a convenience alias for a namespace Uniform Resource Identifier (URI) that fully qualifies the name.

Table 4.6 lists the options available.

Table 4.6. MSXSL Tool Options

Options

Description

“?

Shows this message.

“o filename

Writes output to a named file. Absence of this makes MSXSL dump the result of the transformation directly to the console window.

“m startMode

By default, template rules are grouped within the empty mode. However, they can be explicitly grouped within another mode by specifying the mode attribute on the xsl:template element. The “m option allows you to specify this mode.

“xw

Instructs MSXSL to strip non-significant white space from the input XML document during the load phase.

“xe

Instructs MSXSL to not resolve external definitions during the parse phase. By default, MSXSL instructs the parser to resolve external definitions, such as document type definition (DTD), external subsets , or external entity references, when parsing the source and stylesheet documents.

“v

By default, MSXSL turns off document validation. This option instructs MSXSL to turn on validation during the parse phase.

“pi

If this option is specified instead of a stylesheet argument, MSXSL uses the href attribute from the XML stylesheet PI in the source document as the name of the stylesheet.

“u version

By default, MSXSL uses the latest version of MSXML that it can locate on the machine. This option lets you use a specific version of MSXML: 2.6, 3.0, 4.0, and so on.

“t

Instructs MSXSL to show load and transformation timings. This helps to measure the relative speed of various transformations.

Dash used as source argument loads XML from stdin .

Dash used as stylesheet argument loads XSL from stdin .

The following example transforms the source XML file Customers.xml by using the stylesheet format.xsl to the output file out.xml :

 MSXSL Customers.xml format.xsl o out.xml 

If the arguments contain white spaces, you can use single or double quotes, as shown here:

 MSXSL o out.xml "C:\XML Tools\MSXSL\Customers.xml" format.xsl 

Downloading the MSXSL.EXE Tool

You can download the MSXSL.EXE tool from this URL on the MSDN site: http://download.microsoft.com/download/xml/Utility/2.0/NT5XP/EN-US/msxsl.exe.

For a detailed discussion of all the available options with the tool, visit this page on the MSDN online library: http://msdn.microsoft.com/library/en-us/Dnxslgen/html/msxsl.asp.

only for RuBoard


XML and ASP. NET
XML and ASP.NET
ISBN: B000H2MXOM
EAN: N/A
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net