Post new topic   Reply to topic
Author Message
support-rkalla
Registered Member
Registered Member
Joined: Jan 06, 2004
Posts: 23817

We have noticed a few users posting problems with validation when dealing with files that make use of a schema. We have looked into this and for almost all the cases reported the problem was the location of the Schema is not specified, so it is attempted to be resolved from the "root" directory, which in the case of a web project is the WebRoot, in the case of a Java Project, is the current directory.

Let's look at an Example from using Drools (http://drools.org)

Code:

<?xml version="1.0"?>

<rule-set name="CalculatorWorker"
          xmlns="http://drools.org/rules"
          xmlns:java="http://drools.org/semantics/java"
          xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
          xs:schemaLocation="http://drools.org/rules rules.xsd
                             http://drools.org/semantics/java java.xsd">


<java:import>java.lang.String</java:import>
<java:import>com.csfb.fao.clr.calc.rules.Input</java:import>

<!--
<rule name="blank" salience="-10">

   <parameter identifier="input">
     <class>java.lang.String</class>
    </parameter>

   <java:condition>1==1</java:condition>
   
   <java:consequence>
      System.out.println("Blank");
   </java:consequence>

</rule>
-->

<rule name="Portfolio_Participation_SELL_Exists" salience="-1">

   <parameter identifier="input">
     <class>Input</class>
    </parameter>

   <java:condition>input.getFacilLenderIndic().equals("P") || input.getFacilLenderIndic().equals("M")</java:condition>
   <java:condition>input.getPortfolioPartSellExists().equals("undefined")</java:condition>
   
   <java:consequence>
      //System.out.println("Portfolio_Participation_SELL_Exists");
      input.setPortfolioPartSellExists("Y");
      //System.out.println("Sell indicator: " + input.getPortfolioPartSellExists() + " on " + input);
      drools.modifyObject(input);
   </java:consequence>

</rule>


<rule name="Portfolio_Participation_SELL_Does_NOT_Exists" salience="-1">

   <parameter identifier="input">
     <class>Input</class>
    </parameter>

   <java:condition>input.getFacilLenderIndic().equals("B")</java:condition>
   <java:condition>input.getPortfolioPartSellExists().equals("undefined")</java:condition>
   
   <java:consequence>
      //System.out.println("Portfolio_Participation_SELL_Exists");
      input.setPortfolioPartSellExists("N");
      //System.out.println("Sell indicator: " + input.getPortfolioPartSellExists() + " on " + input);
      drools.modifyObject(input);
   </java:consequence>

</rule>




<rule name="Risk_Ost_2">
     <parameter identifier="input">
     <class>com.csfb.fao.clr.calc.rules.Input</class>
    </parameter>

    <java:condition>input.getOstCount() &gt; 0 </java:condition>
   
    <java:condition>!input.getOtsdTypeCategoryCd().equals("LN") </java:condition>
   
    <java:condition>input.getOtsdTypeCategoryCd().equals("LC") </java:condition>
   
    <java:condition>input.getOpsCount() &gt; 0 </java:condition>
   
    <java:condition>input.getLocIssueFirmInd().equals("N") </java:condition>
   
    <java:condition>input.getPortfolioPartSellExists().equals("Y")</java:condition>

    <java:consequence>
      System.out.println("Calculate RISK_OST_2");
    </java:consequence>
</rule>


<rule name="Risk_Ost_3">
     <parameter identifier="input">
     <class>com.csfb.fao.clr.calc.rules.Input</class>
    </parameter>

   <!-- Facility has outstanding -->
    <java:condition>input.getOstCount() &gt; 0 </java:condition>

    <!-- Outstanding type is not Loan -->
    <java:condition>!input.getOtsdTypeCategoryCd().equals("LN") </java:condition>
   
    <!-- Outstanding type is Letter of Credit -->
    <java:condition>input.getOtsdTypeCategoryCd().equals("LC") </java:condition>

    <!-- Outstanding has OPSs -->
    <java:condition>input.getOpsCount() &gt; 0 </java:condition>
   
      <!-- LC is not CSFB Issue (Fronted) -->
    <java:condition>input.getLocIssueFirmInd().equals("N") </java:condition>
   
    <!-- Portfolio participation SELL does NOT exists -->
    <java:condition>input.getPortfolioPartSellExists().equals("N")</java:condition>

    <java:consequence>
      System.out.println("Calculate RISK_OST_3");
    </java:consequence>
</rule>


</rule-set>


The part we care about here is the header:
Code:

<rule-set name="CalculatorWorker"
          xmlns="http://drools.org/rules"
          xmlns:java="http://drools.org/semantics/java"
          xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
          xs:schemaLocation="http://drools.org/rules rules.xsd
                             http://drools.org/semantics/java java.xsd">


Notice the xs:schemaLocation tag:
Code:

xs:schemaLocation="http://drools.org/rules rules.xsd
                             http://drools.org/semantics/java java.xsd"


The format for these entries is:
<URI> <URL to Schema>

Since there is no location given for the rules.xsd or java.xsd files, the validator is checking the root directory and failing. Now if you use your browser to open up the links: http://drools.org/rules

You'll notice they spit back the contents of these files respectively, so really the location of the schema files are these URIs (NOTE: The URIs in this example happen to be valid URLs, they don't have to be though) so we have two choices now:

    * Download the contents of the two pages and place them into new files rules.xsd and java.xsd which go into the root directory
    * Use the URIs themselves as the URLs to the schema files.


I will show what #2 looks like:
Code:

xs:schemaLocation="http://drools.org/rules http://drools.org/rules
                             http://drools.org/semantics/java http://drools.org/semantics/java"


This looks a little odd, but does the trick. Don't forget to save and then right-click-> Validate XML on the file, viola, no more errors.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
WriteExpress
Registered Member
Registered Member
Joined: Dec 21, 2006
Posts: 4

I also have validation errors both the MyEclipseIDE Version 5.5.1 GA and the latest MyEclipseIDE Full Stack Installer. Eclipse error markers appear to the left of every xmlns declaration (see code below).

I can make them disappear if I click MyEclipse > Preferences > MyEclipse > Validation and click "Allow projects to override these preference settings" and uncheck all the Build Validator checkboxes.

The odd thing is that I don't get the errors in my local copy of JBoss-Seam-2.0.0.BETA1 examples--especially the bookings example. I can copy the code below into one of an .xml file in that project and I don't get the validation errors.

Is my problem project specific and how can I fix it correctly?

Here is my header:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
 
 View user's profile Send private message  
Reply with quote Back to top
All times are GMT - 6 Hours
Post new topic   Reply to topic
® 2014 - Genuitec, LLC.