[Xml-compile] Schemas with mixed elements

Drew Taylor drew at drewtaylor.com
Mon Aug 18 12:31:43 BST 2008


On 13 Aug 2008, at 12:42, Mark Overmeer wrote:

> * Actually, this may be an approach to support by default for mixed
> elements.  However... in your case, fixing the STRUCTURED bug  
> (ignoring
> the mixed attribute at all) will probably work as well.

Hi Mark,

 From the docs in 0.93:
> [available since 0.86] ComplexType and ComplexContent components can  
> be declared with the <mixed="true"> attribute. This implies that  
> text is not limited to the content of containers, but may also be  
> used inbetween elements. Usually, you will only find ignorable white- 
> space between elements.
>
> In this example, the a container is marked to be mixed: <a id="5">  
> before <b>2</b> after </a>
>
> Often the "mixed" option is bending one of both ways: either the  
> element is needed as text, or the element should be parsed and the  
> text ignored. The reader has various options to avoid the need of  
> processing raw XML::LibXML nodes.
>
What I'd like is an option to combine ATTRIBUTES and STRUCTURAL  
handling on the reader. Going back to my particular need, the xml  
looks like:

<Segment>CDATA<Price>...</Price><Foo>...</Foo></Segment>

The text will only occur once, and it will always be immediately after  
the parent tag. The new option I'm proposing would separate out the  
text into the '_' element, perhaps as an array to support multiple  
text chunks (overkill for me but may be useful to others). This is  
similar to the TEXTUAL option.  In addition, the remaining non-text  
elements would be processed and transformed into a data structure as  
with the STRUCTURAL option.

I would be willing to help implement this option, if you 1) don't  
think I'm crazy and 2) can point me in the right direction.

Thanks,

Drew





More information about the Xml-compile mailing list