What is the best way to change a namespace in an xml document

Hi,
I need to change an xml namespaces. The xml has about 200 elements and every element may have a namespace attribute (namespaces are all the same).
Is there any better solution then the following function?
SQL> create or replace function change_namespace(p_xml xmltype, p_namespace varchar2) return xmltype is
  2    l_doc dbms_xmldom.DOMDocument;
  3    l_nodes dbms_xmldom.DOMNodelist;
  4    l_node dbms_xmldom.DOMNode;
  5  begin
  6    l_doc:=dbms_xmldom.NewDOMDocument(p_xml);
  7    l_nodes:=dbms_xmldom.getElementsByTagName(l_doc,'*');
  8    for i in 0..dbms_xmldom.getlength(l_nodes)-1 loop
  9      l_node:=dbms_xmldom.item(l_nodes,i);
10      if i=0 then
11        --set namespace only for the root node
12        dbms_xmldom.setattribute(dbms_xmldom.makeElement(l_node),'xmlns',p_namespace);
13      else
14        --remove all the other namespaces
15        dbms_xmldom.removeattribute(dbms_xmldom.makeElement(l_node),'xmlns');
16      end if;
17    end loop;
18 
19    return dbms_xmldom.getxmltype(l_doc);
20  end;
21  /
Function created.
SQL> select change_namespace(xmltype('<a xmlns="aaa"><b xmlns="aaa">4</b><c>44</c></a>'),'newnamespace')
  2  from dual;
CHANGE_NAMESPACE(XMLTYPE('<AXMLNS="AAA"><BXMLNS="AAA">4</B><C>44</C></A>'),'NEWN
<a xmlns="newnamespace">                                                       
  <b>4</b>                                                                     
  <c>44</c>                                                                    
</a> Ants

Hi,
I found a better and almost 10x faster way to remove the namespaces, using xsl.
here's the original xsl with a little modifications http://bytes.com/forum/thread448445.html
SQL> with t as (select xmltype('<a xmlns="aaa"><b xmlns="aaa">4</b><c>44</c></a>') xcol from dual)
  2  select xmltransform(xcol
  3    ,xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  4               <xsl:template match="*">
  5                <xsl:element name="{local-name()}" namespace="">
  6                 <xsl:apply-templates select="@* | node()" />
  7                </xsl:element>
  8               </xsl:template>
  9              </xsl:stylesheet>'))
10  from t;
XMLTRANSFORM(XCOL,XMLTYPE('<XSL:STYLESHEETVERSION="1.0"XMLNS:XSL="HTTP://WWW.W3.
<a><b>4</b><c>44</c></a>+but check Laurents Schneider's blog website+
I didn't find any posts about namespace on Schneider's blog.
Ants

Similar Messages

  • What is the best way to create a database schema from XML

    What is the best way to create a database schema from XML?
    i have  a complex XML file that I want to create a database from and consistently import new XML files of the same schema type. Currently I have started off by mapping the XSD into Excel and using Mysql for Excel to push into MySQL.
    There must be a more .net microsoft solution for this but I cannot locate the topic and tools by searching. What are the best tools and way to manage this?
    Taking my C# further

    Hi Saythj,
    When mentioning "a database schema from XML", do you mean the
    XML Schema Collections? If that is what you mean, when trying to import XML files of the same schema type, you may take the below approach.
    Create an XML Schema Collection basing on your complex XML, you can find
    many generating tools online to do that.
    Create a Table with the above created schema typed XML column as below.
    CREATE TABLE youTable( Col1 int, Col2 xml (yourXMLSchemaCollection))
    Load your XML files and try to insert the xml content into the table above from C# or some other approaches. The XMLs that can't pass the validation fail inserting into that table.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • What is the best way to create Aperture book from Pages '09 document?

    What is the best way to create Aperture book from Pages '09 document?

    There is no way to import pages documents to Aperture and convert them to an Aperture book. Aperture books can only be created by manually adding images and text to the pages of a book, and using the layout of the predefined templates.
    The best you could do, would be to print your pages document to pdf and import the resulting pdf file into Aperture as a new project. This will create one image for each page. Then select the page images all at once and  create a new book. Select a theme with fullsize page images, like "picture Book", and then add the images of the pages to the empty pages of the book.
    But probably would you get a much better quality and layout, when you recreate your pages document in Aperture, by starting with an empty book and copying and pasting the text from your Pages document. But don't paste the photos from the document - try to use the originals of those photos.

  • What is the best way to change to color of the first word in a paragraph?

    I have a lot of paragraphs where I want the first word to keep the same font, size, type - but I want to change just the color of the lettering.

    p:first-child em {} is overqualifying that selector, I think. First, you do not need the :first-child pseudo element to target that first paragraph, since you already have that <em> tag surrounding that word. What's the point of adding in useless specificity? Second, it overcomplicates and bloats the code.
    I also feel <em> is the wrong tag to apply, depending on whether or not you would pronounce that word differently from the rest of the text. The use of em implies that. If it's merely used for styling, a <span> tag would fit better.
    So I would go with mytax's code. Simple, and efficient.
    Would be handy though if CSS had a :first-word pseudo element :-).
    In the meantime while we wait for improvements, if you DO need complete typographic control, try lettering.js (jquery plugin):
    http://letteringjs.com/
    Like this:
    <p class="word_split">Don't break my heart.</p>
    <script>
    $(document).ready(function() {
      $(".word_split").lettering('words');
    </script>
    And then:
    .word1 {} in your css would target "Don't"
    .word2 {} in your css would target "break"

  • What is the best way to change my account

    When I got my first mac back in 2003 I set my .me account up with my internet service provider. Now, if I move and disconnect from that provider what do I have to do as far as receiving my receipts and emails in iCloud?

    Your icloud account is independent of your provider.  I'm guessing that you used an "non-Apple" email address as the ID for that old account.  Is that right?
    Have you edited the account's info such as contact email address?
    To change your Apple ID go to http://appleid.apple.com and click 'Manage your Apple ID'.   Before you do this turn off location services and Find My iPhone/iPad/Mac on all devices.

  • What is the best way to change the flooring in an image keeping perspective?

    For example, I have an image of a lounge room and want to show a client different flooring options including tiles, floorboards. Key is keeping the perspective and being able to easily select and replace the floor. Thank you!

    A good cheat if you are not sure, is to find and download an image with the appropriate oerspective, and use that as a guide.   I usually do it by eye, start the Free Transform process, and hold down the Ctrl (Cmd) key while dragging corners, and release thwe Ctrl key if I want to resize.  This lets you do it all in one operation with minimum loss of quality, but it certainly helps to make the layer a Smart Object. 
    Actually, thinking about it, definitely make it a SO.  With a normal layer if you need to tweak the transform, the corner handles remain square to the image, and difficult to drag into place.  With an SO the corners will still be at the corners of the object regardless of its shape and orintation.
    But Chuck's idea of using Vanising Point is best if you have the information there in the image to shape the perspective to.
    Check this tutorial by the king of Photoshop for illustration, Steve Caplin
    https://www.video2brain.com/en/courses/creating-perspective-in-photoshop/details
    and this one
    https://www.video2brain.com/en/lessons/drawing-the-floor-and-wall
    One of these days I'll take out a V2B subscription long enough to watch the whole of this course.

  • HT5624 hello . my question is , if i want change my security answers , what is the best way to change it , i tried many time to sent email to restert my security answers , but nothing come to my email . can please help me . thank you .

    hello . i have problem that is i forget my security answers i tried to send it to email but nothing come . how can i slove this problem . please help my thank you .

    Alternatives for Help Resetting Security Questions and Rescue Mail
         1. Apple ID- All about Apple ID security questions.
         2. Rescue email address and how to reset Apple ID security questions
         3. Apple ID- Contacting Apple for help with Apple ID account security.
         4. Fill out and submit this form. Select the topic, Account Security.
         5.  Call Apple Customer Service: Contacting Apple for support in your
              country and ask to speak to Account Security.
    How to Manage your Apple ID: Manage My Apple ID

  • What's the best way to move around in a document?

    Maybe I'm missing something obvious here, but what's the best way to move around in a zoomed in document?
    The only method I've found so far is to drag with two fingers, which keeps resizing the document as it moves around.
    No Hand Tool? No way to zoom to 100%? No way to Fill the Screen with the document?
    Let me know, thanks.

    Hi,
    Panning is being done with two fingers, i.e. you set two fingers down on the screen and then move them in the same direction.
    You can also zoom out by moving the fingers in the opposite direction as when you zoomed in.
    Thanks,
    Ignacio

  • Best way to change fund posted in an EBS document

    What is the best way to change the fund in one line item in a document produced when the electronic bank statment is processed? The bank charges fees that come through the statement and should post to a different fund then any other item such as checks, etc.
    I am trying a substitution but coming across the error Field COBL-KOSTL. does not exist in the screen SAPLKACB 0002.

    The error message that I was receiving...Field COBL-KOSTL. does not exist in the screen SAPLKACB 0002, was coming from function module EXIT_RFEBBU10_001 and include ZXF01U01. The programming code was attempting to default a cost center when the external transaction code = 661. The coding was removed and the default acct assignment cost center was added to the cost element master data. The substitution also worked correctly as it should.

  • What is the best way to format a novel w headers  w/o changing the ...

    what is the best way to format a novel w headers w/o changing the following pages. I've used Microsoft office initially, but publishing house uses a program called word perfect. I find that I have too many blank white pages no matter what i do! Have to fix pagination as well...Paul

    When you start you are offered templates under 2 categories "Word Processing" and "Layout", choose wisely.
    For header and footers yes, you will have to:
    +Menu > Insert > Section break+ at the bottom of the last page of the section you wish to preserve.
    Then you can change the next section and the 2 will stay different.
    Please read the Pages09_UserGuide.pdf, you need to know a lot more than this if your novel is ever to hit the streets.
    Peter

  • What is the best way to have Mac setup for sync-ing 2 calendars?  Any way to change? When we 1st got our Macbook we unknowingly set it up wrong--as 2 separate users, with separate everything. Good for contacts and email, bad for calendar, photos, music.

    What is the best way to have Mac setup for sync-ing 2 calendars?  Any way to change?  When we first got our Macbook we unknowingly set it up as 2 separate users, with separate everything.  Now I have an iphone and I want to sync calendars but not contacts or email.  Any direction you could give would help! thx

    Anyone...anyone? Bueller...Bueller?

  • What's the best way to create and change local workstation account details?

    Hi,
    I need to change local password of an account on a number of our domain based machines. Or create the user if it doesn't exist.
    We have over 200 machines so this will need to be done as a bulk job.
    I've looked into doing this by GPO Preferences, but it appears that MS have removed this functionality with a hotfix.
    What's the best way of doing this now, as I would have through that this is a feature that most organisations would require.
    Thanks

    Hi,
    I understand you. However, based on my understanding, from the standpoint of security, Microsoft has chosen to deprecate this function, for it’s not secure to set passwords
    in Group Policy Preferences.
    The following article sheds more light on this topic and can be referred to for more information.
    Why Passwords in Group Policy Preference are VERY BAD
    http://www.grouppolicy.biz/2013/11/why-passwords-in-group-policy-preference-are-very-bad/
    Best regards,
    Frank Shen

  • What is the best way to edit photos and save changes across devices (without using iphoto)

    So I took allot of vacation photos with my iphone and created a photo stream so they can be viewed across devices. Some are dark and I would like to lighten them up and have the changes saved across devices. What is the best way? I originally tried saving all photos to my pc, editing them them, then syncing to all devices via my pc but, this creates 2 folders on my phone, the actual folder with said vacation name and a folder titled "photo gallery" with the exact same photo's. Not sure why it does that.
    Any suggestions?

    All photos transferred from your computer are saved in the iPhone's Photo Library. The photos in the album or albums below include a pointer only to the original photos stored in the Photo Library. The photos are not duplicated as in taking double the storage space.
    This way you can view the photos in an album only by selecting the album, or all photos in all albums by selecting Photo Library. The same applies if you transfer multiple albums or folders of photos, or a single album or folder.
    Similar to an iTunes playlist on your iPhone. You can listen to a playlist only by selecting the playlist, or listen to all songs by selecting Music. A song placed in a playlist is not duplicated as in taking up double the storage space.
    You can place the edits in the photo stream on your computer, or in the photo stream on your iPhone or other iOS device, and delete the originals in the photo stream prior to the editing.  

  • HT1349 I lost/had my iPhone stolen. Tried using Find My iPhone and it's offline. It was set up. What do I do now? Do I report it stolen? What is the best way in getting back my iPhone if any? Thank you in advance.

    Tried using Find My iPhone and it's offline. It (Find my iPhone) was set up. What do I do now? Do I report it stolen? What is the best way in getting back my iPhone if any? Thank you in advance.

    Find My iPhone is good for misplaced iPhone but not good for thief and it was never meant to be.
    You chance of getting it back is very small.
    There are a few things you can try.
    Try remote lock/wipe your iPhone through Find My iPhone.
    https://www.icloud.com
    You can report to the police, cell carrier (expensive cell charges for international calls, roaming etc)
    Change all the passwords used in iPhone: Apple ID, E-mail, Bank Account ....
    http://support.apple.com/kb/HT2526

  • What is the best way to read and manipulate large data in excel files and show them in Sharepoint

    Hi ,
    I have a large excel file that has 700,000 records in it. The excel file has a few columns that change every day.
    What is the best way to read the data form the excel file in fastest and most efficient way.
    2 nd Problem,
    I have one excel file that has many rows each row contain some data that has certain keywords.
    What I want is  to segregate the data of rows into respective sheets(tabs ) in the workbook.
    for example in rows have following data 
    1. Alfa
    2beta
    3 gama
    4beta
    5gama
    6gama
    7alfa
    in excel
    I want there to be 3 tabs now with each of the key words alfa beta and gamma.

    Hi,
    I don't really see any better options for SharePoint. SharePoint use other production called 'Office Web App' to allow users to view/edit Microsoft Office documents (word, excel etc.). But the web version of excel doesn't support that much records as well
    as there's size limitations (probably the default max size is 10MB).
    Regarding second problem, I think you need some custom solutions (like a SharePoint timer job/webpart ) to read and present data.
    However, if you can reduce the excel file records to something near 16k (which is supported rows in web version of excel) then you can use SharePoint Excel service to refresh data automatically in the excel file in SharePoint from some external sources.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

Maybe you are looking for