Web Deploy parameterization of an XML config file where settings are embedded in CDATA elements - msdeploy

During MSDEPLOY.EXE deployment, I am trying to squirt a parameter into an XML configuration file but the configuration values are stored in CDATA elements. Here are the contents of the file, called paths.xml:
<?xml version="1.0" encoding="UTF-8"?>
<course>
<questionnaires><![CDATA[https://www.site.com/somepage.asp]]></questionnaires>
</course>
I need to transform that URL into something different, but I can't figure out the correct XPATH and syntax for my parameters.xml file, here is what I've got now:
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<parameter name="QuestPath" description="Questionnaires path" defaultValue="<questionnaires><![CDATA[https://www.foo.com/somepage.asp]]></questionnaires>" tags="">
<parameterEntry kind="XmlFile" scope="paths.xml$" match="/course/questionnaires" />
</parameter>
</parameters>
I had very little luck referencing the CDATA element to replace it, so you can see I'm now trying to replace the entire questionnaire element including its CDATA contents. I had to do some escaping of the embedded angle-brackets so parameters.xml wasn't rejected due to invalid XML format.
Now, the resultant paths.xml ends up like:
<?xml version="1.0" encoding="UTF-8"?>
<course>
<questionnaires>https://www.foo.com/somepage.asp</questionnaires>
</course>
So, something has resolved the CDATA element down to its contents only, and CDATA no longer appears in paths.xml which I assume will cause the program that reads it to fail. Help!

Okay - I found a much simpler solution. In conjunction with the developer involved in housing this config XML file on our server, we changed it so the elements just contain the raw URLs, completely dispensing with the CDATA structures.
After testing that the consuming application still appeared to work fine, we agreed they were not needed and therefore I was able to do normal XmlFile replacements on nodes referenced like:
...match="/course/questionnaires/text()"

Related

What is the 'hash' value used for in an App_Code.compiled file?

I'm poking around in an App_Code.compiled file that was generated when i published my website. It looks something like:
<?xml version="1.0" encoding="utf-8"?>
<preserve resultType="6" virtualPath="/ProjectFolderName/App_Code/" hash="5b4133b" filehash="" flags="140000" assembly="App_Code" />
I'm wondering what the value for hash is used for?
The hash value is used to disambiguate the file name, so the page can be compared to past compilations and inspected for changes.
'hash' is used to check the current page for changes, whereas 'filehash' is used to check any source files the page depends on.

Translation file still working after modifying the source?

A part of my .ts file, created with pylupdate4, looks like:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
<name>Main</name>
<message>
<location filename="Main.py" line="2369"/>
<source>Translate me to Ukululu</source>
<translation type="unfinished"></translation>
</message>
Two questions:
1: The translation comes between the <translation>-tags, right?
2: The translation seems to need the line in the main file where the translation is to be inserted ("line=2369"). But everytime I modify the code, the lines change. Hence, do I have to create a new translation file, where I have to manually insert all the (unchanged) translations between the tags again? This seems like a crazy amount of work. Correct me if I am wrong or please explain, how it works (better)!
You are right. The original text comes in the tag <source> while the translation comes in the tag <translation>. When the translation is finished the attribute type="unfinished" will also be removed.
Usually you don't edit ts files manually but you use the QtLinguist tool. I never edit them by hand, since QtLinguist is very easy to use...
In any case, when you change the source code, you simply run
pylupdate4 your_project.pro
This will update all the references to the lines in the ts file, and it will keep the translation already finished. It is smart enough to update the translations even if you move them to a different source file.
You can get further information here
http://pyqt.sourceforge.net/Docs/PyQt4/i18n.html
http://qt-project.org/doc/qt-4.8/linguist-manager.html
Hope this helps

css select xml value and print

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="tibu.css"?>
<THREADS>
<thread address="0011">
<sms msgBox="inbox" date="2012-10-30T06:49:36.529Z" locked="false" seen="true" read="true" serviceCenter="121212" address="0011" encoding="plain">aaaa</sms>
</thread>
<thread address="0123">
<sms msgBox="inbox" date="2012-10-30T06:49:36.529Z" locked="false" seen="true" read="true" serviceCenter="121212" address="0123" encoding="plain">Bugbug</sms>
</thread>
</THREADS>
Is it possible to select the date value and then print it?
If "yes" how can i do it?
I don't think CSS can do this, or if it can it isn't the best tool for the job
Take a look at XSL Transformations
XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML. Normally XSLT does this by transforming each XML element into an (X)HTML element.
Very good resource and tutorials
http://www.w3schools.com/xsl/

How to localize App_GlobalResources in ASP.NET?

i have an ASP.NET website with some "global" resources:
\App_GlobalResources
ContosoFrobberResource.resx
This is in addition to the "local" resources associated with each "aspx" file:
\App_LocalResources
Materials.aspx.resx
Notes.aspx.resx
OrderHistory.aspx.resx
Now i want to localize the site into another locale (e.g. en). i create a resx file for each "local" resource:
\App_LocalResources
Materials.aspx.en.resx
Materials.aspx.en-us.resx
Materials.aspx.en-uk.resx
Materials.aspx.en-sg.resx
Notes.aspx.en.resx
Notes.aspx.en-us.resx
Notes.aspx.en-uk.resx
Notes.aspx.en-sg.resx
OrderHistory.aspx.en.resx
OrderHistory.aspx.en-us.resx
OrderHistory.aspx.en-uk.resx
OrderHistory.aspx.en-sg.resx
And that all works fine; the site displays tailored versions of English for
United States (en-US)
United Kingdom (en-UK)
Singapore (en-SG)
as well as a fallback for generic
English (en)
The problem comes when i try to localize the resources in App_GlobalResources:
\App_GlobalResources
ContosoFrobberResource.resx
ContosoFrobberResource.en-us.resx
The web-site crashes with the error:
CS0101: The namespace 'Resources' already contains a definition for 'ContosoFrobberResource'
How do i localize App_GlobalResources in an ASP.NET website?
Bonus Chatter
ContosoFrobberResource.resx
<?xml version="1.0" encoding="utf-8"?>
<root>
<data name="ProjectDueDate" xml:space="preserve">
<value>Proposal Due Date</value>
</data>
</root>
ContosoFrobberResource.qps.resx
<?xml version="1.0" encoding="utf-8"?>
<root>
<data name="ProjectDueDate" xml:space="preserve">
<value>Prȍposẳl Duɇ Dãtē</value>
</data>
</root>
Found the answer.
ASP.NET doesn't fallback properly to the parent language. If it cannot recognize the file as a "fallback" locale then it fails to parse it, and shows the misleading error.
e.g.
ContosoGrobber.resx
ContosoGrobber.en-us.resx
works fine. But:
ContosoGrobber.resx
ContosoGrobber.en.resx
fails when the "en" portion of the locale string isn't recognized. Changing it to use the full locale name, and avoid the buggy fallback code is the fix. e.g.:
ContosoGrobber.qps.resx
should become:
ContosoGrobber.qps-ploc.resx
In other words: if a browser is requesting locale qps-ploc, ideally you could use
ContosoGrobber.qps.resx
and the local qps-ploc will fallback to qps. But because of the bug in ASP.NET it doesn't fallback correctly. This means you cannot let it fallback; you have to actually handle all possible locales:
ContosoGrobber.qps-ploc.resx
ContosoGrobber.qps-plocm.resx
ContosoGrobber.qps-ploca.resx

insert new item in sharepoint list from flex

i m trying to insert new item on sharepoint list from flex using sharepoint-as3-connector (http://code.google.com/p/sharepoint-as3-connector). but i m getting following error.
Response XML:<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UpdateListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<UpdateListItemsResult>
<Results>
<Result ID="1,UpdateList.NEW">
<ErrorCode>0x8102000a</ErrorCode>
<ErrorText>Invalid URL Parameter
The URL provided contains an invalid Command or Value. Please check the URL again.
below is the header made in soap URL.
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>
TestList
</listName>
<updates>
<Batch OnError="Continue">
<Method ID="1" Cmd="UpdateList.NEW">
<Field Name="ows_LinkTitle">
222222
</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
please help!
The error message is spot on: you are specifying an invalid command in the Cmd attribute of the Method element.
Per the MSDN article for the Method element, valid values for Cmd are:
Delete
New
Update
I have no experience with the "sharepoint-as3-connector", and I suppose it's there to make your life easier. But it's probably worth reviewing the MSDN documentation for the Lists web service (and specifically the UpdateListItems method) so you know what SharePoint is expecting. SharePoint is a delicate flower that cannot be handled harshly; you must know exactly what it wants to keep it happy.
A good walkthrough on MSDN: How to: Update List Items.

Resources