[xsl] Confusing namespaces and xslt

Subject: [xsl] Confusing namespaces and xslt
From: "Paul Ferwerda" <pflists@xxxxxxxxx>
Date: Mon, 29 Sep 2008 14:36:42 -0400
I have a newbie question. I've gone round and around on this issue and
haven't been able to make any headway on my own. I suspect I'm missing
some basic understanding of how to use XPath expressions and how
namespaces are used. so I apologize in advance if the question is a
stupid one.

I need to handle the following xml and generate new xml that makes
some changes to some of the attributes;

<?xml version="1.0" encoding="UTF-8"?>
<box-client xmlns="somecompany.com/box/client"
xmlns:box="http://somecompany.com/box";>
 <name>theclient</name>
 <description>theclient</description>
 <network>
   <box:host>host.somecompany.com</box:host>
   <box:components>
     <box:component>
       <box:name>Ports</box:name>
       <box:port>7801</box:port>
     </box:component>
   </box:components>
 </network>
 <logging>
   <box:rotation-time>24</box:rotation-time>
   <box:file-severity>info</box:file-severity>
 </logging>
 <use-connections>false</use-connections>
 <work-managers>
   <box:work-manager>
     <box:name>WM</box:name>
     <box:description>WM</box:description>
   </box:work-manager>
   <box:work-manager>
     <box:name>ClientRuntime-WM</box:name>
     <box:description>ClientRuntime-WM</box:description>
   </box:work-manager>
 </work-managers>
</box-client>

I inherited the above xml and am unable to  change it so I have to
figure out how to process what I've got.

I need to create a new xml file with a changed value for the
box:rotation-time and I need to add a new
<box:manager>ClientConnections</box:manager> element.

If I understand things correctly, the above xml declares a
somecompany.com/box/client namespace and a http://somecompany.com/box
namespace. I believe that the items in thesomecompany.com/box/client
name space are defined in a client.xsd file and the box items are
defined in a box.xsd file. I don't know why a prefix wasn't used for
the first namespace but it wasn't.

I'm having trouble figuring what xslt/xpath to use to access the
box:rotation-time element and what xslt to use to add in a new
<box:work-manager> inside the <work-managers> element. I'm confused as
to which namesp

If I can figure out the correct namespace I think I can use a for-each
to iterate through the elements and replace the ones I need to replace
or add in the one I need to add it.

Thanks!

Current Thread