Bernd,

With respect to the validation of time and the
validate_GeneralizedTime_patterns_, I've attached a patch.  With
this patch, I believe that generateDS.py produces the pattern that
works for you.  These regular expressions are complicated enough,
and I'm in the dark about what they should and should not be
checking.  So, if this patch works for you, let's go with it.  We
can make adjustments when someone else reports a problem with it.

Here is a little explanation, as far as I can understand it: This
patch removes the code that was replacing "|" with "$|^".  That
replacement was intended to enable us to handle alternatives in
regular expressions by breaking them up into several concatenated
expressions.  *But*, maybe the ability to handle those alternatives
is (or should be) written into the regular expression itself, *if*
the author of the XML schema writes them correctly.  If so, the
replacement that we are removing is not needed, and this patch is
the right thing to do.  At least, that's what I'm hoping.

About your other issue, I'll take a look tomorrow.  But, at first
glance, it looks like the values you are passing in to the export
method are being attached to the wrong arguments.  You are passing
positional arguments.  You could try using the keyword arguments:

    namespace_
    name_
    namespacedef_

You will have to look at one of the export methods to see how each
of those parameters is used.

By the way, your suggestion in your latest email that a module
generated by generateDS.py be able to do an automatic validation of
the exported XML instance document seems like a good idea.  Although
adding something like this line:

    xmllint --schema test.xsd test01.xml

to a batch file does seem like an easy enough way to handle that.
So, I'll put that feature on a "do" list, but it might not be at the
very top of the list.

More later.  Thanks again for your help with these issues.

Dave

On Thu, Jul 19, 2018 at 12:19:52PM +0000, Zimmermann, Bernd wrote:
> Hello Dave,
> 
> very great stuff you've done with generateDS, works like a charm but only 
> after a resolving a few little things.
> 
> First on, this might be a bug:
> 
> XSD Pattern:
> 
> <xsd:simpleType name="GeneralizedTime">
>     <xsd:restriction base="xsd:string">
>         <xsd:pattern 
> value="\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])(.[0-9][0-9]*)?(Z|[\+|\-][0-9]{4})"/>
>     </xsd:restriction>
> </xsd:simpleType>
> 
> results in:
> 
> 
> validate_GeneralizedTime_patterns_ = 
> [['^\\d{4}(0[1-9]$|^1[012])(0[1-9]$|^[12][0-9]$|^3[01])([01][0-9]$|^2[0-3])([0-5][0-9])([0-5][0-9])(.[0-9][0-9]*)?(Z$|^[\\+$|^\\-][0-9]{4})$']]
> 
> which give the warning:
> 
> 
> /var/etsi/work/V1.18.1/Natparas2V18.py:7644: UserWarning: Value 
> "b'20180719123801+0200'" does not match xsd pattern
> restrictions: 
> [['^\\d{4}(0[1-9]$|^1[012])(0[1-9]$|^[12][0-9]$|^3[01])([01][0-9]$|^2[0-3])([0-5][0-9])([0-5][0-9])(.[0-9][0-9]*)?(Z$|^[\\+$|^\\-][0-9]{4})$']]
> warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % 
> (value.encode('utf-8'), self.validate_GeneralizedTime_patterns_, ))
> 
> Adjusting to:
> 
> 
> validate_GeneralizedTime_patterns_ = 
> [['^\\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])(.[0-9][0-9]*)?(Z|[\\+|\\-][0-9]{4})$']]
> 
> gives no warning.
> 
> So it might be a problem with the separator | which results in a wrong ^|$ 
> pattern?
> 
> 
> Second one, discovering a problem with:
> 
> testxml.export(sys.stdout, 0, '', 'retainedDataMessage')
> at:
> outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + 
> namespacedef_ or '', ))
> 
> This works correct, printing out <retainedDataMessage> or with a 
> generatednamespaces.py with GenerateDSNamespaceDefs the <retainedDataMessage 
> NSGIVEN>
> 
> But:
> 
> testxml.export(sys.stdout, 0, 'NSDATA', 'retainedDataMessage')
> 
> gives: <NSDATAretainedDataMessage> which is not correct, it should be 
> <retainedDataMessage NSDATA>,
> so it's printed in the wrong order and a space is missing between the two 
> arguments.
> 
> Perhaps a:
> outfile.write('<%s%s%s' % (name_, namespace_ and ' ' + namespace_ or '', 
> namespacedef_ and ' ' + namespacedef_ or '', ))
> 
> could fix this. Note: the closing tag must be adjusted too.
> 
> Perhaps the export could also be adjusted to overwrite the namespacedef_ if a 
> namespace_ is given or vice versa ...
> 
> I am using the latest version 2.29.17 installed via pip under Python 3.7
> 
> Hope you could fix it.
> 
> Again, great work!
> 
> Best regards,
> Bernd
> 

> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot

> _______________________________________________
> generateds-users mailing list
> generateds-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/generateds-users



-- 

Dave Kuhlman
http://www.davekuhlman.org
diff -r a22d34b487d1 generateDS.py
--- a/generateDS.py     Fri Jul 20 11:49:15 2018 -0700
+++ b/generateDS.py     Tue Jul 24 13:04:16 2018 -0700
@@ -4400,7 +4400,8 @@
         pats1 = restriction.xpath(
             "./xs:pattern/@value", namespaces=ns)
         if pats1:
-            pats2 = [u'^{}$'.format(replaceVbars(p1)) for p1 in pats1]
+            #pats2 = [u'^{}$'.format(replaceVbars(p1)) for p1 in pats1]
+            pats2 = [u'^{}$'.format(p1) for p1 in pats1]
             patterns1.append(pats2)
         #
         # Check for and generate code for each possible type of restriction.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to