Allow element use anywhere

This should cover W3C XML Schema, Relax NG and DTD related problems.
tgolden
Posts: 5
Joined: Thu Mar 09, 2006 5:45 pm

Allow element use anywhere

Post by tgolden » Wed Mar 29, 2006 11:17 pm

Our content creation folks need to be able to specify "hard" line breaks in text elements. My thought was to allow <p/> to appear nested within any element defined in the schema, and then just pass that throgh when transforming the XML to XHTML.

Aside from making everything in the scheuma into a complex type and adding "p" as a valid element, is there another way to support this? I need to stick with XSL 1.0.

Or maybe I should start by asking, "is this the best way to allow for line-breaks in string elements?"

Thanks in advance for your help, suggestions and ideas.

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Re: Allow element use anywhere

Post by sorin_ristache » Thu Mar 30, 2006 2:04 pm

Hello,
tgolden wrote:My thought was to allow <p/> to appear nested within any element defined in the schema, and then just pass that throgh when transforming the XML to XHTML.
You have to put p in the http://www.w3.org/1999/xhtml namespace when you define the schema and allow this namespace to pass in the output of the stylesheet.

Regards,
Sorin

tgolden
Posts: 5
Joined: Thu Mar 09, 2006 5:45 pm

Re: Allow element use anywhere

Post by tgolden » Thu Mar 30, 2006 4:12 pm

sorin wrote: You have to put p in the http://www.w3.org/1999/xhtml namespace when you define the schema and allow this namespace to pass in the output of the stylesheet.
OK, but unless I misunderstand that doesn't solve my problem. If I don't add "p" to every element in the schema, I still get schema validation errors. Did I miss your point?

To rephrase my question: how can I allow one element (e.g., "p") to appear within any other element that is defined in the schema, without explicitly specifying it inside every element of the schema? Or is there a different type I should be using beside xs:string that would automatically allow common html elements like <p>?

Thanks.

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache » Thu Mar 30, 2006 4:44 pm

Hello,

I think you have two options:

- include p inside every type definition of the schema;

- extend every type definition from one root type definition which allows the p element.

Regards,
Sorin

tgolden
Posts: 5
Joined: Thu Mar 09, 2006 5:45 pm

Post by tgolden » Thu Mar 30, 2006 5:09 pm

sorin wrote: - extend every type definition from one root type definition which allows the p element.
Thanks, Sorin. Can you point me to an example of this? I haven't done that before.

Thanks for your help.

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache » Tue Apr 04, 2006 2:36 pm

Hello,

I think that option has to use a substitution group in a root type which can be substituted by different particles in derived types but the root type would restrict too much the layout of the particles of the derived types. So you should use the first option with including a reference to p inside each type definition.

Regards,
Sorin

Post Reply