<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I don't grasp exactly what you're trying to do, but if you need a
program that generates XML documents that conform to a schema for which
date values are relative to today, I agree having the harness write the
older date seems to make sense.<br>
<br>
If generateDS doesn't fully support all the XML Schema date types, you
could do that using PyXB with a program like this:<br>
<br>
<tt>&nbsp; import schema<br>
&nbsp; import pyxb.binding.datatypes as xsd<br>
&nbsp; import datetime<br>
<br>
&nbsp; delta = xsd.duration('P3D')<br>
<br>
&nbsp; s = schema.instance()<br>
&nbsp; s.setElt(datetime.date.today() - delta)<br>
&nbsp; print s.toxml()</tt><br>
<br>
with output:<br>
<br>
&nbsp;<tt>&lt;?xml version="1.0"
?&gt;&lt;instance&gt;&lt;elt&gt;2009-07-06&lt;/elt&gt;&lt;/instance&gt;<br>
</tt><br>
assuming the schema is:<br>
<br>
&nbsp; <tt>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>
&nbsp; &lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;xs:element name="instance" type="structure"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;xs:complexType name="structure"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:sequence&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="elt" minOccurs="0" type="xs:date"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xs:sequence&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/xs:complexType&gt;<br>
&nbsp; &lt;/xs:schema&gt;</tt><br>
<br>
PyXB (see <a class="moz-txt-link-freetext" href="http://pyxb.sourceforge.net">http://pyxb.sourceforge.net</a>) is definitely beta software, but
it's coming along nicely.&nbsp; It makes a strong effort to validate the
data written into the binding instances (in fact, a weakness is that
you can't stop it from trying to validate).&nbsp; It can also handle very
complex schemas, such as those from OpenGIS.<br>
<br>
If you really need to change the type of an element in a complex type
at runtime, it could be done by generating a customized binding (though
you'd have to modify the runtime support class
pyxb.binding.basis.element to allow this particular kind of
customization).<br>
<br>
Peter<br>
<br>
Tennis Smith wrote:
<blockquote
 cite="mid:e84cff280907091206o8a45927gbd70f42b17e4b2fd@mail.gmail.com"
 type="cite">Hi,<br>
  <br>
I'm looking for some guidence in handling a testing issue.&nbsp; I'm new to
XML/XSLT, so please bear with me.<br>
  <br>
First,
a little background.&nbsp; My charter is to generate XML test messages to
make sure we process them correctly.&nbsp; These messages are validated
against a schema.&nbsp; I'm using generateDS to generate the test messages.&nbsp;
This ensures the xml is correct.<br>
  <br>
Everything works great except for one problem that keeps cropping
up.&nbsp; Some elements cannot be defined easily ahead of time when
generating the final test document.&nbsp; <br>
  <br>
For example, a field of
type "xs:date" will have to be modifed because tests are based on a
relative date, not an absolute one. That is, dates in tests are based
on things like "3 days before today". <br>
  <br>
Therefore, I'd like to figure out some way to change certain fields
like date so that I can pass a string and _still validate_ it against
the schema.&nbsp; Using the example, "-3" would be passed in the date field
so that the test harness will recognize it as "today - 3 days".&nbsp; <br>
  <br>
Put another way, the goal is to make this:<br>
  <i>&nbsp; &lt;xs:element maxOccurs="1" minOccurs="0" name="date"
type="xs:date"/&gt;</i><br>
...<span style="color: rgb(51, 51, 255);">behave</span> like this:<br>
&nbsp;<i>&lt;xs:element maxOccurs="1" minOccurs="0" name="date" type="<span
 style="color: rgb(204, 0, 0);">xs:string</span>"/&gt;</i><br>
  <br>
Naturally, I can edit and copy/paste into a completely new schema
file. But I was hoping someone could tell me if I can do some kind of
XSLT or whatever to get the same effect.<br>
  <br>
Thanks,<br>
  <font color="#888888"><br>
  </font>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
XML-SIG maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:XML-SIG@python.org">XML-SIG@python.org</a>
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/xml-sig">http://mail.python.org/mailman/listinfo/xml-sig</a>
  </pre>
</blockquote>
<br>
</body>
</html>