469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

XSLT failing to load include tag in XSD schema file

392 Expert 256MB
I am trying to run an XSLT on a schema (XSD) file. The schema file has a "xsd:include" tag that includes another XSD file. When I load the schema in XML editors like XML Spy the data from all of the files is loaded. When I run the XSL translation only the XSD data from the first file is loaded and translated. The data from the file referenced in the included tag is skipped.

Anyone have any ideas why?

Example XSD file
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" standalone="yes"?>
  2. <xsd:schema targetNamespace="http://ACORD.org/Standards/Life/2" xmlns="http://ACORD.org/Standards/Life/2" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="2.18.00" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  3.     <xsd:include schemaLocation="XMLife2.18.00.xsd" />
  4.     <xsd:element name="ChangeSubType" type="ChangeSubType_Type" />
  5. .....
  6. .....
  7. .....
  8. </xsd:schema>
  9.  
Mar 21 '08 #1
5 3981
jkmyoung
2,057 Expert 2GB
The XSLT engine treats the file purely as XML, ignoring the other meaning behind include.
I would suggest including a template like so:

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="xsd:include">
  2.   <xsl:apply-templates select="document(@schemaLocation)"/>
  3. </xsl:template>
  4.  
Mar 24 '08 #2
pronerd
392 Expert 256MB
Removed post after re-reading the above response.
Mar 24 '08 #3
pronerd
392 Expert 256MB
Im afraid that does not work. That runs the XSLT on the three files independently. It needs to load and process them all as one file. The same way it would if you where loading the XSD to validate XML data.

I have tried it in JDeveloper and XML Spy with the same problem. I also tried removing the XSL prefix. I can not seem to find a way to get it to process the include tag.
Mar 25 '08 #4
jkmyoung
2,057 Expert 2GB
Is it possible to create a giant merged xsd through one pass, and then run a xslt on the result?

Another option might be to create a global reference variable, with all 3 files in it. eg
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="master">
  2.   <xsl:apply-templates select="/" mode="copy"/>
  3. </xsl:variable>
  4. <xsl:template match="xsd:include" mode="copy">
  5.   <xsl:apply-templates select="document(@schemaLocation)/xsd:schema/*"/>
  6. </xsl:template>
  7. <xsl:template match="*" mode="copy">
  8.   <xsl:copy>
  9.     <xsl:copy-of select="@*"/>
  10.     <xsl:apply-templates/>
  11.   </xsl:copy>
  12. </xsl:template>
  13. --
  14. rest of xsl...
  15.  
Mar 25 '08 #5
pronerd
392 Expert 256MB
Is it possible to create a giant merged xsd through one pass, and then run a xslt on the result?
Sorry, that I did not follow up with the solution. That is exactly what I ended up doing.
Apr 1 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

20 posts views Thread by Bernd Fuhrmann | last post: by
1 post views Thread by Duane Morin | last post: by
1 post views Thread by Wil | last post: by
3 posts views Thread by Teksure | last post: by
reply views Thread by Terry Brown | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.