Smart Documents - XSD and Namespace

P

Paul Hasell

Hi, I'm evaluating the use of Excel Smart Documents for data entry systems
and have created an XSD for the data which I want to use both for Excel (to
describe the data) and in the Web service back-end for validation of the
same. However, when Excel attaches the XSD as a map, it assigns it own
namespace to it (typically ns1) which it then includes in the exported XML.
This means I can't verify it using the same XSD as the element namespaces no
longer match!!!

Is there a way around this or must I maintain 2 otherwise identical XSD's??
 
P

Peter Huang [MSFT]

Hi

Based on my research, the two schema should be compatible.
[Schema:SimpleSample]
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="SimpleSample"
targetNamespace="SimpleSample"
elementFormDefault="qualified">

<xsd:complexType name="exampleType">
<xsd:all>
<xsd:element name="textbox" type="xsd:string"/>
<xsd:element name="commandbutton" type="xsd:string"/>
<xsd:element name="help" type="xsd:string"/>
<xsd:element name="radiobutton" type="xsd:string"/>
<xsd:element name="checkbox" type="xsd:string"/>
<xsd:element name="listbox" type="xsd:string"/>
<xsd:element name="image" type="xsd:string"/>
<xsd:element name="documentfragment" type="xsd:string"/>
<xsd:element name="activex" type="xsd:string"/>
<xsd:element name="hyperlink" type="xsd:string"/>
</xsd:all>
</xsd:complexType>

<xsd:element name="example" type="exampleType"/>

</xsd:schema>

[Export xml]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <ns1:example xmlns:ns1="SimpleSample">
<ns1:textbox>1</ns1:textbox>
<ns1:commandbutton />
<ns1:help />
<ns1:radiobutton />
<ns1:checkbox />
<ns1:listbox />
<ns1:image />
<ns1:documentfragment />
<ns1:activex />
<ns1:hyperlink />
</ns1:example>

changed to
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:example xmlns:ns1="SimpleSample"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="SimpleSample C:\test\SimpleSample.xsd">
<ns1:textbox>1</ns1:textbox>
<ns1:commandbutton/>
<ns1:help/>
<ns1:radiobutton/>
<ns1:checkbox/>
<ns1:listbox/>
<ns1:image/>
<ns1:documentfragment/>
<ns1:activex/>
<ns1:hyperlink/>
</ns1:example>

We will find that we can use the SimpleSample.xsd to validate the exported
xml so they should be compatible. That is to say the webservice will
recognize the xml file.

If you have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Paul Hasell

Peter,

Thanks for the reply, I'll give it a try. It's not a very elegant solution
in that it requires inclusion of an arbitrary namespace into a custom
solution. Is this 'ns' namespace by design and will it continue to plague the
next release of Office?
 
P

Peter Huang [MSFT]

Hi

I think the webservice can use the simplesample namespace, the ns1 is just
an alias for the SimpleSample. They should be compatible.
So far I can not make sure if the behavior will be changed in office
12.(next version)

Also I think you may try to send your feedback to the link below.
Make a suggestion
http://office.microsoft.com/en-us/contactus.aspx?Sitename=0

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Paul Hasell

Peter, thanks for the suggestions but I think I might just wait for VSTO
2005, the existing frameworks are just to flakey and the plumbing required
too complex. I can't seem to manage getting anything to work in repeating
elements and since I can't seem to attach to the plumbing to debug it I'll
have to give up for now.

There seems to be too many fragmented bits in this arena at the moment
(VSTO, IBF, Smart Documents) none of which quite do what you want them too.
It's almost as if you guys were using this as an extended public beta before
releasing a unified solution that actually does something truly useful.

Here's hoping VSTO 2005 actually works.
 
P

Peter Huang [MSFT]

Hi

Thanks for your understanding!
Please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Y

Yan-Hong Huang[MSFT]

Hello Paul,

I am reviewing this issue. Sorry for any incovenience that brought to you
and your team. If you are still monitoring the issue and want to know more
details on whether it can be workarounded in the current environment,
please feel free to reply here and we will consult smart document dev
engineer.

There is currently no easy way to do this, but keep an eye out for it in
the future. We are looking at continual improvement, and it's this kind of
feedback that let's us know what things you're trying to do, that we
haven't yet exposed for you.

Thanks very much for your understanding.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Stephen Bullen

Hi Paul,
Hi, I'm evaluating the use of Excel Smart Documents for data entry systems
and have created an XSD for the data which I want to use both for Excel (to
describe the data) and in the Web service back-end for validation of the
same. However, when Excel attaches the XSD as a map, it assigns it own
namespace to it (typically ns1) which it then includes in the exported XML.
This means I can't verify it using the same XSD as the element namespaces no
longer match!!!

Is there a way around this or must I maintain 2 otherwise identical XSD's??

The solution to this is to include your own namespace in your xsd, using
whatever TLA you want, e.g.:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="some_long_namespace_identifier"
xmlns:foo="some_long_namespace_identifier"
elementFormDefault="qualified">
<xsd:element name="MyRoot">
</xsd:element>
</xsd:schema>

When Excel imports the xsd as a map, it will remember the namespace (i.e. the
"some_long_namespace_identifier", but will use its own TLA (ns1, ns2 etc). When
exported, it will use its own TLA, but use *your* namespace:

<?xml version="1.0" standalone="yes"?>
<ns1:MyRoot xmlns:ns1="some_long_namespace_identifier">
</ns1:MyRoot>

Now, because the "ns1" bit is nothing more than an alias used within the file
for some_long_namespace_identifier, that will validate fine against your xsd.
In other words, it's the "some_long_namespace_identifier" that has to match,
rather than the ns1 TLA.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top