2012-05-14 2 views
1

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>&#xa;</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> 
+0

게리슨의 응답을 줄이기 위해 코드를 작성하지 않아도됩니다 (이 방법은 무료 프로그래밍 서비스는 아닙니다). 문제가 발생한 곳을 모른 채 질문에 대답하기는 어렵습니다. 솔루션에 대한 우리의 최선의 시도는 당신이 알고있는 것과 모르는 것을 드러내는 데 도움이 될 것입니다. –

+0

죄송합니다. 필자가 작성한 것의 일부분을 편집했습니다. (더 빨리 첨부했을지라도 읽을 수는 없었습니다.) 다행히도 내가 찾고있는 것을 전달하기를 바랍니다. – erodious

+0

XSLT/XSD 기술을 측정 할 일종의 과제에 대해 궁금한가요? 또는 특정 XSD에 대한 재미있는 프로젝트입니까? 내가 묻는 이유는 XML 네임 스페이스를 사용한다면 어떨까요? 접두사를 URI로 확장 할 예정입니까? XSD가 다른 XSD를 참조하는 경우 (include/import/redefine)? 재미있게하려면 유형, 그룹 또는 XSD 파일과 같은 몇 가지 순환 종속성을 코딩하십시오. 실생활의 XSD를 사용하고 있다면이 특정 작업에 XSLT를 다시 사용하는 것이 좋습니다. –

답변

0

가 ..., 내가 제안 특정 스타일 시트를 부여하지 않고, 광범위하게 귀하의 질문에 대답하려면

(1) 복잡한 유형에 맞게 템플릿을 생성 XSD 공개 수준. 상기 템플릿을위한 시퀀스 생성자는 "S"와 같은 텍스트의 생성을 직접 담당 할 것이다.

(2) 상기 시퀀스 생성자 내에서, 그러나 상기 텍스트 생성 후에, 복합 형 노드에서 호출한다. 이것은 "contains ..."에서 시작하여 원하는 제작의 나머지 부분을 담당하게됩니다.

(3) 설명 컨텐츠 템플리트를 작성하십시오. 여기에 시퀀스 생성자는 두 부분으로 구성됩니다. (3.1) "포함"과 같은 지속적인 생산. (3.2) 시퀀스 구성원에 대한 apply-templates 호출. 이 부분은 "A 유형 X (which ~)"와 같이 생성됩니다.

(4) xs : sequence/xs : element와 일치하는 템플릿을 만듭니다. 3.2에서 추측 하듯이 시퀀스 생성자는 다음 세 부분으로 구성됩니다. (4.1) "X 유형 A"와 같은 제작 ( (4.2) 자식 복합 유형과 관련하여 설명 컨텐츠 템플릿 호출) ; 그리고 마지막으로 (4.3) ")"의 지속적인 생산

목표가 xs : sequence 및 complex 유형으로 제한되는 경우이를 수행해야합니다. 템플릿이 구문 요소와 대략 일치하는이 템플릿 기반 접근법은 xs : choice 등으로 확장 할 수 있어야합니다.

심 레벨 복합 유형에 대한 재귀 설명이 실제로 필요하다고 가정했습니다. 정의.

관련 문제