?
Solved

problem with namespace and XSLT

Posted on 2011-03-15
9
Medium Priority
?
473 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
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

762 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