Outputing & on XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flin2k
    New Member
    • Nov 2009
    • 5

    Outputing & on XML

    I'm using XSLT to process an inbound xml file and wanted to translate all the ® to ® but it's not allowing me to put in a & symbol. When I use ® it's outputing &reg. How can I get the output to format correctly?
    Thanks.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    either allow ® by writing it in the DTD or use its numeric entity.

    PS. there are only 5 named entities defined by default in XML

    Comment

    • flin2k
      New Member
      • Nov 2009
      • 5

      #3
      When I tried to write the ® to the output xml file with the following statement:
      <xsl:with-param name="charsOut" select="'&reg;' "/>

      oXygen complained that the entity "reg" was not declared. Then I try to change the "&" to &amp; as follow:
      <xsl:with-param name="charsOut" select="'&amp;r eg;'"/>
      <xsl:with-param name="charsOut" select="'&#38;r eg;'"/> (I also try this but same result).

      the output became CompanyName&amp ;reg;


      what I need is for the output xml to look like CompanyName&reg ; How can I get this done?

      Thanks.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by flin2k
        oXygen complained that the entity "reg" was not declared.
        that is correct behaviour so far.

        Originally posted by flin2k
        How can I get this done?
        see post above.

        Comment

        • flin2k
          New Member
          • Nov 2009
          • 5

          #5
          Is there a way to force the text "&reg;" to the outbound xml file?

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            yes, and I have already told you, how to do it.

            Comment

            • flin2k
              New Member
              • Nov 2009
              • 5

              #7
              I'm VERY new at this and don't understand what you mean by use its numeric entity or DTD? Any reference I can look up?
              Thanks.

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                let’s try some keywords (in wikipedia)
                named entity
                numeric entity
                DTD
                XSD
                XML
                XML Specification

                Comment

                • flin2k
                  New Member
                  • Nov 2009
                  • 5

                  #9
                  If I read this correctly, I cannot use the "&" character directly so I'll need to use the predefined code "&amp;" thus when I coded the xsl as select="'&amp;r eg;" shouldn't the translation from "&amp;" to "&" take place when output is generated? what am I missing?

                  Thanks.

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    Originally posted by flin2k
                    If I read this correctly, I cannot use the "&" character directly
                    correct

                    Originally posted by flin2k
                    so I'll need to use the predefined code "&amp;"
                    not correct, there are 2 other ways to escape & (or ®)*

                    Originally posted by flin2k
                    thus when I coded the xsl as select="'&amp;r eg;" shouldn't the translation from "&amp;" to "&" take place when output is generated?
                    nope, the substitution is done on screen (i.e. the representation changes), but the &amp; will remain as is in the source code.

                    Originally posted by flin2k
                    what am I missing?
                    link No. 2

                    * - compare what you see as this post’s text with what you see in its source code

                    Comment

                    Working...