Search

Hello,

I’m importing an external XML document into Symphony. Inside the XML doc are nodes called like this:

<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    <pand>pand1</pand>
</diffgr:diffgram>

How can I set my XPath to the <pand>pand1</pand> node with the <for-each select="pathtonode"> ?

At the top of your stylesheet, try adding the diffgr namespace:

<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">

Then you should, I think, be able to do:

<xsl:for-each select="diffgr:diffgram/pand">

I’ve added xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" inside the xsl:stylesheet but it doesn’t do anything.

When I type this <xsl:if test="huizenaanbod/diffgr:diffgram">Good</xsl:if> I see the “Good”.

When I test the case with: <xsl:if test="huizenaanbod/diffgr:diffgram/dsAanbodMakelaar">Good</xsl:if> I don’t see the “Good”.

My XML file looks like this.

<huizenaanbod status="fresh" creation="2010-05-19T15:46:08+02:00">
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
        <dsAanbodMakelaar xmlns="http://ws1.vbo.nl/aanbodmakelaar">
            <Pand diffgr:id="Pand1" msdata:rowOrder="0">
                <PandID>183351</PandID>
                <KantoorID>1283</KantoorID>
                ..............

I use a dynamic XML file for showing buildings. Is there a way to skip the diffgr:diffgram node for example to solve this problem?

Ah, it’s a different story with that dsAanbodMakelaar node. You hadn’t listed that above. That node belongs to yet another namespace. I’m guessing that’s your problem. If I’m not mistaken (and I may very well be), you might be able to do:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
    xmlns:ds="http://ws1.vbo.nl/aanbodmakelaar">

and then use:

<xsl:for-each select="ds:dsAanbodMakelaar/Pand">

or something like that…

Allright, the ds:dsAanbodMakelaar is working just fine, but the other: ds:dsAanbodMakelaar/Pand doesn’t work.

Never mind, the code diffgr:diffgram/ds:dsAanbodMakelaar/ds:Pand/ds:PandID works fine now.
Thanks for helping me czheng!

Ah, yes, forgot the second ds:… glad it workout out :)

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