Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2008, 01:24 PM
Registered User
 
Join Date: Mar 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 'attribute is not declared' error

Getting an error from the map:
Output validation error: The 'PARTNER' attribute is not declared.
The attribute in question is generated by the script:
Code:
<PRT>
  <xsl:for-each select="/s2:Invoice/s2:InvoiceHeader/s2:ListOfNameValueSet/s0:NameValueSet[s0:SetName/text() = 'Data']">
  <xsl:attribute name="PARTNER">
    <xsl:value-of select="s0:ListOfNameValuePair/s0:NameValuePair[s0:Name/text() = 'Partner']/s0:Value/text()"/>
  </xsl:attribute>

  <xsl:attribute name="PRICE">
    <xsl:value-of select="s0:ListOfNameValuePair/s0:NameValuePair[s0:Name/text() = 'Price']/s0:Value/text()"/>
  </xsl:attribute>
  </xsl:for-each>
</PRT>
Using the input file:

<PRT PARTNER="CUSTOMER" PRICE="UNSPECIFIED"></PRT>

The map generates XML:

Code:
<PRT PARTNER="CUSTOMER" PRICE="UNSPECIFIED"></PRT>
I am not sure why it generates the error of that kind, as the attribute is clearly in the XML output.

 
Old April 1st, 2008, 02:18 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Hi,

"Getting an error from the map:", not sure what "the map is".

"Output validation error:" are you validating your XML file? Without seeing your Schema or DTD, I dont think I can help.

Can you provide some more detail?

 
Old April 1st, 2008, 02:29 PM
Registered User
 
Join Date: Mar 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My schema is a collection of files about half a megabyte in size. I have no clue how I could provide you with a schema.

It makes no sense to me that someone would need a schema to figure out the error.

I should have mentioned however that the map is a Visual studio Biztalk project, where xslt is used to map one schema to another, and the error is received when the map is tested.

How an attribute can not be declared, where it is present in the output?

 
Old April 1st, 2008, 03:28 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Sounds like your not allowed to have that attribute "PARTNER" if its not declared. An Attribute must be declared in the DTD or Schema.

"It makes no sense to me that someone would need a schema to figure out the error." - well from what I know about XML validation, you need a DTD or schema to validate and if you want help validating an XML file, we'll need to see either one. Or we can assume your schema doesn't allow an Attribute "PARTNER".


"How an attribute can not be declared, where it is present in the output?" its not, read your error. Its saying "Output validation error:", which means your output is not valid against a schema or dtd...

Good luck.

 
Old April 1st, 2008, 05:32 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This sounds to me as if you are using a schema-aware transformation, and the result document doesn't conform to the schema? If so, we need to understand more about your processing environment and your schema.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 1st, 2008, 05:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>It makes no sense to me that someone would need a schema to figure out the error.

Microsoft error messages can be difficult to decipher at times, but this one seems to me to be saying that your stylesheet output doesn't conform with the target schema. Which means that you can't figure out the error without access to the schema.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 2nd, 2008, 01:20 PM
Registered User
 
Join Date: Mar 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that was most helpful! It was a copy/paste error and I had an attribute popping up in a strange element down in the code.;)






Similar Threads
Thread Thread Starter Forum Replies Last Post
"Name My " not declared error ajkumar Visual Basic 2005 Basics 0 April 19th, 2007 11:29 PM
Soap Error : Attribute xmlns must be declared RatanKumar XML 0 December 4th, 2006 08:07 PM
element is not declared. An error occurred... dazzled XML 3 September 13th, 2004 04:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.