# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-from enkel.wansgli.testhelpers import unit_mod_suite, run_suite
-from enkel.exml.markup import validate as dt_validate
+""" Validation and utilities for the enkel xml languages.
-import validate
-
-def suite():
- return unit_mod_suite(validate, dt_validate)
-
-if __name__ == "__main__":
- run_suite(suite())
+Markup
+======
+ You often find that you want both site-admins and normal users to
+ submit information in a structured way. This often occur in
+ - forums
+ - blogs
+ - wikis
+ And many other systems. For these situations enkel supplies a
+ markup language in the U{http://enkel.sourceforge.net/xml/markup}
+ namespace. See the URL for documentation.
+"""
+++ /dev/null
-XMLNS_FORM = "http://enkel.sourceforge.net/xml/form"
+++ /dev/null
-# This file is part of the Enkel web programming library.
-#
-# Copyright (C) 2007 Espen Angell Kristiansen (
[email protected])
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-
-"""
-EXML form validation.
-@warning: This module depends on the B{lxml} library.
-"""
-
-from os.path import join
-from lxml import etree
-
-from enkel.rngdata import RNGDIR
-
-
-def validate_formsection(xml):
- """ Validate a document agains formsection.rng.
- Parameters and excetions are the same as
- L{enkel.exml.markup.validate.validate_inline}.
- """
- rng_file = join(RNGDIR, "formsection.rng")
- rng_doc = etree.parse(rng_file)
- rng = etree.RelaxNG(rng_doc)
- rng.assertValid(xml)
-
-
-def validate_form(xml):
- """ Validate a document agains form-standalone.rng.
- Parameters and excetions are the same as
- L{enkel.exml.markup.validate.validate_inline}.
- """
- rng_file = join(RNGDIR, "form-standalone.rng")
- rng_doc = etree.parse(rng_file)
- rng = etree.RelaxNG(rng_doc)
- rng.assertValid(xml)
@@ -20,7 +20,8 @@ from enkel.model.field.base import *
from enkel.model.formgen import Form
from enkel.model.ds import One, Many, DatasourceField
from enkel.xmlutils.writer import XmlWriter
-from ns import XMLNS_FORM
+
+from info import XMLNS_FORM
class Form(Form):
"""
@var XMLNS_MARKUP: The namespace used by the exml markup language.
+@var XMLNS_FORM: The namespace used by the exml form language.
"""
XMLNS_MARKUP = "http://enkel.sourceforge.net/xml/markup"
+XMLNS_FORM = "http://enkel.sourceforge.net/xml/form"
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
-EXML markup validation.
+Validation of various exml languages.
+
+@note: When the documentation below refers to a "<filename>.rng"
+ it refers to a file in enkel/rngdata/.
@warning: This module depends on the B{lxml} library.
"""
@@ -33,7 +36,7 @@ def validate_inline_field(fieldname, xml, offset):
of exml inline.
>>> from enkel.model.field.xmlf import XmlField
- >>> from ns import XMLNS_MARKUP as ns
+ >>> from info import XMLNS_MARKUP as ns
>>> f = XmlField(validate=validate_inline_field)
>>> xml = u"<inline xmlns='%s'>hello</inline>" % ns
>>> f.validate("f", xml)
@@ -45,13 +48,13 @@ def validate_inline_field(fieldname, xml, offset):
def validate_inline(xml):
- """ Validate a xml document against inline.rng.
+ """ Validate a xml document against "inline.rng".
Examples
========
>>> from lxml.etree import parse, XML
>>> from cStringIO import StringIO
- >>> from ns import XMLNS_MARKUP as ns
+ >>> from info import XMLNS_MARKUP as ns
>>> doc = "<inline xmlns='%s'><em>hello</em></inline>" % ns
>>> validate_inline(XML(doc))
@@ -83,7 +86,7 @@ def validate_section_field(fieldname, xml, offset):
of exml section.
>>> from enkel.model.field.xmlf import XmlField
- >>> from ns import XMLNS_MARKUP as ns
+ >>> from info import XMLNS_MARKUP as ns
>>> f = XmlField(validate=validate_section_field)
>>> xml = u"<section xmlns='%s'><h>hello</h></section>" % ns
>>> f.validate("f", xml)
@@ -104,6 +107,31 @@ def validate_section(xml):
rng.assertValid(xml)
+
+def validate_formsection(xml):
+ """ Validate a document agains "formsection.rng".
+ Parameters and excetions are the same as
+ L{enkel.exml.markup.validate.validate_inline}.
+ """
+ rng_file = join(RNGDIR, "formsection.rng")
+ rng_doc = etree.parse(rng_file)
+ rng = etree.RelaxNG(rng_doc)
+ rng.assertValid(xml)
+
+
+def validate_form(xml):
+ """ Validate a document agains "form-standalone.rng".
+ Parameters and excetions are the same as
+ L{enkel.exml.markup.validate.validate_inline}.
+ """
+ rng_file = join(RNGDIR, "form-standalone.rng")
+ rng_doc = etree.parse(rng_file)
+ rng = etree.RelaxNG(rng_doc)
+ rng.assertValid(xml)
+
+
+
+
def suite():
import doctest
return doctest.DocTestSuite()
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from enkel.wansgli.testhelpers import unit_mod_suite, run_suite
+from enkel.exml import validate as dt_validate
-import markup, form
+import validate, formgen
def suite():
- return unit_mod_suite(markup, form)
+ return unit_mod_suite(validate, dt_validate, formgen)
if __name__ == "__main__":
run_suite(suite())
+++ /dev/null
-# This file is part of the Enkel web programming library.
-#
-# Copyright (C) 2007 Espen Angell Kristiansen (
[email protected])
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-from enkel.wansgli.testhelpers import unit_mod_suite, run_suite
-
-import formgen, validate
-
-
-def suite():
- return unit_mod_suite(formgen, validate)
-
-if __name__ == "__main__":
- run_suite(suite())
@@ -21,8 +21,8 @@ from datetime import date, time, datetime
from lxml.etree import XML
from enkel.wansgli.testhelpers import unit_case_suite, run_suite
-from enkel.exml.form.formgen import Form
-from enkel.exml.form.validate import validate_form
+from enkel.exml.formgen import Form
+from enkel.exml.validate import validate_form
from enkel.model.data import Manip
from enkel.model.util import ModelData
from enkel.model.ds import One, Many
+++ /dev/null
-# This file is part of the Enkel web programming library.
-#
-# Copyright (C) 2007 Espen Angell Kristiansen (
[email protected])
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-from unittest import TestCase
-from cStringIO import StringIO
-from lxml.etree import XML
-
-from enkel.wansgli.testhelpers import unit_case_suite, run_suite
-from enkel.exml.markup.validate import \
- validate_section, validate_inline
-from enkel.exml.markup.ns import XMLNS_MARKUP
-
-
-SECTION = \
-u"""<section xmlns="%s">
- <h>This is a test</h>
- <p>
- Really it is;)
- </p>
-</section>""" % XMLNS_MARKUP
-
-INLINE = u"""<inline xmlns="%s">
- A <strong>strong</strong> <em>person</em>.
-</inline>""" % XMLNS_MARKUP
-
-
-class TestValidate(TestCase):
- def test_validate_section(self):
- validate_section(XML(SECTION))
- def test_validate_inline(self):
- validate_inline(XML(INLINE))
-
-
-def suite():
- return unit_case_suite(TestValidate)
-
-if __name__ == '__main__':
- run_suite(suite())
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from unittest import TestCase
+from cStringIO import StringIO
from lxml.etree import XML
from enkel.wansgli.testhelpers import unit_case_suite, run_suite
-from enkel.exml.markup.ns import XMLNS_MARKUP
-from enkel.exml.form.ns import XMLNS_FORM
-from enkel.exml.form.validate import \
+from enkel.exml.validate import \
+ validate_section, validate_inline, \
validate_formsection, validate_form
+from enkel.exml.info import XMLNS_MARKUP, XMLNS_FORM
FORM = \
@@ -57,7 +58,24 @@ u"""<section xmlns="%(XMLNS_MARKUP)s">
</section>""" % vars()
+SECTION = \
+u"""<section xmlns="%s">
+ <h>This is a test</h>
+ <p>
+ Really it is;)
+ </p>
+</section>""" % XMLNS_MARKUP
+
+INLINE = u"""<inline xmlns="%s">
+ A <strong>strong</strong> <em>person</em>.
+</inline>""" % XMLNS_MARKUP
+
+
class TestValidate(TestCase):
+ def test_validate_section(self):
+ validate_section(XML(SECTION))
+ def test_validate_inline(self):
+ validate_inline(XML(INLINE))
def test_validate_formsection(self):
validate_formsection(XML(FORMSECTION))
def test_validate_form(self):