Menu

building LinkedTree from TinyTree loses base

David Lee
2009-03-07
2012-10-08
  • David Lee

    David Lee - 2009-03-07

    If I re-build a LinkedTree model from a TinyTree model, the base URI of interier expanded entity nodes is lost.

    Example
    If I start with this document and build a TinyTree from this URI

    http://tests.xproc.org/tests/doc/xml-base-test.xml

    which is

    <!DOCTYPE doc
    <!ENTITY subdoc SYSTEM "xml-base-chap.xml">
    >
    <doc>
    <p>This has one base URI: <uri>xml-base-test.xml</uri></p>
    <?pi in base-test?>
    &subdoc;
    <p>This has the original base URI.</p>
    </doc>

    ============

    I can get the base URI of the included <div> element correctly

    base-uri( $foo//div ) =>
    http://tests.xproc.org/tests/doc/xml-base-chap.xml

    But if I then re-build a LinkedTree from the TinyTree the base URI of the expanded node (div) is lost

    Using this code to re-build the document :

    private XdmNode build( Source src ) throws SaxonApiException
    {
    // Must get element node or saxon doent rebuild, it wraps
    if( src instanceof DocumentInfo )
    src = (NodeInfo)(((DocumentInfo)src).iterateAxis(net.sf.saxon.om.Axis.CHILD).next());

    AugmentedSource asrc = AugmentedSource.makeAugmentedSource(src);
    asrc.setTreeModel(Builder.LINKED_TREE);
    return mBuilder.build(asrc);
    }


    Now using the resulting doc, the base uri is now the documents uri

    base-uri( //div ) =>
    http://tests.xproc.org/tests/doc/xml-base-test.xml

    Is this expected behaviour ? or is this a bug ?
    Is there any way to tell the builder to preserve the base URI's of its source ?

    I can provide full source if needed, (will take a bit of work to extract it out to just this test case, but if it helps I can do it)

    Thank you !
    -David
    dlee@calldei.com

     
    • Michael Kay

      Michael Kay - 2009-03-11

      I have fixed this for the 9.2 release, and have added a couple of tests.

      Meanwhile, I suspect you can achieve the required effect by running a stylesheet that does

      <xsl:template match="/">
      <xsl:copy-of select="."/>
      </xsl:template>

      Michael Kay
      http://www.saxonica.com/

       
      • David Lee

        David Lee - 2009-03-11

        Thanks! It helps knowing I'm not imagining things.