2010-05-12 2 views
1

요소 ComplexType을 확인할 수 있습니까?XSLT 유형 검사

난이 (간체)를 가지고

complexType Record 
complexType Customer extension of Record 
complexType Person extension of Record 

<xsl:template match="/"> 
    <records> 
    <xsl:apply-templates /> 
    </records> 
</xsl:template> 

<xsl:template match="!!! TYPECHECK FOR RECORD !!!" name="Record"> 
    <record><xsl:value-of select="." /></record> 
</xsl:template> 

것이 가능 elementstype 포함 확인한다. 상속?

요소 이름은 Record의 하위 유형이라는 것을 알고 있습니다.

schema 1: 
    complexType name="Customer" 
     extension base="Record" 

    element name="customers" 
     element name="customer" type="Customer" 

schema 2: 
    complexType name="Person" 
     extension base="Record" 

    element name="persons" 
     element name="person" type="Person" 

schema ?: 
    complexType name="UnknownType" 
     extension base="Record" 

    element name="unknowns" 
     element name="unknown" type="UnknownType" 

xml 1: 
<customers> 
    <customer /> 
    <customer /> 
</customers> 

xml 2: 
<persons> 
    <person /> 
    <person /> 
</persons> 

xml ?: 
<?s> 
    <? /> 
    <? /> 
</?s> 

난 당신이 무슨 뜻인지 모르겠어요 (내가 생각하는) 유형

+0

좋은 질문 (+1). 솔루션에 대한 내 대답을 참조하십시오. :) –

답변

0

에 의해 일치 할 필요가 있도록 XML 입력 IST 사용자 정의.

다른 태그 이름은 태그 이름이 다르므로 xslt에서는 노드 유형을 결정하는 태그를보아야합니다.

실제로 노드가 논리에 의해 지정된 구조를 가지고 있는지 확인하는 것은 xslt 작업이 아닙니다. 이를 위해 xslt 프로세서에 전달하기 전에 스키마에 대해 문서의 유효성을 검사해야합니다.

편집

난 아직 잘 모르겠지만, 내 this question 어떤 도움이 될 수 있었던 것처럼 보인다.

+0

요소 이름은 유형에 바인딩되지 않고 트리의 단지 표현입니다. complexType name = "Record"... 요소 이름 = "x"type = "Record", 요소 이름 = "y "type ="기록 ". 둘 다 기록입니다. 내 상황에서는 그것을 모르기 때문에 요소 이름을 사용할 수 없습니다. –

+0

요청한 내용을 이해하기 전에 실제 XML을 게시해야 할 수도 있습니다. 나는 솔직히 길을 잃었다. –

+0

아직 확실하지 않지만 링크를 방문하여 도움이되는지 확인하십시오. – GSerg

1

XPath는 2.0 (이것은 XSLT 2.0 수단) 하나의 연산자 instance-of 사용할 수

. instance-of element(*, my:Record)