RE: Validate XSL approach?

"Tim Hibbs" <[email protected]> Thu, 18 Feb 2010 17:06:29 -0600
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <06ACD6C2DAA98749B533845A78D451AF05D835A4@MEMEXCH07V.corp.ds.fedex.com>
 
 Perfect, Michael. I switch these questions to the other list, though
you've addressed these directly. 

Thanks once again.

Tim Hibbs
FedEx Services
350 Spectrum Loop
Colorado Springs, CO 80921
719-484-2131


-----Original Message-----
From: Michael Ludwig [mailto:[email protected]] 
Sent: Thursday, February 18, 2010 3:57 PM
To: Xalan-J Users
Subject: Re: Validate XSL approach?

Tim Hibbs schrieb am 18.02.2010 um 12:16:59 (-0600):

> 1.	In the XSL below, is it a reasonable approach to discard
> "unwanted" text nodes with the template
> 	
> 	 <xsl:template match="frq:From | frq:HeaderDate | frq:HeaderTime
> | frq:FaxNumber">
> 	 </xsl:template>?

I'd prefer <xsl:template match="..."/>, the other version might result
in additional whitespace depending on your settings.

> 	*	Is there a better way to do this?
> 	*	Must this be done element-by-element, or is there a
> "shorthand" way of eliminating a set of sibling nodes via XPath 
> expression?

<!-- discard all element nodes below frq:CommonData --> <xsl:template
match="frq:CommonData/*"/>

Read up about priorities when matching nodes.

> 2.	Given the inclusion of the namespace specifier
> "xmlns:frq="http://www.fedex.com/schemas/freightRateQuotation" in the 
> XSL, must all references to nodes in that namespace always be preceded

> with "frq:" wherever they are referenced (such as in xsl:template 
> match="..." statements)?

Yes.

> 3.	I'd like to "left align" the "To:" and "Email Address:" lines in
> my output. Is there a defined set of output formatting rules in XSL 
> (which in particular defines how output lines are indented)?

Whitespace accuracy is a bit tedious in all template languages I've
seen, which has to do with the nature of the template: sometimes you
want the whitespace for output, sometimes you want it only for source
code formatting.

Take a look at <xsl:strip-space> and <xsl:text>.

Newline with numeric character reference: <xsl:text>&#10;</xsl:text>

> As suggested yesterday by Michael Ludwig, I included an "<xsl:output 
> method="html" indent="yes"/>" line, but that doesn't seem to impact 
> other than the HTML syntax elements.

If you want plain text: <xsl:output method="text"/>

General XSL questions are better asked at xsl-list at mulberrytech dot
com.

--
Michael Ludwig