RE: [xsl] adding namespaces to result nodes

Subject: RE: [xsl] adding namespaces to result nodes
From: omprakash.v@xxxxxxxxxxxxx
Date: Fri, 8 Apr 2005 17:21:07 +0530
Hi,
        Since you popped the question "why do namespace prefixes matter so
much?", here's my answer:

Iam trying to add another view besides the existing plain text view and
tree view I have in an editor application Iam working on.  I thought html
tables presented a nice solution to my problem. I could render the html
such that the nodes and the text are rendered inline unlike the tree view
where you need 2 panes, one for the elements and another for the text.

However, in order to render my xml as a html table I have to transform the
same using XSLT. The problem is the user may change the contents in the new
view such as add/delete nodes, alter the text content etc. If so, I need to
be able to regenerate the original xml from the html ( XHTML) before
saving.

Iam not sure it would be acceptable to anyone if they gave a xml file
without prefixes and the html view added prefixes to the XML and gave it
back to them.

Iam welcome to any other suggestions in helping me achieve the same.

Hope this explains my problem.

Cheers,
Omprakash.V

























                                                                                                                                       
                      "Michael Kay"                                                                                                    
                      <mike@xxxxxxxxxx         To:      <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>                                              
                      om>                      cc:      (bcc: omprakash.v/Polaris)                                                     
                                               Subject: RE: [xsl] adding namespaces to result nodes                                    
                      04/08/2005 04:56                                                                                                 
                      PM                                                                                                               
                      Please respond                                                                                                   
                      to xsl-list                                                                                                      
                                                                                                                                       
                                                                                                                                       




>          Iam taking the text of an element in the input file
> and making it
> into an element. The element in question is named 'slideshow' and it
> doesn't have a prefix. You say
> "the processor may put the element in the default namespace, or it may
> invent a prefix"
> Does this mean the processor Iam using (xalan) is adding the
> prefix whereas
> another processor may not.

Yes. If you write

<xsl:element name="slideshow" namespace="http://some.uri/"/>

Then the processor may generate

<ns0:slideshow xmlns:ns0="http://some.uri/"/>

or

<slideshow xmlns="http://some.uri/"/>

- it's implementation-defined.

XSLT 2.0 has rules that make the generation of namespace prefixes slightly
more predictable, though there are still cases where the processor is
allowed to dream one up.

>
> Iam not tied to any processor and I may opt for another
> processor if this
> is the case other things permitting.

It's not a good idea to choose a processor because it happens to do what
you
want, when the language says that the behavior of your stylesheet is
unpredictable. Better to ask yourself some questions about the requirement
you are trying to satisfy - why do namespace prefixes matter so much?

Michael Kay
http://www.saxonica.com/





This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

Current Thread