where to add a node in WordML

J

Jialiang Ge [MSFT]

Hello Dave,

Both Word 2003 WordML and OpenXML have very strict rules of what can be
embedded in an element. The rules are defined in the XML schemas:

For WordML:
http://www.microsoft.com/downloads/details.aspx?FamilyId=FE118952-3547-420A-
A412-00A2662442D9&displaylang=en
(if the URL is broken, you may search "Office 2003: XML Reference Schemas"
in http://www.microsoft.com/downloads/Search.aspx?displaylang=en)

For OpenXML:
See the OpenXML specification. The spec documents include the schema of
each element type.

Take the element 'rPr' in WordML as an example,
The file wordnet.xsd in the WordML schema download defines 'rPr' as the
type 'rPrElt'.
<xsd:element name="rPr" type="rPrElt" minOccurs="0">

The 'rPrElt' is declared as this:

<xsd:complexType name="rPrElt">
<xsd:annotation>
<xsd:documentation>Defines the properties of the contents of this
run.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="rStyle" type="stringProperty" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Represents a character style for this
run.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="rFonts" type="fontsElt" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Represents the fonts for this
run.</xsd:documentation>
</xsd:annotation>
</xsd:element>
.................................
<xsd:element ref="aml:annotation" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>Revision marking of run
properties.</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
</xsd:complexType>

The line
<xsd:choice maxOccurs="unbounded">
means that we can only have the elements "rStyle", "rFonts", etc in 'rPr'
http://msdn.microsoft.com/en-us/library/ms256109.aspx
Therefore, if you put a self-defined xml element in rPr:
<w:rPr><w:rFonts w:hint="fareast"/><selfDefinedElement /></w:rPr>
Microsoft Word will report an error found in the Word XML.

Please let me know whether these info fits your request.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

If we need to add something to the document (it's an ID) - where/how
should we do so?

thanks - dave


Hello Dave,

Both Word 2003 WordML and OpenXML have very strict rules of what can be
embedded in an element. The rules are defined in the XML schemas:

For WordML:
http://www.microsoft.com/downloads/details.aspx?FamilyId=FE118952-3547-420A-
A412-00A2662442D9&displaylang=en
(if the URL is broken, you may search "Office 2003: XML Reference Schemas"
in http://www.microsoft.com/downloads/Search.aspx?displaylang=en)

For OpenXML:
See the OpenXML specification. The spec documents include the schema of
each element type.

Take the element 'rPr' in WordML as an example,
The file wordnet.xsd in the WordML schema download defines 'rPr' as the
type 'rPrElt'.
<xsd:element name="rPr" type="rPrElt" minOccurs="0">

The 'rPrElt' is declared as this:

<xsd:complexType name="rPrElt">
<xsd:annotation>
<xsd:documentation>Defines the properties of the contents of this
run.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="rStyle" type="stringProperty" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Represents a character style for this
run.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="rFonts" type="fontsElt" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Represents the fonts for this
run.</xsd:documentation>
</xsd:annotation>
</xsd:element>
................................
<xsd:element ref="aml:annotation" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>Revision marking of run
properties.</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
</xsd:complexType>

The line
<xsd:choice maxOccurs="unbounded">
means that we can only have the elements "rStyle", "rFonts", etc in 'rPr'
http://msdn.microsoft.com/en-us/library/ms256109.aspx
Therefore, if you put a self-defined xml element in rPr:
<w:rPr><w:rFonts w:hint="fareast"/><selfDefinedElement /></w:rPr>
Microsoft Word will report an error found in the Word XML.

Please let me know whether these info fits your request.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

You can search xsd:any in the xml schemas in my last reply, and find the
items whose namespace is ##any, or ##other, or ##local. These are the
element types that we can insert our self-defined xml nodes. For example,

<xsd:any processContents="skip" namespace="##other" minOccurs="0"></xsd:any>

In

<xsd:complexType name="simpleFieldType">
<xsd:annotation>
<xsd:documentation>Defines a field in the
document.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="fldData" type="stringType" minOccurs="0"
maxOccurs="1">
<xsd:annotation>
<xsd:documentation>Represents field data.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="r" type="rElt">
<xsd:annotation>
<xsd:documentation>Represents the run element. This is the leaf
container for data in a Word document -- text, pictures, and so
on.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="fldSimple" type="simpleFieldType" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>Represents simple Word field (with plain
text instructions). These fields are run-time calculated entities in Word
(for example, page numbers).</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="hlink" type="hLinkType">
<xsd:annotation>
<xsd:documentation>Represents hyperlink element (analogous to
HTML &lt;a href=...&gt; tag).</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:group ref="runLevelElts"></xsd:group>
<xsd:any processContents="skip" namespace="##other"
minOccurs="0"></xsd:any>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="instr" type="stringType" use="required">
<xsd:annotation>
<xsd:documentation>Gets or sets instruction text for a
field.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="fldLock" type="onOffType">
<xsd:annotation>
<xsd:documentation>Gets or sets whether the field is locked from
being recalculated.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>

It means that, in an element of type 'simpleFieldType', we can have a
self-defined element after the element 'fldData'.

Dave, where do you expect to add the self-defined element (an ID)? There
are very limited places that we can add this based on the schema.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

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

David Thielen

THis was what I needed - thank you very much


Hello Dave,

You can search xsd:any in the xml schemas in my last reply, and find the
items whose namespace is ##any, or ##other, or ##local. These are the
element types that we can insert our self-defined xml nodes. For example,

<xsd:any processContents="skip" namespace="##other" minOccurs="0"></xsd:any>

In

<xsd:complexType name="simpleFieldType">
<xsd:annotation>
<xsd:documentation>Defines a field in the
document.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="fldData" type="stringType" minOccurs="0"
maxOccurs="1">
<xsd:annotation>
<xsd:documentation>Represents field data.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="r" type="rElt">
<xsd:annotation>
<xsd:documentation>Represents the run element. This is the leaf
container for data in a Word document -- text, pictures, and so
on.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="fldSimple" type="simpleFieldType" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>Represents simple Word field (with plain
text instructions). These fields are run-time calculated entities in Word
(for example, page numbers).</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="hlink" type="hLinkType">
<xsd:annotation>
<xsd:documentation>Represents hyperlink element (analogous to
HTML &lt;a href=...&gt; tag).</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:group ref="runLevelElts"></xsd:group>
<xsd:any processContents="skip" namespace="##other"
minOccurs="0"></xsd:any>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="instr" type="stringType" use="required">
<xsd:annotation>
<xsd:documentation>Gets or sets instruction text for a
field.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="fldLock" type="onOffType">
<xsd:annotation>
<xsd:documentation>Gets or sets whether the field is locked from
being recalculated.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>

It means that, in an element of type 'simpleFieldType', we can have a
self-defined element after the element 'fldData'.

Dave, where do you expect to add the self-defined element (an ID)? There
are very limited places that we can add this based on the schema.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

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


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

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