Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

problem with namespace and XSLT

Posted on 2011-03-15
9
Medium Priority
?
480 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

610 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