Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2006, 03:53 AM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSD with Namespacing

Hi All

I really hope you can be of some assistance!

I'm currently working on an XML producing C# component. It uses a WSDL and an XSD (thru MS' xsd.exe and wsdl.exe) to create a proxy by which the XML is sent.

I can produce clean valid XML, but I cannot work out how to get namespaces into the code.

This is my XML:
Code:
 <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
 .....
    <API>CREATE_ARR_ARRANGEMENT</API>
  </MSG_HEADER>
  <MSG_BODY>
    <CreateArrearsArrangement>
      <accountPaymentReference>71335</accountPaymentReference>
      <startDate>2006-02-13</startDate>
  .....
And FYI this is what the Service provider states I should be sending
Code:
<?xml version="1.0" encoding="UTF-8"?>
......
     <ng0:API>CREATE_ARR_ARRANGEMENT</ng0:API>
</ng0:MSG_HEADER>
<ng0:MSG_SOAP_HEADER/>
<ng0:MSG_BODY>
   <ng1:CreateArrearsArrangement>
      <ng1:accountPaymentReference>71335</ng1:accountPaymentReference>
      <ng1:startDate>2006-02-13</ng1:startDate>
 .....
Here is some of the XSD code.
Code:
 <xs:element name="CreateArrearsArrangement">
    <xs:annotation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="accountPaymentReference" type="xs:date">
          <xs:annotation>
            <xs:documentation>This is the Pay....</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="startDate" type="xs:date">
          <xs:annotation>
            <xs:documentation>This is the Sta....nt</xs:documentation>
          </xs:annotation>
        </xs:element>
You can see above there is this:
Code:
<xs:element name="CreateArrearsArrangement">
I have tried setting this to:
Code:
<xs:element name="ng1:CreateArrearsArrangement">
and:
Code:
<xs:element name="ng1:CreateArrearsArrangement" ref="ng1:CreateArrearsArrangement">
but to no avail. I can't use ref on it's own all the time, because for most elements I require the type="" attribute to be set.

Does anyone have experience using namespaces in XSDs? Google for once is just evading being helpful!!
 
Old June 15th, 2006, 04:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The "name" attribute of a component defined in a schema (e.g. an element) is always a local name: it is implicitly qualified by the targetNamespace defined on the xs:schema element. You can choose whether locally-declared elements (an xs:element within xs:complexType) should be in the target namespace or in no namespace by using the elementFormDefault attribute on xs:schema. Globally-declared elements (xs:element directly within xs:schema) are always in the target namespace.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD.EXE Gen’d C# Deserializing w/ .xsd Subst Group greenstone XML 0 November 9th, 2007 09:27 PM
XSD JonDeNoitaly BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 May 7th, 2007 08:32 AM
xsd deleme nerssi XML 1 July 5th, 2006 05:17 AM
xsd question kgoldvas XML 3 May 4th, 2006 03:14 AM
Merging XSD files in one XSD file by using what? haoxuqian XML 1 November 4th, 2005 01:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.