XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 2nd, 2003, 12:21 PM
jakuza's Avatar
jakuza jakuza is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 65 jakuza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 52 sec
Reputation Power: 6
Question Namespace inheritance and XSLT

Hi there.

I just wonder if there's a way to manage identical tags in XML source(s) with different XSL templates. Just to be clear, an example:

....
<space1:body>
<ciccio>Bla bla</ciccio>
</space1:body>

<space2:body>
<ciccio>1243</ciccio>
</space2:body>
....

I'd like to be able to manage the two <ciccio> with a template depending on their parent's namespace.
I tried this in my XSL sheet:

....
<xsl:template match="space1:ciccio">
ciccio is a nice guy
</xsl:template>

<xsl:template match="space2:ciccio">
ciccio is a number
</xsl:template>
.....

but it doesn't seem to match.
Anybody there knows how to do this?
Thanx since now.

Reply With Quote
  #2  
Old June 6th, 2003, 04:25 AM
torrent torrent is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Location: UK
Posts: 59 torrent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Neither ciccio appear to have a namespace defined for them, which means they are taking any default namespace defined in the document. I think to achieve what you want you will need to do something like this:
Code:
<space1:body>
    <space1:ciccio>Bla bla</space1:ciccio>
</space1:body>

<space2:body>
    <space2:ciccio>1243</space2:ciccio>
</space2:body>

Reply With Quote
  #3  
Old June 6th, 2003, 07:48 AM
jakuza's Avatar
jakuza jakuza is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 65 jakuza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 52 sec
Reputation Power: 6
Quote:
Code:
<space1:body>
    <space1:ciccio>Bla bla</space1:ciccio>
</space1:body>

<space2:body>
    <space2:ciccio>1243</space2:ciccio>
</space2:body>


I tried this, but it revealed to be not useful to me. Declaring explicitely <space1:ciccio> or <space2:ciccio> it's exactly like declaring <ciccio1> or <ciccio2>, like declaring two different tags.
I'd need to know a way, if it exists, to put the same tag in different point of my XML document (namespaces?) and have those processed back in two different ways.
I initially hoped that namespace declaration was inheritable (see my previous post in this thread); this could have permitted to simply declare the same <ciccio> tag under different tags with respective explicit namespace assignment. But it doesn't seem to work. But neither this way you propose seem to be useful to me
Thank you anyway.

Reply With Quote
  #4  
Old June 6th, 2003, 08:04 AM
torrent torrent is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Location: UK
Posts: 59 torrent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
You have to explicitly state the namespace for every element other than those for which a default namespace has been set (either in the root or at an element level).

I think the problem lies with how you are processing your XML file, or how you are transforming it (XSLT). I think we need more info.

Reply With Quote
  #5  
Old June 6th, 2003, 08:16 AM
jakuza's Avatar
jakuza jakuza is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 65 jakuza User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 52 sec
Reputation Power: 6
Trying to build an effective example:

Suppose I have to render a login form on a web site.
It could be rendered in a menu on the page side or sometimes in the page main body. Both are described with the same XML (suppose tag <login>....</login>) but not rendered by the same XSLT.

I intended to define a 'body' namespace and a 'menu' namespace. Whenever the XSLT processor finds a <login> tag it calls a different template depending on the namespace the <login> falls within.

Now I'm starting thinking another way: I could define templates matching the "body/login" pattern and another one matching "menu/login". This would permit me to render two different login forms called by the same <login> tag in two different contexts, isn'it?

Bye again.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Namespace inheritance and XSLT


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway