Copied to clipboard

Flag this post as spam?

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


  • Stephen Kiers 41 posts 62 karma points
    Aug 13, 2010 @ 18:13
    Stephen Kiers
    0

    Dynamic URL in GetXmlDocumentByUrl

    I am trying to write XSLT that will import a dynamci external XML document to display the information on my website. I continually get a "Invalid URI: The URI scheme is not valid." error though.

    My thought is this. I set the dynamic subdomain via a variable (ChangableSubdomain) and then I combine it with the source address (http://sourceURL.com/) and then I use the combined variable with umbraco.library:GetXmlDocumentByUrl

    So if I write:

      <xsl:variable name="sourceURLxml" select="umbraco.library:GetXmlDocumentByUrl('https://sourceURL.com/testsubdomain/')" />

    Problem is if I write

      <xsl:variable name="ChangableSubdomain">testsubdomain</xsl:variable>
      <xsl:variable name="sourceURL">'https://www.sourceURL.com/<xsl:value-of select="$ChangableSubdomain"/>/'</xsl:variable>
    <xsl:variable name="sourceURLxml" select="umbraco.library:GetXmlDocumentByUrl($sourceURL)"/>

    it doesn't work.

     

    Suggestions? Help? Thanks!!!!!

  • Stephen Kiers 41 posts 62 karma points
    Aug 13, 2010 @ 18:14
    Stephen Kiers
    0

    FYI. Eventually ChangableSubdomain will actually be a macro parameter that is passed in on the page.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Aug 13, 2010 @ 20:35
    Chriztian Steinmeier
    0

    Hi Stephen,

    It's the literal apostrophes that's breaking stuff - try this instead:

    <xsl:variable name="ChangableSubdomain">testsubdomain</xsl:variable>
    <xsl:variable name="sourceURL" select="concat('https://www.sourceURL.com/', $ChangableSubdomain, '/')" />
    <xsl:variable name="sourceURLxml" select="umbraco.library:GetXmlDocumentByUrl($sourceURL)"/>

    To create a string variable you can do 2 things (added spaces not necessary):

    <xsl:variable name="myVar" select=" 'Text content here' " />

    or:

    <xsl:variable name="myVar">Text content here</xsl:variable>

    - note that the literal method (#2) doesn't need the apostrophes. Normally (for processor optimization reasons, I've read) the first method is better than the other if you're just doing simple strings like those.

    /Chriztian

  • Stephen Kiers 41 posts 62 karma points
    Aug 13, 2010 @ 21:00
    Stephen Kiers
    0

    That was great.I even thought to try the concat method; but I had tried so many I knew one of you would know the answer right off...

    Sorry I can't high five you (whatever that does) I am not karmad enough...

Please Sign in or register to post replies

Write your reply to:

Draft