xmlns menace

following is the xml file which i pass to xsl created by me.

<?xml version="1.0" ?>
<a xmlns="http://blah.blah/blah">
      <name>again blah</name>

now if i dont put xmlns attribute in xml, xsl outputs the html
in desired format. but if i put it just simply displays the values
of xml elements..
so my question is that how do i make my xsl ignore that xmlns attribute of
root element of the xml file?? i have tried google for hrs , but
i dint get anything.. so please can somebody help with it??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
If you want to simply ignore the namespace (which probably isn't the best solution) then you can simply make your templates match on local-name(), something like:

<xsl:template match="*[local-name()='a']">
    <!-- Other stuff here -->

The better way to do it is to define an alias for the namespace in you xsl, something like:

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

        <xsl:template match="x:a">
            <xsl:value-of select="x:name" />


Hope this helps.
ghatlodiaAuthor Commented:
thanks a lot for your reply..
this is first time ,i am using xslt. now the solution  u gave me
will work.. but the thing is that xml file which  i am getting is from
web service and each time i get different segment of xml. what i mean is that
there is only one schema,but each time i will get different part of it. so for me the root
element of xml will vary each time. in that case , i dont know how to
implement your solution..
should i go for variable kind of thing or should i just write xsl for whole xml file
according to schema ??
i would really appreciate , if u could tell me that.

About following xml that u gave

<xsl:template match="*[local-name()='a']">
    <!-- Other stuff here -->

what should i put at "other stuff" ? sorry i dint get that.


Carl TawnSystems and Integration DeveloperCommented:
Thing thing with XSL is that it is a big pattern matching engine.  All you need to do is write templates to handle and nodes that you are interested in.  This is flexible because you can have templates for nodes that may or may not be in the XML.

How you format your XSL depends entirely on what you need to do.

Probably the best thing to do would be to, like you said, write an XSL based on the schema.  Once you're more comfortable with XSL you can always go back and rework it or remove the bits you don't need.

You can start by replacing <!-- Other stuff here --> with <xsl:apply-templates />.  This tells the parser to start processing all the child nodes of the current node (if that makes sense).

Hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ghatlodiaAuthor Commented:
 i tried the other solution that u suggested would be better. and it rocks now
i cant thank u enough, man..
again thanks a lot..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.