Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Validating XML via transformation

From: "Keith Chadwick" <keith@--------------.--->
To: NULL
Date: 7/1/2004 10:36:00 AM
Hey Folks,

Want to know if I am the correct path for this.  We currently have a ASP
system using SQL Server 2000 and we use a fair amount of xslt to render data
returned from the database with the for xml auto.  This works absolutely
great in the system and has greatly improved performance over ado
enumeration in asp.  But not I have had a curve ball thrown at me by the
client.  What they want to do is validate the data and set an attribute on
each node indicating if there is something wrong.  Does not sound to
difficult but one of the item they wish to validate is the e-mail address.
An example of the xml data.

<ROOT>
    <learner fname="howdy" lname="doody" email="howdy@d..."/>
    <learner fname="howdy" lname="doody" email="@doody.com"/>
    <learner fname="howdy" lname="doody" email="howdy@"/>
</ROOT>

So my first through was to run a transformation that would validate this
data and return the resulting xml for transformation to xml. The first
validation transformation would result in this.

<ROOT>
    <learner fname="howdy" lname="doody" email="howdy@d..." valid="1"/>
    <learner fname="howdy" lname="doody" email="@doody.com" valid="0"/>
    <learner fname="howdy" lname="doody" email="howdy@"  valid="0"/>
</ROOT>

Simple enough the problem is coming up with valid logic to test the email
address.  I managed to find the below on perfectxml.com.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="Email" type="EmailType" />
  <xsd:simpleType name="EmailType" >
    <xsd:restriction base="xsd:token">
      <xsd:pattern
value="([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(([a-zA-Z0-9_-])*\.([a-zA-Z0-9_-])
+)+"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>

Now this looks great but my problem is how do I hook the xsd type definition
into a validation routine within the xslt that validates the xml and sets
the valid attribute?

Thanks In Advance
Keith Chadwick





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent