Namespace prefix xmlns has not been declared
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 26
- Joined: Tue Dec 22, 2009 2:40 pm
Namespace prefix xmlns has not been declared
Post by metalhammer »
Hi, it's my first serious attempt at XSLT, sow probably a noob question.
I am trying to make a template match with an attribute in it. The attribute has a xmlns namespace. Oxygen says I have to declare the xmlns namespace, but I thought that the xmlns namespace didn't had to be declared. (I wouldn't now how either)
This is a shortened version of the xml file
And this is my XSLT file for now
I got an error on this line:
I am trying to make a template match with an attribute in it. The attribute has a xmlns namespace. Oxygen says I have to declare the xmlns namespace, but I thought that the xmlns namespace didn't had to be declared. (I wouldn't now how either)
This is a shortened version of the xml file
Code: Select all
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<?xml-stylesheet type="text/xsl" href="XMP_omvormen.xslt"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.2-c063 53.352624, 2008/07/30-18:05:41 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/"
xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/">
<egGr:nrpages>4</egGr:nrpages>
<egGr:startlogpage>1</egGr:startlogpage>
<egGr:units>mm</egGr:units>
<egGr:vsize>126.9380112</egGr:vsize>
<egGr:hsize>210.</egGr:hsize>
<egGr:margtop>14.</egGr:margtop>
<egGr:margbot>14.0000076</egGr:margbot>
<egGr:margleft>14.00000381</egGr:margleft>
<egGr:margright>14.</egGr:margright>
<egGr:vshrink>1.</egGr:vshrink>
<egGr:hshrink>.996</egGr:hshrink>
<egGr:readerspread>False</egGr:readerspread>
<egGr:colorprofloc>EGDatabase</egGr:colorprofloc>
<egGr:colorprofname>crom_offs</egGr:colorprofname>
<egGr:colorprofdesc>crom_offs</egGr:colorprofdesc>
<egGr:trapped>True</egGr:trapped>
<egGr:screenreg>False</egGr:screenreg>
<egGr:inks>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<egInk:name>5405</egInk:name>
<egInk:type>pantone</egInk:type>
<egInk:frequency>150.</egInk:frequency>
<egInk:angle>22.5</egInk:angle>
<egInk:dotshape>R</egInk:dotshape>
<egInk:r>.3218039274</egInk:r>
<egInk:g>.4258823395</egInk:g>
<egInk:b>.4894117713</egInk:b>
<egInk:attribute>normal</egInk:attribute>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>583</egInk:name>
<egInk:type>pantone</egInk:type>
<egInk:frequency>150.</egInk:frequency>
<egInk:angle>82.5</egInk:angle>
<egInk:dotshape>R</egInk:dotshape>
<egInk:r>.6988235116</egInk:r>
<egInk:g>.7109804153</egInk:g>
<egInk:b>0.</egInk:b>
<egInk:attribute>normal</egInk:attribute>
</rdf:li>
</rdf:Seq>
</egGr:inks>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:egPDFNat="http://ns.esko-graphics.com/pdfnatversion/1.0/">
<egPDFNat:flexripversion>undetermined</egPDFNat:flexripversion>
<egPDFNat:version>201</egPDFNat:version>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreateDate>2007-07-04T16:36:14+02:00</xmp:CreateDate>
<xmp:CreatorTool>Esko PackEdge 7.0 NT Jun 26 2007, build 627</xmp:CreatorTool>
<xmp:MetadataDate>2007-07-04T16:36:16+02:00</xmp:MetadataDate>
<xmp:ModifyDate>2007-07-04T16:36:16+02:00</xmp:ModifyDate>
<xmp:Rating>4</xmp:Rating>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- DWXMLSource="sample_file_esko.xml" -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:egink="http://ns.esko-graphics.com/inkinfo/1.0/" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:egbarc="http://ns.esko-graphics.com/barcode/1.0/" xmlns:x="adobe:ns:meta/" xmlns:egextfl2="http://ns.esko-graphics.com/extfileslist/2.0/" xmlns:egcadreg="http://ns.esko-graphics.com/cadreg/1.0/" xmlns:egextfl="http://ns.esko-graphics.com/extfileslist/1.0/" xmlns:eginkcovl="http://ns.esko-graphics.com/inkcovlist/1.0/" xmlns:xmpmm="http://ns.adobe.com/xap/1.0/mm/" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:egpdfnat="http://ns.esko-graphics.com/pdfnatversion/1.0/" xmlns:egextf="http://ns.esko-graphics.com/extfile/1.0/" xmlns:egcadl="http://ns.esko-graphics.com/cadlist/1.0/" xmlns:xmprights="http://ns.adobe.com/xap/1.0/rights/" xmlns:egpagl="http://ns.esko-graphics.com/pagerangelist/1.0/" xmlns:egbarcl="http://ns.esko-graphics.com/barcodelist/1.0/" xmlns:eggr="http://ns.esko-graphics.com/grinfo/1.0/" xmlns:xmpbj="http://ns.adobe.com/xap/1.0/bj/" xmlns:egfontl="http://ns.esko-graphics.com/fontlist/1.0/" xmlns:stref="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:egfont="http://ns.esko-graphics.com/fontinfo/1.0/" xmlns:egpag="http://ns.esko-graphics.com/pagerange/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:template match="/">
<html>
<head>
<title>Dit is de visuele weergave van een XMP bestand</title>
</head>
<body>
<h2>Dit is de visuele weergave van een XMP bestand</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="/x:xmpdata/rdf:RDF/rdf:Description[@xmlns:eGR]">
<h3>Beschrijving</h3>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<xsl:template match="/x:xmpdata/rdf:RDF/rdf:Description[@xmlns:eGR]">
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Namespace prefix xmlns has not been declared
Hi,
Declarations like xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" which can appear on an element are namespace mappings. After such a declaration if you use the mapped prefix for an element the element will be in the mapped namespace.
So <egGr:nrpages> means the element nrpages is in the namespace http://ns.esko-graphics.com/grinfo/1.0/.
We do not know exactly what you are trying to accomplish.
The match="/x:xmpdata/rdf:RDF/rdf:Description[@xmlns:egGR]" you are using would mean that you want to match every rdf:Description which contains the egGr attribute with the namespace specified by the mapping of the prefix xmlns. xmlns is a reserved XML keyword and cannot be used as a prefix name.
If you are trying to find the element which contains a certain prefix mapping like: xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" defined on it then this again cannot be accomplished as prefix mappings are special attributes which cannot be matched by XPath expressions.
Maybe you can give us more details about what you are trying to match with the template from the XML file and if you want to match an element or an attribute.
You can also find a good XSLT tutorial here:
http://www.zvon.org/xxl/XSLTutorial/Boo ... tents.html
Declarations like xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" which can appear on an element are namespace mappings. After such a declaration if you use the mapped prefix for an element the element will be in the mapped namespace.
So <egGr:nrpages> means the element nrpages is in the namespace http://ns.esko-graphics.com/grinfo/1.0/.
We do not know exactly what you are trying to accomplish.
The match="/x:xmpdata/rdf:RDF/rdf:Description[@xmlns:egGR]" you are using would mean that you want to match every rdf:Description which contains the egGr attribute with the namespace specified by the mapping of the prefix xmlns. xmlns is a reserved XML keyword and cannot be used as a prefix name.
If you are trying to find the element which contains a certain prefix mapping like: xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" defined on it then this again cannot be accomplished as prefix mappings are special attributes which cannot be matched by XPath expressions.
Maybe you can give us more details about what you are trying to match with the template from the XML file and if you want to match an element or an attribute.
You can also find a good XSLT tutorial here:
http://www.zvon.org/xxl/XSLTutorial/Boo ... tents.html
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Tue Dec 22, 2009 2:40 pm
Re: Namespace prefix xmlns has not been declared
Post by metalhammer »
I want to match a <rdf:Description> element with the xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" attribute.
This way I think I can make a template for everything in the
element
This way I think I can make a template for everything in the
Code: Select all
<rdf:Description rdf:about=""
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/"
xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/">
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Namespace prefix xmlns has not been declared
Hi,
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" is a special namespace mapping attribute which cannot be matched by any XPath expression (the XSLT processor uses it only to map prefixes to namespaces and does not even recognize it as an attribute).
You can use match="/x:xmpdata/rdf:RDF/rdf:Description to match all Description elements in the http://www.w3.org/1999/02/22-rdf-syntax-ns# namespace.
Regards,
Radu
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/" is a special namespace mapping attribute which cannot be matched by any XPath expression (the XSLT processor uses it only to map prefixes to namespaces and does not even recognize it as an attribute).
You can use match="/x:xmpdata/rdf:RDF/rdf:Description to match all Description elements in the http://www.w3.org/1999/02/22-rdf-syntax-ns# namespace.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Tue Dec 22, 2009 2:40 pm
Re: Namespace prefix xmlns has not been declared
Post by metalhammer »
Hi,
My XSLT has to work on different XML files. Some of these files have the
element in it, others have not. They have a rdf:Description elements with other namespaces as attributes.
Is there a way to check in XSLT if the
is present in the XML file without having to check every child element of it?
My XSLT has to work on different XML files. Some of these files have the
Code: Select all
<rdf:Description rdf:about=""
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/"
xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/">
Is there a way to check in XSLT if the
Code: Select all
<rdf:Description rdf:about=""
xmlns:egGr="http://ns.esko-graphics.com/grinfo/1.0/"
xmlns:egInk="http://ns.esko-graphics.com/inkinfo/1.0/">
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Namespace prefix xmlns has not been declared
Hi,
You can use the namespace axis to check that a namespace is declared, for example:
Or, if you want to check also the prefixes:
Best Regards,
George
You can use the namespace axis to check that a namespace is declared, for example:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
version="1.0">
<xsl:template match="rdf:Description[
namespace::*[.='http://ns.esko-graphics.com/grinfo/1.0/'] and
namespace::*[.='http://ns.esko-graphics.com/inkinfo/1.0/']
]">
Got it!
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
version="1.0">
<xsl:template match="rdf:Description[
namespace::*[.='http://ns.esko-graphics.com/grinfo/1.0/' and name()='egGr'] and
namespace::*[.='http://ns.esko-graphics.com/inkinfo/1.0/' and name()='egInk']
]">
Got it!
</xsl:template>
</xsl:stylesheet>
George
George Cristian Bina
-
- Posts: 26
- Joined: Tue Dec 22, 2009 2:40 pm
Re: Namespace prefix xmlns has not been declared
Post by metalhammer »
Hi,
thanks, that was what I was searching for.
Is there a way to make it work in firefox to?
thanks, that was what I was searching for.
Is there a way to make it work in firefox to?
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Namespace prefix xmlns has not been declared
If this does not work in Firefox then it may be an issue that they have with the namespace axis. I suggest to try searching or asking on a Firefox related forum to see if this is a known issue and if there is a workaround to access namespaces in Firefox.
Best Regards,
George
Best Regards,
George
George Cristian Bina
-
- Posts: 26
- Joined: Tue Dec 22, 2009 2:40 pm
Re: Namespace prefix xmlns has not been declared
Post by metalhammer »
I think I'll stick with safari.
Thanks a lot for all your help!
Thanks a lot for all your help!
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service