xsl-list
[Top] [All Lists]

RE: [xsl] Xpath/XSLT 2.0 & Schema Question

2010-04-01 11:08:18

Schema-awareness means that the type information is used by the XSLT
processor, but there is no standard facility that makes the type information
available for introspection by the application itself.

One thing you could try is to export the schema in Saxon's SCM format, which
is designed to be easier for applications to process than raw schema
documents. There's a Saxon extension function to get the type annotation of
an element or attribute node, and you could use this to get details of the
simple or complex type from the SCM schema. But it rather depends what you
are trying to do with the type information.

Regards,

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

-----Original Message-----
From: Luke Stedman [mailto:luke(_dot_)stedman(_at_)gmail(_dot_)com] 
Sent: 01 April 2010 16:59
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Xpath/XSLT 2.0 & Schema Question

Apologies in advance for what is probably a very 
simple/basic/stupid question.

I have just started using XSL 2.0, having had enough of the 
restrictions of XSL 1.0, and am trying to write a XSL that is 
schema aware.

I would like to process an XML file and add 
information/process something based on the schema, for 
example adding class information to XML output or processing 
an element in a specific way if we want a console script or 
Python script output.

I have tried for the last couple of hours to get the code 
working but seem to be unable to, a small snippet of code is below...

  <xsl:template match="*[(_at_)name and @xsi:type]">
  <xsl:copy>
   <xsl:copy-of select="@*"/>
   <xsl:attribute name="action" select="'new'"/>
   <xsl:variable name="name" select="name(.)"/>
   <xsl:variable name="type" select="current()/@xsi:type"/>
   <xsl:variable name="object" select="element(*, $type)"/> 
<!-- I want to get the relevant schema entry here -->
   <xsl:message>
    ++++
    <xsl:value-of select="current()/@name"/>
    <xsl:variable name="type" select="current()/@xsi:type"/>
    <xsl:value-of select="$object//base"/>
    ++++
   </xsl:message>
   <xsl:apply-templates/>
  </xsl:copy>
 </xsl:template>

Am I misunderstanding the functionality or doing something wrong?

If I have missed a relevant post on the list or obvious link 
then please point me in its direction, I was unable to find 
one using a search.

Apologies again for any stupid comments/expectations.
Luke

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--