html / xml language support

Bertjan Broeksema b.broeksema at home.nl
Tue Jan 26 19:33:09 UTC 2010


On Tuesday 26 January 2010 20:07:11 Ruan Strydom wrote:
> > This solely depends on you. I'm not a really into XML, but isn't XSD just
> >  XML? I.e. shouldn't a XML parser be able to handle XSD? DTD otoh looks
> >  different, so probably needs it's own parser.
> 
> The reason for giving XSD its own lexer/parser is because its a language on
> its own, XML is just the medium:
> 
>   <xs:simpleType name="orderidtype">
>     <xs:restriction base="xs:string">
>       <xs:pattern value="[0-9]{6}"/>
>     </xs:restriction>
>   </xs:simpleType>
> 
> 
> so the lexer will break it up similar to html and xml but the parser will
>  have to handle simpleType with a special meaning, whereas <ns:order
>  orderType="" /> does not. In this case the orderType attribute is given
>  meaning by the simpleType declaration and by its inclusion.
> 
> I suppose its a bit like:
> 
> class Test {
> };
> 
> Test t;
> 
> The class declaration is treated differently to its usage? Also CSS is
>  treated differently to HTML.
> 
> Or am I wrong? This whole thing has me as confused as vomit in a
>  tumble-dryer.

No, you're right here. XSD servers as a type system for XML files. I'm not 
completely sure if it makes sense to implement it in KDevelop (given that it 
will be quite big effort) because you're actually reimplementing tools like 
xmllint. 

There are several interesting use cases for this, though:

1) Creating a skeleton XML file with the minimum required nodes according to 
the schema
2) Text completion when editing XML files based on it. 
3) Advanced editor support (e.g. fading out parts of a document that are not 
in a specific namespace).
3) On the fly validation (though this is not the most interesting one imo, 
because xmllint does a good job).

You would need an parser which handles XSD files (also the imports in the 
correct way). I guess its best to base this on the Qt Xml classes. You might 
also want to have a look at the QtXmlPattern module.

Actually, thinking about it. This would be an excellent contribution to 
KDevelop, but this alone (good XSD support) will already be a huge effort! I'd 
suggest, if you're interested in this that you limit your scope to this first 
(you'll easily get lost soon otherwise).

Tough I won't have much time to really help with the implementation, I'm 
available for questions/suggestions. I've worked with several XML standards in 
the past (XSD, XForms, XHTML and XSLT) and I really missed a good editor which 
is able to handle complex XML documents containing different XML flavors.

Cheers,

Bertjan




More information about the KDevelop-devel mailing list