On Thu, 09 Apr 2009 07:41:28 -0700, test user <[email protected]> wrote:

Hi,

I need to add prefixes to all element nodes(parent and child elements)

*Input Xml:*

     <Repeater>
        <ItemTemplate>
             <Button>
             </Button>
        </ItemTemplate>
     </Repeater>

*Desired Output:*
**
      <asp:Repeater>
        <asp:ItemTemplate>
             <asp:Button>
             </asp:Button>
        </asp:ItemTemplate>
     </asp:Repeater>


Actually, I think your desired output is really
       <asp:Repeater xmlns:asp="http://asp";>
         <asp:ItemTemplate>
              <asp:Button>
              </asp:Button>
         </asp:ItemTemplate>
      </asp:Repeater>

I say this not to be pedantic but to make the point that
what you really want to do is change the names of all
your elements.  The way to do this is not to play games
with the prefix, but to perform a recursive transformation
of the node, e.g.

declare namespace asp="http://asp";;

declare function local:rename ($items as item()*) as item()*
{
    for $i in $items return typeswitch ($i)
    case $e as element() return
        element {fn:QName("http://asp",fn:local-name($e)}  {
             $e/@*, rename($e/node())
       }
    case document-node() return document { rename($i/node()) }
    default return $i
};


//Mary

[email protected]
Principal Engineer
Mark Logic Corporation
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to