Is there any way to remove or not to include certain xml elements while creating from mpxj library? - mpxj

currently when working with mpxj library, generated task xml will have following attributes
<Task>
<UID>0</UID>
<ID>0</ID>
<Name>Naruto Uzumaki</Name>
<Active>1</Active>
<Manual>0</Manual>
......
......
</Task>
I do not want Active and Manual tags present in the generated xml, is there any way to achieve this? Kindly help.
Thanks in Advance.

I'm not sure of MS Project's behaviour if these values are removed entirely... if it would give you the defaults you are expecting when it reads the file. On that basis it is not something you can change in MPXJ itself.
However, one simple way to achieve what you want would be to apply an XSL transformation to the generated XML to remove the elements you don't want. The answer to this StackOverflow question provides an example of how this could be done.
Assuming you are using Java and you are writing to a stream you can probably use one of the mechanisms highlighted in this StackOverflow question to take the output directly from MPXJ and pass it through an XSL transformation.

Related

Generate DDIC structure from XSD?

I have a number of XSDs that are part of the enterprise definitions for several services at the client.
I would like to be able to take a single XSD and generate a DDIC structure from it (without the use of PI!)
Seeing as you can generate proxies directly from a WSDL, and this also generates structures and data elements from the XSD definitions inside the WSDL, there is obviously already ABAP code that does this.
But do you know what classes/function modules to use to achieve this? Perhaps there is a convenient utility function or class method that takes the XSD as input and generates the relevant DDIC objects?
Some background on why I need this:
Some of the services include variable sections that include a piece of XML containing the data for one of the enterprise XSD entities; I am hoping to have a DDIC representation of these, which I can fill at runtime and then convert to XML to include in the message.
There is a program on the system called SPROX_XSD2PROXY with which you can upload one or more XSD files which will generate proxy objects for you.
You also end up with a service consumer with a corresponding class and what looks like a dummy operation.
The program is fairly short; it uploads the files(s) to an XSTRING, then converts the XSD(s) to WSDL(s) and finally the WSDL(s) to proxy objects using methods of a class called CL_PROXY_TEST_UTILS.
However, the result is satisfactory as it does give me a structure I can work with. And by examining the contents of those methods, it may be possible to build a more fine-tuned tool if I need one.

Visual Studio 2008 Read values from XSD file

First post. I am trying to read the values of any XSD in Visual Basic. I want the application to read back values like complextypes, elements etc. I have been looking at MSXML2 but most examples include validation against a XML file. I only want to read XSD and get information. Will xml reader be able to read a XSD file? Any help be great.
It depends a lot on what you're trying to do with this information, therefore the prerequisites you need to have in place before doing it.
For all but really trivial tasks, I recommend the use of classes in System.Xml.Schema namespace, particularly start with XmlSchema and XmlSchemaSet. This would allow you to manipulate XSDs any way you want; it would also allow you to validate the schemas before using them, if it would prove to be a requirement.
For completeness, and for what I would call very simple tasks, you may also think that XSD is just XML, so then any XML processor should allow you to load an XSD and interogate it as needed.
All of the above, since you've mentioned VS2008, would be on Visual Basic.NET. If you're still on Visual Basic and need to rely on MSXML, then I would refer you to this article on using Visual Basic and SOM.

Take data from a .xml file to a text

So I have a XML file that contains a lot of data. My task is to extract the 'name' and 'description' information from the XML file so it reads out. I have been messing with it for a while, and I got half way there.
The way the data that I need to extract in the XML file looks like is
<name> Some Name</name>
and the data that is in the description is
<description> The Description </description>
What I have done is extract all the description to a text file, but I know I am doing this the hard/not efficient way. Any ideas?
Also, if I could add some detail to help describe what I am doing, I can do so! Hopefully I described it efficiently though.
Based on comments in question, create a C# application which uses XPath to extract the nodes you are interested in.
A good tutorial to follow:
http://support.microsoft.com/kb/308333

XSD TO XML Conversion

I want to write a java program, Input - XSD File I need to retreive all the element name from the xsd and need to create an xml file as an output with the retreived element name. If anyone of you have the sample code, please share it.
Thanks
You are not rephrasing your question,but still i found some suggestions for you.See if its useful for you.Please check the following link...
http://www.narendranaidu.com/2010/04/xsd-to-xml-and-vice-versa.html
Alright use JAXME or XSOM to parse your schema and use DOM or JDOM to write the element names to new xml
if you want to create a sample XML from schema ..you can use XMLspear tool to do that.
http://www.donkeydevelopment.com/

How can I perform Search&Replace on an XML file after WIX installation?

After installing my files using WIX 3.5 I would like to changes some values in one of my xml files.
Currently there are multiple entries like this:
<endpoint address="net.tcp://localhost/XYZ" .../>
I would like to change the localhost to the real servername wich is available due to a property. How can I perform this replacement on each entry inside this xml file? Is there a way to do this without writing an own CA?
Thanks in advance!
XmlConfig and/or XmlFile elements are your friends here.
UPDATE: Well, according to the comments below, it turns out that only part of the attribute (or element) value should be changed. This seems not to be supported by either of two referenced elements.
I would take one of the two approaches then:
Use third-party "read XML" actions, like this one
It's better than creating your own because you can rely on deeper testing in this case
Teach your build script to control the string pattern
Let's say you put `net.tcp://localhost/XYZ` to build file and your code is pointed out to take this value as a string pattern to use at install time. For instance, keep the string pattern as a Property in your MSI package. When it changes, e.g. to `net.tcp://localhost/ABC` you'll have to change nothing in your action. In this case from a XMLFile perspective you always know your FROM and TO attribute values.
If your XML configuration file is not large, you can load the file into memory and perform replace using JScript.
var s = "<endpoint address=\"net.tcp://localhost/XYZ\" .../>";
var re = /"net.tcp:\/\/localhost\//g;
var r = s.replace(re, "\"http://newhost.com/");
Here s is your complete XML file, re is the regular expression, and r would contain the result or replace.
You can read and write to public properties of Windows Installer using JScript. Yet there's still one problem: you have to read your XML file and to write it back to disk. To do it, you can use Win32_ReadFile and Win32_WriteFile custom actions from the AppSecInc. MSI Extensions library referenced by Yan in his answer.
However, it could be easier to write a complete Custom Action which will load your XML configuration file, do the replace, and write the file back to disk. To do it you can use XSLT and JScript (see an example code).
InstallShield has a built-in data driven custom action called Text Search. It basically allows for RegEx style replacements like what you are describing.
WiX doesn't have this functionality but you could write a custom action ( say using C#/DTF ) to do it for you.
There nothing in Wix, you can do to change something in a file without using a custom action. If you don't want to use CA, you can consider saving the settings in some other place e.g. User's registry and always read that setting from there

Resources