<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:nor="http://schemas.cordys.com/NorthwindMetadata">
<soapenv:Header/>
<soapenv:Body>
<nor:UpdateOrder_x0020_Details reply="yes" commandUpdate="no" preserveSpace="no" batchUpdate="no">
<nor:tuple>
<nor:new>
<nor:Order_x0020_Details qAccess="0" qConstraint="0" qInit="0" qValues="">
<nor:OrderID>11113</nor:OrderID>
<nor:ProductID>43</nor:ProductID>
<nor:UnitPrice>36.0000</nor:UnitPrice>
<nor:Quantity>25</nor:Quantity>
<nor:Discount>0</nor:Discount>
</nor:Order_x0020_Details>
</nor:new>
</nor:tuple>
<nor:tuple>
<nor:new>
<nor:Order_x0020_Details qAccess="0" qConstraint="0" qInit="0" qValues="">
<nor:OrderID>11113</nor:OrderID>
<nor:ProductID>30</nor:ProductID>
<nor:UnitPrice>99.000</nor:UnitPrice>
<nor:Quantity>10</nor:Quantity>
<nor:Discount>0</nor:Discount>
</nor:Order_x0020_Details>
</nor:new>
</nor:tuple>
<nor:tuple>
<nor:new>
<nor:Order_x0020_Details qAccess="0" qConstraint="0" qInit="0" qValues="">
<nor:OrderID>11113</nor:OrderID>
<nor:ProductID>40</nor:ProductID>
<nor:UnitPrice>88.0000</nor:UnitPrice>
<nor:Quantity>19</nor:Quantity>
<nor:Discount>0</nor:Discount>
</nor:Order_x0020_Details>
</nor:new>
</nor:tuple>
</nor:UpdateOrder_x0020_Details>
</soapenv:Body>
</soapenv:Envelope>
3
A
답변
0
사용이 XPath를 사용하여 아래 데이터에서 제품 ID의 최소 및 최대 값을 찾을 수 있습니다에
//nor:tuple[
not(following-sibling::nor:tuple/nor:new//nor:ProductID > nor:new//nor:ProductID
or
preceding-sibling::nor:tuple/nor:new//nor:ProductID > nor:new//nor:ProductID)
]
가 (최대 값을 찾기 위해 예를 43
) :
//nor:tuple[
not(following-sibling::nor:tuple/nor:new//nor:ProductID > nor:new//nor:ProductID
or
preceding-sibling::nor:tuple/nor:new//nor:ProductID > nor:new//nor:ProductID)
]/nor:new//nor:ProductID
는, 최소 값을 찾을 수 <
와 >
를 교체하려면.
1
I. XPath는 2.0
사용이 XPath는 2.0 표현 : 각각
max(/*/*/*/*/*/*/nor:ProductID)
과 :
min(/*/*/*/*/*/*/nor:ProductID)
II. XPath는 1.0
사용이 XPath는 1.0 식 : 각각
/*/*/*/*/*/*/nor:ProductID
[not(. > following::nor:ProductID)
and
not(. > preceding::nor:ProductID)
]
하고 :
:
여기/*/*/*/*/*/*/nor:ProductID
[not(. < following::nor:ProductID)
and
not(. < preceding::nor:ProductID)
]
두 솔루션의 XSLT 기반 인증 인 I. XSLT 1.0 :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:nor="http://schemas.cordys.com/NorthwindMetadata">
<soapenv:Header/>
<soapenv:Body>
<nor:UpdateOrder_x0020_Details reply="yes" commandUpdate="no" preserveSpace="no" batchUpdate="no">
<nor:tuple>
<nor:new>
<nor:Order_x0020_Details qAccess="0" qConstraint="0" qInit="0" qValues="">
<nor:OrderID>11113</nor:OrderID>
<nor:ProductID>43</nor:ProductID>
<nor:UnitPrice>36.0000</nor:UnitPrice>
<nor:Quantity>25</nor:Quantity>
<nor:Discount>0</nor:Discount>
</nor:Order_x0020_Details>
</nor:new>
</nor:tuple>
<nor:tuple>
<nor:new>
<nor:Order_x0020_Details qAccess="0" qConstraint="0" qInit="0" qValues="">
<nor:OrderID>11113</nor:OrderID>
<nor:ProductID>30</nor:ProductID>
<nor:UnitPrice>99.000</nor:UnitPrice>
<nor:Quantity>10</nor:Quantity>
<nor:Discount>0</nor:Discount>
</nor:Order_x0020_Details>
</nor:new>
</nor:tuple>
<nor:tuple>
<nor:new>
<nor:Order_x0020_Details qAccess="0" qConstraint="0" qInit="0" qValues="">
<nor:OrderID>11113</nor:OrderID>
<nor:ProductID>40</nor:ProductID>
<nor:UnitPrice>88.0000</nor:UnitPrice>
<nor:Quantity>19</nor:Quantity>
<nor:Discount>0</nor:Discount>
</nor:Order_x0020_Details>
</nor:new>
</nor:tuple>
</nor:UpdateOrder_x0020_Details>
</soapenv:Body>
</soapenv:Envelope>
원하는 정확한 결과 제작된다 :이 변환은 제공된 XML 문서에인가
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:nor="http://schemas.cordys.com/NorthwindMetadata">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
min: <xsl:value-of select=
"/*/*/*/*/*/*/nor:ProductID
[not(. > following::nor:ProductID)
and
not(. > preceding::nor:ProductID)
]
"/>
<xsl:text>/ max: </xsl:text>
<xsl:value-of select=
"/*/*/*/*/*/*/nor:ProductID
[not(. < following::nor:ProductID)
and
not(. < preceding::nor:ProductID)
]
"/>
</xsl:template>
</xsl:stylesheet>
min: 30/ max: 43
II. XSLT 2.0 :
이 변환 (위) 같은 XML 문서에 적용되는<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:nor="http://schemas.cordys.com/NorthwindMetadata">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
max: <xsl:sequence select=
"max(/*/*/*/*/*/*/nor:ProductID)"/>
<xsl:text>/ min: </xsl:text>
<xsl:sequence select=
"min(/*/*/*/*/*/*/nor:ProductID)"/>
</xsl:template>
</xsl:stylesheet>
, 다시 원하는, 정답은 생산 :
max: 43/ min: 30
최종 참고 : 언제나처럼 XPath 표현식에 접두어가 붙은 이름이있을 때, 사용 된 XPath 엔진의 API가 네임 스페이스 및 접두사의 바인딩을 등록하는 데 사용되어 있어야합니다.
관련 문제
- 1. MATLAB에서 다차원 행렬의 최대 또는 최소를 어떻게 찾을 수 있습니까?
- 2. vb.net을 사용하여 배열에서 최소값과 최대 값 찾기
- 3. 최소값과 최대 값을 가진 php - srand? 또는 PRNG 대안?
- 4. Java에서 xpath 표현식을 확인하십시오.
- 5. xtraGridControl에서 편집 가능한 열의 최소값과 최대 값을 설정하십시오.
- 6. PHP 배열의 최소값과 최대 값 얻기
- 7. Selenium IDE에서 xPath 표현식을 어떻게 확인합니까?
- 8. JqueryUi 범위 슬라이더 : 최소값과 최대 값을 구분 된 필드에 넣습니다.
- 9. IEEE 확장 배정 밀도의 최소값과 최대 값을 계산하는 방법은 무엇입니까?
- 10. XPath 표현식을 구문 분석합니다.
- 11. XPath 문에서 문자열 위치 (인덱스)를 어떻게 찾을 수 있습니까?
- 12. XPath 표현식을 문서 순서로 정렬
- 13. 정규 표현식을 사용하여 java 클래스의 메소드를 찾을 수 있습니까?
- 14. XPath 표현식을 사용하여 하위 노드에 액세스 할 수 없음
- 15. XPath 1.0으로 최대 자식 수 찾기
- 16. ggplot2를 사용하여 표현식을 대체 할 수 있습니까?
- 17. Linq를 사용하여 UIElement를 어떻게 찾을 수 있습니까?
- 18. (C++) 어떻게 최대 시스템 날짜를 찾을 수 있습니까?
- 19. 아래의 LINQ 쿼리를 어떻게 향상시킬 수 있습니까?
- 20. MSXML에서 XPath 쿼리의 최대 길이가 있습니까?
- 21. 정규 표현식을 사용하여 특정 크기의 단어를 어떻게 일치시킬 수 있습니까?
- 22. PHP에서 정규 표현식을 사용하여 모든 조건을 어떻게 일치시킬 수 있습니까?
- 23. javascript에서 "프로토 타입"값을 어떻게 찾을 수 있습니까?
- 24. 이 정규 표현식을 어떻게 향상시킬 수 있습니까?
- 25. Htm.Textbox MVC의 최대 값을 어떻게 설정할 수 있습니까?
- 26. xpath 표현식을 사용하여 html 파일의 요소를 모두 찾습니다.
- 27. XPath 값을 기준으로 특성을 선택하십시오.
- 28. 어떻게 datagridview에서 동일한 값을 반복 찾을 수
- 29. XPath (lxml)에서 요소의 내용을 어떻게 일치시킬 수 있습니까?
- 30. GDataXML - xpath min 함수를 찾을 수 없음
좋은 질문입니다. +1. 두 가지 다른 (XPath 1.0 및 XPath 2.0) one-liner 표현에 대한 내 대답을보십시오. 완벽한 XSLT 기반 검증도 제공됩니다. –