Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XPath expression to a custom property in Word 2007 ?

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 11/8/2008 7:30:00 PM
Kay-Christian Wessel wrote:
> I'm trying to map a custom property of a Word 2007 document to a 
> contentcontrol.
> 
> Mapping is not so hard :
> 
> Dim strXPath As String
> strXPath = "tree/fruit/fruitType[1]"
> ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath
> 
> But setting the right XPath is is giving me a hard time.
> 
> Here is the custom XML file :
> 
>  <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> - <Properties 
> xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" 
> xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"> 
> 
> - <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" 
> name="MyFirstCustomProperty">
>  <vt:lpwstr>FirstText</vt:lpwstr>
>  </property>
> - <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" 
> name="MySecondCustomProperty">
>  <vt:lpwstr>SecondText</vt:lpwstr>
>  </property>
>  </Properties>
> 
> 
> What would be the correct XPath expression to MySecondCustomProperty ?

It is not clear what you want to achieve. "MySecondCustomProperty" is an 
attribute value in your XML sample. Do you want an XPath expression 
evaluating to that attribute value?
I suspect you want to select the "property" element having a "name" 
attribute with value "MySecondCustomProperty". One way to do that is
/*[local-name() = "Properties"]/*[local-name() = "property"][@name = 
"MySecondCustomProperty"]

Or you need to bind prefixes to namespace URIs and use those prefixes. I 
don't know how you do that with Word 2007 but assuming the prefix "cp" 
is bound to the namespace URI 
"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" 
you can use
/cp:Properties/cp:property[@name = "MySecondCustomProperty"]



-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent