import problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • IsValidUN
    New Member
    • Jul 2007
    • 17

    import problem

    I have an XSD which has an import to an XSD located on the web which has a DTD within it. (Using VS-2005 2.0 framework)

    If I load the XSD using the following, it can't find elements defined within the "xmldsig-core-schema.xsd" file, when I validate.
    [HTML]Dim oXmlReaderSetti ngs As New XmlReaderSettin gs()
    oXmlReaderSetti ngs.ProhibitDtd = False
    '-- Set for schema validation
    oXmlReaderSetti ngs.ValidationT ype = ValidationType. Schema
    oXmlReaderSetti ngs.Schemas.Add (Nothing, "WS-TDL.xsd")
    Dim oRequestReader As New StringReader(.. .
    Dim oPayloadXmlRead er As XmlReader = XmlReader.Creat e(oRequestReade r, oSchemasSetting s
    [/HTML]

    If I explicitly load the xsd from the web, I can validate except when the doc has a element which requires a definition that is in the XSD on the web.
    FOR example:
    -- Load xsd
    ' do something like the following to explicitly load the xsd
    oXmlReaderSetti ngs.Schemas.Add (Nothing,
    http://www.w3.org/TR/2002/REC-xmldsi...re-schema.xsd)

    I get the following type of error
    The element 'X509IssuerSeri al' has invalid child element 'X509IssuerName '. List of possible elements expected: 'X509IssuerName ' in namespace 'http://www.w3.org/2000/09/xmldsig#'.



    Any Ideas as to why this is or how to correct the problem? (WS-TDL.XSD file being loaded is listed below)
    [HTML]
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:aix_tdl=" http://www.accessitx.c om/TDL_Interface" elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
    <xs:import namespace="http ://www.w3.org/2000/09/xmldsig#" schemaLocation= "http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd" />
    <xs:import namespace="http ://www.accessitx.c om/TDL_Interface" schemaLocation= "TDL_Interface. xsd" />
    <xs:complexTy pe name="TDLReques t_DateType">
    <xs:sequence>
    <xs:element name="StartDate " type="xs:dateTi me" />
    <xs:element name="EndDate" type="xs:dateTi me" />
    </xs:sequence>
    </xs:complexType>
    <xs:complexTy pe name="TDLReques t_SNType">
    <xs:sequence>
    <xs:element name="SerialNum ber" type="xs:string " />
    </xs:sequence>
    </xs:complexType>
    <xs:complexTy pe name="TDLReques t_X509NameType" >
    <xs:sequence>
    <xs:element name="X509Issue rSerial" type="ds:X509Is suerSerialType" minOccurs="0" />
    <xs:element name="X509Subje ctName" type="xs:string " minOccurs="0" />
    </xs:sequence>
    </xs:complexType>
    <xs:complexTy pe name="TDLReques t_All">
    <xs:sequence>
    <xs:element name="All" />
    </xs:sequence>
    </xs:complexType>
    <xs:element name="TDLReques t">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="SequenceI D" type="xs:long" />
    <xs:element name="UserNameT oken" type="xs:base64 Binary" />
    <xs:element name="RequestPa yload" type="TDLReques t_PayloadType" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:complexTy pe name="TDLReques t_PayloadType">
    <xs:choice>
    <xs:element name="Certifica tionDateRange" type="TDLReques t_DateType" />
    <xs:element name="Installat ionDateRange" type="TDLReques t_DateType" />
    <xs:element name="ChangedDa teRange" type="TDLReques t_DateType" />
    <xs:element name="SerialNo" type="TDLReques t_SNType" />
    <xs:element name="X509Name" type="TDLReques t_X509NameType" />
    <xs:element name="All" type="TDLReques t_All" />
    </xs:choice>
    </xs:complexType>
    <xs:complexTy pe name="tdlAction ">
    <xs:simpleConte nt>
    <xs:extension base="xs:string ">
    <xs:attribute name="scope" type="xs:anyURI " use="optional" default="http://www.accessitx.c om/TDL_Interface#a ction" />
    </xs:extension>
    </xs:simpleConten t>
    </xs:complexType>
    <xs:element name="TDLUpdate ">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="SequenceI D" type="xs:long" />
    <xs:element name="UserNameT oken" type="xs:base64 Binary" />
    <xs:element name="UpdatePay load">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="Action" type="tdlAction " />
    <xs:choice>
    <xs:element name="Add">
    <xs:complexType >
    <xs:sequence maxOccurs="unbo unded">
    <xs:element name="Site" type="aix_tdl:F acilityType" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="Update">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="Old_Site" type="aix_tdl:F acilityType" />
    <xs:element name="New_Site" type="aix_tdl:F acilityType" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="Delete">
    <xs:complexType >
    <xs:sequence maxOccurs="unbo unded">
    <xs:element name="Site" type="aix_tdl:F acilityType" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="TDLRespon se">
    <xs:complexType >
    <xs:choice>
    <xs:element name="Ack" />
    <xs:element name="Sites" type="aix_tdl:F acilityType" maxOccurs="unbo unded" />
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    [/HTML]
    Last edited by Dököll; Jul 24 '07, 12:52 AM. Reason: Code tags
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    It sounds like the elements in your xml file are not in the correct namespace, and/or do not have a namespace.
    Is the xml file you are receiving actually valid?

    Comment

    • IsValidUN
      New Member
      • Jul 2007
      • 17

      #3
      >>It sounds like the elements in your xml file are not in the correct namespace, >>and/or do not have a namespace.
      >>Is the xml file you are receiving actually valid?

      I believe that the "file" is valid I am able to validate it unless it has tags defined in the "imported" namespace

      'sample that validates
      Dim sRequest As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf "<TDLRequest><S equenceID>35266 737</SequenceID><Use rNameToken>ZAVs bG9gQ29ybGQ=</UserNameToken>< RequestPayload> <X509Name><X509 SubjectName>MyT est</X509SubjectName ></X509Name></RequestPayload> </TDLRequest>"

      'sample that won't validate
      Dim sRequest As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf & "<TDLRequest><S equenceID>27352 66737</SequenceID><Use rNameToken>ZAVs bG9gQ29ybGQ=</UserNameToken>< RequestPayload> <X509Name><X509 IssuerSerial><X 509IssuerName>S teve</X509IssuerName> <X509SerialNumb er>1001</X509SerialNumbe r></X509IssuerSeria l><X509SubjectN ame>MyTest</X509SubjectName ></X509Name></RequestPayload> </TDLRequest>"

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        The elements in the schema http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd appear to be in the namespace, http://www.w3.org/2000/09/xmldsig#"

        I would think this would validate:
        Dim sRequest As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf & "<TDLRequest><S equenceID>27352 66737</SequenceID><Use rNameToken>ZAVs bG9gQ29ybGQ=</UserNameToken>< RequestPayload> <X509Name><X509 IssuerSerial><X 509IssuerName xmlns="http://www.w3.org/2000/09/xmldsig#" >Steve</X509IssuerName> <X509SerialNumb er>1001</X509SerialNumbe r></X509IssuerSeria l><X509SubjectN ame>MyTest</X509SubjectName ></X509Name></RequestPayload> </TDLRequest>"

        Comment

        • IsValidUN
          New Member
          • Jul 2007
          • 17

          #5
          Thanks!
          Your answer may be correct, but I found another way.
          I specifed the namespace in the initial element and in the specific tags which point to the namespace.

          <?xml version="1.0" encoding="UTF-8"?>
          <TDLRequest xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><Sequ enceID>27352667 37...<ds:X509Is suerName>Steve</ds:X509IssuerNa me><ds:X509Seri alNumber>1001</ds:X509SerialNu mber>...</TDLRequest>"

          Comment

          Working...