Loading ...
Sorry, an error occurred while loading the content.
 

Character entity Reference.

Expand Messages
  • touchlenin
    Greetings to all, Does anyone know, how to retain the Character entity reference in the output XML after XSL transformation. ie., for example, i have an XML
    Message 1 of 5 , Aug 24, 2005
      Greetings to all,

      Does anyone know, how to retain the Character entity reference in
      the output XML after XSL transformation.

      ie., for example, i have an XML like

      Source.xml
      -----------
      <author>
      <abstract>This is an abstract ñ</abstract>
      <title>This is a title</title>
      ...
      </author>

      normally after this source xml is transformed using XSL
      the "ñ" transforms to its corresponding symbol.

      But my requirement is to retain the "ñ" character entity in
      the resultant XML after stylesheet transformation.

      I am using MSXML 4.0 Parser, and XSLT version 1.0.


      Any example on this is always welcome.


      With Regards,
      Lenin.
    • G. Ken Holman
      ... It is outside the scope of XSLT 1.0 to preserve the input syntax in the output syntax. ... Correct ... the XSLT processor is allowed to use any syntax for
      Message 2 of 5 , Aug 24, 2005
        At 2005-08-24 15:18 +0000, touchlenin wrote:
        >Does anyone know, how to retain the Character entity reference in
        >the output XML after XSL transformation.

        It is outside the scope of XSLT 1.0 to preserve the input syntax in
        the output syntax.

        >ie., for example, i have an XML like
        >
        >Source.xml
        >-----------
        ><author>
        > <abstract>This is an abstract ñ</abstract>
        > <title>This is a title</title>
        > ...
        ></author>
        >
        >normally after this source xml is transformed using XSL
        >the "ñ" transforms to its corresponding symbol.

        Correct ... the XSLT processor is allowed to use any syntax for the
        output serialization. In fact, the XSLT processor doesn't even know
        the input syntax that was acted on by the embedded XML processor.

        >But my requirement is to retain the "ñ" character entity in
        >the resultant XML after stylesheet transformation.

        There is no built-in entity for ñ in XML, and there is no
        control over the internal declaration subset of the output
        serialization, so there is no way to preserve this in XSLT 1.0.

        I hope this help, though I realize it doesn't give you the answer you want.

        . . . . . . . . Ken


        --
        World-wide on-site corporate, govt. & user group XML/XSL training.
        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
        Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/f/bc
        Legal business disclaimers: http://www.CraneSoftwrights.com/legal
      • Mike Trotman
        This is something I remember struggling with a few years ago. I then realised that I didn t need to do it. So my initial question would be - why do you want to
        Message 3 of 5 , Aug 24, 2005
          This is something I remember struggling with a few years ago.

          I then realised that I didn't need to do it.

          So my initial question would be - why do you want to preserve the entity
          and in what format
          (is it in a file with a particular encoding containing a character
          representation of your XML document?)
          What is wrong with having a correctly encoded character?

          The only times I had to deal with this were with the GBP symbol when I
          was passing an XML document from one application to another
          - and needed an intermediate serialization of it
          - and I couldn't get an encoding of the output that was accepted as the
          input.
          And I had problems with MSXML - as it kept insisting that everything was
          UTF-16 - even when it wasn't.

          I eventually managed to get the encodings right so that I could use the
          native character representations.


          Apart from this - I can't think of any cases where it is necessary or
          desirable.

          The only way this should be possible is if there is an option to MSXML
          to 'preserve character entities' - i.e. store them internally and
          reproduce them on output..
          I am not aware of such an option - but that doesn't mean there isn't one.

          It is tricky because the document will be parsed as an XML document 1st
          - when your text 'ñ' will get resolved as an entity for your
          declarations.
          From that point on it is potentially indistinguishable from the UNICODE
          representation.
          (i.e. if you had got the appropriate '&#x....;' in your document the
          resultant in-memory XML document would be the same.)

          There is the XSLT unparsed-entity-uri Function - but that would require
          you to have an entity representing 'ñ'.
          You could output it in your encoding as <![CDATA[ñ]]>.
          But neither of those would work unless your output document or catalog
          also contained a DOCTYPE entity definition of ntilde.

          All this sort of dancing around is a very strong suggestion that this is
          a bad idea.
          And with XML that usually means what you are doing is either using a
          tool that doesn't conform properly
          - or that there is something about the process which breaks XML conventions
          - or that there is an alternative approach where you don't need to do it.


          But - if you do find a way - let me know because I'm sure I'll hit the
          problem again and forget (again) how I solved it.


          Mike

          touchlenin wrote:

          >Greetings to all,
          >
          >Does anyone know, how to retain the Character entity reference in
          >the output XML after XSL transformation.
          >
          >ie., for example, i have an XML like
          >
          >Source.xml
          >-----------
          ><author>
          > <abstract>This is an abstract ñ</abstract>
          > <title>This is a title</title>
          > ...
          ></author>
          >
          >normally after this source xml is transformed using XSL
          >the "ñ" transforms to its corresponding symbol.
          >
          >But my requirement is to retain the "ñ" character entity in
          >the resultant XML after stylesheet transformation.
          >
          >I am using MSXML 4.0 Parser, and XSLT version 1.0.
          >
          >
          >Any example on this is always welcome.
          >
          >
          >With Regards,
          >Lenin.
          >
          >
          >
          >
          >
          >
          >
          >Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >
          >Message Scanned by ClamAV on datalucid.com
          >
          >
          >

          --
          Datalucid Limited


          Message Scanned by ClamAV on datalucid.com
        • Chris Loschen
          There is an extension somewhere that takes a properties file set up like this ntilde 246 And returns the ñ entity when it sees the ö character
          Message 4 of 5 , Aug 24, 2005
            There is an extension somewhere that takes a properties file set up like
            this

            ntilde 246

            And returns the ñ entity when it sees the ö character
            reference. Sorry, I don't remember the details, but I think it was
            connected with xalan. It works by doing a translation from character
            reference to entity during the serialization process.

            Google might help you track it down -- sorry I don't have time right
            this second. Good luck!

            Chris Loschen

            -----Original Message-----
            From: XSL-FO@yahoogroups.com [mailto:XSL-FO@yahoogroups.com] On Behalf
            Of G. Ken Holman
            Sent: Wednesday, August 24, 2005 11:38 AM
            To: XSL-FO@yahoogroups.com
            Subject: Re: [XSL-FO] Character entity Reference.

            At 2005-08-24 15:18 +0000, touchlenin wrote:
            >Does anyone know, how to retain the Character entity reference in the
            >output XML after XSL transformation.

            It is outside the scope of XSLT 1.0 to preserve the input syntax in the
            output syntax.

            >ie., for example, i have an XML like
            >
            >Source.xml
            >-----------
            ><author>
            > <abstract>This is an abstract ñ</abstract>
            > <title>This is a title</title>
            > ...
            ></author>
            >
            >normally after this source xml is transformed using XSL the "ñ"
            >transforms to its corresponding symbol.

            Correct ... the XSLT processor is allowed to use any syntax for the
            output serialization. In fact, the XSLT processor doesn't even know the
            input syntax that was acted on by the embedded XML processor.

            >But my requirement is to retain the "ñ" character entity in the
            >resultant XML after stylesheet transformation.

            There is no built-in entity for ñ in XML, and there is no control
            over the internal declaration subset of the output serialization, so
            there is no way to preserve this in XSLT 1.0.

            I hope this help, though I realize it doesn't give you the answer you
            want.

            . . . . . . . . Ken


            --
            World-wide on-site corporate, govt. & user group XML/XSL training.
            G. Ken Holman mailto:gkholman@...
            Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
            Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
            Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/f/bc
            Legal business disclaimers: http://www.CraneSoftwrights.com/legal



            ------------------------ Yahoo! Groups Sponsor --------------------~-->
            Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home
            page http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/9rHolB/TM
            --------------------------------------------------------------------~->


            Yahoo! Groups Links










            _______________
            Siebel
            IT'S ALL ABOUT THE CUSTOMER
            Visit www.siebel.com

            This e-mail message is for the sole use of the intended recipient(s) and contains confidential and/or privileged information belonging to Siebel Systems, Inc. or its customers or partners. Any unauthorized review, use, copying, disclosure or distribution of this message is strictly prohibited. If you are not an intended recipient of this message, please contact the sender by reply e-mail and destroy all soft and hard copies of the message and any attachments. Thank you for your cooperation.
          • Eliot Kimber
            ... With XSLT 2 you can use the character map feature to map specific characters to any string in the output, including an entity reference. However, this
            Message 5 of 5 , Aug 24, 2005
              touchlenin wrote:
              > Greetings to all,
              >
              > Does anyone know, how to retain the Character entity reference in
              > the output XML after XSL transformation.

              With XSLT 2 you can use the character map feature to map specific
              characters to any string in the output, including an entity reference.
              However, this requires you to define a mapping for each
              character--there's no way to have a generalized entity-preserving mechanism.

              One way to do this out side of, but in concert with your XSLT processor,
              is to create a custom SAX filter that escapes entity references before
              the XML data stream is passed to the XSLT processor. For example, you
              could use the SAX filter to change entity references to elements and
              then use template rules to output the corresponding entity reference for
              those tags, e.g.:

              ˜ -> SAX filter -> <mystuff:entityref name="tilde"/> -> XSLT:

              <xsl:template match="mystuff:entityref">
              <xsl:text disable-output-escaping="yes">&</xsl:text>
              <xsl:value-of select="@name"/>
              <xsl:text>;</xsl:text>
              </xsl:template>

              Cheers,

              E.
              --
              W. Eliot Kimber
              Professional Services
              Innodata Isogen
              9390 Research Blvd, #410
              Austin, TX 78759
              (512) 372-8155

              ekimber@...
              www.innodata-isogen.com
            Your message has been successfully submitted and would be delivered to recipients shortly.