It is a valid xml file. Its an xml processing instruction.
the full path to that node is "/processing-instruction('define')[1]". 
 
http://aspalliance.com/515_Working_with_XML_Processing_Instructions_in_C
 
as we can see in the output xmlpoke is able to find the node, but it
throws an exception when it tries to modify the value.
 
-Alim

________________________________

From: Bob Archer [mailto:[EMAIL PROTECTED] 
Sent: April 27, 2007 4:49 PM
To: Hassam, Alim; nant-users@lists.sourceforge.net
Subject: RE: [NAnt-users] XMLPoke with Xml processing instructions



Is this a valid XML file? I know you only showed a snipit of it. What is
the full path to that node?

 

BOb

 

 

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Hassam,
Alim
Sent: Friday, April 27, 2007 4:44 PM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] XMLPoke with Xml processing instructions

 

Hi,

 

I'm having trouble doing an xml poke on an xml processing instruction. 

My xml document contains a line like this:

 

<?define Property_ProductVersion = "2.0.4305.0" ?>

 

and I would like to update that version number from an nant task.

I did the following:

 

 <target name="updateVersionNumber" description="Updates the version
number.">
    <xmlpoke file="${ project.usersettings.integrationview.path
}\DataAnalyzer/Deployment/Installer/DataAnalyzerInstaller/DataAnalyzerIn
staller.wxs"
             value="Test"
             xpath="/processing-instruction('define')[1]"
             verbose="true" />

 </target>

 

but nant fails, it gives be the following error:

 

updateVersionNumber:

 

  [xmlpoke] Attempting to load XML document in file
'C:\Views\SRVCCALBD_ADA2.0_int\DataAnalyzer\Deployment\Installer\DataAna
lyzerInstaller\DataAnalyzerInstaller.wxs'.
  [xmlpoke] XML document in file
'C:\Views\SRVCCALBD_ADA2.0_int\DataAnalyzer\Deployment\Installer\DataAna
lyzerInstaller\DataAnalyzerInstaller.wxs' loaded successfully.
  [xmlpoke] Selecting nodes with XPath expression
'/processing-instruction('define')[1]'.
  [xmlpoke] Found '1' nodes matching XPath expression
'/processing-instruction('define')[1]'.
  [xmlpoke] Updating nodes with value 'Test'.
  [xmlpoke] Updating node '0'.

 

BUILD FAILED

 

C:\Views\SRVCCALBD_ADA2.0_int\DataAnalyzer\DesignImplementation\Source\d
efault.build(91,6):
Could not poke at XML file
'C:\Views\SRVCCALBD_ADA2.0_int\DataAnalyzer\Deployment\Installer\DataAna
lyzerInstaller\DataAnalyzerInstaller.wxs'.:
NAnt.Core.BuildException:
C:\Views\SRVCCALBD_ADA2.0_int\DataAnalyzer\DesignImplementation\Source\d
efault.build(91,6):
Could not poke at XML file
'C:\Views\SRVCCALBD_ADA2.0_int\DataAnalyzer\Deployment\Installer\DataAna
lyzerInstaller\DataAnalyzerInstaller.wxs'. 

---> System.InvalidOperationException: Cannot set the InnerXml for the
current node because it is either read-only or cannot have children.
   at System.Xml.XmlNode.set_InnerXml(String value)
   at NAnt.Core.Tasks.XmlPokeTask.UpdateNodes(XmlNodeList nodes, String
value)
   at NAnt.Core.Tasks.XmlPokeTask.ExecuteTask()
   --- End of inner exception stack trace ---
   at NAnt.Core.Tasks.XmlPokeTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Target.Execute()
   at NAnt.Core.Project.Execute(String targetName, Boolean
forceDependencies)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()

 

Total time: 0.6 seconds.

 

A few questions:

Am I doing something wrong? Is there another way of doing what I'm
trying to do? 

 

Looking at the source code I see that the XMLPokeTask is trying to write
to the InnerXML field of the XMLNode. Looking online I seem to
understand that in the case of an XMLProcessingInstructionNode it should
write to the value field. If that's the case would it be a good idea to
update the XmlPokeTask to write to the value field in case of
XMLProcessingInstructionNode? 

 

Thank you for your responses!

-Alim

 

------------------------------------------------------------------------
------
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is 
available at http://www.merck.com/contact/contacts.html) that may be 
confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this 
message. If you are not the intended recipient, and have received this 
message in error, please notify us immediately by reply e-mail and then 
delete it from your system.

------------------------------------------------------------------------
------


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is 
available at http://www.merck.com/contact/contacts.html) that may be 
confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this 
message. If you are not the intended recipient, and have received this 
message in error, please notify us immediately by reply e-mail and then 
delete it from your system.

------------------------------------------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to