Solved

problem with namespace and XSLT

Posted on 2011-03-15
9
465 Views
Last Modified: 2013-11-11
this is only the beginning of my xslt code, the result of the html is i don't see the xmlns attribute. i thought it's something to do with xsl:template match? otherwise it might be something in the CMS system I use.
<xsl:template match="/XmlOutput">
<html xml:lang="en" lang="en" xmlns:v="http://www.w3.org/2006/vcard/ns#">
	<xsl:attribute name="xmlns">
	<xsl:text>http://www.w3.org/1999/xhtml</xsl:text>
	</xsl:attribute>

Open in new window


<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title>

Open in new window

0
Comment
Question by:itinfserv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35136615
which xmlns do you refer too?
"xmlns" is a namespace node, it is NOT an attribute
"xmlns" is NOT an allowed name for an xsl:attribute

if you want to set the namespace you need to add namespace nodes instead.

Can you tell me what problem you are actually experiencing
Do you want to keep the vcard namespace?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35136631
If you want to set the default namespace
just put it as default in the xsl:stylesheet element
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml"
    version="1.0">

Open in new window

0
 
LVL 1

Author Comment

by:itinfserv
ID: 35136665
I have the following code for RDF layoug

    <xsl:template match="/XmlOutput">
	<html
	 xmlns="http://www.w3.org/1999/xhtml"
	 xml:lang="en" lang="en"
	 xmlns:argot="http://purl.oclc.org/argot/"
	 xmlns:dc="http://purl.org/dc/terms/"
	 xmlns:foaf="http://xmlns.com/foaf/0.1/"
	 xmlns:v="http://www.w3.org/2006/vcard/ns#"
	 xmlns:dbp="http://dbpedia.org/resource/">
            <xsl:call-template name="html_header"/>
            <xsl:call-template name="html_body"/>
        </html>
    </xsl:template>

Open in new window

I appended all the namespaces - xmlns and before i had
        <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">

Open in new window

instead, so only one name space for the whole document, but now for the RDF I need several namespaces.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:itinfserv
ID: 35136692
i wanted to have the following code inside the html tag.
<xsl:if test="Modules/Module[@componentId='SingleContent']/Singlecontent/contentManager/metadataManager/metadata/aParsedParameter/isRdf">
	<xsl:attribute name="xmlns:argot">
                <xsl:text>http://purl.oclc.org/argot/</xsl:text>
	</xsl:attribute>
	<xsl:attribute name="xmlns:dc">
		<xsl:text>http://purl.org/dc/terms/</xsl:text>
	</xsl:attribute>
	<xsl:attribute name="xmlns:foaf">
		<xsl:text>http://xmlns.com/foaf/0.1/</xsl:text>
	</xsl:attribute>
	<xsl:attribute name="xmlns:v">
		<xsl:text>http://www.w3.org/2006/vcard/ns#</xsl:text>
        </xsl:attribute>
	<xsl:attribute name="xmlns:dbp">
		<xsl:text>http://dbpedia.org/resource/</xsl:text>
	</xsl:attribute>
</xsl:if>

Open in new window

i understand from you it's invalide.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35136718
yes, but your earlier example is not invalid

    <xsl:template match="/XmlOutput">
      <html
       xmlns="http://www.w3.org/1999/xhtml"
       xml:lang="en" lang="en"
       xmlns:argot="http://purl.oclc.org/argot/"
       xmlns:dc="http://purl.org/dc/terms/"
       xmlns:foaf="http://xmlns.com/foaf/0.1/"
       xmlns:v="http://www.w3.org/2006/vcard/ns#"
       xmlns:dbp="http://dbpedia.org/resource/">

is allowed

but add these nodes to the xsl:stylesheet as well
0
 
LVL 1

Author Comment

by:itinfserv
ID: 35136803
ok modified the xsl:stylesheet to be
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xforms="http://www.w3.org/2002/xforms/cr"
                xmlns:af="http://cmsxml.com/2004/aform"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:ev="http://www.w3.org/2001/xml-events"
  			    xmlns:argot="http://purl.oclc.org/argot/"
				xmlns:dc="http://purl.org/dc/terms/"
				xmlns:foaf="http://xmlns.com/foaf/0.1/"
				xmlns:v="http://www.w3.org/2006/vcard/ns#"
				xmlns:dbp="http://dbpedia.org/resource/"				
                version="1.0">

Open in new window

it might be something in the CMS system I use, but the support of this product is very slow, so thought I can solve the issue before they get into that.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 35136889
OK, but what is the result of this stylesheet?
0
 
LVL 1

Author Comment

by:itinfserv
ID: 35136911
I just got a response from the support of my CMS and they told me it's to blame on the CMS, so I case I can close that ticket, but I learnt quite a lot on namespace in XSLT, so I'll give u the full mark.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35136943
cheers
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question