Search

Are they created externally and get imported? After filling them out in the DS editor I dont see them in the page, nor the debug page. I am using:

 xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:media="http://search.yahoo.com/mrss/"

Schould they be noted as:

name:  atom
uri:    http://www.w3.org/2005/Atom

Same goes for the variable name and feed uri, I assumed they would be taken from the DSname and URL. I don't see them appear. What am I doing wrong?

When I manually paste all in the page, all works.

I think you have to manually add them to your XSLT like I did with a del.icio.us feed:

<xsl:stylesheet 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     xmlns:rss="http://purl.org/rss/1.0/" version="1.0"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     exclude-result-prefixes="rss dc">

You can then keep them from outputting in your XHTML by using the exclude-result-prefixes attribute.

I'm not sure why you have to do it this way. It seems like you already do this work in the External XML Data Source, but I had to do both to make it work. This is something I don't quite understand either.

Here's another forum post on the topic.

With dynamic XML you are only required to declare namespaces in the data source editor for ones you actually use in the XPath field.

For example, if your XPath is: something/book:title/@isbn, you only need to declare the namespace book. All other namespaces will either be automatically copied on to the resultant XML or ignored, depending on their relation to the resultant XML.

I got it. When pulling in my Del.icio.us RSS feed I adjusted my datasource to only include the namespaces in my Xpath: rdf and rss (rss is in place of the empty, defaut namespace)

rdf:RDF/rss:item[position()&lt;=15]

But in my XSLT, I still need to include the namespace used there too. I select nodes with dc and rss namespces, so my XSLT utility has to declare them.

<xsl:stylesheet 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     xmlns:rss="http://purl.org/rss/1.0/" version="1.0"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     exclude-result-prefixes="rss dc">

Since I'm not using the other namspaces, I don't need to declare them.

Yep, that's it! :)

this will probably be a vague question, but when i get this in my xml:

<error>XML returned is invalid.</error>

about a DS that is a Dynamic XML source, what does that usually mean? I looked at the rss feed i'm pulling in and the xml is well-formed. I'm not entirely sure if I'm setting up my DS completely right. I'm trying to pull in my Pandora RSS feed. a screenshot of my settings is attached and my feed is here: http://feeds.pandora.com/feeds/people/wtdtan/stations.xml

Attachments

Try removing the xmlns: from your namespace declarations in your DS config.

once i make that change, do i need to wait X amount of minutes before I see anything coming in? i removed the xmlns: from my DS, but i'm still receiving that error node.

I am trying to use the Github RSS feed, and while I can see the XML in my debug page I cannot access it through Xpath. I suppose this is related to atom and namespace declaration, but after following instructions in related topics I don’t get any content displayed anyhow.

This is my feed: http://github.com/carsten.atom

I have put in name: atom and URI: http://www.w3.org/2005/Atom in the namespace declaration on the admin screen.

This a short version of my code:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/2005/Atom">

<xsl:template match="/data/github">
    <ul>
        <xsl:apply-templates select="feed/entry" />
    </ul>
</xsl:template>

<xsl:template match="/data/github/feed/entry">
    <li><xsl:value-of select="title" /></li>
</xsl:template>

Changing /feed to atom:feed or xmlns to xmlns:atom does not change a thing.

 <feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">

It doesn’t look like the feed declares any namespace other than the default, so you shouldn’t have to worry about anything. Just add it as a data source, add it to your page configuration and it should show up in your XML.

I also ran the feed through an XML validator and it fails, so that will keep it from working in Symphony. That may be the root of the problem.

As an aside, you can bypass namespace woes in XPath by using local-name(). It doesn’t solve the root problem though, so it’s pretty much a dirty hack.

/node/another-node/ns:node
<xsl:value-of select="/node/another-node/*[local-name()='node']"/>

Carsten: Did you override the default namespace? (reference: http://getsymphony.com/forum/discussions/35/

Remember that XML with a default namespace means all elements have a namespace – they are just blank, which makes XPath selection impossible. The solution is to override the default namespace with your own in XSLT.

The namespace of the feed will prevent you from simply accessing /feed/entry, although it seems that you can. What worked for me: no namespace declaration in the Dynamic XML data source (as MrBlank says), declaring xmlns:atom="http://www.w3.org/2005/Atom" in the XSL, and accessing the nodes by atom:feed/atom:entry.

So, If I understand correctly, the default namespace on the feed of http://www.w3.org/2005/Atom hides all the atom: prefixes of the nodes in the XML?

Anyway, thanks for your help!

Carsten: yes what you essentially have done is override the default namespace with an XPath accessible namespace.

They don’t really “hide” the atom: namespace, rather what “default namespace” means is without declaring the namespace:node notation, all node are of the default namespace. If you could visually represent this, it’ll look something like…

:feed/:entry

That is, of course invalid - but basically, the namespace is literally BLANK.

  • If you don’t declare a default namespace, nodes have no namespace.
  • If you declare a default namespace, nodes have a BLANK namespace.

In XPath the above are different things.

The solution, as you have done is to give the default namespace (in your case http://www.w3.org/2005/Atom) a name you could use for XPath to select. Which you have chosen atom. Technically, you could name it whatever you like as long as your XPath use it to select the node.

Hope that explains it.

Could you please explain in detail how to use http://github.com/carsten.atom as datasource. I did following:

1 Define New Datasource DynamicXML
2 Name: carsten
3 URL: http://github.com/carsten.atom
4 Namespace Declaration: ?? xmlns=”http://www.w3.org/2005/Atom” ??
5 Included Elements: /feed/entry

But I dont get any results.

I got it working:

1 Define New Datasource DynamicXML
2 Name: carsten
3 URL: http://github.com/carsten.atom
4 Namespace Declaration: NAME carsten URI http://www.w3.org/2005/Atom
5 Included Elements: /carsten:feed/carsten:entry

Now to the XSL:

1 Create a Page with Datasource carsten
2 Modify the header

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:carsten="http://www.w3.org/2005/Atom" exclude-result-prefixes="carsten" ><xsl:for-each select="/data/carsten/carsten:entry"> <xsl:call-template name="git-items"/> </xsl:for-each>

<xsl:template name="git-items"> <h2><a><xsl:value-of select="carsten:title"/></a></h2> <p><xsl:value-of select="carsten:content" disable-output-escaping="yes"/></p> <p><a href="{carsten:link/@href}" title="{carsten:title}"> <xsl:value-of select="carsten:title"/></a></p> </xsl:template>

But the question now is: How do I get rid of “carsten:node”, just to get the Xpath addressed with

“/data/carsten/entry/title/” ?

I thought I will get this when using “exclude-result-prefixes”.

??

Does anybody have an Idea how to ged rid of the namespace-prefix (carsten:node) ??

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details