Adding in an XML Schema

C

chemicals

I am using Office 2003 Professional. I am trying to follow an example for
adding an XML schema to a Word document and I get the following error: "The
XML expansion pack or schema file could not be installed". I can't see
anything wrong.

Here is the xsd code:

<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:schemas-microsoft-com.office11demos.WordProductsSD"
targetNamespace="urn:schemas-microsoft-com.office11demos.WordProductsSD"
elementFormDefault="qualified"
attributeFormDefault="unqualified" id="Contract">
<xsd:complexType name="contract">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="CaseCode" type="xsd:string" />
<xsd:element name="Casediscription" type="xsd:string" />
<xsd:element name="element1" type="xsd:string" />
<xsd:element name="Nextdateofhearin" type="xsd:string" />
<xsd:element name="summary" type="xsd:string" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
 
S

Shauna Kelly

Hi

I had no problem using this xsd. I did the following:

1. I saved the xsd as a file.

2. In Word, I created a new document and did Tools > Templates and Add-ins.
On the XML Schema tab, I clicked Add Schema, navigated to the .xsd file,
gave it an Alias, and clicked OK.

3. The XML structure task pane opened and told me that no XML elements have
yet been applied. (If you can't see the task pane, do View > Task Pane, and
then at the top of the task pane, use the drop-down list to choose XML
Structure.)

4. I have to un-tick "List only child elements of current element" to see
the possible elements to apply.

5. I can select some text and click on an element to apply it.

However, I suspect that your xsd may not do what you had in mind for it to
do. I hasten to say that I don't claim any particular expertise in XSD, but
I think you may have needed something like the following. And note that if
you use this, you do not need to un-tick "List only child elements of
current element" and you can produce a valid document.

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:schemas-microsoft-com.office11demos.WordProductsSD"
targetNamespace="urn:schemas-microsoft-com.office11demos.WordProductsSD"
elementFormDefault="qualified" attributeFormDefault="unqualified"
id="Contract">
<xsd:element name="Contract">
<xsd:complexType >
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="CaseCode" type="xsd:string"/>
<xsd:element name="Casediscription" type="xsd:string"/>
<xsd:element name="element1" type="xsd:string"/>
<xsd:element name="Nextdateofhearin" type="xsd:string"/>
<xsd:element name="summary" type="xsd:string"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>



Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

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