Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Unwanted xmlns attribute and how to put element name into element attribute
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pavol Misik  
View profile  
 More options May 26 2009, 1:45 am
Newsgroups: mozilla.dev.tech.xslt
From: Pavol Misik <pmi...@gmail.com>
Date: Tue, 26 May 2009 07:45:48 +0200
Local: Tues, May 26 2009 1:45 am
Subject: Unwanted xmlns attribute and how to put element name into element attribute
I want to transform xml to xul.

I have a following xml:

<?xml version="1.0"?>
<?xml-stylesheet href="XSLTFile1.xsl" type="text/xsl" title="default
stylesheet"?>
<setings>
   <applicationInfo>
     <node name="Vendor" value=""/>
     <node name="Name" value="Thunderbird"/>
     <node name="ID" value="{3550f703-e582-4d05-9a08-453d09bdfdc6}"/>
     <node name="Version" value="2.0.0.21"/>
     <node name="AppBuildID" value="2009030215"/>
     <node name="PlatformVersion" value="1.8.1.21"/>
     <node name="PlatformBuildID" value="2009030215"/>
   </applicationInfo>
   <accounts>
     <account key="account1">
       <incomingserver key="server1">
         <node name="type" value="none"/>
         <node name="prettyName" value="Local Folders"/>
         <node name="hostName" value="Local Folders"/>
       </incomingserver>
     </account>
     <account key="account2">
       <incomingserver key="server2">
         <node name="type" value="pop3"/>
         <node name="prettyName" value="aa@aa"/>
         <node name="hostName" value="aa"/>
       </incomingserver>
     </account>
   </accounts>
</setings>

and following xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
    <window id="export-window" title="Example"
            xmlns:html="http://www.w3.org/1999/xhtml"

xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
       <tree flex="1">
        <treecols>
             <treecol id="idName" label="Name" flex="1" primary="true"/>
             <treecol id="idValue" label="Value" flex="2"/>
        </treecols>

        <treechildren>
            <xsl:apply-templates/>
        </treechildren>
       </tree>
    </window>
</xsl:template>

   <xsl:template match="node">
     <treeitem>
       <treerow>
         <xsl:element name="treecell">
           <xsl:attribute name="label">
             <xsl:value-of select="@name"/>
           </xsl:attribute>
         </xsl:element>

         <xsl:element name="treecell">
           <xsl:attribute name="label">
             <xsl:value-of select="@value"/>
           </xsl:attribute>
         </xsl:element>
       </treerow>
     </treeitem>
   </xsl:template>

   <xsl:template match="account|incomingserver">
     <treeitem container="true" open="true">
       <treerow>
         <xsl:element name="treecell">
           <xsl:attribute name="label">
             <xsl:value-of select="@key"/>
           </xsl:attribute>
         </xsl:element>
       </treerow>
       <treechildren>
         <xsl:apply-templates/>
       </treechildren>
     </treeitem>
   </xsl:template>

   <xsl:template match="accounts">
     <treeitem container="true" open="true">
       <treerow>
         <treecell label="accounts"/>
       </treerow>
       <treechildren>
         <xsl:apply-templates/>
       </treechildren>
     </treeitem>
   </xsl:template>

   <xsl:template match="applicationInfo">
     <treeitem container="true" open="true">
       <treerow>
         <treecell label="applicationInfo"/>
       </treerow>
       <treechildren>
         <xsl:apply-templates/>
       </treechildren>
     </treeitem>
   </xsl:template>
</xsl:stylesheet>

Problem is that when is transformation I get unwanted xmlns attribute
for element applicationInfo and accounts

I get this:
<treeitem container="true" open="true" xmlns="">

1. How to ban to add this attribute to output xml?
2. Does it exist way how to get name of element that match template and
use it in template? I want to do something like I highlighted by   >>>
and <<<. I want to put name of element to attribute value.

   <xsl:template match="applicationInfo">
     <treeitem container="true" open="true">
       <treerow>
         <treecell label="  >>>applicationInfo<<<  "/>
       </treerow>
       <treechildren>
         <xsl:apply-templates/>
       </treechildren>
     </treeitem>
   </xsl:template>

thanks

PM-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options May 26 2009, 6:35 am
Newsgroups: mozilla.dev.tech.xslt
From: Martin Honnen <mahotr...@yahoo.de>
Date: Tue, 26 May 2009 12:35:57 +0200
Local: Tues, May 26 2009 6:35 am
Subject: Re: Unwanted xmlns attribute and how to put element name into element attribute

Pavol Misik wrote:
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" indent="yes"/>

> <xsl:template match="/">
>    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
>    <window id="export-window" title="Example"
>            xmlns:html="http://www.w3.org/1999/xhtml"

> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

Move those namespace declarations to the xsl:stylesheet root element if
you want them to be in scope for literal result elements in all templates:

   <xsl:stylesheet
     xmlns:xs="http://www.w3.org/1999/XSL/Transform"
     version="1.0"
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     xmlns:html="http://www.w3.org/1999/xhtml">

That way you won't get those

>   <xsl:template match="node">
>     <treeitem>

xmlns="" later on here.

> 2. Does it exist way how to get name of element that match template and
> use it in template? I want to do something like I highlighted by   >>>
> and <<<. I want to put name of element to attribute value.

>   <xsl:template match="applicationInfo">
>     <treeitem container="true" open="true">
>       <treerow>
>         <treecell label="  >>>applicationInfo<<<  "/>

           <treecell label="{name()}"/>

--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pavol Misik  
View profile  
 More options May 26 2009, 7:19 am
Newsgroups: mozilla.dev.tech.xslt
From: Pavol Misik <pmi...@gmail.com>
Date: Tue, 26 May 2009 13:19:05 +0200
Local: Tues, May 26 2009 7:19 am
Subject: Re: Unwanted xmlns attribute and how to put element name into element attribute
Thank you.
It works.

PM-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »