This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 206823 - Function Validate XML over XML schema doesn't find all errors
Summary: Function Validate XML over XML schema doesn't find all errors
Status: NEW
Alias: None
Product: xml
Classification: Unclassified
Component: Schema (show other bugs)
Version: 7.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-01 12:09 UTC by debuggercz
Modified: 2012-03-14 14:17 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description debuggercz 2012-01-01 12:09:54 UTC
Product Version: NetBeans IDE Dev (Build 201112270601)
Java: 1.7.0_01; Java HotSpot(TM) 64-Bit Server VM 21.1-b02
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\deuggercz\.netbeans\dev
Cache directory: C:\Users\deuggercz\.netbeans\dev\var\cache

Steps:
1. Use File | New Project... to create new Web Application project located in
your home directory.
2. Invoke File | New File... from main menu.
3. Select XML category and XML Schema (empty) as file type. Push Next.
4. Type addressbook into File Name, change Folder field to src\java\schema (on
Windows platform is \ and on Un*x is / as separator) and press Finish.
5. Copy this content:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:simpleType name="EmailType">
    <xsd:restriction base="xsd:string">
        <xsd:pattern value="[a-z.]*@[a-z]*.[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>

into clipboard.
6. Press CTRL + A in the editor and then click Edit | Paste from main menu.
7. Right click editor area and choose Validate XML from popup menu.
8. Click The value following "encoding" ... [1] link. It highlights the first
line in editor and moves cursor there.
9. Correct the error and repeat step 2.
10. Go after each error and fix it according to hints mentioned in the comment
below the error line.

One error isn't recognize by function Validate XML. This error is on the line number 16 (Wrong data type. Should be here xsd:date instead xsd:data.)
Comment 1 Svata Dedic 2012-03-14 14:17:51 UTC
Understood -- but there's a little what can be done: the Schema for Schemata defines the xsd:attribute's type attr as follows:

<xs:attribute name="type" type="xs:QName"/>

because of xsd:import, the integrity (QName must exist in the import closure) cannot be expressed by Schema language, I think. However, XML schema support in NB could notice that and provide error hint in the editor.

Turning to an enhancement on XSD support.