Page 1 of 1

Allow element use anywhere

Posted: Wed Mar 29, 2006 11:17 pm
by tgolden
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.

Re: Allow element use anywhere

Posted: Thu Mar 30, 2006 2:04 pm
by sorin_ristache
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

Re: Allow element use anywhere

Posted: Thu Mar 30, 2006 4:12 pm
by tgolden
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.

Posted: Thu Mar 30, 2006 4:44 pm
by sorin_ristache
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

Posted: Thu Mar 30, 2006 5:09 pm
by tgolden
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.

Posted: Tue Apr 04, 2006 2:36 pm
by sorin_ristache
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