This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Creating an input form, XML -> XSLT -> HTML


I found an example in the archives dated 17 Oct 1999 23:49:15 from Clark Evans.
The example is supposed to handle attributes as well as elements, but given
this input:

<JobPositionSeeker status = "active">
 <JobPositionSeekerId>JaneDoe2000-06-01-LOR1235</JobPositionSeekerId>
 <Supplier>
  <SupplierId idOwner = "LotsOfResumes.com">LOR1235</SupplierId>
  <SupplierName>LotsOfResumes.com</SupplierName>
  <Contact>
   <PersonName>
    <FormattedName type = "presentation">Bob Smith</FormattedName>
   </PersonName>
(OTHER INPUT TRUNCATED)


It produces this output:

/JobPositionSeeker[0001]
 /JobPositionSeeker[0001]/JobPositionSeekerId[0001]JaneDoe2000-06-01-LOR1235
 /JobPositionSeeker[0001]/Supplier[0001]
  /JobPositionSeeker[0001]/Supplier[0001]/SupplierId[0001]LOR1235
  /JobPositionSeeker[0001]/Supplier[0001]/SupplierName[0001]LotsOfResumes.com
  /JobPositionSeeker[0001]/Supplier[0001]/Contact[0001]
   /JobPositionSeeker[0001]/Supplier[0001]/Contact[0001]/PersonName[0001]

/JobPositionSeeker[0001]/Supplier[0001]/Contact[0001]/PersonName[0001]/FormattedName[0001]Bob
Smith

(OTHER OUTPUT TRUNCATED)

The attributes status, idowner and presentation aren't in the output! How can I
get those too?

Regards,

Ron




Trevor Nash wrote:

> Ron King <roncking@home.com> wrote:
>
> >How can I get a string representing the path in xslt?
>
> If you look back in the archives of this list you will find references
> to general ways of doing this for any node.  I don't remember where
> exactly.  You will also find it useful to look at the FAQ and
> www.jenitennison.com, http://www.bayes.co.uk/xml among others.
>
> If the document isn't huge or performance isn't particularly an issue,
> and if its always an element you are after, then a simple approach is
> to generate something of the form "//*[n]" which you can do with:
>  concat('//*[', concat(count(preceeding::*|ancestor-or-self::*), ']')
> (I didn't test that, if it is wrong I am sure someone will correct me
> ;-)
> This is intended as a hint to get you started, not a complete
> solution.
>
> ><xsl:text disable-output-escaping="yes"> First Name: <![CDATA[<]]>input
> >type="text" name="</xsl:text><xsl:value-of
> >select="generate-id()"/><xsl:text>" value="</xsl:text><xsl:value-of
> >select="GivenName"/><xsl:text disable-output-escaping="yes">"> </xsl:text>
> >
>
> Others have already pointed out the 'right' way to do this.  If you
> are not sure why your attempt is wrong (other than readability) try
> putting the result of the transformation into a DOM instead of a file.
>
> You might worry about the / in <input ... /> in the answers you have
> been given, which is not legal HTML.  Don't.  The XSLT processor will
> look after this for you.
>
> Out of curiosity: how did you arrive at your disable-output-escaping
> solution?  What resources did you use?  Is there a web site out there
> somewhere with examples like this?  A magazine article maybe?
>
> I know there are others who listen to this list who are also XSLT
> trainers, and may be interested in your answer.
>
> I hope you have not paid for any XSLT trainng or advice - if you have,
> you were robbed ;-)
>
> Regards,
> Trevor Nash
> --
> Traditional training & distance learning,
> Consultancy by email
>
> Melvaig Software Engineering Limited
> voice:     +44 (0) 1445 771 271
> email:     tcn@melvaig.co.uk
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]