Jump to content

namespace detection


Guest certest2

Recommended Posts

Guest certest2

Hi all,i have the xml like<?xml version="1.0" encoding="UTF-8"?><Payload> <ns1:AppHdr xmlns:ns1="urn:xsd:$ahV10"> <ns1:From> <ns1:Type>NAME</ns1:Type> <ns1:Id>PM</ns1:Id> </ns1:From> <ns1:MsgRef>void</ns1:MsgRef> <ns1:CrDate>2006-02-04T00:00:00.000+05:30</ns1:CrDate> </ns1:AppHdr></Payload>namespace name ns1 is not fix, but it's value is going to remain as same.i want to transform it another xml, how shld i proceed?

Link to comment
Share on other sites

You can select elements by their namespace URI, by using parenthesis before the element name, in which you write the namespace URI. For example:

{urn:xsd:$ahV10}AppHdr/{urn:xsd:$ahV10}From

I'm not sure if this is applicable on prefixed elements though. I know it works with default namespaces (xmlns="xs:anyURI", not xmlns:prefix="anyURI"), but never tryed it with prefixes.Btw, it's useless to have a prefix if it's going to change. Choose your prefixes wisely. As far as XSLT goes though, if you're making a stylesheet for handling data that's not yours, it is a good idea to know and use the above.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...