Transformation: data to attr val.

Subject: Transformation: data to attr val.
From: "Maltby, David G" <david.g.maltby@xxxxxxxx>
Date: Tue, 13 Jul 1999 07:45:46 -0700
I am doing transformations using jade -t sgml and am have some difficulty
getting and using the contents of an element in the source document as an
attribute value in the target document.  For example if my source document
is:

<!DOCTYPE source [
<!ELEMENT source  - - (version,text)  >
<!ELEMENT version - - (#PCDATA) >
<!ELEMENT text    - - (#PCDATA) >
]>

<source>
  <version>1</version>
  <text>My text</text>
</source>

I would like it to be transformed to:

<!DOCTYPE target [
<!ELEMENT target  - - (version,text)  >
<!ELEMENT version - - (#PCDATA) >
<!ATTLIST version num CDATA #REQUIRED >
<!ELEMENT text    - - (#PCDATA) >
]>

<target>
  <version num=1></version>
  <text>My text</text>
</target>

However, using the following style-sheet:

<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!-- test getting content from source into attribute val. in target -->
]>

;;; --- required -----
(declare-flow-object-class 
   element "UNREGISTERED::James Clark//Flow Object Class::element")
;;;

;;; -- root ------------------
(element SOURCE
	(make element gi: "target")
)

;;;------------------------
(element VERSION
	(make element gi: "version"
	 			attributes: '(("num" (data (current-node))))
	)
)

;;;------------------------
(element TEXT
	(make element gi: "text")
)

Jade replies with a " invalid value for "attributes" characteristic " error.
I have also tried to create a variable (my preference because I have to use
this value elsewhere) and although the (define (*var*) ...) seems to get the
value, using *var* or (literal (*var*)) as the second item in the list gives
the same error.  Stubbing in a hard value, such as "stub", runs fine and
gives the expected results.  I am stumped because "attributes" is looking
for a list of list(s) of strings and I thought (data (current-node)) was
providing that.  I would deeply appreciate a pointer in the right direction.

I am new to DSSSL and Scheme, but I am thrilled about the amazingly good
things I have been able to accomplish. 

David Maltby
IETM Team
Lockheed Martin Missile and Space


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread