Profilo di Ashish"Getting better never st...FotoBlogElenchiAltro ![]() | Guida |
"Getting better never stops" - Sachin Tendulkar22 novembre Software engineer and the social serviceI have been working as a .NET developer for quite some time now. I always wanted to be a doctor. I thought that is the most nobel profession you can ever have. Because when your loved one is sick you look up to that doctor after you pray to the god. So, if you are a doctor, you have the best opportunity to serve the human kind and the society. Now I could not be a doctor of course :-). Recently I heard Jeffery Ritcher saying that he wanted to write books because he thinks that when he write books/articles, he is helping people. Because he runs into people who say that they got a job when they read his book and they learnt how garbage collector works. So, he feels incredibly awesome that because of his book, somebody got a job and could support family and children and he helped in that. He also comes across some people who say that this software which is running in this hospital, they learnt how to work with virtual memory from his book and they put that in that software and that makes him feel that he is making a massive impact to the society with this little contribution to the hospital helping people's lives. He says that this is the reason he writes books because he is helping the world to be a better place. What a nobel thought and no doubt why he is a hero many developers like me! Now we all know that we all can't be a Jeffery Ritcher. But It gets to me this thinking that you can serve society this way (or can think some other ways), something which I never thought of. hmmm... 02 ottobre Difference between RPC and Document-Centric/Message Oriented applicationWith Document/Literal encoding/ Message oriented application, the payload of a message is an XML fragment that can be validated against the corresponding XML schema, for instance: <?xml version="1.0" encoding="UTF-8"?> RPC (remote procedure call)/Literal more closely corresponds to remote procedure invocations. <?xml version="1.0" encoding="UTF-8"?> One important difference between RPC and Document web services is that with RPC web services, XML schema will only be created for complex type parameters. It is thus not possible to validate the entire XML fragment contained in the SOAP body. 20 settembre SQL Server –Error - The FOR XML clause is not allowed in a INSERT statement. - Returning the result of a FOR XML, ELEMENTS in a dynamic query to a variableProblem :- When you try to execute a dynamic query having the FOR XML AUTO like this (ignore the query itself for now, you can find the complete script at the end of this article):- DECLARE @Data2 TABLE(col xml) You get an error like the following "The FOR XML clause is not allowed in a INSERT statement.” From http://msdn.microsoft.com/en-us/library/aa226520(SQL.80).aspx:- The above is applicable for SQL server 2005 as well. Very annoying… However, if you have something like below, the query would get executed successfully:- SELECT @Query= 'SELECT ( SELECT Customer.CustomerID,Address.FullAddress,Phone.PhoneNumberFROM #tempCustomer Customer JOIN #tempAddress Address ON Address.CustomerID= Customer.CustomerID JOIN #tempPhone Phone ON Phone.CustomerID= Customer.CustomerID FOR XML AUTO, ELEMENTS ) '
Notice that I prefixed the query with ‘SELECT(‘ and suffixed it with ‘)’. This would allow the query to execute but to return the data in text format rather than XML. However, you can have the result stored in a column of XML data type of a temporary table/variable and It would appear as if the result was XML. So we need to stuff the prefix and then the suffix in the query. Here is where the STUFF function would come to rescue. It is different from REPLACE function as it allows you to replace a specific instance of a character for a length. The complete query :- (Just run it) /* Temporary table to hold sample data. Forgive me for not using the table variable as they would be out of scope when I would use them in the dynamic query*/
if OBJECT_ID('tempdb..#tempPhone') is not null /* Insert sample data*/ /* Build the dynamic query*/ /* There can be many 'SELECT' in the query, we need to get the last one as that would be the one 19 settembre Procrastination
The problem This is how I try to overcome this?
06 settembre Programmatically showing only the custom styles in the style pane of a Word 2007 file
The project in which I working nowadays is a content authoring and management system and makes extensive use of Word 2007. The system has two parts in context of the problem I am going to discuss about – One part where the Admin uploads a Word 2003 (.doc) file containing all the custom styles created in there into the system. Let us call this file as a word template. The second part is where the user uploads his own content files Word 2003 (.doc) files in the system. When the user uploads the content in the system, the styles from the word template gets into the to the uploaded content file (more on this later). This facilitated the styles being introduced in the system only once (or whenever the Admin wants) using the template and the same styles getting used in all the content files without having the user to recreate them in each content file. This also offered the consistency in the styles used in the content files used in the system. Problem :- When the user uploads the content and then later opens the content for editing, he was seeing the inbuilt styles as well and they wanted only the custom styles and “Clear Formatting” option to be seen in the content file. Silly , isn’t it. But this is was requirement.:-) Just to make sure we we are all clear on what an in-built and what a custom style is :-
Open Word 2003 and choose Format > Styles and Formatting and what ever styles you see in the style pane are all in-built styles. And you can create a new style by clicking on the “New Style” button. I created one “MyCustomStyle”. So this is the custom style in my file. I need to take the attention back to my following line which I mentioned earlier :- “When the user uploads the content in the system, the styles from the word template gets into the to the uploaded content file (more on this later). “ The way we do this is following :- 1. Convert the template word 2003 file to word 2007 format using a third party component named “Aspose.Words.dll” (www.aspose.com) Just in case you are not aware, a Word 2007 file is an archive/zip file. You can rename any Word file (.docx) to zip file and extracts its contents as if it was a Zip file. When you look into the contents of that zip file, you will see each component of the word 2007 being represented by a file. Read about this here. All the above four steps happen while the user attempts to open the file and when the file was ultimately opened, he sees the inbuilt styles as well along with the custom styles which is the problem. When I started looking into the problem(an you, dear reader must have realized by now for sure), it seemed that user can always filter the custom styles:- However, this is exactly what the users of the application did not want to do. So the effort of convincing them was in vain. So, first I started looking at if Aspose.Words.dll offers any API to change the filter to show only the custom styles in the word 2003 file, when we convert the content 2007 file back to 2003. It turns out that It does not and a request for incorporating that change would take months. I started looking at any other commercial product which would do a better job than Aspose and even the using Office Migration Utility(OFC) and wordconv.exe (comes with the Office compatibility pack). Those did not help either. So then I looked at if we can find something in the files in the content word 2007 archive itself. There must be something in that archive which is telling Microsoft Word 2007 which types of styles to show in the style pane. I came across an article at http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.stylepaneformatfilter(office.14).aspxWhich states that For this , the w:stylePaneFormatFilter element in the settings.xml of the docx file can have the following values:- To test this, I created a new file in Word 2007 and created a new style named “MyCustomStyle” in it. Then I rename that .docx file to .zip and then unzipped the same:- and extracted and navigate to Word folder to see the Settings.xml:- Opened that file and see the following structure :- I added the following node right under the root of the xml:- Updated the zip file and renamed the zip file back to docx and opened the docx file and saw only my custom style and “Clear All”! |
||||||
|
|
|||||
|
|