A
A
Anton2015-04-02 22:52:58
XSL & XSLT
Anton, 2015-04-02 22:52:58

How to work with Atom.xml + XSL?

I want to process the Atom of a blog with Google Blogger using XSL. PHPShtorm highlights the "uri is not registered" error for the root element:

<?xml version='1.0' encoding='UTF-8'?>

<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
      xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss'
      xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'>

That is, each of the parameters ( xmlns:blogger xmlns:gd ...) he does not like. Tried to follow the links - only one works.
Next are the namespaces in the code that are defined above:
<thr:total>0</thr:total>
        <gd:extendedProperty name="commentSource" value="1"/>

As a result, if you just cut out the definitions, the parser swears that unknown namespaces are present - which is logical. And if you leave everything as it is, the parser does not see everything that is inside
. That is, you write in XSL:
<xsl:for-each select="//entry">
                    <xsl:sort order="descending" select="."/> йцукен

                </xsl:for-each>

And it just doesn't show up. You remove the uri from the feed - the loop works, but an error is thrown on the namespaces.
How to be here?
I use the browser parser and the parser built into php.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2015-04-03
@fattan

Eureka:
All the magic is in namespaces.
stole the solution from here
In xls, you need to explain what it is Atom and use its namespace

<?xml version="1.0" encoding="utf-8"?>
<x:stylesheet version="1.0"
                xmlns:atom="http://www.w3.org/2005/Atom"
                xmlns:x="http://www.w3.org/1999/XSL/Transform">
    <x:output
            method="html"
            media-type="text/html"
            indent="yes"
            encoding="UTF-8"/>

    <x:template match="/atom:feed">
        <x:text disable-output-escaping='yes'>&lt;!DOCTYPE html></x:text>
        <html>
            <head>
                <title>DOCTYPE html 5</title>
            </head>
            <body>
                <x:for-each select="atom:entry">
                    <x:sort order="descending" select="."/>
                    <h2>бла бла бла</h2>
                    Опубликовано: <x:value-of select="atom:published"/><br /> 
                </x:for-each>

            </body>
        </html>
    </x:template>

</x:stylesheet>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question