IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: aliceraia
About
User Name: aliceraia
Forum Rank: Member
Real Name: Alice Raia
Location US
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Wednesday, August 31, 2005
Last Visit: Thursday, November 2, 2006 9:39:46 PM
Number of Posts: 2
[0.01% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: "Cast As" Transform Error
Posted: Friday, February 17, 2006 4:09:25 PM
We have a transformation function that seems to be evaluating to an unusual numeric type noted as xdt:_numeric_ and we are trying to cast the value to an xs:string. We are using the Saxon engine. Is there any way to force the parameters prior to the casting to something that will probably cast appropriately? Or perhaps we could apply some function that would do the cast for us?

Here is the output of the transformation:

Error at xsl:value-of on line 261 of :
XPTY0004: Casting from xdt:_numeric_ to xs:string can never succeed
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:126)
at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:130)
at net.sf.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:85)
at com.adx.view.backing.util.processor.ApplyStyle.main(ApplyStyle.java:52)


Here is the header of the XSL file with the function we’re attempting to execute following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n1="http://www.foo.com/xml/FooDoc" >
<xsl:output version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="no" media-type="text/html" />
<xsl:template match="/">


And here is the function we are trying to execute:

<xsl:for-each select="n1:MonetaryAmount">
<xsl:for-each select="n1:MonetaryAmountValue">
<input style="background-color:silver; background-image:LOCK; " value="">
<xsl:attribute name="value">
<xsl:value-of select="
for $a in (sum(../../../../../../n1:InvoiceDetail/n1:LineItemDetail/n1:FlexFields/n1:FlexField1)
+
sum(for $j in (../../../../../../n1:InvoiceHeader/n1:AllowancesAndCharges/n1:AllowOrCharge)
return
$j/n1:ACQuantity1/n1:QtyNode/n1:QuantityValue * $j/n1:Rate +
$j/n1:ACAmount +
$j/n1:Percent/n1:PercentNumeric * $j/n1:ACBasisForPercent div 100) ) cast as xs:string
return(
if ( matches( $a , &quot;\.&quot; ) )
then
for $b in substring-after($a, &quot;.&quot;)
return
if ( string-length($b) &gt; 2 )
then round-half-to-even($a cast as xs:double,2)
else if ( string-length($b) = 1 )
then concat($a,&quot;0&quot;)
else if ( string-length($b) = 2 )
then $a
else concat($a,&quot;00&quot;)
else concat($a,&quot;.00&quot;))" />
</xsl:attribute>
</input>
</xsl:for-each>
</xsl:for-each>



Thanks in advance!

Topic: Update "Hidden" XML Element
Posted: Thursday, December 15, 2005 4:58:52 PM
I have an XML instance that has the following structure:

<SellerPartNumber>
<PartNum/>
</SellerPartNumber>

<BuyerPartNumber>
<PartNum/>
</BuyerPartNumber>

<StandardPartNumber>
<PartNum/>
</StandardPartNumber>

"SellerPartNumber/PartNum" and "BuyerPartNumber/PartNum" are both on my StyleVision template (input form). "StandardPartNumber/PartNum" is NOT on the input form.

Whenever "BuyerPartNumber/PartNum" is updated, I need to also update the "StandardPartNumber/PartNum" element automatically with the contents of "BuyerPartNumber/PartNum".

Any ideas on this ? I know there are convoluted ways to do this, I was hoping to get feedback from Altova on the *best* way to do this in StyleVision.

Thanks !

Alice Raia

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.