Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Mar 13, 2013 @ 16:53
    Alex Skrypnyk
    0

    Search in external xml file

    Hi,

    Could XSLTSearch do search in the external xml file?

    Thanks,

    Alex

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 13, 2013 @ 17:24
    Douglas Robar
    0

    Hi, Alex,

    Sure! But why would you want to? It would need to follow the xml schema that Umbraco uses (compare with the site's ~/app_data/umbraco.config file).

    Assuming you have an xml file that follows the correct schema then you'd load the xml file into the $source variable rather than getting it directly from Umbraco.

    The easy way to do that would be to make sure the external xml file were downloadable via some url (either on your site or someone else's) and use the umbraco.library:GetXmlDocumentByUrl() and pass in the url to the xml file you want to load. Or you could try to use <xsl:import> if the file is local.

    cheers,
    doug. 

  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Mar 13, 2013 @ 17:55
    Alex Skrypnyk
    0

    Hi Douglas,

    We have xml file in such format:

    <?xml version="1.0" encoding="UTF-8"?>
    <pages>
    <page link="http://www.entitledto.co.uk/help/benefitscharity.aspx" id="benefitscharity">
    <title> Income from voluntary or charity sources</title><content> Income from voluntary or charity sources</content>
    </page>
    <page link="http://www.entitledto.co.uk/help/accessibilitystatement.aspx" id="accessibilitystatement"><title>Accessibility Statement</title>
    <content>Accessibility Statement</content>
    </page>

    It is from our other site.

    We want to create search for this content.

    Thanks,

    Alex

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 13, 2013 @ 18:03
    Douglas Robar
    0

    That's possible, but you'd need to change the xpath throughout XSLTsearch.xslt to use your schema. Though if you really only have a <title> and <content> element it would also be considerably simplified from what is needed for Umbraco content. You'd also need to update the results display to use the page link="" for the urls in the results.

    Definitely possible but not a trivial change. The benefit of course is you keep all the logic about ranking results, searching for terms, paged results, etc etc.

    Let me know how you get on with the project.

    cheers,
    doug. 

  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Mar 13, 2013 @ 18:13
    Alex Skrypnyk
    0

    Do you think to change external xml file format is faster way to do this ?

    I'm not very strong in xslt )

    THanks,

    Alex

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 13, 2013 @ 18:37
    Douglas Robar
    100

    I suppose it depends on how the external xml file is generated an if it's easy to change its schema. Not sure how you'd handle the external links conveniently tho; there is no equivalent property in the umbraco schema. So that would be an update to the one or two places I use umbraco.library:NiceUrl() in the xsltsearch.xslt file.

    If you're not overly strong with xslt then modifying xsltsearch.xslt may be quite a lot of effort. It is well-commented but even so it is a rather involved bit of xslt. 

    cheers,
    doug. 

Please Sign in or register to post replies

Write your reply to:

Draft