You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Florian Wendland <fl...@freenet.de> on 2007/08/27 13:11:10 UTC
Validation with default-Attribute
Hello all,
I have tried to validate a simple xml document with a simple schema,
too. If have only 1 Element with one attribute, which i have defines as
optional, but with an default content.
I had exepected, that xerces would add the default attribute into the
psvi (n my case a streamresult-object), but the result is a xml document
without the default attribute.
Here is my Java-Code:
##################################################################
final Result res = new StreamResult(new FileWriter(new
File("d:\\output.xml")));
final Source source = new StreamSource(new FileReader(new
File(input.toURI())));
SchemaFactory sf = SchemaFactory.newInstance(NAMESPACE);
Schema f = sf.newSchema(schema);
Validator val = f.newValidator();
val.validate(source, res);
##################################################################
Did i miss something?
Thx
mfw
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Validation with default-Attribute
Posted by Prashant Reddy <pr...@pramati.com>.
If i remember correctly you needed to normalize DOM before default
attributes are inserted by parser. Not sure what is the equivalent for a
StreamResult.
HTH
-Prashant
On Mon, 2007-08-27 at 13:11 +0200, Florian Wendland wrote:
> Hello all,
>
> I have tried to validate a simple xml document with a simple schema,
> too. If have only 1 Element with one attribute, which i have defines as
> optional, but with an default content.
>
> I had exepected, that xerces would add the default attribute into the
> psvi (n my case a streamresult-object), but the result is a xml document
> without the default attribute.
>
> Here is my Java-Code:
> ##################################################################
> final Result res = new StreamResult(new FileWriter(new
> File("d:\\output.xml")));
>
> final Source source = new StreamSource(new FileReader(new
> File(input.toURI())));
>
> SchemaFactory sf = SchemaFactory.newInstance(NAMESPACE);
>
> Schema f = sf.newSchema(schema);
>
> Validator val = f.newValidator();
>
> val.validate(source, res);
> ##################################################################
>
> Did i miss something?
> Thx
> mfw
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org