XSD 문서를 가지고 있는데, complexTypes에 다른 complexType 인 요소가 자주 포함되어있는 문서화를 위해 XSL을 구문 분석하려고합니다. 가능한 경우 이러한 컨테이너 옆에 복잡한 유형 요소의 내용을 표시하고 싶습니다.XSL로 XSD 복합 요소 유형을 확장 하시겠습니까?
<xs:complexType name="S">
<xs:sequence>
<xs:element name="A" type="X"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="X">
<xs:sequence>
<xs:element name="F"/>
<xs:element name="G"/>
<xs:element name="H"/>
</xs:sequence>
</xs:complexType>
가 어떻게 위의이 같은으로 표시 얻을 것이다 : 여기에 내가 함께 일하고 있어요 무엇의 간단한 예제가 "S는 X 형의 포함 (F, G를 포함하고 H)?"
미리 도움 주셔서 감사합니다.
추가 예 :
<xsl:for-each select="*">
<xsl:choose>
<!-- call template without param -->
<xsl:when test="name() = 'xs:complexType'">
<xsl:value-of select="@name"/>
<xsl:text> contains </xsl:text>
<xsl:call-template name="top"/>
<xsl:text>
</xsl:text>
</xsl:when>
<!-- for contained elements with types -->
<xsl:when test="@type != '' and name() = 'xs:element' and $typeToLocate = ''">
<xsl:value-of select="@name"/>
<xsl:text> of type </xsl:text>
<xsl:value-of select="@type"/>
<xsl:text>(which contains: </xsl:text>
<!--
point at which i want processor to return to root, locate the
indicated complex type, output its contents then continue going
through schema.
-->
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="@type"/>
</xsl:call-template>
<xsl:text>)</xsl:text>
</xsl:when>
<!-- when type is located, send it to signal proper output -->
<xsl:when test="$typeToLocate != '' and $typeToLocate = @name">
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="$typeToLocate"/>
</xsl:call-template>
</xsl:when>
<!-- for elements contained in indicated type -->
<xsl:when test="$typeToLocate != '' and name() = 'xs:element'">
<xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="$typeToLocate"/>
</xsl:call-template>
</xsl:when>
<!-- for continuing through non-content elements under found type -->
<xsl:when test="$typeToLocate != ''">
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="$typeToLocate"/>
</xsl:call-template>
</xsl:when>
<!-- for ignoring non-content elements during normal processing -->
<xsl:otherwise>
<xsl:call-template name="top"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
게리슨의 응답을 줄이기 위해 코드를 작성하지 않아도됩니다 (이 방법은 무료 프로그래밍 서비스는 아닙니다). 문제가 발생한 곳을 모른 채 질문에 대답하기는 어렵습니다. 솔루션에 대한 우리의 최선의 시도는 당신이 알고있는 것과 모르는 것을 드러내는 데 도움이 될 것입니다. –
죄송합니다. 필자가 작성한 것의 일부분을 편집했습니다. (더 빨리 첨부했을지라도 읽을 수는 없었습니다.) 다행히도 내가 찾고있는 것을 전달하기를 바랍니다. – erodious
XSLT/XSD 기술을 측정 할 일종의 과제에 대해 궁금한가요? 또는 특정 XSD에 대한 재미있는 프로젝트입니까? 내가 묻는 이유는 XML 네임 스페이스를 사용한다면 어떨까요? 접두사를 URI로 확장 할 예정입니까? XSD가 다른 XSD를 참조하는 경우 (include/import/redefine)? 재미있게하려면 유형, 그룹 또는 XSD 파일과 같은 몇 가지 순환 종속성을 코딩하십시오. 실생활의 XSD를 사용하고 있다면이 특정 작업에 XSLT를 다시 사용하는 것이 좋습니다. –