Search

It’s only a select box that I’m using for one of the fields, no luck with an answer from me Brian ;)

Screenshot attached! It may be me doing the xsl wrong. I hope it is, so I can learn how to do it right…

Attachments:
Symphony – XML Importers.png

@designermonkey - First off, I’m a little confused by your XML.

<product id="523634" parentid="523465" usertypeid="Level 3">
        <name>Cala San Vicente</name>
        <values>
            <value attributeid="introduction"/>
            <value attributeid="more-info"/>
            <value attributeid="things-to-do"/>
        </values>
        <product id="523639" parentid="523634" usertypeid="Accommodation">
            <name>Hotel Molins</name>
        </product>
    </product>

In your XML Importer, I see your XPath expressions for Introduction, More Info, Things To Do, need to be updated (per your XML).

For Introduction it should be ./values/value[attributeid='introduction']/text()

For More Info it should be ./values/value[attributeid='more-info']/text()

For Things To Do it should be ./values/value[attributeid='things-to-do']/text()

But, per your XML, when you import these fields, you will not get a value. Since all of those nodes are all empty in your XML.

They are currently, I didn’t want to overload the xml while I was testing. The final xml will have text in there, and a lot of it…

Don’t I need the @ in an attribute ie @attributeid? I’m sure that’s right… But yes, I need the /text() at the end… Missed that…

EDIT:

I’ve put the word test in every /values/value now, and it still won’t work, same error.

Right. I’ve just removed all the xml and left one product in there

<products>
    <product id="523295" parentid="523272" usertypeid="Level 1">
        <name>Casa Murta</name>
        <values>
            <value attributeid="introduction">test</value>
            <value attributeid="more-info">test</value>
            <value attributeid="things-to-do">test</value>
        </values>
    </product>
</products>

Just to test. I changed the Included Elements line to: (one at a time)

/products/product, /, /products. //product

and it still doesn’t work.

I’ve had nothing but trouble with this extension since I started to think about using it. I keep putting it off and every time I come back to it everyone else can use it but me!

I really need this working before the end of next week as I’m presenting Symphony to my employers, and if I can’t get it to do what I said it could, I’m going to look an idiot.

/products/product, /, /products. //product

This line does not make sense to me.

What I meant was:

I’ve tried all variations as follows:

/products/product

/

/products

//product

None of which are working.

@designermonkey -

Please post a screenshot of your latest XML Importer page. Also, can your remind me which version of Symphony you are running?

Also, you might consider downloading the “unstable” branch of the repository… I found it to be more stable and functional than the master branch.

I’ve had nothing but trouble with this extension since I started to think about using it. I keep putting it off and every time I come back to it everyone else can use it but me!

We’ve been using this extension successfully for importing our semester calendar.

@Nils - Have you figured out a way to import multiple values in on a SelectBox, SelectBox Link, or ReferenceLink? Also, would you mind sharing how you used the PHP Function section? The XMLImporterHelper functions… did you write those?

  1. I’m using version 2.0.8RC3.
  2. Attached. I’ve followed your advice too and added text()
  3. The master branch doesn’t even work! So I have the unstable version.

I’m sorry if I’m sounding stroppy, I’ve had a very long day and I’m getting tired, but I have a problem, and I can’t stop till it’s fixed (one of my flaws/benefits lol). Thanks so much for your help so far.

It seems to me that the error is being caused because my Included Elements string is wrong, as it’s saying that no xml is being found, I’m so confused now.

test xml:

<products>
    <product id="523295" parentid="523272" usertypeid="Level 1">
        <name>Casa Murta</name>
        <values>
            <value attributeid="introduction">test</value>
            <value attributeid="more-info">test</value>
            <value attributeid="things-to-do">test</value>
        </values>
    </product>
</products>
Attachments:
Symphony – XML Importers.png

I want to sincerely apologize to everyone. I have had trouble every time I use this, simply because I am a t*@t.

My colloeague looked over my shoulder and said: “You’ve got that URL wrong.”

I’m going to sleep for a few days, try and calm down, then repeatedly punch myself in the arm for pennance of making out that the extension is flawed.

I feel like such a fool.

@designermonkey… in your predicate, [@usertypeid='introduction'], shouldn’t that be [@attributeid='introduction']?

Same with More info and Things to Do

@designermonkey - No worries man! I totally understand. Hope you get some rest.

@Brian: Yes, I’m populating Select Box Fields (and a modified version of Select Box Link). But I’m not sure if all my modifications to this extension are available in the main repository. This is the code I use: http://github.com/nilshoerrmann/xmlimporter

These are my XMLImporterHelpers:

<?php

    class XMLImporterHelpers {

        static function markdownify($string) {
            require_once(EXTENSIONS . '/xmlimporter/lib/markdownify/markdownify_extra.php');
            $markdownify = new Markdownify_Extra(true, MDFY_BODYWIDTH, false);
            $markdown = $markdownify->parseString($string);
            $markdown = htmlspecialchars($markdown, ENT_NOQUOTES, 'UTF-8');     
            return $markdown;
        }

        static function prettyfy($string) {
            $string = str_replace('<BR />', ' ', $string);
            $string = str_replace('<br />', ' ', $string);
            $string = str_replace('  ', ' ', $string);
            $string = str_replace(" - ", ' &#8211; ', $string);
            $string = XMLImporterHelpers::markdownify($string);
            return $string;
        }

        /**
         * Convert dates from "1 January 2010, 12:00 to 2 January 2010, 12:00"
         * to a suitable array for the Date and Time field.
         */     
        static function convertDateTime($string) {
            list($from, $to) = explode(' to ', $string);
            // Get from date and time
            list($sdate, $stime) = explode(', ', $from);
            list($sday, $smonth, $syear) = explode('.', $sdate);
            if(!$sday) return NULL;
            if(strlen($stime) == 2) {
                $shrs = $stime;
                $smin = 0;
            }
            else {
                list($shrs, $smin) = explode('.', $stime);
            }           
            // Get to date and time
            list($edate, $etime) = explode(', ', $to);
            list($eday, $emonth, $eyear) = explode('.', $edate);
            if(strlen($etime) == 2) {
                $ehrs = $etime;
                $emin = 0;
            }
            else {
                list($ehrs, $emin) = explode('.', $etime);
            }
            // Create range
            $range = array();
            $range['start'][] = date('j F Y, H:i', mktime(intval($shrs), intval($smin), 0, $smonth, $sday, $syear));
            $range['end'][] = date('j F Y, H:i', mktime(intval($ehrs), intval($emin), 0, $emonth, $eday, $eyear));
            return $range;
        }

        /**
         * Return "yes" if a import node is found.
         * Helpful for populating checkboxes
         */
        static function sayYes($string) {
            return 'yes';
        }

        /**
         * Create a markdown formatted list element for each text line
         */
        static function createList($string) {
            if(empty($string)) return;
            // unify line breaks
            $string = str_replace('<BR />', '<br />', $string);
            $string = str_replace('<BR>', '<br />', $string);
            // Get lines
            $lines = explode('<br />', $string);
            // Create list
            $list = '';
            foreach($lines as $line) {
                if(empty($line)) continue;
                $line = XMLImporterHelpers::prettyfy($line);        
                $dash = ((strpos($line, '-') === 0) ? '': '- ');
                $list .= $dash . $line . "n";
            }
            return $list;
        }

        /**
         * Create taglist
         */
        static function createTaglist($string) {
            $string = XMLImporterHelpers::prettyfy($string);
            $string = trim(trim($string), ',');
            // Trim twice to handle item with no internal teacher
            $string = trim(trim($string), ',');
            return $string;         
        }

    }

?>

(Never mind — I missed a post above)

Your totally right Brian, changed the predicates…

I’ve solved my idiocy, however now none of my Select Boxes are populating. Do they have the same issue as Select Box Links? I’ve populated one manually, checked in the database and it has the words Level 1 which is one of my options, and is also the attribute value being asked for in the xml, yet it won’t pouplate.

Strange.

edit Yet again, a spelling mistake on my part. I’m going away now.

This is how I import to a select box:

concat(Dozent/@LastName, ', ', Persons/Person/@LastName, ', ', ExternalPerson/text())

@Nils - When you are doing your imports on the Select Box fields are you allowing multiple values? So, it will import multiple values.

Yes.

@Nils - sorry for so many questions, would you mind sharing how you setup that import field. I’ve been been trying evrything and can’t get it to accept multiple values.

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