You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Dave Brosius <db...@mebigfatguy.com> on 2006/01/27 02:35:30 UTC

specifying default values for text nodes

I have a class that implements an xsd enforcer, ie, it makes sure that an
xml instance follows a schema, and if it doesn't makes corrections in the
instance until it does. Most of that works fine, however i'm having a
problem where if a new simple content element needs to be inserted, because
it is missing in the instance, i don't know what value to give the text
node.

I couldn't find any way to specify 'fixed' or 'default' values for text in a
schema definition, like you can with attributes. Is this true?

If so, how would you suggest doing this? Can i add processing instructions
into the xsd file? Is that rational?

Any ideas, Thanks!

--dave 


Re: specifying default values for text nodes

Posted by Dave Brosius <db...@mebigfatguy.com>.
> This really isn't the appropriate list for a question about XML Schema.

*blush* Ha! that's true! Sorry all for the interruption. I'm using 
transforms in the code, and forgot
that the real question wasn't about xalan. oops.

> Why can't you just used the "default" attribute in the element 
> declaration?

again. stupid me. yes of course. I was looking at the <xsd:simpleType> 
definition for one.

thanks again.
-dave

----- Original Message ----- 
From: "David Bertoni" <db...@apache.org>
To: <xa...@xml.apache.org>
Sent: Thursday, January 26, 2006 9:25 PM
Subject: Re: specifying default values for text nodes


> Dave Brosius wrote:
>> I have a class that implements an xsd enforcer, ie, it makes sure that an
>> xml instance follows a schema, and if it doesn't makes corrections in the
>> instance until it does. Most of that works fine, however i'm having a
>> problem where if a new simple content element needs to be inserted, 
>> because
>> it is missing in the instance, i don't know what value to give the text
>> node.
>>
>> I couldn't find any way to specify 'fixed' or 'default' values for text 
>> in a
>> schema definition, like you can with attributes. Is this true?
>>
>> If so, how would you suggest doing this? Can i add processing 
>> instructions
>> into the xsd file? Is that rational?
>>
>
> This really isn't the appropriate list for a question about XML Schema.
>
>> Any ideas, Thanks!
>>
>
> Why can't you just used the "default" attribute in the element 
> declaration?
>
> <xs:element name="foo" type="xs:string" default="blah"/>
>
> Dave
>
> 


Re: specifying default values for text nodes

Posted by David Bertoni <db...@apache.org>.
Dave Brosius wrote:
> I have a class that implements an xsd enforcer, ie, it makes sure that an
> xml instance follows a schema, and if it doesn't makes corrections in the
> instance until it does. Most of that works fine, however i'm having a
> problem where if a new simple content element needs to be inserted, because
> it is missing in the instance, i don't know what value to give the text
> node.
> 
> I couldn't find any way to specify 'fixed' or 'default' values for text 
> in a
> schema definition, like you can with attributes. Is this true?
> 
> If so, how would you suggest doing this? Can i add processing instructions
> into the xsd file? Is that rational?
> 

This really isn't the appropriate list for a question about XML Schema.

> Any ideas, Thanks!
>

Why can't you just used the "default" attribute in the element declaration?

<xs:element name="foo" type="xs:string" default="blah"/>

Dave