Covert a document with Qualified elements to Unqualified Elements

Hi,

What kind of XML jugglery will permit me to covert a XML Document with 
"Qualified" elements into an XML document without Qualified Elements.

eg: The source document is something like

<ns0:baseelement xmlns:"http://schemas.myorg.com/solutions/yabadaba">
    <ns0:record1>
        <ns0:nelement1>value</ns0:nelement1>
        ...
        ...
    </ns0:record1>
    ...
    ...
</ns0:baseelement>

to something like

<baseelement xmlns:"http://schemas.myorg.com/solutions/yabadaba">
    <record1>
        <nelement1>value</nelement1>
        ...
        ...
    <record1>
    ...
    ...
</baseelement>

Regards,
Ravi Shankar
0
3/9/2008 5:56:00 AM
dotnet.xml 7266 articles. 0 followers. Follow

5 Replies
1110 Views

Similar Articles

[PageSpeed] 22

Ravi Shankar wrote:

> What kind of XML jugglery will permit me to covert a XML Document with 
> "Qualified" elements into an XML document without Qualified Elements.
> 
> eg: The source document is something like
> 
> <ns0:baseelement xmlns:"http://schemas.myorg.com/solutions/yabadaba">
                    ^^^^^^^
That is not proper XML syntax, I think you want 
xmlns:ns0="http://schemas.myorg.com/solutions/yabadaba".

>     <ns0:record1>
>         <ns0:nelement1>value</ns0:nelement1>
>         ...
>         ...
>     </ns0:record1>
>     ...
>     ...
> </ns0:baseelement>
> 
> to something like
> 
> <baseelement xmlns:"http://schemas.myorg.com/solutions/yabadaba">
                ^^^^^^^
That isn't proper XML syntax either. I think you want 
xmlns="http://schemas.myorg.com/solutions/yabadaba".

>     <record1>
>         <nelement1>value</nelement1>
>         ...
>         ...
>     <record1>
>     ...
>     ...
> </baseelement>

An XSLT stylesheet could do the job:

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">

   <xsl:template match="*">
     <xsl:element name="{local-name()}" namespace="{namespace-uri()}">
       <xsl:apply-templates select="@* | node()"/>
     </xsl:element>
   </xsl:template>

   <xsl:template match="@* | text() | comment() | processing-instruction()">
     <xsl:copy/>
   </xsl:template>

</xsl:stylesheet>


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
3/9/2008 12:03:45 PM
Ravi Shankar wrote:

> What kind of XML jugglery will permit me to covert a XML Document with 
> "Qualified" elements into an XML document without Qualified Elements.

Here is how you could solve that with LINQ to XML in the .NET framework 3.5:

             XDocument doc = XDocument.Load(@"XMLFile1.xml");
             foreach (XAttribute att in 
doc.Descendants().Attributes().Where(a => a.Name.Namespace == 
XNamespace.Xmlns).ToList())
             {
                 att.Remove();
             }
             doc.Save(@"XMLFile2.xml");



-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
3/9/2008 3:00:56 PM
Hello Martin,

Thank you for the quick response.
The output I've mentioned I get as a result of XML De-serialization.

I've a schema for which I used XSD to generate classes and compiled them 
into a DLL. In BizTalk I then use the schea to define a message and use the 
classes to help me manipulate various components of the message within the 
BizTalk orchestration...

Now I ran into a situation where I need to pass this deserialized object as 
a parameter to a ASP.Net WebService and get the response back which was not 
working and while debugging I found that while I had a quialified element 
message I needed to generate a message which has unqualified elements.

Your response with XSL is an option I could possibly use within an external 
..Net component I could call from the orchestration as a helper function.

Thanks & Regards, 
Ravi Shankar


"Martin Honnen" wrote:

> Ravi Shankar wrote:
> 
> > What kind of XML jugglery will permit me to covert a XML Document with 
> > "Qualified" elements into an XML document without Qualified Elements.
> > 
> > eg: The source document is something like
> > 
> > <ns0:baseelement xmlns:"http://schemas.myorg.com/solutions/yabadaba">
>                     ^^^^^^^
> That is not proper XML syntax, I think you want 
> xmlns:ns0="http://schemas.myorg.com/solutions/yabadaba".
> 
> >     <ns0:record1>
> >         <ns0:nelement1>value</ns0:nelement1>
> >         ...
> >         ...
> >     </ns0:record1>
> >     ...
> >     ...
> > </ns0:baseelement>
> > 
> > to something like
> > 
> > <baseelement xmlns:"http://schemas.myorg.com/solutions/yabadaba">
>                 ^^^^^^^
> That isn't proper XML syntax either. I think you want 
> xmlns="http://schemas.myorg.com/solutions/yabadaba".
> 
> >     <record1>
> >         <nelement1>value</nelement1>
> >         ...
> >         ...
> >     <record1>
> >     ...
> >     ...
> > </baseelement>
> 
> An XSLT stylesheet could do the job:
> 
> <xsl:stylesheet
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    version="1.0">
> 
>    <xsl:template match="*">
>      <xsl:element name="{local-name()}" namespace="{namespace-uri()}">
>        <xsl:apply-templates select="@* | node()"/>
>      </xsl:element>
>    </xsl:template>
> 
>    <xsl:template match="@* | text() | comment() | processing-instruction()">
>      <xsl:copy/>
>    </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 
0
3/9/2008 5:25:00 PM
Ravi Shankar wrote:

> I've a schema for which I used XSD to generate classes and compiled them 
> into a DLL. In BizTalk I then use the schea to define a message and use the 
> classes to help me manipulate various components of the message within the 
> BizTalk orchestration...
> 
> Now I ran into a situation where I need to pass this deserialized object as 
> a parameter to a ASP.Net WebService and get the response back which was not 
> working and while debugging I found that while I had a quialified element 
> message I needed to generate a message which has unqualified elements.

Whether an element is marked up as
   <foo xmlns="http://example.com/2008/ex1"></foo>
or as
   <pf1:foo xmlns:pf1="http://example.com/2008/ex1"></pf1:foo>
should not matter to a web service.

As you are using XML serialization/deserialization you might also want 
to have a look at 
<URL:http://msdn2.microsoft.com/en-us/library/ms163161.aspx> as there 
you can provide a third parameter mapping namespace URIs to prefixes.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
3/9/2008 5:36:55 PM
Hi Martin,

Thank you for the reference.
The problem has been resolved. The schema that we were working with has 
basic definition  issues. Once we sorted those out, the resultant classes 
generated by XSD worked fine.

I cannot control the serialization/deserialization as this is done by the 
SOAP adapter that comes with BizTalk.. All I can ensure is that the message 
is passed with correct data.

Thanks & Regards,
-- 
Ravi Shankar


"Martin Honnen" wrote:

> Ravi Shankar wrote:
> 
> > I've a schema for which I used XSD to generate classes and compiled them 
> > into a DLL. In BizTalk I then use the schea to define a message and use the 
> > classes to help me manipulate various components of the message within the 
> > BizTalk orchestration...
> > 
> > Now I ran into a situation where I need to pass this deserialized object as 
> > a parameter to a ASP.Net WebService and get the response back which was not 
> > working and while debugging I found that while I had a quialified element 
> > message I needed to generate a message which has unqualified elements.
> 
> Whether an element is marked up as
>    <foo xmlns="http://example.com/2008/ex1"></foo>
> or as
>    <pf1:foo xmlns:pf1="http://example.com/2008/ex1"></pf1:foo>
> should not matter to a web service.
> 
> As you are using XML serialization/deserialization you might also want 
> to have a look at 
> <URL:http://msdn2.microsoft.com/en-us/library/ms163161.aspx> as there 
> you can provide a third parameter mapping namespace URIs to prefixes.
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 
0
3/13/2008 7:48:00 AM
Reply:

Similar Artilces:

Copy and Paste from One Document to another without changing forma
Everytime I copy and paste from one publisher 2003 document to another the formats change after I paste it to a new document. Then I need to go to the new document and change all the formats for each text box so it includes all of the text in the original tex box. It defaults to something other then what was pasted from the original document. How can I change it keep the same as what I originaly copied dltgng wrote: > Everytime I copy and paste from one publisher 2003 document to another the > formats change after I paste it to a new document. Then I need to go to the > new do...

Document Map
I have Outlook 2002 w/ Windows XP. Anytime that I hit reply to a message that has come up the Document Map opens. Is there a way to disable this feature? I am running a network and I dont have this problem on any of the other machines. I dont want the doucment map to open automatically upon reply. It will only do it to emails that have a plain text format, none of the HTML formated ones have this problem. Have you tried to delete the document map within the styles and formatting menu? >-----Original Message----- >I have Outlook 2002 w/ Windows XP. Anytime that I hit >...

Document Tracking
Dear all Is it possible to track when a workbook is opened ... how man times...? how long... when... etc... without the one opening th workbook knowing that this tracking is happening...? could we get al these info in a txt file created which the user is unaware...? cheer -- Message posted from http://www.ExcelForum.com "hce >" <<hce.14jkvn@excelforum-nospam.com> wrote in message news:hce.14jkvn@excelforum-nospam.com... > Dear all > > Is it possible to track when a workbook is opened ... how many > times...? how long... when... etc... without the one open...

Documentation on Creating Front End / Back End???
Hello I was wondering if MS (or any other resource) has online documentation on setting up an Exchange structure with a Front end server and 2 back end servers. I have seen information from different sites and pieced things together but I was hoping for a complete scenario document or how to document to verify that I haven't missed any steps. Thanks TKE402 On Wed, 10 Aug 2005 06:56:03 -0700, tke402 <tke402@discussions.microsoft.com> wrote: >Hello I was wondering if MS (or any other resource) has online documentation >on setting up an Exchange structure with a Front end...

Forms and Documents
Hello, Newsgroupians: Again, I'm veering away from dialog-based applications, and I am entering the realm of documents and views. However, I'm a little confused with some details, and I'm wondering if I could receive some help. First, I am creating a SDI. I have a class derived from CFromView called CMyView. It is related to the document CMyDoc, which is, of course, derived from CDocument. Now, I've added a member variable called m_pView to the CMyDoc, which is a pointer to the "view" that is associated with the document. Where is the best location to ini...

Typing in Greek on a Word document
How do I type in Greek on a Word document? I have XP and Word 2002. I have also downloaded Microsoft Visual Keyboard. Even though I see references to Greek in the help area, none of them seem to apply to my version of Word. When I go to help > language, the only option that I see is set language, but that doesn't seem to be what I'm looking for. Thanks m78 wrote: > How do I type in Greek on a Word document? I have XP and Word 2002. I have > also downloaded Microsoft Visual Keyboard. Even though I see references to > Greek in the help area, none of t...

MSXML2 to Load xml document using ISO-8859-1 encoding
HI My application connects to the UPS server which returns an ISO-8859-1 encoded XML response. I need a part of this response, ie. the AccessLicenseAgreement , which i need to display in my application and then return to the UPS server with the next request. Their server matches what they sent me with what i return back to them. Due to the difference in the encoding method it returns an Invalid AccessLicenseAgreement error back to me. I set my request Processing Instruction to ISO-8859-1 encoding, but i still get the same error from them. I am guessing the problem is when i read it in using Lo...

Paste Special and Lotus Notes document link
When you use the Paste Special command on the Edit menu to paste a Lotus Notes document link into Microsoft Excel, and you click to select the Paste Link and the Display As Icon check boxes in the Paste Special dialog box, a blank rectangle rather than an icon is pasted onto the spreadsheet, and you cannot active the document link by double-clicking it ... This actually worked for me -- once -- but it doesn't work now. Any workaround ??? ...

unlock document
how do you unlock a modified document, that was already stored to your computer. I can not got back into the document and make changes. If you are seeing a message in the status bar that says “This modification is not allowed because the document is locked,” and if this is Word 2007, then most likely it is a trial version that has expired. If you're getting the error message in Word 2003, or if this is an activated retail copy of Word 2007, see http://support.microsoft.com/default.aspx?SCID=kb;en-us;818852 -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type ...

Make Publisher open with my standard document
I'm tired of having to dig through all the templates to find an 8.5 x 11 document template! I am a home user and everything I do is based on 8.5 x 11 paper. Is it possible to make Publisher open DIRECTLY to this choice and not open to the Getting Started with Microsoft Publisher 2007 template list? Thanks a million! K When I start Publisher it opens to a blank 8�"x11" worksheet. I use Publisher 2000 but the following my solve your puzzle. Start Publisher Select Tools Options Uncheck "Use catalog at startup." -- Don - Publisher 2000� ...

how do I delete a deleted file from the list of documents?
I deleted the file but the name still appears in the list of documents See http://www.gmayor.com/clear_recently_used_file_list.htm. -- Stefan Blom Microsoft Word MVP "Bugsey" <Bugsey@discussions.microsoft.com> wrote in message news:4E34619A-A528-4887-A9B7-0E5CD3759A54@microsoft.com... >I deleted the file but the name still appears in the list of documents > Hi, To remove files that no longer exist from the list in Word 2007, click the Office Button, click Word Options, click Advanced, go about half-way down the list of options, set the n...

How do I insert a WORD document with footnotes in a PUBLISHER fil.
We print a non-profit newsletter in PUBLISHER. Frequently, we receive legal articles in WORD format for the news letter. Many of these WORD documents contain footnotes that appear at the end of the document. When the WORD document is inserted not the PUBLISHER file, all of the footnotes are lost. The, each footnote must be retyped inot the PUBLISHER file. Any suggetions? Thanks in advance. Microsoft Publisher doesn't support footnotes. You will have to recreate them manually. And if it were me doing that - I'd get used to Ctrl-C and Ctrl-V. -- JoAnn Paules MVP Micros...

Messages routing Document/View/MainFrame/Application
Can you tell me if the message routing on Windows CE is the same of Win32(win XP) Can you send a good link about the message routing Thank's Marc In article <#SdOLZEREHA.3660@tk2msftngp13.phx.gbl>, marc__lefebvre_pub_NOSPAM@hotmail.com says... > Can you tell me if the message routing on Windows CE is the same of > Win32(win XP) No, nobody can tell you -- not with certainty anyway. MS distributes the CE Platform Builder, which allows an individual vendor to "adjust" CE to fit the application(s) they support. This makes it difficult to say anything about ...

Merging Protected word documents.
I have 3 Protected word documents that I would like to have in 1 document. I cannot get them to keep their individual spacing ad margins when I import the documents. How can I do this? ...

How Do I Copy A List Of Filenames Into A Word Document?
I have a list of filenames in a directory and I wish to copy and paste the names of the files only into a WORD document. How do I go about this task? See the freeware Printfolders utility that you can download from my web site. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> &q...

XSD/Schema: Who do I set a default for a date-type element?
If I specify a default value in an .xsd-File like this ... <xs:element name="element1" type="xs:dateTime" minOccurs="0" default="2004-02-10T00:00:00.0000000+01:00" /> .... and try to build a dataset with xsd /d Dataset.xsd, i receive an "value doesn't fit the datatype" error. I tried already formats like "2001-01-01" or "2000/01/01" with the same result. Does someone know the right format? This is my original file: <?xml version="1.0" encoding="utf-8" ?> <xs:schema id="Dataset1...

Variable IMAGE in document header
Hi, I hava a one-page 2 week calendar in Excel which I print out, it show the week numers, festvities, school vacation dates and whatever els you want to put into it. The print macro allows me to choose how many two-week sheets I want Let's say I can have it print the current week and next week on on page, the next page starts 14 days after the current week. Has anybody experimented in any manner to have excel choose a differen image file in the page header automatically> I would like to have i choose a diffrenet image for each output. Any ideas? Thanks, Hans:confused -- hhall M...

Documents in Public Folders
Can you post documents in public folders? If so, what type of folder do I need to create in order to post word docs, excel sheets, etc? -- Thank you! Just a regular folder for messages, then you can just drag & drop the file right into the public folder without having to create a seperate post and then put the file/attachment. "Michael" <Michael@discussions.microsoft.com> wrote in message news:FDE9D90F-8772-4A45-82E3-8179AEB7D761@microsoft.com... > Can you post documents in public folders? If so, what type of folder do I > need to create in order to post word...

Print three copies and send end of document for crystal reports
I am looking for a tool that will allow me to send a code from crystal that says print the page 3 times and then send an end of document so the printer will print three copies and then staple. The report will generate multiple work orders but before the next work order number I want it to print 3 copies and send an end of document to the printer so it will print the three pages and then staple. Crystal wants to send an end of document either per page or per report. Is this something anyone has come across or can do? Well, one way to accomplish this would be to send one document with t...

link to another document of Excel 2003
I want to insert a link in a cell of worksheet A in workbook A to a cell in worksheet B in workbook B which contains worksheets A-D. I can only link to workbook B and cannot link to worksheet B. Thanks -- eva cheng It would be useful if you showed us the formula you were using. In general, you want the following syntax: =[BookB]SheetB!$A$1 Regards, Fred "eva cheng" <evacheng@discussions.microsoft.com> wrote in message news:734EB356-653C-49F8-A954-FA2756781667@microsoft.com... >I want to insert a link in a cell of worksheet A in workbook A to a cel...

Connection error on Document Load
I am calling XmlDocument.Load with a url string, but get the message "The underlying connection was closed: Unable to connect to the remote server." When I put the exact same URL in IE, the xml file comes up just fine. Also, we only get this error when running from some machines, not all. Does anyone know what is wrong? Thanks. I was getting the same kind of error using XmlTextReader with a url string. Check out the following: http://support.microsoft.com/?kbid=888527 and look at the section on Undocumented bugs in the .NET Class Library (NCL). Also, google the term: useU...

can you use voice narration in a word document or just in powerpoi
I know I can use voice narration in powerpoint but I am trying to figure out if you could use it to explain a word document. ...

Format Xml Document in VS2005
On advice of Stan Kitsis on this forum, I was able to format in VS an XML document by Selecting Edit / Advanced / Format document. It worked. But now I am attempting to do the same thing again, with the same xml document, and the format command is no longer on the list. When I press Ctrl-K, Ctrl-D, a message on the status bar says "The key combination (Ctrl+K, Ctrl+D is bound to command (Format Document) which is not currently available." So how do I cause that command to be available again? Thanks, Randy Neall Forget it. I had forgotten I was in a debugging session at the time...

I can no longer see the pictures in a Publisher document?
I have created a publisher document with many images. Now when I open the file no images can be seen. If I convert the file to PDF the images are again visible. If >view, pictures, detailed display isn't solving this... Slide the acceleration down on your adapter, control panel, display folder, settings tab, advanced button, troubleshoot tab, If this is your solution you need to go to the web site of your video card and look around for an upgraded driver. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Phil Elliott&qu...

Recent documents don't display
Recent documents work in Word but not in Excel. Not grayed out, but simply does not show any. -- Dana Go to Office Button- Go to Excel Options-Advanced, then go down to “Display” In the first line “Show this number of Recent Documents” check the number & modify as you like. -- MFS22 "danappofc" wrote: > Recent documents work in Word but not in Excel. Not grayed out, but simply > does not show any. > -- > Dana Documents that you opened by double-clicking their icon will not show in the list. Only those that you opened from within Ex...