XSLT failing to load include tag in XSD schema file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    XSLT failing to load include tag in XSD schema file

    I am trying to run an XSLT on a schema (XSD) file. The schema file has a "xsd:includ e" 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
    Code:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <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">
    	<xsd:include schemaLocation="XMLife2.18.00.xsd" />
    	<xsd:element name="ChangeSubType" type="ChangeSubType_Type" />
    .....
    .....
    .....
    </xsd:schema>
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    The XSLT engine treats the file purely as XML, ignoring the other meaning behind include.
    I would suggest including a template like so:

    [code=xml]
    <xsl:template match="xsd:incl ude">
    <xsl:apply-templates select="documen t(@schemaLocati on)"/>
    </xsl:template>
    [/code]

    Comment

    • pronerd
      Recognized Expert Contributor
      • Nov 2006
      • 392

      #3
      Removed post after re-reading the above response.

      Comment

      • pronerd
        Recognized Expert Contributor
        • Nov 2006
        • 392

        #4
        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.

        Comment

        • jkmyoung
          Recognized Expert Top Contributor
          • Mar 2006
          • 2057

          #5
          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
          [code=xml]
          <xsl:variable name="master">
          <xsl:apply-templates select="/" mode="copy"/>
          </xsl:variable>
          <xsl:template match="xsd:incl ude" mode="copy">
          <xsl:apply-templates select="documen t(@schemaLocati on)/xsd:schema/*"/>
          </xsl:template>
          <xsl:template match="*" mode="copy">
          <xsl:copy>
          <xsl:copy-of select="@*"/>
          <xsl:apply-templates/>
          </xsl:copy>
          </xsl:template>
          --
          rest of xsl...
          [/code]

          Comment

          • pronerd
            Recognized Expert Contributor
            • Nov 2006
            • 392

            #6
            Originally posted by jkmyoung
            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.

            Comment

            Working...