Re: [xsl] Schema and fixed attribute value

Subject: Re: [xsl] Schema and fixed attribute value
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 17 Jul 2002 17:29:22 +0100
Hi Bruno,

>  I tried to load the unit.xml as a DOMSource by using Xerces2.0.2  parser
>  with features like
>  parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
>  parser.setFeature("http://apache.org/xml/features/validation/schema",true);
>  parser.setFeature("http://xml.org/sax/features/namespaces";, true);
> parser.setFeature("http://apache.org/xml/features/validation/schema/normalized-value",true
>   );
> parser.setFeature("http://apache.org/xml/features/validation/schema/element-default",true)
>  ;
>
>  but the attribute value seems to be not accessible in my stylesheet.

That surprises me. Xerces should be able to add the attribute in the
DOM just as if it had been specified in the XML document originally.
You might try setting the validation feature to true as well as the
ones that you've set above:

  parser.setFeature("http://xml.org/sax/features/validation",true);

The Xerces documentation suggests that the normalized-value and
element-default features only work if validation occurs, which implies
that the same might be true for fixed/default attribute values as
specified in XML Schema.
  
If that doesn't work, I suggest that you ask on the
xerces-j-user@xxxxxxxxxxxxxx mailing list.

If all else fails, you might be able to access the schema from XSLT in
order to work out what the fixed value of the attribute is. However,
processing XML Schemas with XSLT is not trivial (unless you constrain
the schemas), so if you can fix the DOM that you're passing to Xalan
that will be the best option.

Let us know if that works...

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread