Hi Scott

From: "Scott Willy" <[EMAIL PROTECTED]>
> It sounds like the best solution is the specialized factories.
>
> ValidatingDocumentFactory for guys (even gals) who how a XML view of the
> world and just want to protect themselves from bad things. And an
> EncodingDocumentFactory for guys who want a more Java interpretation of
> String and not break XML's view.
>
> Slick...well to be confirmed when I actually write my
> EncodingDocumentFactory.

By all means submit some code for this :-)

I'll add it on to the to do list for now.

I'm thinking that the EncodingDocumentFactory could be a mode or a
derivation of the ValidatingDocumentFactory as there is probably just a few
different validations / encodings required. e.g.

    public String validateElementName(String text);
    public String validateElementText(String text);
    public String validateAttributeName(String text);
    public String validateAttributeValue(String text);
    public String validateNamespaceURI(String text);
    public String validateNamespacePrefix(String text);

All of which will be quite similar and could either do some encoding or
throw a DocumentException.

Though I'd like to have a SchemaDocumentFactory first which is capable of
doing XML Schema Data Type validation & conversion from String <-> Objects
(such as Date, Number et al) using Sun's data type library...



> > If a developer knows that their String may contain invalid characters
then
> > something like the following may be used...
> >
> >     // encode XML sensitive characters
> >     String escapedString = DocumentHelper.encodeString( "some text > < &
> > " );
> >
> >     // encode binary data
> >     String escapedString = DocumentHelper.encodeBinary( byte[]
someData );
>
> Yes. These would be useful and would be used in the specialized Text node
> class to hide this from the Java world-view guy.

Again I'd like to keep that in a special DocumentFactory if possible.


> > Note that if you've regular text which contains special XML
> > characters like
> > < > & then you can always use CDATA sections.
> > For example
> >
> >     Element element = ...;
> >     element.addCDATA( "<this contains > & special characters !" );
>
> Yes, this it OK for special chars, but not the nasty ones :-)
>
> Now back to the JDOM world...our current projects are based on it, so
> switching now is not an option. I will have to just look on lustfully at
the
> features of dom4j...

:-)

There's always the next project to look forward to :-)

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to