Intro to Word XML Part 3: Using Your Own Schema
[This post has been removed due to legal concerns]
Comments
- Anonymous
July 26, 2005
Thanks, Brian! Now you have me waiting for how to capture events on those elements. - Anonymous
July 28, 2005
The comment has been removed - Anonymous
July 28, 2005
I think it's ALT+F11 for VBE instead of CTRL+F11 - Anonymous
July 28, 2005
Ignace, you're right. Thanks for the correction. I just updated it to say "ALT + F11"
Dave, what are the scenarios you are interested in. Office 11 already has a good amount of XML support (between Word, InfoPath, FrontPage, and Excel). In Office 12 we continue to make improvements, which we'll talk about more at PDC. It's hard to answer your question though in regards to competition since editing XML is a fairly basic, generic thing. It really comes down to what type of XML you are editing and what the scenario is.
-Brian - Anonymous
July 28, 2005
Brian, ah, you're not a mind-reader {:>}. Sorry to be so vague; I'm working in the Publishing sector - books, manuals, newsletters, etc. I'd like my authors to be able to create structured content (XML) in Word and also be able to create "a" style and layout on top of that or apply a predefined style (probably can do most of this in WordML). I'd also like them to be able to work on say a chapter, a primarily "virtual" xml doc that would allow them to link content from other xml docs e.g. letters, graphics, articles, etc. stored in a common repository. Then of course they might open up a book and add chapter links etc. What do you think? - Anonymous
August 17, 2005
The comment has been removed - Anonymous
August 17, 2005
I guess I need new glasses - In my previous post I got both reference names spelled wrong.
My apologies to Peter Sefton and Bryan Wilhite. - Anonymous
November 03, 2005
The comment has been removed - Anonymous
November 03, 2005
Hey Alexander, the quick answer is no, you cannot control the prefix we use to write out the files. If it's really important to you though, you could always save through an XSLT that takes everything in a particular namespace and forces it to use the prefix you want.
More importantly though, you should never rely on a prefix. When you're programming against the files, you should use the namespace to build up your XPaths, not the prefix. Prefixes are able to change without effecting the actual meaning of the file at all. It's just a shorthand for the actual namespace.
Let me know if that helps and you're able to get it working ok?
-Brian - Anonymous
November 03, 2005
Brian,
Thanks for the quick response.
I'm a bit of a newbie to this world and I'm afraid that I've never seen an XPath expression that used namespaces instead of prefixes.
One of my expressions looks like this ...
/w:wordDocument/w:body/wx:sect/u:designOverviewSection/u:designComponent[@number='1']/u:name
and the namespace looks like this ...
xmlns:u="http://www.unisys.com/schemas/3dve/designView"
which Word might change to something like this ...
xmlns:ns1="http://www.unisys.com/schemas/3dve/designView"
By chance are you saying that I have to write my program to first find out what word changed my prefix to and then dynamically revise all of my XPath expressions?
Or is there some way to use a namespace instead of a prefix in an XPath expression itself.
-Brian - Anonymous
November 03, 2005
How are you using this XPath? Is it in an XSLT, or through the XML DOM, or some other way? - Anonymous
November 04, 2005
XPath is being used in an external XML processing application which uses DOM (dom4j). The XPath expressions are hard-coded into this program.
I believe that I will have to modify this program to dynamically determine what word has changed the namespace prefix to & then re-generate the XPath expressions accordingly.
--Alex - Anonymous
November 04, 2005
Have you tried using the SetProperty method to set your SelectionNamespaces. You should be able to use that for the DOM to specify what you want your prefix to map to. Then it won't matter what prefix is used in the actual XML file, it will only matter what namespace that prefix is mapped to. For example:
oXML.setProperty("SelectionNamespaces", "xmlns:my='myNamespace'")
or something like that...
This is really the right way for dealing with XML. You should never view the prefix as having any meaning on it's own. It's always the namespace you should be programming against.
-Brian - Anonymous
December 09, 2005
Brian,
I think that I did not communicate the nature of the problem correctly.
I am using an external program that moves content from one Word document into another Word document. It uses an input file that contains an XPath expression to locate the content in the source document and another XPath expression to pinpoint the location to which the content is to be pasted in the target document. These XPath expressions are actually written into an external XML file and used as input to the process and they "must" use the namespace prefix.
When word chooses to rename the namespace prefixes that I have chosen to use it breaks my program. There is no way for me to dynamically update the XPath expressions in my non-WordML input file.
I'd like to suggest that you at least consider reserving some namespace prefixes for use by programmers and not dynamically change these whenever Word documents are saved. - Anonymous
June 09, 2006
Hi Brian,
Thanks for the valuable information.
I have a few queries here.
Suppose I need to keep a track of the changes made to a Word document by a user. For doing this say i add tags like </s:employee> to all the paragraphs in the document so that the paragraphs can be identified with the tags. But these tags can be removed by the user at any point of time. Is there some other concrete way to do the same?
Also, I came across ids like wsp:rsidRDefault, wsp:rsidR and wsp:rsidP associated with paragraphs which seem to change with every change made to the corresponding paragraph. On what basis do these Ids change? - Anonymous
August 10, 2006
When I save as data only, my child elements (of the
root) all have blank/null namespaces xmlns=""...what is the reasoning
with this and is there a way to have my namespace used in all elements?
<Incident_Report xmlns="http://www.disa.mil/DISA-PAC-PNC-IR">
<Report_Classification xmlns="" />
Thanks,
Denise