我有一個名為 products 的輸入檔案 xml,我的課程 xml 都在組合 xml 中,并且該檔案應該包含課程 xml 中的所有標題。在這種情況下,產品 xml 中的標題數量為 3,即
- 發射類鏈接 - HDU_VILT01 - 1
- 發射類鏈接 - HDU_VILT01 - 3
- 發射類鏈接 - HDU_VILT01 - 5
但在課程 xml 中有 6 個 Instructor_Led_Webinar_Lesson_Data 標題所以我需要回圈并顯示沒有找到匹配課程的驗證。任何人都可以幫助在流模式下回圈。
更新的源 xml
<?xml version='1.0' encoding='utf-8'?>
<FileAndCourses>
<Maps>
<Locations>
<Location>
<InternalValue>7070</InternalValue>
<ExternalValue>Laval</ExternalValue>
</Location>
<Location>
<InternalValue>7000</InternalValue>
<ExternalValue>TORSSC</ExternalValue>
</Location>
</Locations>
<Rooms>
<Room>
<InternalValue>LOCATION-6-3881</InternalValue>
<ExternalValue>Ottawa District Training Center</ExternalValue>
</Room>
</Rooms>
</Maps>
<Instructors>
<Instructor>
<InstructorID>119417764</InstructorID>
<WorkdayUserName>AXH4006</WorkdayUserName>
</Instructor>
</Instructors>
<AllCourses
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wd="urn:com.workday/bsvc">
<wd:Learning_Course>
<wd:Learning_Blended_Course_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2b24f4f5c40000</wd:ID>
<wd:ID wd:type="Learning_Course_ID">00151744</wd:ID>
<wd:ID wd:type="Learning_Course">Designing Kitchens Part II</wd:ID>
</wd:Learning_Blended_Course_Reference>
<wd:Learning_Course_Data>
<wd:ID>00151744</wd:ID>
<wd:Effective_Date>2014-10-04</wd:Effective_Date>
<wd:Inactive>0</wd:Inactive>
<wd:Course_Title>Designing Kitchens Part II</wd:Course_Title>
<wd:Description>Designing Kitchens Part II</wd:Description>
<wd:Course_Number>00151744</wd:Course_Number>
<wd:Topic_Reference>
<wd:ID wd:type="WID">9d1f49654c8310154e239c7090fc0000</wd:ID>
<wd:ID wd:type="Learning_Topic">Product Knowledge - US</wd:ID>
</wd:Topic_Reference>
<wd:Language_Reference>
<wd:ID wd:type="WID">da594226446c11de98360015c5e6daf6</wd:ID>
<wd:ID wd:type="User_Language_ID">en_US</wd:ID>
</wd:Language_Reference>
<wd:Minimum_Enrollment_Capacity>0</wd:Minimum_Enrollment_Capacity>
<wd:Maximum_Enrollment_Capacity>0</wd:Maximum_Enrollment_Capacity>
<wd:Waitlist_Capacity>0</wd:Waitlist_Capacity>
<wd:Unlimited_Capacity>1</wd:Unlimited_Capacity>
<wd:Learning_Pricing_Data>
<wd:Pricing_Enabled>0</wd:Pricing_Enabled>
<wd:Price_in_Training_Credits>0</wd:Price_in_Training_Credits>
</wd:Learning_Pricing_Data>
<wd:Time_Value_Reference>
<wd:ID wd:type="WID">f31be4fd5caa10001d7c625e27014929</wd:ID>
<wd:ID wd:type="Learning_Time_Unit_ID">HOURS</wd:ID>
</wd:Time_Value_Reference>
<wd:Total_Course_Duration>18</wd:Total_Course_Duration>
<wd:Enable_Auto_Enrollment_from_Waitlist>0</wd:Enable_Auto_Enrollment_from_Waitlist>
<wd:Legacy_Course>1</wd:Legacy_Course>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df56ab318140000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">100735117</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">b7f5fd27bc071018bbed7a460ce30000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">119417764</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df57b8e81f30002</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">104034590</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:All_Locations>0</wd:All_Locations>
<wd:Exclude_from_Recommendations>1</wd:Exclude_from_Recommendations>
<wd:Exclude_from_Search_and_Browse>0</wd:Exclude_from_Search_and_Browse>
<wd:Disable_Express_Interest>1</wd:Disable_Express_Interest>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>1</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 1</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>2</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 2</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>3</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 3</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>4</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 4</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>5</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 5</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>6</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 6</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>7</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2b23247d3f0004</wd:ID>
<wd:ID wd:type="Media_ID">MEDIA-6-4195</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">MEDIA-6-4195</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Welcome to HDU Distance Learning</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>8</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>0</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">358e28e73d5d10109aef5b042fc20000</wd:ID>
<wd:ID wd:type="Media_ID">cninv000000000020562.zip</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">cninv000000000020562.zip</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Course Feedback HDUv3</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
</wd:Learning_Course_Data>
</wd:Learning_Course>
<wd:Learning_Course>
<wd:Learning_Blended_Course_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2c78dc802e0001</wd:ID>
<wd:ID wd:type="Learning_Course_ID">00170024CA</wd:ID>
<wd:ID wd:type="Learning_Course">Design Basics (Designer Training 4) - Virtual ILT</wd:ID>
</wd:Learning_Blended_Course_Reference>
<wd:Learning_Course_Data>
<wd:ID>00170024CA</wd:ID>
<wd:Effective_Date>2019-02-26</wd:Effective_Date>
<wd:Inactive>0</wd:Inactive>
<wd:Course_Title>Design Basics (Designer Training 4) - Virtual ILT</wd:Course_Title>
<wd:Description><p>In this 5 module virtual course the designer will learn the basics of drafting and laying out basic designs for Contractors and DIY customers.</p></wd:Description>
<wd:Course_Number>00170024CA</wd:Course_Number>
<wd:Topic_Reference>
<wd:ID wd:type="WID">9d1f49654c8310154e4430e071ef0000</wd:ID>
<wd:ID wd:type="Learning_Topic">Customer Service and Selling Skills - CAN</wd:ID>
</wd:Topic_Reference>
<wd:Language_Reference>
<wd:ID wd:type="WID">da5948c0446c11de98360015c5e6daf6</wd:ID>
<wd:ID wd:type="User_Language_ID">en_CA</wd:ID>
</wd:Language_Reference>
<wd:Minimum_Enrollment_Capacity>4</wd:Minimum_Enrollment_Capacity>
<wd:Maximum_Enrollment_Capacity>10</wd:Maximum_Enrollment_Capacity>
<wd:Waitlist_Capacity>0</wd:Waitlist_Capacity>
<wd:Unlimited_Capacity>0</wd:Unlimited_Capacity>
<wd:Learning_Pricing_Data>
<wd:Pricing_Enabled>0</wd:Pricing_Enabled>
<wd:Price_in_Training_Credits>0</wd:Price_in_Training_Credits>
</wd:Learning_Pricing_Data>
<wd:Time_Value_Reference>
<wd:ID wd:type="WID">f31be4fd5caa10001d7c6231be3b4927</wd:ID>
<wd:ID wd:type="Learning_Time_Unit_ID">MINUTES</wd:ID>
</wd:Time_Value_Reference>
<wd:Total_Course_Duration>900</wd:Total_Course_Duration>
<wd:Enable_Auto_Enrollment_from_Waitlist>0</wd:Enable_Auto_Enrollment_from_Waitlist>
<wd:Legacy_Course>1</wd:Legacy_Course>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df5cfa198ca0000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">718700459</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df5c99611170000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">713400041</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df5c72adbc60000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">702300581</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:All_Locations>0</wd:All_Locations>
<wd:Exclude_from_Recommendations>1</wd:Exclude_from_Recommendations>
<wd:Exclude_from_Search_and_Browse>0</wd:Exclude_from_Search_and_Browse>
<wd:Disable_Express_Interest>1</wd:Disable_Express_Interest>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>1</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 1</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>2</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 2</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>3</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 3</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>4</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 4</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>5</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 5</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>6</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2c770c4c2b0003</wd:ID>
<wd:ID wd:type="Media_ID">MEDIA-6-4222</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">MEDIA-6-4222</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Log in Instructions (Adobe Connect - Designer 4_DesignBasics) (updated May 2022)</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>7</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>0</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">358e28e73d5d1010910342e9c79a0000</wd:ID>
<wd:ID wd:type="Media_ID">cninv000000000019226.zip</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">cninv000000000019226.zip</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Course Evaluation - vILT (L1)</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
</wd:Learning_Course_Data>
</wd:Learning_Course>
</AllCourses>
<Offerings>
<Offering>
<Lesson>
<Offering-ID>C2212001 DL 3Wks Mon 4pm-7pm EASTERN</Offering-ID>
<Course-Number>00151744</Course-Number>
<Min-Seats>10</Min-Seats>
<Max-Seats>20</Max-Seats>
<Webinar>Y</Webinar>
<Title>Launch Class Link - HDU_VILT01 - 1</Title>
<Start-Date>11/28/2022</Start-Date>
<Start-Time>04:00PM</Start-Time>
<End-Date>11/28/2022</End-Date>
<End-Time>07:00PM</End-Time>
<Facilitator-LDAP>AXH4006</Facilitator-LDAP>
<Location/>
<Room/>
<Language>en_US</Language>
<Webinar-URL>https://hdu.adobeconnect.com</Webinar-URL>
</Lesson>
<Lesson>
<Offering-ID>C2212001 DL 3Wks Mon 4pm-7pm EASTERN</Offering-ID>
<Course-Number>00151744</Course-Number>
<Min-Seats>10</Min-Seats>
<Max-Seats>20</Max-Seats>
<Webinar>Y</Webinar>
<Title>Launch Class Link - HDU_VILT01 - 3</Title>
<Start-Date>12/05/2022</Start-Date>
<Start-Time>04:00PM</Start-Time>
<End-Date>12/05/2022</End-Date>
<End-Time>07:00PM</End-Time>
<Facilitator-LDAP>AXH4006</Facilitator-LDAP>
<Location/>
<Room/>
<Language>en_US</Language>
<Webinar-URL>https://hdu.adobeconnect.com</Webinar-URL>
</Lesson>
<Lesson>
<Offering-ID>C2212001 DL 3Wks Mon 4pm-7pm EASTERN</Offering-ID>
<Course-Number>00151744</Course-Number>
<Min-Seats>10</Min-Seats>
<Max-Seats>20</Max-Seats>
<Webinar>Y</Webinar>
<Title>Launch Class Link - HDU_VILT01 - 5</Title>
<Start-Date>12/12/2022</Start-Date>
<Start-Time>04:00PM</Start-Time>
<End-Date>12/12/2022</End-Date>
<End-Time>07:00PM</End-Time>
<Facilitator-LDAP>AXH4006</Facilitator-LDAP>
<Location/>
<Room/>
<Language>en_US</Language>
<Webinar-URL>https://hdu.adobeconnect.com</Webinar-URL>
</Lesson>
</Offering>
</Offerings>
</FileAndCourses>
預期產出
<?xml version="1.0" encoding="UTF-8"?>
<OfferingsWithCourse>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 2</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 4</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 6</Error>
</OfferingsWithCourse>
但得到這個輸出
<?xml version="1.0" encoding="UTF-8"?>
<OfferingsWithCourse>
<Error>No offering for 00170024CA title Session 1</Error>
<Error>No offering for 00170024CA title Session 2</Error>
<Error>No offering for 00170024CA title Session 3</Error>
<Error>No offering for 00170024CA title Session 4</Error>
<Error>No offering for 00170024CA title Session 5</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 2</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 4</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 6</Error>
</OfferingsWithCourse>
我只想驗證輸入檔案課程編號 00151744 而不是源資料上的課程,你能幫幫我嗎?
uj5u.com熱心網友回復:
如果任務是根據/查找任何Offerings/Offering/Lesson/Title匹配項,然后比較and 's那么這是一種使用流式傳輸的方法:wd:LearningCourseCourse-Numberwd:IDTitlewd:Course_Lesson_Datawd:Title
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:wd="urn:com.workday/bsvc"
exclude-result-prefixes="#all"
version="3.0">
<xsl:accumulator name="learning-course-id" as="xs:string?" initial-value="()" streamable="yes">
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:ID/text()" select="string()"/>
</xsl:accumulator>
<xsl:accumulator name="webinars" as="map(xs:string, xs:string*)" initial-value="map{}" streamable="yes">
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:Course_Lesson_Data/wd:Instructor_Led_Webinar_Lesson_Data/wd:Title/text()"
select="let $id := accumulator-before('learning-course-id')
return
if (map:contains($value, $id))
then map:put($value, $id, ($value($id), string()))
else map:put($value, $id, string())"/>
</xsl:accumulator>
<xsl:accumulator name="classroom-lessons" as="map(xs:string, xs:string*)" initial-value="map{}" streamable="yes">
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:Course_Lesson_Data/wd:Instructor_Led_Lesson_Data/wd:Title/text()"
select="let $id := accumulator-before('learning-course-id')
return
if (map:contains($value, $id))
then map:put($value, $id, ($value($id), string()))
else map:put($value, $id, string())"/>
</xsl:accumulator>
<xsl:mode on-no-match="shallow-skip" use-accumulators="#all" streamable="yes"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/FileAndCourses">
<OfferingsWithCourse>
<xsl:apply-templates select="Offerings/Offering"/>
</OfferingsWithCourse>
</xsl:template>
<xsl:template match="Offering/Lesson">
<xsl:apply-templates select="copy-of()" mode="grounded"/>
</xsl:template>
<xsl:mode name="grounded" on-no-match="shallow-copy"/>
<xsl:template mode="grounded" match="Lesson[Webinar = 'Y'][let $webinars := accumulator-before('webinars') return if (map:contains($webinars, Course-Number)) then not(Title = $webinars(Course-Number)) else false()]">
<xsl:copy>
<xsl:copy-of select="*"/>
<Error>
<xsl:text>No intructor-led webinar lesson found in course with title: </xsl:text>
<xsl:value-of select="Title"/>
<xsl:text>. </xsl:text>
</Error>
</xsl:copy>
</xsl:template>
<xsl:template mode="grounded" match="Lesson[Webinar = 'N'][let $lessons := accumulator-before('classroom-lessons') return if (map:contains($lessons, Course-Number)) then not(Title = $lessons(Course-Number)) else false()]">
<xsl:copy>
<xsl:copy-of select="*"/>
<Error>
<xsl:text>No intructor-led classrom lesson found in course with title: </xsl:text>
<xsl:value-of select="Title"/>
<xsl:text>. </xsl:text>
</Error>
</xsl:copy>
</xsl:template>
<xsl:template mode="grounded" match="Lesson[Webinar = 'Y'][not(map:contains(accumulator-before('webinars'), Course-Number))] | Lesson[Webinar = 'N'][not(map:contains(accumulator-before('classroom-lessons'), Course-Number))]">
<xsl:copy>
<xsl:copy-of select="*"/>
<Error>
<xsl:text>Unable to find active course </xsl:text>
<xsl:value-of select="Course-Number"/>
<xsl:text> in Workday. </xsl:text>
</Error>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
反過來,檢查是否有給定的產品wd:Course_Lesson_Data將是
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:wd="urn:com.workday/bsvc"
exclude-result-prefixes="#all"
version="3.0">
<xsl:accumulator name="learning-course-id" as="xs:string?" initial-value="()" streamable="yes">
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:ID/text()" select="string()"/>
</xsl:accumulator>
<xsl:accumulator name="lesson-mandatory" as="xs:boolean?" initial-value="()" streamable="yes">
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:Course_Lesson_Data" select="false()"/>
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:Course_Lesson_Data/wd:Make_Lesson_Mandatory/text()" select=". = 1"/>
</xsl:accumulator>
<xsl:accumulator name="webinars" as="map(xs:string, xs:string*)" initial-value="map{}" streamable="yes">
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:Course_Lesson_Data/wd:Instructor_Led_Webinar_Lesson_Data[accumulator-before('lesson-mandatory')]/wd:Title/text()"
select="let $id := accumulator-before('learning-course-id')
return
if (map:contains($value, $id))
then map:put($value, $id, ($value($id), string()))
else map:put($value, $id, string())"/>
</xsl:accumulator>
<xsl:accumulator name="classroom-lessons" as="map(xs:string, xs:string*)" initial-value="map{}" streamable="yes">
<xsl:accumulator-rule match="AllCourses/wd:Learning_Course/wd:Learning_Course_Data/wd:Course_Lesson_Data/wd:Instructor_Led_Lesson_Data[accumulator-before('lesson-mandatory')]/wd:Title/text()"
select="let $id := accumulator-before('learning-course-id')
return
if (map:contains($value, $id))
then map:put($value, $id, ($value($id), string()))
else map:put($value, $id, string())"/>
</xsl:accumulator>
<xsl:accumulator name="offered-lesson-id" as="xs:string?" initial-value="()" streamable="yes">
<xsl:accumulator-rule match="Offerings/Offering/Lesson/Course-Number/text()" select="string()"/>
</xsl:accumulator>
<xsl:accumulator name="offered-lessons" as="map(xs:string, xs:string*)" initial-value="map{}" streamable="yes">
<xsl:accumulator-rule match="Offerings/Offering/Lesson/Title/text()"
select="let $id := accumulator-before('offered-lesson-id')
return
if (map:contains($value, $id))
then map:put($value, $id, ($value($id), string()))
else map:put($value, $id, string())"/>
</xsl:accumulator>
<xsl:mode on-no-match="shallow-skip" use-accumulators="#all" streamable="yes"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/FileAndCourses" expand-text="yes">
<OfferingsWithCourse>
<xsl:apply-templates/>
<xsl:variable name="webinars" select="accumulator-after('webinars')"/>
<xsl:variable name="offered-lessons" select="accumulator-after('offered-lessons')"/>
<xsl:for-each select="map:keys(accumulator-after('webinars'))">
<xsl:variable name="webinar-id" select="."/>
<xsl:for-each select="$webinars(.)[not(. = $offered-lessons($webinar-id))]">
<Error>No offering for {$webinar-id} title {.}</Error>
</xsl:for-each>
</xsl:for-each>
</OfferingsWithCourse>
</xsl:template>
</xsl:stylesheet>
對于您的樣本資料,此輸出
<?xml version="1.0" encoding="UTF-8"?>
<OfferingsWithCourse>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 2</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 4</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 6</Error>
</OfferingsWithCourse>
對于您使用輸入/輸出示例的最新編輯,通過將最后一個模板(在上面的第二個 XSLT 中)更改為
<xsl:template match="/FileAndCourses" expand-text="yes">
<OfferingsWithCourse>
<xsl:apply-templates/>
<xsl:variable name="webinars" select="accumulator-after('webinars')"/>
<xsl:variable name="offered-lessons" select="accumulator-after('offered-lessons')"/>
<xsl:for-each select="map:keys(accumulator-after('webinars'))[. = map:keys($offered-lessons)]">
<xsl:variable name="webinar-id" select="."/>
<xsl:for-each select="$webinars(.)[not(. = $offered-lessons($webinar-id))]">
<Error>No offering for {$webinar-id} title {.}</Error>
</xsl:for-each>
</xsl:for-each>
</OfferingsWithCourse>
</xsl:template>
uj5u.com熱心網友回復:
執行此操作的最簡單方法可能是使用流式洗掉所有與問題無關的資料,然后使用非流式常規樣式表來測驗連接條件。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/529030.html
上一篇:回圈檔案中的行,從第二列創建串列
下一篇:使用PHP將陣列放入csv
