2 Replies Latest reply: Feb 14, 2013 4:23 PM by Marco Gralike RSS

    Specifying Pretty_Print

    CRoberts
      I am working with this version of Oracle:
      BANNER
      ------------------------------------------------------------------------------
      Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
      PL/SQL Release 11.2.0.2.0 - Production
      CORE    11.2.0.2.0      Production
      TNS for Solaris: Version 11.2.0.2.0 - Production
      NLSRTL Version 11.2.0.2.0 - Production
      My problem concerns retrieving xml documents from Oracle's XDB repository. These retrieved document are used by another service that converts these into both Html and Pdf formats for distribution. However, once is a great while this conversion fails. Those responsible for this service allege that the failure occurs because the documents are in Pretty_Print. I am not fully convinced of this and need to find out if that is in fact the case.

      The documents in question are shredded xml documents that use the older Object-Relational method of storage. To retrieve a document I simply use XdbUriType (wrapped via a Plsql function):
      Select XdbUriType('/legalservices/repository/drafts/2013/RN201301110.caml.history/RN20130111001.caml').GetClob() as doc
      FROM Dual
      I get a document like this. This is merely a template, if fully fleshed out it could be megabytes in size:
      <?xml version="1.0" encoding="UTF-8"?>
      <?xml-stylesheet type="text/xsl" href="/legalservices/application/editor/pkgs/caml/MeasureDoc_to_HTML.1.xsl"?>
      <caml:MeasureDoc xmlns:caml="http://lc.ca.gov/legalservices/schemas/caml.1#" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3
      .org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1" xsi:schemaLocatio
      n="http://lc.ca.gov/legalservices/schemas/caml.1#                       /legalservices/application/schemas/CAML.1.xsd">
        <caml:Description>
          <caml:RequestNum>RN1301110</caml:RequestNum>
          <caml:SecurityNum>xxxxx</caml:SecurityNum>
          <caml:Id>RN20130111001</caml:Id>
          <caml:VersionNum>01</caml:VersionNum>
          <caml:LegislativeInfo>
            <caml:MeasureType>BILL</caml:MeasureType>
            <caml:MeasureState>DRAFT</caml:MeasureState>
          </caml:LegislativeInfo>
          <caml:Authors>
            <caml:Legislator idRef="{idRef}">
              <caml:Contribution>LEAD_AUTHOR</caml:Contribution>
              <caml:House>ASSEMBLY</caml:House>
              <caml:Name>______</caml:Name>
            </caml:Legislator>
          </caml:Authors>
          <caml:Title xmlns:caml="http://lc.ca.gov/legalservices/schemas/caml.1#">
               An act to <?xm-replace_text {Enter the title here}?>
               relating to <?xm-replace_text {relatingTo}?>.
            </caml:Title>
          <caml:GeneralSubject>
            <caml:Subject>
              <?xm-replace_text {Enter the Subject Here}?>
            </caml:Subject>
          </caml:GeneralSubject>
          <caml:DigestText xmlns:caml="http://lc.ca.gov/legalservices/schemas/caml.1#"><p xmlns="http://www.w3.org/1999/xhtml">
              <?xm-replace_text {Enter the digest text here}?>
            </p></caml:DigestText>
          <caml:DigestKey>
            <caml:VoteRequired>MAJORITY</caml:VoteRequired>
            <caml:Appropriation>NO</caml:Appropriation>
            <caml:FiscalCommittee>NO</caml:FiscalCommittee>
            <caml:LocalProgram>NO</caml:LocalProgram>
          </caml:DigestKey>
        </caml:Description>
        <caml:Bill id="bill">
          <caml:Preamble>The people of the State of California do enact as follows:</caml:Preamble>
        </caml:Bill>
      </caml:MeasureDoc>
      This sort of looks like it is in Pretty_Print, but it may not be. It may be faithfully rendered exactly the Xml Editor created it. Here are my questions:

      1) How can I tell explicitly if a document is being reconstituted using Pretty_Print. Perhaps an environmental or context test prior to retrieval?
      2) Is this retrieval method flawed or perhaps a better somewhat exists? Is it somewhat better to use XQuery?
      3) Is there a replacement for DBMS_XDBUTIL_INT.SETPRINTMODE other than using XmlSerialize?

      Thank you.
        • 1. Re: Specifying Pretty_Print
          odie_63
          Those responsible for this service allege that the failure occurs because the documents are in Pretty_Print. I am not fully convinced of this and need to find out if that is in fact the case.
          I'm not convinced either.
          I've already seen some third-party tools failing because the content was not in pretty-print, but never the opposite.
          This sort of looks like it is in Pretty_Print, but it may not be. It may be faithfully rendered exactly the Xml Editor created it.
          So what's your definition of "Pretty Print"? What's "their" definition?

          2) Is this retrieval method flawed or perhaps a better somewhat exists? Is it somewhat better to use XQuery?
          What would be the "flaw" you're talking about?

          Yes, you can use XQuery and access the repository via the fn:doc function, this does not pretty-print (as far as my tests go) :
          select xmlserialize(document column_value)
          from xmltable(
               'fn:doc("/legalservices/repository/drafts/2013/RN201301110.caml.history/RN20130111001.caml")'
             ) ;
          However, if we use the optimized method that target the underlying OR table directly, it does pretty-print :
          select xmlserialize(document column_value)
          from xmltable(
               '(#ora:defaultTable YOUR_TABLE #)
                {fn:doc("/legalservices/repository/drafts/2013/RN201301110.caml.history/RN20130111001.caml")}'
           ) ;
          3) Is there a replacement for DBMS_XDBUTIL_INT.SETPRINTMODE other than using XmlSerialize?
          Where did you learn about SETPRINTMODE? It's not documented and only used internally.

          What's wrong with XMLSerialize?
          Ultimately, if the issue is really the pretty-printing behaviour then you could always use it with the NO INDENT option.
          • 2. Re: Specifying Pretty_Print
            Marco Gralike
            - LOL Start -

            Just wanted to make a remark that it would be stupid to rely on internal packages due to the fact that it is at Oracle's discretion when they change it or how they use it without being obliged to follow rules and therefore being marked as "undocumented".

            They only way probably could have been come up with this use of the package is due http://psoug.org/reference/dbms_xdbutil_int.html, but that site doesn't have a warning regarding "you're stupid if you are actually using this in your code for production reasons"... So my :-) when I saw the remark on DMorgan's site of undocumented obscurities "SETPRINTMODE (dropped from 11g)"
            Why use something like XMLSERIALIZE that is supported by Oracle if you can use of something that is cool and undocumented

            - End of LOL -