html / xml language support
Ruan Strydom
ruan at jcell.co.za
Wed Jan 27 21:06:03 UTC 2010
Thank you for your input. Although I should not comment yet, as I have not
done enough investigation yet, I have made "quements" ;) on some of the things
bellow:
Another question is SGML? Should I support it fully or only the quirks in HTML
ie <br> <input> etc.? I honestly do not feel like throwing this into the mix
as well?
On Tuesday 26 January 2010 21:33:09 Bertjan Broeksema wrote:
> 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
You would have to explain a bit more here ;) Do you mean auto creating the XML
from the XSD / DTD? Perhaps even java and C++ classes for serialization?
class Test : public QObject {
Q_OBJECT
Q_PROPERTY(QString member1 ...)
Q_PROPERTY(QString member2 ...)
QXML_ELEMENT(member1 elementname)
QXML_ATTRIBUTE(member2 attributename)
};
Perhaps even C# classes? (Uggg let me go wash my fingers, makes me think of
M$) ;)
> 2) Text completion when editing XML files based on it.
This is the biggest reason for doing this. Plus some validation while typing
(restriction -> patterns, limits etc). But also when creating XSD's, these are
then treated as regular XML and the XMLSchema namespace is used for validation
and completion?
> 3) Advanced editor support (e.g. fading out parts of a document that are
> not in a specific namespace).
That is a really good idea. Now I will have to do this :)
> 3) On the fly validation (though this is not the most interesting one imo,
> because xmllint does a good job).
I have made a plugin already based on libxml for validation, it is part of
this project, also XML catalog. I would not say they are perfect but I use
them now regularly at work.
>
> 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.
When I wrote the formatter I started of using the QXmlReader, the problem was
that it was too strict. To give a example for completion: I may have a
unclosed element at the top of the document (which we will have to flag of
coarse) but at the bottom I still want the completion to work cause I will get
back to the error at the top when I have finished typing at the bottom.
I had a look a the QtXmlPattern module it is not as strict apparently, but the
biggest problem here I think is not parsing XML but interpreting XSD's and
DTD's into something useful/meaningful (DUChain)? And at the moment I do not
have a top view of the whole thing, just "wonda's".
>
> 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).
If it works yes.... I worked on a couple of broken small plugins mainly to
learn how kdevelop works (gettersetter, formatters, documents, etc). But yes
my main concern now is parsing XSD's and DTD's. The reason for doing both is
because I want to reuse as much as possible for both. Let me know if you think
is this is a bad idea?
>
> 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.
I will hold you too this... this was a mistake on your behalf ;)
I will try to browse through the webkit, netbeans and eclipse sources to see
how they did it.
>
> Cheers,
>
> Bertjan
>
More information about the KDevelop-devel
mailing list