TS 73 XML

XML, DTD and XSD Tools Test Specification

Contact: Michal Strnad, Jiri Skrivanek
Version: NetBeans 7.3
Last update: December 4, 2012
Introduction: This test specification is focused on testing of XML support in NetBeans IDE. It is based on TS_71_XML.

Contents


XML

Test suite: Syntax highlighting

Purpose: This test suite checks that syntax highlighting in XML editor is correct.

  1. New XML document
    1. Use File | New Project... to create new Java Application project.
    2. Use File | New File..., select XML category and XML Document as file type. Push Next
    3. Type diary1 into File Name, let default value in Folder field src\javaapplication1 and press Next.
    4. Let Well-formed Document option selected and press Finish.
    5. Verify that new diary1.xml file is opened in editor containing only <root> and </root> elements.
  2. Syntax highlighting
    1. Replace default content with the following:
<?xml version="1.0" encoding="UTF-8"?>
 <week id="2" year="2005">
    <day id="1">
        3rd of January, Monday
        <!-  - invalid data
    </day>
</week>
    1. Check that proper colors should be used for tags blue, attributes green, values brown, comments grey and plain text black. Invalid data section is highlighted in red color.

Test suite: Validation

Purpose: This test suite checks that it is possible to check structure and contents of XML file.

  1. Check structure
    1. Right click editor area and choose Check XML from popup menu.
    2. One error must be reported in Output - XML check window.
    3. Click Comment must start with "<!---". link. It should highlight the line with error in editor and move cursor there.
    4. Delete that line and repeat step 1.
    5. XML checking must finish successfully without any error.
  2. Create DTD
    1. Right click editor area and choose Generate DTD... from popup menu.
    2. Push OK in follow-up dialog.
    3. New diary1.dtd file should be opened in editor containing definitions for week and day elements.
  3. Validate contents
    1. Switch to diary1.xml editor tab, right click editor area and choose Validate XML from popup menu.
    2. One error must be reported in Output - XML check window.
    3. Click cvc-elt.1: Cannot find the declaration of element 'week'. link. It should highlight the line with error in editor and move cursor there.
    4. Type <!DOCTYPE week SYSTEM "diary1.dtd"> at line 2 and repeat step 1.
    5. Verify that no error shows up in Output - XML check window and XML file validates successfully.

Test suite: Code completion

Purpose: This test suite checks that code completion in XML editor is working correctly.

  1. Tags completion
    1. Switch to diary1.dtd editor tab and replace CDATA by (2012|2013) in definition of year attribute at line 25.
    2. Type <!ENTITY boolean "true|false"> at last line and Save the diary1.dtd file.
    3. Switch to diary1.xml editor tab. Add new line at end of the file and type <.
    4. Press CTRL+Space. Two suggestions day and week show up.
    5. Type w which should leave only week in the list of suggestions.
    6. Press Enter.
    7. Now you should have <week written at last line.
  2. Attributes completion
    1. Press Space and invoke code completion by CTRL+Space again.
    2. Two attributes must show up id and year.
    3. Use Arrow Down to select year and press Enter.
    4. Now you should have <week year="" written at last line.
  3. Values completion
    1. While having cursor between the quotation marks press CTRL+Space to invoke code completion.
    2. Press Enter, then End and type > to complete the tag.
    3. Editor should add value. Now you should have <week year="2013"> and new code completion window with end tag should be shown. Press Enter.
    4. <week year="2013"></week> should be written at last line.
  4. Entities completion
    1. Type & and wait for code completion.
    2. 6 items will be suggested including boolean entity.
    3. Type a which should reduce the list to only amp and apos items. Press Enter.
    4. amp; should be automatically completed so that you have </week>&amp; at last line now.

Test suite: Big files

  1. Open big file
    1. Download mondial.xml.zip and unzip it somewhere.
    2. Copy mondial.xml file under javaapplication1 package and double click it.
    3. Question dialog should warn the user that mondial.xml is a big file. Press Yes to agree with opening the file.
    4. mondial.xml should be opened in editor.
  2. XML structure
    1. Right click into editor view and select Check XML from popup menu.
    2. An error message .../mondial.dtd (The system cannot find the file specified) [2] should be writen in Output window.
    3. Right click editor view again, but this time choose Generate DTD... from popup menu.
    4. Don't change the name of DTD file, just press OK button.
    5. New file mondial.dtd should be generated and open in editor.
    6. Right click into editor view and select Check DTD. DTD checking should finish without any warnings.
    7. Change the view back to mondial.xml and repeat step 1.
    8. Right click into editor view and select Validate XML from popup menu.
    9. Document should by valid and not any problem should be shown during check and validation.
  3. Navigation
    1. Press Ctrl+7 to show Navigator window.
    2. Expand mondial node and double-click on some country.
    3. The country that you selected in Navigator window and displayed in editor view.

DTD

Test suite: Syntax highlighting

Purpose: This test suite checks that syntax highlighting in DTD editor is correct.

  1. New DTD document
    1. Use File | New File..., select XML category and DTD Entity as file type. Push Next.
    2. Type diary into File Name, let default value in Folder field javaapplication1 and press Finish.
    3. Verify that new diary.dtd file is opened in editor containing only definition of root element.
  2. Syntax highlighting
    1. Replace content of diary.dtd by the following:
<?xml version="1.0" encoding=UTF-8"?>
<!-- Error: Missing " char. Should be: encoding="UTF-8" -->

<!ENTITY %days SYSTEM "sub/days.dtd">
<!-- Error: Missing space. Should be: % days -->
<!ELEMENT root ANY/>
<!-- Error: Invalid ending. Should be: ANY> -->
<ATTLIST root private CDATA #REQUIRED>
<!-- Error: Invalid declaration. Should be: <!ATTLIST -->
%days;
    1. Check that proper colors should be used for keywords dark blue, symbols bold black, processing instruction targets dark red, values orange, comments grey, plain text black and references blue. Invalid data section is highlighted in red color.

Test suite: Validation

  1. Check DTD
    1. The diary.dtd file contains 4 errors in total.
    2. Right click editor area and choose Check DTD from popup menu.
    3. The first error about unquoted string shows up in the output .
    4. Click the The value following "encoding" in the text declaration must be a quoted string. [1] link which takes the cursor to line 1.
    5. Correct the error and repeat step 2.
    6. Go after each error and fix it according to hints mentioned in the comment below the error line.
    7. The last step is remove line with %days;
    8. Save the changes.

Test suite: Generate from DTD

  1. CSS stylesheet
    1. Create a new time.dtd and replace default content with the following:
<?xml version='1.0' encoding='UTF-8'?>
<!--- One year in Earth's life.
(id - number of year,
leap - indication whether year is leap or not)
-->
<!ELEMENT year (month)*>
<!ATTLIST year id CDATA #IMPLIED>
<!ATTLIST year leap (true|false) #REQUIRED>

<!--- One month of year.
(id - number of month)
-->
<!ELEMENT month (day)*>
<!ATTLIST month id CDATA #IMPLIED>

<!--- One day of month.
(id - number of day)
-->
<!ELEMENT day (#PCDATA)>
<!ATTLIST day id CDATA #IMPLIED>
    1. Right click editor area of time.dtd file and select Generate CSS... action.
    2. Change default filename from timeStylesheet to time and press OK button.
    3. New time.css stylesheet file gets generated and opened in editor.
  1. HTML documentation
    1. Right click editor area of time.dtd file and invoke Generate Documentation... from popup menu.
    2. Change default timeDocumentation file name to time and press OK button.
    3. New time.html page file gets generated and opened in system default browser. It contains element index and details sections with description taken from comments above each element and links for faster navigation.
  2. DOM scanner
    1. Right click editor area of time.dtd file and invoke Generate DOM Tree Scanner... from popup menu.
    2. Change default TimeScanner file name to MyTimeScanner and press OK button.
    3. New MyTimeScanner.java class file gets generated and opened in editor.
    4. Right-click project node and choose Build.
    5. Check that it is possible to generate DOM tree scanner class that is immediately compilable.
  3. SAX handler
    1. Right click editor area of time.dtd file and invoke SAX Document Handler Wizard... from popup menu.
    2. Push Next.
    3. For month element select Ignore handler type and change handler method to monthMethod. Then push Next twice.
    4. Change handler interface to MyTimeHandler, handler implementation to MyTimeHandlerImpl and generated parser to MyTimeParser. Finally push Finish.
    5. One XML and four Java class files get generated. MyTimeHandlerImpl.java gets opened in editor.
    6. Verify that TimeSAXBindings.xml file contains <bind element='month' method='month' type='IGNORE' ></bind>.
    7. Finally Build project again.
    8. Verify that it is possible to generate DOM tree scanner class that is immediately compilable.

Test suite: Big files

  1. Open big DTD
    1. Save this document under javaapplication1 package into created project.
    2. Check that Xhtml1-strict.dtd is open in editor.
  2. CSS stylesheet in big file
    1. Right click editor area of xhtml1-strict.dtd file and select Generate CSS... action.
    2. Press OK button.
    3. New xhtml1-strictStylesheet.css stylesheet file gets generated and opened in editor.
  3. HTML documentation of DTD
    1. Right click editor area of xhtml1-strict.dtd file and invoke Generate Documentation... from popup menu.
    2. Press OK button.
    3. New xhtml1-strictDocumentation.html page file should be generated and opened in system default browser.

XSD

This part contains procedures for testing XML schema editor. The xml module provides syntax highlighting, bracket matching, code folding, navigator and validation/transformation actions in the editor.

Test suite: Syntax highlighting

Purpose: This test suite checks that syntax highlighting in XSD editor is

  1. New XSD document
    1. Invoke File | New File... from main menu.
    2. Select XML category and XML Schema (empty) as file type. Push Next.
    3. Type addressbook into File Name, let default value in Folder field and press Finish.
    4. New addressbook.xsd file should be opened in editor containing default definition.
  2. Syntax highlighting
    1. Replace default content by the following:
<?xml version="1.0" encoding=ISO-8859-1" ?>
<!-- Error: " char missing. Correct: encoding="ISO-8859-1" -->
<abc:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- Error: unbound prefix. Correct: <xsd:schema -->

<xsd:simpleType name="EmailType">
    <xsd:restriction base="xsd:string">
        <xsd:pattern value="[a-z.]*@[a-z]*.[a-z]*">
        <!-- Error: unterminated element. Correct: [a-z]*"/> -->
    </xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="FriendType">
    <xsd:sequence>
        <xsd:elephant name="email" type="EmailType" minOccurs="1"/>
        <!-- Error: incorrect content. Correct: <xsd:element -->
    </xsd:sequence>
    <xsd:attribute name="nickname" use="required" type="xsd:string"/>
    <xsd:attribute name="birthday" type="xsd:data"/>
    <!-- Error: unknown type. Correct: "xsd:date" -->
</xsd:complexType>

<xsd:element name="address book">
<!-- Error: invalid attribute value. Correct: ="addressbook" -->
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="friend" type="FriendType" maxOccur="unbounded"/>
            <!-- Error: invalid attribute. Correct: maxOccurs=" -->
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
</xsd:schema>
    1. Check proper colors are used for XSD elements blue, attributes green, values orange, comments grey and metadata dark blue.

Test suite: Validation

Purpose: This test suite checks that it is possible to check structure and contents of XSD file.

  1. Check structure
    1. The addressbook.xsd file contains 3 structure errors in total.
    2. Right click editor area and choose Check XML from popup menu.
    3. Click The value following "encoding" ... [1] link. It highlights the first line in editor and moves cursor there.
    4. Correct the error and repeat step 2.
    5. Go after each error and fix it according to hints mentioned in the comment below the error line.
    6. In the end XML checking finished must show up in the status bar of IDE.
  2. Validate contents
    1. The addressbook.xsd file contains 4 content errors in total.
    2. Right click editor area and choose Validate XML from popup menu.
    3. Several errors must be reported in Output - XML check window
    4. Click Invalid content was found starting with element 'xsd:elephant'... [15] link. It highlights line 15 in editor and moves cursor there.
    5. Correct the error and repeat step 2.
    6. Go after each error and fix it according to hints mentioned in the comment below the error line.
    7. Fix also xsd:data to xsd:date which is not reported (Bug 206823).
    8. In the end XML validation finished must show up in the status bar of IDE.
  3. XSD constrained XML
    1. Invoke File | New File... from main menu.
    2. Select XML category and XML Document as file type. Push Next.
    3. Type addressbook into File Name, let default value in Folder field and press Next.
    4. Select XML Schema-Constrained Document option and push Next.
    5. Push Browse and pick up addressbook.xsd. Also check Import during selecting addressbook.xsd
    6. Verify that column Schema is set to the proper path and Root is set to addressbook. If everything is alright check Primary
    7. Push Next and than Finish.
    8. Copy the following text and paste it into addressbook element:
<friend nickname="michal.strnad" birthday="1987-03-29">
    <email>michal.strnad*oracle.com</email>
</friend>
    1. Remove empty <friend> elements.
    2. Right click addressbook.xml node and invoke Validate XML.
    3. The value 'michal.strnad*oracle.com' of element 'email' is not valid, error shows up.
    4. Correct the e-mail address by replacing * char by @ char and repeat step 9.
    5. The addressbook.xml file validates successfully and XML validation finished message shows up in Output - XML check window.
  1. Transformation
    1. Open new file wizard.
    2. Select XML|XSL Stylesheet and click Next.
    3. Set file name to addressbook and click Finish.
    4. Replace default content of opened file with the following:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    version="1.0">
    <xsl:template match="/">
        <html>
            <head><title>Address Book XML Schema</title></head>
            <body>
                <h1>Address Book XML Schema</h1>
                <xsl:apply-templates select="//xsd:schema/xsd:element"/><p/>
                <xsl:apply-templates select="//xsd:schema/xsd:simpleType"/><p/>
                <xsl:apply-templates select="//xsd:schema/xsd:complexType"/>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="xsd:element">
        Element name: <b><xsl:value-of select="@name"/></b><br/>
        Element type: <b><xsl:value-of select="@type"/></b>
        <ul>
            <xsl:apply-templates select="xsd:complexType/xsd:sequence/xsd:element"/>
        </ul>
    </xsl:template>
    
    <xsl:template match="xsd:simpleType">
        Simple type: <b><xsl:value-of select="@name"/></b>
        <ul>
            Value: <xsl:value-of select="xsd:restriction/xsd:pattern/@value"/>
        </ul>
    </xsl:template>

    <xsl:template match="xsd:complexType">
        Complex type: <b><xsl:value-of select="@name"/></b><br/>
        <ul>
            <xsl:apply-templates select="xsd:sequence/xsd:element"/><br/>
            <xsl:apply-templates select="xsd:attribute"/>
        </ul>
    </xsl:template>
    <xsl:template match="xsd:attribute">
        Attribute name: <b><xsl:value-of select="@name"/></b><br/>
    </xsl:template>
</xsl:stylesheet>
    1. Right click addressbook.xsd node and invoke XSL Transformation....
    2. Browse for previously created addressbook.xsl as XSLT Script and type addressbook.html into Output.
    3. Select Open in Browser as Process Output and push OK.
    4. Transformation finished is printed into Output - XSLT Processor window and browser gets opened displaying newly generated Address Book XML Schema html document.
  1. Code folding
    1. Switch to addressbook.xsd file and invoke View|Code Folds|Collapse All from main menu.
    2. Move mouse over the root fold <xsd:schema> which shows content of this element in popup window.
    3. Click + icons next to line numbers to expand code folds.
    4. Set cursor at the line 6 i.e. <xsd:simpleType> and press CTRL+ +.
    5. Verify that code fold <xsd:simpleType name="EmailType"> is expanded.
  2. Navigator
    1. Make sure that Navigator view contains tree structure of addressbook.xsd schema.
    2. Double click to expand/collapse all nodes and verify that particular line gets highlighted in editor and cursor moves there.
  3. Completion of tags
    1. Create a new line right after tag <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">.
    2. Type <xsd: and press Ctrl+Space.
    3. Code completion should offer one possibility. Choose xsd:element and press Enter.
    4. Code completion should complete the tag <xsd:element name="">.
  4. Completion of attributes
    1. Move cursor after quotation marks in recently created <xsd:element name="">.
    2. Press Space and Ctrl+Space.
    3. Attributes should be offered. Select minOccurs and press Enter.
    4. Attribute should be completed so you have <xsd:element name="" minOccurs="">.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo