Solved

problem with namespace and XSLT

Posted on 2011-03-15
9
451 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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

863 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

20 Experts available now in Live!

Get 1:1 Help Now