New tests: Streaming with validation + strip-type-annotations
authorMichael Kay <mike@saxonica.com>
Thu, 18 Jan 2018 16:05:46 +0000
changeset 1813 af284262f61e
parent 1812 85ef3146eed5
child 1814 2c63493cda70
New tests: Streaming with validation + strip-type-annotations
tests/attr/streamable/_streamable-test-set.xml
tests/attr/streamable/bad-loans.xml
tests/attr/streamable/streamable-147.xsl
tests/attr/streamable/streamable-148.xsl
tests/attr/streamable/streamable-149.xsl
--- a/tests/attr/streamable/_streamable-test-set.xml	Thu Jan 18 16:04:27 2018 +0000
+++ b/tests/attr/streamable/_streamable-test-set.xml	Thu Jan 18 16:05:46 2018 +0000
@@ -36,6 +36,13 @@
       </source>
       <schema file="loans.xsd" uri="loans.xsd"/>
    </environment>
+   
+   <environment name="bad-loans">
+      <source file="bad-loans.xml" uri="bad-loans.xml" streaming="true" validation="strict">
+         <description>Invalid data instance</description>
+      </source>
+      <schema file="loans.xsd" uri="loans.xsd"/>
+   </environment>
 
    <environment name="mixed">
       <source file="mixed.xml" uri="mixed.xml" streaming="true">
@@ -2853,4 +2860,56 @@
       </result>
    </test-case>
    
+   <test-case name="streamable-147">
+      <description>xsl:source-document: validate source, but strip type annotations</description>
+      <created by="Michael Kay" on="2018-01-16"/>
+      <environment ref="loans"/>
+      <dependencies>
+         <feature value="schema_aware"/>
+         <feature value="streaming"/>
+      </dependencies>
+      <test>
+         <stylesheet file="streamable-147.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+            <assert>//Amount[@decimal='false']</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="streamable-148">
+      <description>xsl:source-document: validate source, and preserve type annotations</description>
+      <created by="Michael Kay" on="2018-01-16"/>
+      <environment ref="loans"/>
+      <dependencies>
+         <feature value="schema_aware"/>
+         <feature value="streaming"/>
+      </dependencies>
+      <test>
+         <stylesheet file="streamable-148.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert>//Amount[@decimal='true']</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="streamable-149">
+      <description>xsl:source-document: validate source, and strip type annotations; invalid input</description>
+      <created by="Michael Kay" on="2018-01-16"/>
+      <environment ref="bad-loans"/>
+      <dependencies>
+         <feature value="schema_aware"/>
+         <feature value="streaming"/>
+      </dependencies>
+      <test>
+         <stylesheet file="streamable-149.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTTE1510"/>
+      </result>
+   </test-case>
+   
+   
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/streamable/bad-loans.xml	Thu Jan 18 16:05:46 2018 +0000
@@ -0,0 +1,278 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<myroot>
+<ACERequest version="2.1">
+  <Deal>
+    <Pool>
+      <PoolIdentifier>22</PoolIdentifier>
+      <Loan>
+        <LoanStatus>
+          <LoanStatusType>Origination</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>400000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanStatus>
+          <LoanStatusType>CurrentAsOfDate</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>350000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Origination</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.90</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.80</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>Combined</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.95</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <Property>
+          <Address>
+            <PostalCode>22102</PostalCode>
+            <State>VA</State>
+          </Address>
+          <PropertyCharacteristic>
+            <PropertyCharacteristicType>PropertyType</PropertyCharacteristicType>
+            <PropertyCharacteristicValue>TownHouse</PropertyCharacteristicValue>
+          </PropertyCharacteristic>
+          <PropertyPurchase>
+            <PurchasePriceAmount>450000.0</PurchasePriceAmount>
+          </PropertyPurchase>
+          <PropertyValuation>
+            <PropertyAppraisedValueAmount>500000.0</PropertyAppraisedValueAmount>
+          </PropertyValuation>
+        </Property>
+        <FinancialInstrumentIdentifier>111</FinancialInstrumentIdentifier>
+        <LoanPurposeType>Purchase</LoanPurposeType>
+        <NoteDate>2002-08-13</NoteDate>
+        <your:extra my:value="22" xmlns:your="http://your.com/ns" xmlns:my="http://my.com/ns" xmlns:hers="http://hers.com/ns"><!--comment-->242<?PI?></your:extra>
+      </Loan>
+      <Loan>
+        <LoanStatus>
+          <LoanStatusType>Origination</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>400000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanStatus>
+          <LoanStatusType>CurrentAsOfDate</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>350000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Origination</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.90</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.80</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>Combined</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.95</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <Property>
+          <Address>
+            <PostalCode>71045</PostalCode>
+            <State>TX</State>
+          </Address>
+          <PropertyCharacteristic>
+            <PropertyCharacteristicType>PropertyType</PropertyCharacteristicType>
+            <PropertyCharacteristicValue>TownHouse</PropertyCharacteristicValue>
+          </PropertyCharacteristic>
+          <PropertyPurchase>
+            <PurchasePriceAmount>450000.0</PurchasePriceAmount>
+          </PropertyPurchase>
+          <PropertyValuation>
+            <PropertyAppraisedValueAmount>500000.0</PropertyAppraisedValueAmount>
+          </PropertyValuation>
+        </Property>
+        <FinancialInstrumentIdentifier>111</FinancialInstrumentIdentifier>
+        <LoanPurposeType>Purchase</LoanPurposeType>
+        <NoteDate>2002-08-13</NoteDate>
+      </Loan>
+      <Loan>
+        <LoanStatus>
+          <LoanStatusType>Origination</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>600000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanStatus>
+          <LoanStatusType>CurrentAsOfDate</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>500000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Origination</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.90</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.80</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>Combined</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.95</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <Property>
+          <Address>
+            <PostalCode>33303</PostalCode>
+            <State>MD</State>
+          </Address>
+          <PropertyCharacteristic>
+            <PropertyCharacteristicType>PropertyType</PropertyCharacteristicType>
+            <PropertyCharacteristicValue>TownHouse</PropertyCharacteristicValue>
+          </PropertyCharacteristic>
+          <PropertyPurchase>
+            <PurchasePriceAmount>550000.0</PurchasePriceAmount>
+          </PropertyPurchase>
+          <PropertyValuation>
+            <PropertyAppraisedValueAmount>600000.0</PropertyAppraisedValueAmount>
+          </PropertyValuation>
+        </Property>
+        <FinancialInstrumentIdentifier>111</FinancialInstrumentIdentifier>
+        <LoanPurposeType>Purchase</LoanPurposeType>
+        <NoteDate>2002-08-13</NoteDate>
+      </Loan>
+      <Loan xml:lang="de">
+        <LoanStatus>
+          <LoanStatusType>Origination</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>800000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanStatus>
+          <LoanStatusType>CurrentAsOfDate</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>750000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Origination</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.90</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.80</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>Combined</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.95</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <Property>
+          <Address>
+            <PostalCode>31926</PostalCode>
+            <State>CA</State>
+          </Address>
+          <PropertyCharacteristic>
+            <PropertyCharacteristicType>PropertyType</PropertyCharacteristicType>
+            <PropertyCharacteristicValue>TownHouse</PropertyCharacteristicValue>
+          </PropertyCharacteristic>
+          <PropertyPurchase>
+            <PurchasePriceAmount>1000000.0</PurchasePriceAmount>
+          </PropertyPurchase>
+          <PropertyValuation>
+            <PropertyAppraisedValueAmount>1100000.0</PropertyAppraisedValueAmount>
+          </PropertyValuation>
+        </Property>
+        <FinancialInstrumentIdentifier>111</FinancialInstrumentIdentifier>
+        <LoanPurposeType>Purchase</LoanPurposeType>
+        <NoteDate>2002-08-13</NoteDate>
+      </Loan>
+      <Loan xml:lang="en-GB">
+        <LoanStatus>
+          <LoanStatusType>Origination</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>200000.X</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanStatus>
+          <LoanStatusType>CurrentAsOfDate</LoanStatusType>
+          <UnpaidPrincipalBalanceAmount>175000.0</UnpaidPrincipalBalanceAmount>
+        </LoanStatus>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Origination</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.90</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>FirstLienOnly</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.80</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <LoanToValueRatio>
+          <LoanToValueRule>
+            <LoanScopeType>Combined</LoanScopeType>
+            <TimeType>Current</TimeType>
+            <PercentIndicator>N</PercentIndicator>
+          </LoanToValueRule>
+          <LoanToValueRatioPercent>.95</LoanToValueRatioPercent>
+        </LoanToValueRatio>
+        <Property>
+          <Address>
+            <PostalCode>28165</PostalCode>
+            <State>AZ</State>
+          </Address>
+          <PropertyCharacteristic>
+            <PropertyCharacteristicType>PropertyType</PropertyCharacteristicType>
+            <PropertyCharacteristicValue>TownHouse</PropertyCharacteristicValue>
+          </PropertyCharacteristic>
+          <PropertyPurchase>
+            <PurchasePriceAmount>250000.0</PurchasePriceAmount>
+          </PropertyPurchase>
+          <PropertyValuation>
+            <PropertyAppraisedValueAmount>300000.0</PropertyAppraisedValueAmount>
+          </PropertyValuation>
+        </Property>
+        <FinancialInstrumentIdentifier>111</FinancialInstrumentIdentifier>
+        <LoanPurposeType>Purchase</LoanPurposeType>
+        <NoteDate>2002-08-13</NoteDate>
+      </Loan>
+    </Pool>
+    <DealIdentifier>1</DealIdentifier>
+    <ACERequestType>Quarterly_ARIMA_WRSI_Model</ACERequestType>
+  </Deal>
+</ACERequest>
+</myroot>      
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/streamable/streamable-147.xsl	Thu Jan 18 16:05:46 2018 +0000
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes=" xs"
+    input-type-annotations="strip"
+    version="3.0">
+       
+  
+  <!-- xsl:variable with a sequence constructor -->
+   
+  <xsl:import-schema schema-location="loans.xsd"/>
+
+  <xsl:mode name="s" streamable="yes"/>
+  <xsl:mode name="t" streamable="yes"/>
+       
+  <xsl:output method="xml" indent="yes" encoding="UTF-8" />
+  
+    
+  <xsl:template name="main" match="/">
+    <out>
+      <xsl:source-document streamable="true" href="loans.xml" validation="strict">
+        <xsl:apply-templates select="." mode="s"/>
+      </xsl:source-document>
+    </out>
+  </xsl:template>
+  
+  <xsl:template match="text()" mode="s"/>
+  
+  <xsl:template match="LoanToValueRatio|Property" mode="s"/>
+  
+  <xsl:template match="Loan" mode="s">
+    <Loan><xsl:apply-templates mode="s"/></Loan>
+  </xsl:template>
+  
+      
+   <xsl:template match="LoanStatus" mode="s">
+       <xsl:variable name="temp">
+         <Id>Standard</Id>
+         <xsl:apply-templates mode="s"/>
+         <Note>A note</Note>
+       </xsl:variable> 
+       <A><xsl:copy-of select="$temp"/></A> 
+       <C><xsl:value-of select="$temp/Amount"/></C>
+       <PostStatus>The end</PostStatus>
+   </xsl:template>
+   
+   <xsl:template match="LoanStatusType" mode="s">
+     <Data><xsl:value-of select="."/></Data>
+   </xsl:template>
+   
+   <xsl:template match="UnpaidPrincipalBalanceAmount" mode="s">
+     <Amount decimal="{data(.) instance of xs:decimal}"/>
+   </xsl:template>
+   
+
+   
+   
+
+</xsl:transform>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/streamable/streamable-148.xsl	Thu Jan 18 16:05:46 2018 +0000
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes=" xs"
+    input-type-annotations="preserve"
+    version="3.0">
+       
+  
+  <!-- xsl:variable with a sequence constructor -->
+   
+  <xsl:import-schema schema-location="loans.xsd"/>
+
+  <xsl:mode name="s" streamable="yes"/>
+  <xsl:mode name="t" streamable="yes"/>
+       
+  <xsl:output method="xml" indent="yes" encoding="UTF-8" />
+  
+    
+  <xsl:template name="main" match="/">
+    <out>
+      <xsl:source-document streamable="true" href="loans.xml" validation="strict">
+        <xsl:apply-templates select="." mode="s"/>
+      </xsl:source-document>
+    </out>
+  </xsl:template>
+  
+  <xsl:template match="text()" mode="s"/>
+  
+  <xsl:template match="LoanToValueRatio|Property" mode="s"/>
+  
+  <xsl:template match="Loan" mode="s">
+    <Loan><xsl:apply-templates mode="s"/></Loan>
+  </xsl:template>
+  
+      
+   <xsl:template match="LoanStatus" mode="s">
+       <xsl:variable name="temp">
+         <Id>Standard</Id>
+         <xsl:apply-templates mode="s"/>
+         <Note>A note</Note>
+       </xsl:variable> 
+       <A><xsl:copy-of select="$temp"/></A> 
+       <C><xsl:value-of select="$temp/Amount"/></C>
+       <PostStatus>The end</PostStatus>
+   </xsl:template>
+   
+   <xsl:template match="LoanStatusType" mode="s">
+     <Data><xsl:value-of select="."/></Data>
+   </xsl:template>
+   
+   <xsl:template match="UnpaidPrincipalBalanceAmount" mode="s">
+     <Amount decimal="{data(.) instance of xs:decimal}"/>
+   </xsl:template>
+   
+
+   
+   
+
+</xsl:transform>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/streamable/streamable-149.xsl	Thu Jan 18 16:05:46 2018 +0000
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes=" xs"
+    input-type-annotations="strip"
+    version="3.0">
+       
+  
+  <!-- xsl:variable with a sequence constructor -->
+   
+  <xsl:import-schema schema-location="loans.xsd"/>
+
+  <xsl:mode name="s" streamable="yes"/>
+  <xsl:mode name="t" streamable="yes"/>
+       
+  <xsl:output method="xml" indent="yes" encoding="UTF-8" />
+  
+    
+  <xsl:template name="main" match="/">
+    <out>
+      <xsl:source-document streamable="true" href="bad-loans.xml" validation="strict">
+        <xsl:apply-templates select="." mode="s"/>
+      </xsl:source-document>
+    </out>
+  </xsl:template>
+  
+  <xsl:template match="text()" mode="s"/>
+  
+  <xsl:template match="LoanToValueRatio|Property" mode="s"/>
+  
+  <xsl:template match="Loan" mode="s">
+    <Loan><xsl:apply-templates mode="s"/></Loan>
+  </xsl:template>
+  
+      
+   <xsl:template match="LoanStatus" mode="s">
+       <xsl:variable name="temp">
+         <Id>Standard</Id>
+         <xsl:apply-templates mode="s"/>
+         <Note>A note</Note>
+       </xsl:variable> 
+       <A><xsl:copy-of select="$temp"/></A> 
+       <C><xsl:value-of select="$temp/Amount"/></C>
+       <PostStatus>The end</PostStatus>
+   </xsl:template>
+   
+   <xsl:template match="LoanStatusType" mode="s">
+     <Data><xsl:value-of select="."/></Data>
+   </xsl:template>
+   
+   <xsl:template match="UnpaidPrincipalBalanceAmount" mode="s">
+     <Amount decimal="{data(.) instance of xs:decimal}"/>
+   </xsl:template>
+   
+
+   
+   
+
+</xsl:transform>
+