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 190087

Summary: Unable to use local XSD schema for XML validation
Product: xml Reporter: mdeggersbeans <mdeggersbeans>
Component: SchemaAssignee: Svata Dedic <sdedic>
Status: VERIFIED FIXED    
Severity: normal CC: jglick, mmirilovic, pjiricka, swpalmer
Priority: P2    
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description mdeggersbeans 2010-09-02 00:38:59 UTC
Environment
===========

OS:         Fedora Linux 2.6.34.6-47.fc13.i686
JDK:        1.6.0_21 (32 bit)
NetBeans:   6.8, 6.9.1
Subversion: 1.6.9

Project
=======

Plugin:     Portal Pack 3.0.4
Maven:      2.2.1 (locally installed)
Archetype:  jetspeed 2.2.1

Use Case
========

Jetspeed contains a number of Jetspeed - specific XML files along with
their corresponding XSD Schema files. These XML files are complex, and
it would be advantageous to leverage NetBeans XML completion and
validation tools.

1. Make use of locally installed XSD Schema
2. Code completion for complex XML files based on XSD Schema
3. Validation for complex XML files based on XSD Schema

Scenario 1
===========
Attempt to register a locally available XSD catalog in a shared area:

Steps
-----
1. Place XSD Schema in a public place on the platform:
   (/usr/share/sgml/jetspeed-2)
2. Add the schemas to the User catalog via the following:
   a. Tools->DTDs and Schemas->User catalog [read-write]
   b. Select Add Local DTD or Schema
   c. Use System ID of http://portals.apache.org/jetspeed
   d. Browse to /usr/share/sgml/jetspeed-2/jetspeed-portlet.xsd
   e. Add to catalog (shows up as a new entry)
3. Attempt to create a new XML file
   a. File->New->XML Document
   b. Location [project-artifact]/WEB-INF/jetspeed-portlet.xml
   c. Document type XML Schema-Constrained Document
   d. Browse by Namespace

Expected
--------
1. Namespace to be present as http://portals.apache.org/jetspeed
2. XSD jetspeed-portlet.xsd to be available

Actual
------
1. No namespaces available for import

Scenario 1a
===========

Modifications
-------------
2.
   c. Use System ID of
      file:/usr/share/sgml/jetspeed-2/jetspeed-portlet.xsd

Actual
------
1. No namespaces available for import


Scenario 2
==========
Add XSD schema to project outside of the source tree area and access
them via Filename (modification of Scenario 1, Step 3.d.)

Steps
-----
1. Put XSD schemas into project tree outside of the source
   a. Make a directory [project-artifact]/xsd
   b. Copy necessary schemas to directory
2. Attempt to create a new XML file
   a. File->New->XML Document
   b. Location [project-artifact]/WEB-INF/jetspeed-portlet.xml
   c. Document type XML Schema-Constrained Document
   d. Browse by Filename

Expected
--------
1. XSD Schema to be present by file name

Actual
------
1. New directory did not show up
2. No XSD schemas available for document

Scenario 2a
===========

Modifications
-------------

2. Attempt to create a new XML file
   d. Browse by Namespace

Expected
--------
1. No namespaces available for import

Actual
------
1. Namespaces available for import (!)

File Creation
-------------
1. Complete pathname of XSD schema in XML file
   a. This will obviously break configuration management
2. Change to remote URL for namespace
   a. Fixes configuration management
   b. Access network for validation (potential validation failure)

Scenario 2b
===========

Modifications

1. Put the XSD schema inside the project tree inside the source
   a. Make the directory [artifact-id]/src/main/xsd
   b. Copy XSD schemas to this directory
2. Attempt to create a new XML file
   a. File->New->XML Document
   b. Location [project-artifact]/WEB-INF/jetspeed-portlet.xml
   c. Document type XML Schema-Constrained Document
   d. Browse by Filename / Namespace

Expected
--------

1. Filename browsing to work
2. Namespace browsing to fail
3. File reference in XML document to be relative

Actual
------

1. Filename browsing works
2. Namespace browsing works (!)
3. File reference in XML document is absolute (!)
   a. this will still be unacceptable for configuration management

Summary of Issues
=================

1. File based XSD schema outside of project directory fails to work
2. File based XSD schema inside project directory uses absolute paths
3. Addition of XSD schema based on a local web server doesn't seem to
   be possible

As an aside, I noticed that some of the XSD schemas referenced by
NetBeans points to nbres:[path], which translates to:

~/.netbeans/[version]/modules/[path-in-jar]

How could this be leveraged to solve this problem?
Comment 1 swpalmer 2011-03-01 19:33:20 UTC
*** Bug 191271 has been marked as a duplicate of this bug. ***
Comment 2 Petr Jiricka 2011-03-04 13:02:11 UTC
Sounds like the only possible workaround is to just create an empty file and specify the schema manually, by copy-pasting, right?
Comment 3 Petr Jiricka 2011-03-09 13:28:35 UTC
Requesting a waiver for NetBeans 7.0.
Comment 4 Petr Jiricka 2011-03-11 17:19:04 UTC
Waiver approved.
Comment 5 Petr Jiricka 2011-05-04 12:51:32 UTC
Requesting a waiver for NetBeans 7.0.1.
Comment 6 Jesse Glick 2011-05-05 15:34:34 UTC
Is there any particular reason this is expected to be difficult or dangerous to fix?
Comment 7 Petr Jiricka 2011-05-06 08:16:11 UTC
I don't think so - this is simply the issue of the lack of expertise/resources.
Comment 8 Petr Jiricka 2011-06-08 08:26:55 UTC
Waiver approved.
Comment 9 Svata Dedic 2011-09-27 14:38:46 UTC
* namespaces of schemas added to the catalog show up in the 'by namespace' browser
* those schemas, if used, will not produce schemaLocation entry in the XML document

The validation actually did not use user catalog at all; this seems to be fixed. Code completion also improved for schemas served from the user catalog a bit since the configured schemas are recognized as schemas, not as random resolved resources.

The rest is probably an enhancement request - the current XML Catalog support needs to be streamlined to be usable.
Comment 10 Quality Engineering 2011-09-28 13:59:58 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/c41d09b68a5b
User: Svata Dedic <sdedic@netbeans.org>
Log: #190087: schema-constrained XML wizard shows namespaces of schemas added to XML catalog by the user. Validation uses XML schema catalog to resolve NS URIs.