This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Importing ns from xml to xslt (?!) ...


Hi,

I've just starting fiddling around with xforms in xslt.

My current problem is that the form elements (input, etc) should contain
xpath ref's to elements in xforms:model/instance. The XSL uses evaluate()
to do this so that's not a problem (except it being xslt off-spec).

BUT, these ref's will most often be namespaced. And, since the idea is to
make a general xsl to be used with all xforms, the xsl would not be aware
of these namespaces resulting in the evaluate() not being able to perform.

See the working example xml/xsl below. The current  xmlns:my=...  in
xsl:stylesheet  should not be there. Is this possible in some way?


Thanks,
-Kurt.


---XML---

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="xforms.xsl" type="text/xsl"?>

<thing
  xmlns:xforms="http://www.w3.org/2002/01/xforms";
  xmlns:my="http://my.com";
>

  <xforms:model>
    <xforms:instance>
      <project xmlns="http://my.com";>
        <title>The Dummy Project</title>
        <leader>
          <firstname>Jane</firstname>
          <lastname>Eyre</lastname>
        </leader>
      </project>
    </xforms:instance>
  </xforms:model>

  <group xmlns="http://www.w3.org/2002/01/xforms";>
    <input ref="my:title">
      <caption>Project</caption>
    </input>
    <input ref="my:leader/my:firstname">
      <caption>First name</caption>
    </input>
    <input ref="my:leader/my:lastname">
      <caption>Last name</caption>
    </input>
  </group>

</thing>



---XSL---

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xsl:version="1.0"
  xmlns:saxon="http://icl.com/saxon"; extension-element-prefixes="saxon"
  xmlns:xforms="http://www.w3.org/2002/01/xforms";

  xmlns:my="http://my.com";

>

  <xsl:output method="html" encoding="ISO-8859-1"/>

  <xsl:template match="thing">
    <H1>xforms-xslt // test 1</H1>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="xforms:group//xforms:input">
    <small><xsl:value-of select="xforms:caption"/></small><br/>
    <input name="{@ref}"
      value="{
        saxon:evaluate(
          concat('//xforms:model/xforms:instance//',@ref)
        )
      }"
    />
    <br/><br/>
  </xsl:template>

  <xsl:template match="xforms:model"/>

</xsl:stylesheet>















__________
kurt george gjerde <kurt.gjerde@media.uib.no>
intermedia uib, university of bergen






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]