Solved

problem with namespace and XSLT

Posted on 2011-03-15
9
450 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
  • 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
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 about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now