Displaying XML in Word 2003 - exposing attributes of elements

E

Eric Safern

Hi,

We're considering using Word 2003 as an xml editor to create and modify xml documents authored in our existing schema.

The problem is, we make heavy use of attributes in our xml, and these are not visible in the default data view.

To elaborate, our xml looks something like this:

<textelement id="question1">
Who are you?
</textelement><textelement id="question2">
Where do you live?
</textelement>

etc.

This shows up as

<<textelement>>Who are you?<<textelement>><<textelement>>Where do you live?<<textelement>>

Without the 'id' attributes being visible, I can't tell one element from the next when editing the xml without right-clicking on each element.

If I used an xslt, I could generate some kind of new xml file with the attributes visible. But wouldn't that change the actual xml so that the schema would be changed when I went to save the xml?

I suppose I could then write another xslt to re-transform the data into the old schema before I save, but that seems like a pain. Is there another way?


Thanks,

Eric Safern
 
L

Lars-Eric Gisslén

Eric,

I suppose the XML fraction you have below is just an exampel with different
Tag and Attribute names than in the real XML file. If not, you should
redesign your Schema.

From W3C:
-------------
Validity constraint: One ID per Element Type

No element type may have more than one ID attribute specified.
--------------

Regards,
Lars-Eric

Eric Safern said:
Hi,

We're considering using Word 2003 as an xml editor to create and modify
xml documents authored in our existing schema.
The problem is, we make heavy use of attributes in our xml, and these are
not visible in the default data view.
To elaborate, our xml looks something like this:

<textelement id="question1">
Who are you?
</textelement><textelement id="question2">
Where do you live?
</textelement>

etc.

This shows up as

<<textelement>>Who are you?<<textelement>><<textelement>>Where do you
live? said:
Without the 'id' attributes being visible, I can't tell one element from
the next when editing the xml without right-clicking on each element.
If I used an xslt, I could generate some kind of new xml file with the
attributes visible. But wouldn't that change the actual xml so that the
schema would be changed when I went to save the xml?
I suppose I could then write another xslt to re-transform the data into
the old schema before I save, but that seems like a pain. Is there another
way?
 
M

MARY MCRAE

Hi Eric,

My suggestion would be to create an MS version of your schema that
replaces your current element identifiers with the values of the id
attributes. You can then incorporate this into your transform that you would
apply when opening an xml instance. When you save, you can hook in another
transform that would perform the reverse operation - transforming the
element identifiers into the id attributes on the very generic textelement.

If you build all this into a smart document solution (along with styles to
enhance editing, a document actions task pane, etc.) the end user won't have
to worry about any of this. It also allows the end user to quickly create
XML without having to continually edit attributes, which your existing users
may appreciate as well.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RXJpYyBTYWZlcm4=?=,
We're considering using Word 2003 as an xml editor to create and modify xml
documents authored in our existing schema.Word 2003 was not designed to be an XML editor, and really isn't the proper
tool. The real purpose of XML in Word (besides being able to save to "WordML" so
that Word docs can be read/written without having Word), is to support the new
SmartDocument feature.

Besides the workaround your describe, the only other option that occurs to me
would be to display the attribute information in a non-modal UserForm, or
possibly in toolbar controls. Which would mean having VBA code running...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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