[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xpath expression in <xsl:stylesheet> element

Subject: xpath expression in <xsl:stylesheet> element
From: astockley@xxxxxxxxxxx
Date: Fri, 24 Aug 2001 10:05:07 -0700
xpath expression in xsl
I am trying to create a generic stylesheet for a number of different
input.xml. Each input.xml has a different factType which in turn has its
own schema whose location and name I want to specify in the output. (For
Example ideally I want the output root element to be
<LoginHypothesis xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:ia="http://www.orincon.com/ia" xsi:schemaLocation=
"http://www.orincon.com/ia LoginHypothesis.xsd">)

I would also like to automatically get the name of the schema from the
incoming document as opposed to having it hard coded in the stylesheet.

1) How do I get the "xsi:schemaLocation="http://www.orincon.com/ia
LoginHypothesis.xsd" text to appear?
2) Can I use xpath in the <xsl:stylesheet> element to extract this
LoginHypothesis factType value from the input.xml?

I have tried xsi:schemaLocation="http://www.orincon.com/ia
{ia:unorderedFact/child::factType/text()}.xsd" with no joy.

Any suggestions on how I handle this gratefully received.

Thank you

Annie

This is what I have at the moment
input.xml
<ia:unorderedFact
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="http://www.orincon.com/ia UnorderedFact.xsd"
xmlns:ia="http://www.orincon.com/ia">
     <factType>LoginHypothesis</factType>
     <slot>
          <tag>userName</tag>
          <ia:userName>jpublic</ia:userName>
     </slot>
     <slot>
          <tag>hostName</tag>
          <ia:hostName>linux1</ia:hostName>
     </slot>
...
</ia:unorderedFact>

stylesheet.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:ia="http://www.orincon.com/ia"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<xsl:output method="xml" indent="yes"/>
  <xsl:template match="ia:unorderedFact">
    <xsl:element name="{child::factType/text()}">
      <xsl:text/>
      <xsl:for-each select="//slot">
        <xsl:choose>
           <xsl:when test="count(child::*)=2">
             <xsl:element name="{child::tag/text()}">
               <xsl:value-of select="./*[position()=2]"/>
             </xsl:element>
             <xsl:text/>
           </xsl:when>
           <xsl:when test="count(child::*)>2">
......
</xsl:stylesheet>

output.xml
<?xml version="1.0" encoding="UTF-8"?>
<LoginHypothesis xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:ia="http://www.orincon.com/ia">
<userName>jpublic</userName>
<hostName>linux1</hostName>
....
</LoginHypothesis>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.