Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: can XSL escape?

  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    can XSL escape?

    I'm making this up, but what I want amounts to:

    <xsl:escape-output><xsl:value-of select="node_data"/></xsl:escape-output>


    Or maybe there's an XPath way. Any ideas?

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    I'm not sure I follow. Isn't that what CDATA sections are for?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I'm generating js variables. eg:

    <greeting>hello</greeting>

    becomes

    var greeting = "hello";

    But if the XML has

    <greeting>"Hello", he said, "it's nice to see you"</greeting>

    How do I turn that into JS without getting errors?

  • #4
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Hm. Maybe by using &amp;quot; or &amp;apos; . I think these are valid in XML.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #5
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Originally posted by Alex Vincent
    Hm. Maybe by using &amp;quot; or &amp;apos; . I think these are valid in XML.
    yup

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could also the \x escape sequence with hex codes. This is valid in JS:

    var greeting = "\x22Hello\x22, he said, \x22it\x27s nice to see you\x22";

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried those entitites - but they get parsed back into " and ' in the transformation ... end result is the same.

    But hex codes I haven't tried. Thanks - I'll try that now


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •